Quote:
Originally Posted by ross
hmm, how do you open the 'diskid'?
With something like "DISKNAMEn:diskid"?
That the system looks for in the 'current directory' first and for that it asks you the disk of the executable?
|
It just attempts a call to Open() for the diskid being requested, the diskid comes from the filename being requested.
A look in SnoopDOS revealed there was a Lock created on the executable which I couldn't remember doing. I then had a look at some of the Workbench boot code and sure enough calles to Lock(). Bypassing this makes things work but I'm unsure how necessary the code is to make it work from Workbench. I didn't write this code, I think it came from one of the Devpac disks on how to launch executables correctly from Workbench.
Code:
WORKBENCH_BOOT MACRO
ThisTask equ $114
pr_CLI equ $ac
pr_MsgPort equ $5c
sm_ArgList equ $24
cli_CommandName equ $10
movea.l ExecBase,a6
lea DOSNAME,a1
jsr _LVOOldOpenLibrary(a6)
movea.l d0,a5 ; dosbase
movea.l ThisTask(a6),a3
move.l pr_CLI(a3),d3 ; d3 = CLI or WB (NULL)
bne.s _from_cli
_from_wb:
; Get startup message if we started from Workbench
lea pr_MsgPort(a3),a0
jsr _LVOWaitPort(a6) ; wait for a message
lea pr_MsgPort(a3),a0
jsr _LVOGetMsg(a6) ; then get it
movea.l d0,a3 ; a3 = WBStartup message
movea.l sm_ArgList(a3),a0
move.l (a0),d5 ; (wa_Lock) FileLock on program dir
exg a5,a6 ; _dos
bsr.s _common
; Reply to the startup message
jsr _LVOForbid(a6) ; it prohibits WB to unloadseg me
lea (a3),a1
jmp _LVOReplyMsg(a6) ; reply to WB message and exit
_from_cli:
; Get FileLock via command name if we started from CLI
link a3,#-256
; Copy BCPL string to C-style string
lea (sp),a1
lsl.l #2,d3
movea.l d3,a0
move.l cli_CommandName(a0),a0
adda.l a0,a0
adda.l a0,a0
move.b (a0)+,d0
.c: move.b (a0)+,(a1)+
subq.b #1,d0
bne.b .c
clr.b (a1)
; Get a lock on the program and its parent
exg a5,a6 ; _dos
move.l sp,d1 ; d1 = STRPTR name (command string)
moveq #SHARED_LOCK,d2 ; d2 = accessMode
jsr _LVOLock(a6)
move.l d0,d7
move.l d0,d1
jsr _LVOParentDir(a6)
move.l d7,d1
move.l d0,d3 ; d3 = Lock on CLI program dir
move.l d0,d5 ; d5 = common Lock
jsr _LVOUnLock(a6)
unlk a3
_common:
move.l d5,d1
jsr _LVOCurrentDir(a6) ; CD to the program dir
move.l d0,d4 ; d4 = initial launch directory
lea infodata(pc),a0
lea id_UnitNumber(a0),a2
move.l d5,d1
move.l a0,d2
jsr _LVOInfo(a6)
tst.l d0
beq.b _rts
move.l (a2),d0 ; d0 = current floppy device for the main exe
movem.l d3/d4/a3/a5/a6,-(sp)
bsr START
movem.l (sp)+,d3/d4/a3/a5/a6
move.l d3,d1 ; UnLock program dir or zero (from WB)
jsr _LVOUnLock(a6)
move.l d4,d1 ; CD to the initial directory
jsr _LVOCurrentDir(a6)
lea (a6),a1
lea (a5),a6
jsr _LVOCloseLibrary(a6)
moveq #0,d0
_rts: rts
cnop 0,4
infodata: ds.l 12
ENDM