Closed andrewbird closed 5 years ago
So we know DPB is good. What's next? CDS?
yes, to check the flags and dpb pointer within the cds entry.
dosdebug> d 0669:0210
dosdebug>
0669:0210 47 3A 5C 00 00 00 00 00 00 00 00 00 00 00 00 00 G:\.............
0669:0220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0669:0230 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0669:0240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0669:0250 00 00 00 00 40 00 00 D4 02 FF FF FF FF FF FF 02 ....@..T..
0669:0260 00 00 00 00 00 00 00 00 48 3A 5C 00 00 00 00 00 ........
find DPB pointer within CDS
dosdebug> d 0669:0255
dosdebug>
0669:0255 00 00 D4 02 FF FF FF FF FF FF 02 00 00 00 00 00 ..T.......
0669:0265 00 00 00 48 3A 5C 00 00 00 00 00 00 00 00 00 00 ...H:\..........
0669:0275 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0669:0285 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0669:0295 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0669:02a5 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF ............
0669:02b5 FF FF 02 00 00 00 00 00 00 00 00 49 3A 5C 00 00 .........I:\..
0669:02c5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
DPB entry
dosdebug> d 02d4:0000
dosdebug>
02d4:0000 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02d4:0010 00 00 00 00 00 B2 02 00 FF FF FF FF FF 00 00 00 .....2.....
02d4:0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02d4:0030 00 00 00 00 00 00 00 00 00 00 00 00 00 7E 06 FF .............~.
02d4:0040 42 D9 02 20 00 00 00 00 00 00 00 00 00 00 00 00 BY. ............
02d4:0050 E8 8C 0D 68 0A DD 15 58 87 0B BD 2C 74 87 EE 2E h..h.].X..=,t.n.
02d4:0060 68 E4 CB A8 42 6F D8 5A 95 63 1A E5 F3 B0 4A 0F hdK(BoXZ.c.es0J.
02d4:0070 39 F4 64 3A 38 56 29 2A 3A 37 38 1B 05 32 50 26 9td:8V)*:78..2P&
which matches
00D9:1B19 (F:)
driver unit: 5
bytes_per_sect = 0x200
last_sec_in_clust = 0x3f
sec_shift = 0x6
reserv_secs = 0x1
num_fats = 0x2
root_ents = 0x200
data_start = 0x217
max_clu = 0xfa00
sects_per_fat = 0xfb
first_dir_off = 0x1f7
device driver = 0070:0618
media_id = 0xf8
accessed = 0x0
next_DPB = 02D4:0000
first_free_clu = 0x0
fre_clusts = 0xffff
02D4:0000 (G:)
driver unit: 0
bytes_per_sect = 0x0
last_sec_in_clust = 0x0
sec_shift = 0x0
reserv_secs = 0x0
num_fats = 0x0
root_ents = 0x0
data_start = 0x0
max_clu = 0x0
sects_per_fat = 0x0
first_dir_off = 0x0
device driver = 02B2:0000
media_id = 0x0
accessed = 0xff
next_DPB = FFFF:FFFF
first_free_clu = 0x0
fre_clusts = 0x0
So that looks good except the geometry is not initialised in the DPB for G:
drive.
Flags are good at CDS + 0x043 #define CDS_FLAG_READY 0x4000
C_MEDIACHK
ioctl returns error and media_check()
then throws int24 instead of building BPB.
So something curious about the driver's media_check routine, it correctly sets 'media changed' in the request header, but then after consulting some local vars it returns error status. That's why the bpb never gets set.
An MS link map file I built if you are interested. usermap load-ms xmsdsk.map 0x02b2
or wherever devs
tells you it was loaded.
Address Publics by Value
0000:0018 xmsdsk_rh_pointer
0000:00a6 xmsdsk_strategy
0000:00b2 xmsdsk_interrupt
# Command table
# 02b2:001c 01 02 DE 00 F8 00 07 01 1A 01 DA 00 DA 00 DA 00 ..^.x.....Z.Z.Z.
# 02b2:002c 16 01 16 01 DA 00 DA 00 DA 00 00 02 01 01 00 01 ....Z.Z.Z.......
# 02b2:003c 00 00 00 00 F8 00 00 08 00 01 00 00 00 00 00 00 ....x...........
# 02b2:004c 00 00 00 90 06 FF 00 00 00 00 00 00 00 00 00 00 ...............
# 02b2:005c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000:0201 xmsdsk_initialisation
0000:00de xmsdsk_media_check
0000:00f8 xmsdsk_get_bpb
0000:0107 xmsdsk_ioctl_input
0000:011a xmsdsk_input
0000:00da xmsdsk_dummy
0000:00da xmsdsk_dummy
0000:00da xmsdsk_dummy
0000:0116 xmsdsk_output
0000:0116 xmsdsk_output
0000:00da xmsdsk_dummy
0000:00da xmsdsk_dummy
0000:00da xmsdsk_dummy
#
0000:011d xmsdsk_common_io
0000:0036 xmsdsk_data_bpb
0000:0051 xmsdsk_data_media_changed
0000:004b xmsdsk_magic_word_1
0000:004d xmsdsk_magic_word_2
The magic vars that stop status being returned as good for media check are are named as such. I couldn't see them set during the initialisation, and current values are zero.
dosdebug>
reading MSLINK map file 'xmsdsk.map'
symbol table now contains 274 symbol(s)
dosdebug> bp xmsdsk_interrupt
dosdebug> bp xmsdsk_strategy
dosdebug> g
dosdebug>
system state: stopped
AX=00a6 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08ec BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3206
CS:IP=02b2:00a6 SS:SP=00d9:08ec
xmsdsk_strategy:
02b2:00a6 2E891E1800 mov cs:[0018],bx
dosdebug> t
dosdebug>
system state: stopped
AX=00a6 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08ec BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=02b2:00ab SS:SP=00d9:08ec
02b2:00ab 2E8C061A00 mov cs:[001A],es
dosdebug>
dosdebug>
system state: stopped
AX=00a6 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08ec BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=02b2:00b0 SS:SP=00d9:08ec
02b2:00b0 CB retf
dosdebug>
dosdebug>
system state: stopped
AX=00a6 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f0 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=078b:03ee SS:SP=00d9:08f0
078b:03ee 5F pop di
dosdebug>
dosdebug>
system state: stopped
AX=00a6 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f2 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=078b:03ef SS:SP=00d9:08f2
078b:03ef 5E pop si
dosdebug>
dosdebug>
system state: stopped
AX=00a6 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f2 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=078b:03ef SS:SP=00d9:08f2
078b:03ef 5E pop si
dosdebug>
dosdebug>
system state: stopped
AX=00a6 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f4 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=078b:03f0 SS:SP=00d9:08f4
078b:03f0 8B4408 mov ax,[si+08]
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f4 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=078b:03f3 SS:SP=00d9:08f4
078b:03f3 894604 mov [bp+04],ax
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f4 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=078b:03f6 SS:SP=00d9:08f4
078b:03f6 FF5E04 call far word [bp+04]
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f0 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=02b2:00b2 SS:SP=00d9:08f0
xmsdsk_interrupt:
02b2:00b2 9C pushf
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f0 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=02b2:00b2 SS:SP=00d9:08f0
xmsdsk_interrupt:
02b2:00b2 9C pushf
dosdebug>
dosdebug> t
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08ee BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000b3306
CS:IP=02b2:00b3 SS:SP=00d9:08ee
02b2:00b3 60 pusha
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08de BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=02b2:00b4 SS:SP=00d9:08de
02b2:00b4 1E push ds
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08dc BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=02b2:00b5 SS:SP=00d9:08dc
02b2:00b5 06 push es
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08da BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=02b2:00b6 SS:SP=00d9:08da
02b2:00b6 0E push cs
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08d8 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=02b2:00b7 SS:SP=00d9:08d8
02b2:00b7 1F pop ds
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08da BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=02b2:00b8 SS:SP=00d9:08da
02b2:00b8 C43E1800 les di,[0018]
dosdebug>
02b2:00bc 268A5D02 mov bl,es:[di+02]
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=0301 CX=0000 DX=091c SI=0000 DI=037c SP=08da BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3306
CS:IP=02b2:00c0 SS:SP=00d9:08da
02b2:00c0 D0E3 shl bl,1
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=0302 CX=0000 DX=091c SI=0000 DI=037c SP=08da BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3302
CS:IP=02b2:00c2 SS:SP=00d9:08da
02b2:00c2 32FF xor bh,bh
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=0002 CX=0000 DX=091c SI=0000 DI=037c SP=08da BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3346
CS:IP=02b2:00c4 SS:SP=00d9:08da
02b2:00c4 33C0 xor ax,ax
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=0002 CX=0000 DX=091c SI=0000 DI=037c SP=08da BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3346
CS:IP=02b2:00c6 SS:SP=00d9:08da
02b2:00c6 FF971C00 call near word [bx+001C]
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=0002 CX=0000 DX=091c SI=0000 DI=037c SP=08d8 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3346
CS:IP=02b2:00de SS:SP=00d9:08d8
xmsdsk_media_check:
02b2:00de 8A1E5100 mov bl,[0051]
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=00ff CX=0000 DX=091c SI=0000 DI=037c SP=08d8 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3346
CS:IP=02b2:00e2 SS:SP=00d9:08d8
02b2:00e2 26885D0E mov es:[di+0E],bl
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=00ff CX=0000 DX=091c SI=0000 DI=037c SP=08d8 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3346
CS:IP=02b2:00e6 SS:SP=00d9:08d8
02b2:00e6 0ADB or bl,bl
dosdebug>
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=00ff CX=0000 DX=091c SI=0000 DI=037c SP=08d8 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3386
CS:IP=02b2:00e8 SS:SP=00d9:08d8
02b2:00e8 790D jns 00F7 ($+d)
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=00ff CX=0000 DX=091c SI=0000 DI=037c SP=08d8 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3386
CS:IP=02b2:00ea SS:SP=00d9:08d8
02b2:00ea 8B1E4B00 mov bx,[004B]
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=0000 CX=0000 DX=091c SI=0000 DI=037c SP=08d8 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3386
CS:IP=02b2:00ee SS:SP=00d9:08d8
02b2:00ee 0B1E4D00 or bx,[004D]
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=0000 CX=0000 DX=091c SI=0000 DI=037c SP=08d8 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3346
CS:IP=02b2:00f2 SS:SP=00d9:08d8
02b2:00f2 7503 jne 00F7 ($+3)
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=0000 CX=0000 DX=091c SI=0000 DI=037c SP=08d8 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3346
CS:IP=02b2:00f4 SS:SP=00d9:08d8
02b2:00f4 B80180 mov ax,8001
dosdebug>
dosdebug>
system state: stopped
AX=8001 BX=0000 CX=0000 DX=091c SI=0000 DI=037c SP=08d8 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3346
CS:IP=02b2:00f7 SS:SP=00d9:08d8
02b2:00f7 C3 ret
dosdebug>
dosdebug>
system state: stopped
AX=8001 BX=0000 CX=0000 DX=091c SI=0000 DI=037c SP=08da BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3346
CS:IP=02b2:00ca SS:SP=00d9:08da
02b2:00ca 0D0001 or ax,0100
dosdebug>
dosdebug>
dosdebug>
system state: stopped
AX=8101 BX=0000 CX=0000 DX=091c SI=0000 DI=037c SP=08da BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3382
CS:IP=02b2:00cd SS:SP=00d9:08da
02b2:00cd C43E1800 les di,[0018]
dosdebug>
dosdebug>
system state: stopped
AX=8101 BX=0000 CX=0000 DX=091c SI=0000 DI=037c SP=08da BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3382
CS:IP=02b2:00d1 SS:SP=00d9:08da
02b2:00d1 26894503 mov es:[di+03],ax
dosdebug>
dosdebug>
system state: stopped
AX=8101 BX=0000 CX=0000 DX=091c SI=0000 DI=037c SP=08da BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3382
CS:IP=02b2:00d5 SS:SP=00d9:08da
02b2:00d5 07 pop es
dosdebug>
dosdebug>
system state: stopped
AX=8101 BX=0000 CX=0000 DX=091c SI=0000 DI=037c SP=08dc BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3382
CS:IP=02b2:00d6 SS:SP=00d9:08dc
02b2:00d6 1F pop ds
dosdebug>
dosdebug>
system state: stopped
AX=8101 BX=0000 CX=0000 DX=091c SI=0000 DI=037c SP=08de BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3382
CS:IP=02b2:00d7 SS:SP=00d9:08de
02b2:00d7 61 popa
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08ee BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000a3382
CS:IP=02b2:00d8 SS:SP=00d9:08ee
02b2:00d8 9D popf
dosdebug>
dosdebug>
system state: stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f0 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000b3306
CS:IP=02b2:00d9 SS:SP=00d9:08f0
02b2:00d9 CB retf
dosdebug>
If you patch jne at 02b2:00f2 to jmp, will it work then?
I tried something similar earlier in tweaking the status value to success. I got further on but ended up with a different (I/O I think) error.
Can you think of a reason it might do?
mov bx,[004B]
or bx,[004D]
Can you see what is there in these vars under freedos?
I saw them under dosdebug to be zero (in the media_check).
So even under freedos it returns an error? How is so?
Sorry I misunderstood you, I didn't try freedos(still struggling with FDPP != FreeDOS) yet, but will now.
Interestingly it doesn't check those values under freedos 1.20
dosdebug>
system state: stopped
AX=0000 BX=0002 CX=02e7 DX=02e7 SI=0000 DI=037c SP=0872 BP=0890
DS=02c5 ES=00d8 FS=0000 GS=0000 FL=000a3346
CS:IP=02c5:00c6 SS:SP=00d8:0872
02c5:00c6 FF971C00 call near word [bx+001C]
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=0002 CX=02e7 DX=02e7 SI=0000 DI=037c SP=0870 BP=0890
DS=02c5 ES=00d8 FS=0000 GS=0000 FL=000a3346
CS:IP=02c5:00de SS:SP=00d8:0870
02c5:00de 8A1E5100 mov bl,[0051]
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=0001 CX=02e7 DX=02e7 SI=0000 DI=037c SP=0870 BP=0890
DS=02c5 ES=00d8 FS=0000 GS=0000 FL=000a3346
CS:IP=02c5:00e2 SS:SP=00d8:0870
02c5:00e2 26885D0E mov es:[di+0E],bl
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=0001 CX=02e7 DX=02e7 SI=0000 DI=037c SP=0870 BP=0890
DS=02c5 ES=00d8 FS=0000 GS=0000 FL=000a3346
CS:IP=02c5:00e6 SS:SP=00d8:0870
02c5:00e6 0ADB or bl,bl
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=0001 CX=02e7 DX=02e7 SI=0000 DI=037c SP=0870 BP=0890
DS=02c5 ES=00d8 FS=0000 GS=0000 FL=000a3302
CS:IP=02c5:00e8 SS:SP=00d8:0870
02c5:00e8 790D jns 00F7 ($+d)
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=0001 CX=02e7 DX=02e7 SI=0000 DI=037c SP=0870 BP=0890
DS=02c5 ES=00d8 FS=0000 GS=0000 FL=000a3302
CS:IP=02c5:00f7 SS:SP=00d8:0870
02c5:00f7 C3 ret
but printing it shows
dosdebug> d 02c5:004b
dosdebug>
02c5:004b 80 3E 00 00 90 06 01 01 00 00 00 00 00 00 00 00 .>..............
02c5:005b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:006b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:007b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:008b 00 00 00 00 00 00 00 17 F5 00 F0 00 02 00 00 01 ........u.p.....
02c5:009b 00 00 1A 00 00 00 00 78 0A EC 02 2E 89 1E 18 00 .......x.l......
02c5:00ab 2E 8C 06 1A 00 CB 90 9C 60 1E 06 0E 1F C4 3E 18 .....K..`....D>.
02c5:00bb 00 26 8A 5D 02 D0 E3 32 FF 33 C0 FF 97 1C 00 0D .&.].Pc23@....
So under fdpp, 0000:0051 xmsdsk_data_media_changed
has -1 (media changed) and 0 (no info) under freedos.
You can use gdb watchpoints with lowmem_base or mem_base
and cpu_emu=vm86sim to see who puts -1 to that var.
Btw why dosdebug doesn't print that var symbolically?
Its not like it is ds:[0] that would get broken.
Media changed is initially -1, then after it's checked it changes to zero. It's never successful on fdpp, so doesn't change.
I don't know why the symbol isn't printed.
Media changed is initially -1, then after it's checked it changes to zero.
Then why on freedos it is immediately zero?
Then why on freedos it is immediately zero?
No, its 1, not changed.
02c5:00de 8A1E5100 mov bl,[0051]
dosdebug>
dosdebug>
system state: stopped
AX=0000 BX=0001
But under fdpp its -1.
Where you got the symbols btw?
Wrote them by hand by reading the command table dump and knowing driver structure.
Then why on freedos it is immediately zero?
Because I have to wait for the driver to be loaded in order to set the breakpoint and load the symbols, I can't guarantee that media_check hasn't already been called and set the variable to 1.
Can you give me the magic gdb incantation to set a watchpoint for word at 02c5:004b?
I'm using this
watch *(unsigned short int *) &lowmem_base[(0x02c5<<4)+0x004b]
But it doesn't trap the change to
(gdb) p/x *(unsigned short int *) &lowmem_base[(0x02c5<<4)+0x004b]
$3 = 0x3e80
Just these
Thread 1 "dosemu.bin" hit Hardware watchpoint 1: *(unsigned short int *) &lowmem_base[(0x02c5<<4)+0x004b]
Old value = 7762
New value = 7782
0x080e7935 in fatfs_read (f=0x8aac920, buf=11040, pos=17281, len=1) at fatfs.c:345
345 MEMCPY_2DOS(buf, b, 0x200);
(gdb) next
Thread 1 "dosemu.bin" hit Hardware watchpoint 1: *(unsigned short int *) &lowmem_base[(0x02c5<<4)+0x004b]
Old value = 7782
New value = 29542
0x080e7935 in fatfs_read (f=0x8aac920, buf=11040, pos=17281, len=1) at fatfs.c:345
345 MEMCPY_2DOS(buf, b, 0x200);
2 things to try: use vm86sim and set the watchpoint ALSO to mem_base (with same treatment as lowmem_base)
Couldn't set two hardware breakpoints, so had to choose. I also note that mem_base == 0, even so setting watchpoint on
*(unsigned short int *) &mem_base[(0x02c5<<4)+0x004b]
didn't stop at at all.
Now using vm86sim, was fullsim before
Switch $_cpu_vm properly.
I set it now to "emulated" and now got to see
Thread 1 "dosemu.bin" hit Hardware watchpoint 1: *(unsigned short int *) &mem_base[(0x02c5<<4)+0x004b]
Old value = 7762
New value = 16000
0x081452ee in Gen_sim (op=23, mode=4099) at codegen-sim.c:663
663 *AR1.pwu = DR1.w.l;
(gdb) p/x *(unsigned short int *) &mem_base[(0x02c5<<4)+0x004b]
$5 = 0x3e80
(gdb) bt
#0 0x081452ee in Gen_sim (op=23, mode=4099) at codegen-sim.c:663
#1 0x081339b9 in _ModRM (opc=137 '\211', PC=12503, mode=4099) at modrm-gen.c:146
#2 0x08121839 in _Interp86 (PC=12503, basemode=3) at interp.c:1072
#3 0x0811d2ce in Interp86 (PC=1045789, mod0=3) at interp.c:395
#4 0x08131b7f in e_vm86 () at cpu-emu.c:1144
#5 0x0810f851 in do_vm86 (x=0x88dac40 <vm86u>) at do_vm86.c:433
#6 0x0810f8be in _do_vm86 () at do_vm86.c:455
#7 0x0811006b in run_vm86 () at do_vm86.c:590
#8 0x081100e7 in loopstep_run_vm86 () at do_vm86.c:614
#9 0x080affe7 in main (argc=11, argv=0xbffff704) at emu.c:422
setting set mhpdbgc.want_to_stop=1
allowed me to stop in the init section of the driver
dosdebug> u 02c5:0201
dosdebug>
xmsdsk_initialisation:
02c5:0201 C8240000 enter 0024,00
02c5:0205 56 push si
02c5:0206 57 push di
02c5:0207 8C16D847 mov [47D8],ss
02c5:020b 8926DA47 mov [47DA],sp
02c5:020f 892EDC47 mov [47DC],bp
02c5:0213 FA cli
02c5:0214 8CD8 mov ax,ds
02c5:0216 8ED0 mov ss,ax
02c5:0218 BDDE49 mov bp,49DE
02c5:021b A1DC47 mov ax,[47DC]
02c5:021e 2B06DA47 sub ax,[47DA]
dosdebug>
dosdebug>
02c5:0222 8BD5 mov dx,bp
02c5:0224 2BD0 sub dx,ax
02c5:0226 8BE2 mov sp,dx
02c5:0228 FB sti
02c5:0229 68823E push 3E82
02c5:022c E82F23 call 255E ($+232f)
02c5:022f 59 pop cx
02c5:0230 B430 mov ah,30
02c5:0232 CD21 int 21
02c5:0234 A2673F mov [3F67],al
02c5:0237 3C03 cmp al,03
02c5:0239 730B jnc 0246 ($+b)
02c5:023b FF36A63D push word [3DA6]
02c5:023f E81D04 call 065F ($+41d)
dosdebug>
dosdebug>
02c5:0242 59 pop cx
02c5:0243 E9FE03 jmp 0644 ($+3fe)
02c5:0246 C41E1800 les bx,[0018]
02c5:024a 268A4716 mov al,es:[bx+16]
02c5:024e A25000 mov [0050],al
02c5:0251 803E500000 cmp byte [0050],00
02c5:0256 7C07 jl 025F ($+7)
02c5:0258 803E500019 cmp byte [0050],19
02c5:025d 7E06 jle 0265 ($+6)
02c5:025f FF36A83D push word [3DA8]
02c5:0263 EBDA jmp short 023F ($-26)
02c5:0265 E8331B call 1D9B ($+1b33)
02c5:0268 0BC0 or ax,ax
02c5:026a 7405 je 0271 ($+5)
02c5:026c 68A83E push 3EA8
02c5:026f EBCE jmp short 023F ($-32)
02c5:0271 A1E64C mov ax,[4CE6]
02c5:0274 8B16E44C mov dx,[4CE4]
02c5:0278 89169200 mov [0092],dx
02c5:027c A39400 mov [0094],ax
02c5:027f 16 push ss
02c5:0280 8D46FA lea ax,[bp-06]
dosdebug>
dosdebug>
02c5:0283 50 push ax
02c5:0284 16 push ss
02c5:0285 8D46FC lea ax,[bp-04]
02c5:0288 50 push ax
02c5:0289 E82D1B call 1DB9 ($+1b2d)
02c5:028c 83C408 add sp,0008
02c5:028f C1F808 sar ax,08
02c5:0292 8BF0 mov si,ax
02c5:0294 E86306 call 08FA ($+663)
02c5:0297 8BF8 mov di,ax
02c5:0299 83FF02 cmp di,0002
02c5:029c 7E13 jle 02B1 ($+13)
02c5:029e 83FE02 cmp si,0002
02c5:02a1 7E0E jle 02B1 ($+e)
dosdebug>
dosdebug>
02c5:02a3 16 push ss
02c5:02a4 8D46F6 lea ax,[bp-0A]
02c5:02a7 50 push ax
02c5:02a8 E87F1D call 202A ($+1d7f)
02c5:02ab 59 pop cx
02c5:02ac 59 pop cx
02c5:02ad 0BC2 or ax,dx
02c5:02af 751F jne 02D0 ($+1f)
02c5:02b1 C746F60000 mov word [bp-0A],0000
02c5:02b6 C746F80000 mov word [bp-08],0000
02c5:02bb 16 push ss
02c5:02bc 8D46F6 lea ax,[bp-0A]
02c5:02bf 50 push ax
02c5:02c0 E8A81B call 1E6B ($+1ba8)
02c5:02c3 59 pop cx
02c5:02c4 59 pop cx
02c5:02c5 0BC0 or ax,ax
02c5:02c7 7507 jne 02D0 ($+7)
02c5:02c9 FF36AA3D push word [3DAA]
02c5:02cd E96FFF jmp 023F ($-91)
02c5:02d0 C41E1800 les bx,[0018]
02c5:02d4 268B4714 mov ax,es:[bx+14]
02c5:02d8 268B5712 mov dx,es:[bx+12]
02c5:02dc 8956DE mov [bp-22],dx
02c5:02df 8946E0 mov [bp-20],ax
02c5:02e2 C45EDE les bx,[bp-22]
dosdebug>
dosdebug>
02c5:02e5 268A07 mov al,es:[bx]
02c5:02e8 8846DD mov [bp-23],al
02c5:02eb C746E60000 mov word [bp-1A],0000
02c5:02f0 C746E80000 mov word [bp-18],0000
02c5:02f5 EB0C jmp short 0303 ($+c)
02c5:02f7 FF46DE inc word [bp-22]
02c5:02fa C45EDE les bx,[bp-22]
02c5:02fd 268A07 mov al,es:[bx]
02c5:0300 8846DD mov [bp-23],al
02c5:0303 807EDD2E cmp byte [bp-23],2E
dosdebug>
dosdebug>
02c5:0307 75EE jne 02F7 ($-12)
02c5:0309 EB0C jmp short 0317 ($+c)
02c5:030b FF46DE inc word [bp-22]
02c5:030e C45EDE les bx,[bp-22]
02c5:0311 268A07 mov al,es:[bx]
02c5:0314 8846DD mov [bp-23],al
02c5:0317 807EDD30 cmp byte [bp-23],30
02c5:031b 7C06 jl 0323 ($+6)
02c5:031d 807EDD39 cmp byte [bp-23],39
02c5:0321 7E3E jle 0361 ($+3e)
02c5:0323 807EDD0D cmp byte [bp-23],0D
dosdebug>
dosdebug>
02c5:0327 7438 je 0361 ($+38)
02c5:0329 807EDD0A cmp byte [bp-23],0A
02c5:032d 75DC jne 030B ($-24)
02c5:032f EB30 jmp short 0361 ($+30)
02c5:0331 8B4EE8 mov cx,[bp-18]
02c5:0334 8B5EE6 mov bx,[bp-1A]
02c5:0337 33D2 xor dx,dx
02c5:0339 B80A00 mov ax,000A
02c5:033c E83839 call 3C77 ($+3938)
02c5:033f 50 push ax
02c5:0340 8A46DD mov al,[bp-23]
02c5:0343 98 cbw
02c5:0344 05D0FF add ax,FFD0
02c5:0347 52 push dx
02c5:0348 99 cwd
02c5:0349 5B pop bx
02c5:034a 59 pop cx
02c5:034b 03C1 add ax,cx
02c5:034d 13D3 adc dx,bx
02c5:034f 8946E6 mov [bp-1A],ax
02c5:0352 8956E8 mov [bp-18],dx
02c5:0355 FF46DE inc word [bp-22]
02c5:0358 C45EDE les bx,[bp-22]
02c5:035b 268A07 mov al,es:[bx]
02c5:035e 8846DD mov [bp-23],al
02c5:0361 807EDD30 cmp byte [bp-23],30
02c5:0365 7C06 jl 036D ($+6)
dosdebug>
dosdebug>
02c5:0367 807EDD39 cmp byte [bp-23],39
02c5:036b 7EC4 jle 0331 ($-3c)
02c5:036d 8B46E6 mov ax,[bp-1A]
02c5:0370 0B46E8 or ax,[bp-18]
02c5:0373 7503 jne 0378 ($+3)
02c5:0375 E99602 jmp 060E ($+296)
02c5:0378 803E673F04 cmp byte [3F67],04
02c5:037d 7307 jnc 0386 ($+7)
02c5:037f 33D2 xor dx,dx
02c5:0381 B8F07F mov ax,7FF0
02c5:0384 EB06 jmp short 038C ($+6)
02c5:0386 BA1F00 mov dx,001F
dosdebug>
dosdebug>
02c5:0389 B8E0FD mov ax,FDE0
02c5:038c 8946EE mov [bp-12],ax
02c5:038f 8956F0 mov [bp-10],dx
02c5:0392 8B46E8 mov ax,[bp-18]
02c5:0395 8B56E6 mov dx,[bp-1A]
02c5:0398 3B46F0 cmp ax,[bp-10]
02c5:039b 7223 jc 03C0 ($+23)
02c5:039d 7705 ja 03A4 ($+5)
02c5:039f 3B56EE cmp dx,[bp-12]
02c5:03a2 761C jbe 03C0 ($+1c)
02c5:03a4 FF76F0 push word [bp-10]
02c5:03a7 FF76EE push word [bp-12]
dosdebug>
dosdebug>
02c5:03aa FF36AC3D push word [3DAC]
02c5:03ae E8AD21 call 255E ($+21ad)
02c5:03b1 83C406 add sp,0006
02c5:03b4 8B46F0 mov ax,[bp-10]
02c5:03b7 8B56EE mov dx,[bp-12]
02c5:03ba 8956E6 mov [bp-1A],dx
02c5:03bd 8946E8 mov [bp-18],ax
02c5:03c0 8B56E8 mov dx,[bp-18]
02c5:03c3 8B46E6 mov ax,[bp-1A]
02c5:03c6 050F00 add ax,000F
02c5:03c9 83D200 adc dx,0000
02c5:03cc B104 mov cl,04
02c5:03ce E8EF35 call 39C0 ($+35ef)
02c5:03d1 B104 mov cl,04
02c5:03d3 E8C935 call 399F ($+35c9)
02c5:03d6 8946F2 mov [bp-0E],ax
02c5:03d9 8956F4 mov [bp-0C],dx
02c5:03dc 8B46F4 mov ax,[bp-0C]
02c5:03df 8B56F2 mov dx,[bp-0E]
02c5:03e2 3B46F8 cmp ax,[bp-08]
02c5:03e5 721A jc 0401 ($+1a)
02c5:03e7 7705 ja 03EE ($+5)
02c5:03e9 3B56F6 cmp dx,[bp-0A]
dosdebug>
dosdebug>
02c5:03ec 7613 jbe 0401 ($+13)
02c5:03ee 8B46F8 mov ax,[bp-08]
02c5:03f1 8B56F6 mov dx,[bp-0A]
02c5:03f4 8956F2 mov [bp-0E],dx
02c5:03f7 8946F4 mov [bp-0C],ax
02c5:03fa 68BE3E push 3EBE
02c5:03fd E8E523 call 27E5 ($+23e5)
02c5:0400 59 pop cx
02c5:0401 8B46F8 mov ax,[bp-08]
02c5:0404 8B56F6 mov dx,[bp-0A]
02c5:0407 2B56F2 sub dx,[bp-0E]
02c5:040a 1B46F4 sbb ax,[bp-0C]
dosdebug>
dosdebug>
02c5:040d 8956E2 mov [bp-1E],dx
02c5:0410 8946E4 mov [bp-1C],ax
02c5:0413 8B46E2 mov ax,[bp-1E]
02c5:0416 0B46E4 or ax,[bp-1C]
02c5:0419 741C je 0437 ($+1c)
02c5:041b 833E883F00 cmp word [3F88],0000
02c5:0420 7415 je 0437 ($+15)
02c5:0422 68E04B push 4BE0
02c5:0425 FF76E4 push word [bp-1C]
02c5:0428 FF76E2 push word [bp-1E]
02c5:042b E82104 call 084F ($+421)
dosdebug>
dosdebug>
02c5:042e 83C406 add sp,0006
02c5:0431 0BC0 or ax,ax
02c5:0433 7402 je 0437 ($+2)
02c5:0435 EB29 jmp short 0460 ($+29)
02c5:0437 685200 push 0052
02c5:043a FF76F4 push word [bp-0C]
02c5:043d FF76F2 push word [bp-0E]
02c5:0440 E80C04 call 084F ($+40c)
02c5:0443 83C406 add sp,0006
02c5:0446 0BC0 or ax,ax
02c5:0448 741D je 0467 ($+1d)
02c5:044a 8B46E2 mov ax,[bp-1E]
02c5:044d 0B46E4 or ax,[bp-1C]
02c5:0450 740E je 0460 ($+e)
02c5:0452 833E883F00 cmp word [3F88],0000
02c5:0457 7407 je 0460 ($+7)
02c5:0459 68E04B push 4BE0
02c5:045c E87204 call 08D1 ($+472)
02c5:045f 59 pop cx
02c5:0460 FF36AE3D push word [3DAE]
02c5:0464 E9D8FD jmp 023F ($-228)
02c5:0467 8B46E2 mov ax,[bp-1E]
02c5:046a 0B46E4 or ax,[bp-1C]
02c5:046d 740E je 047D ($+e)
02c5:046f 833E883F00 cmp word [3F88],0000
dosdebug>
dosdebug>
02c5:0474 7407 je 047D ($+7)
02c5:0476 68E04B push 4BE0
02c5:0479 E85504 call 08D1 ($+455)
02c5:047c 59 pop cx
02c5:047d 8B46F4 mov ax,[bp-0C]
02c5:0480 8B56F2 mov dx,[bp-0E]
02c5:0483 D1E2 shl dx,1
02c5:0485 D1D0 rcl ax,1
02c5:0487 89164B00 mov [004B],dx
02c5:048b A34D00 mov [004D],ax(xmsdsk_magic_word_2)
02c5:048e 833E4D0001 cmp word [004D],0001
02c5:0493 770E ja 04A3 ($+e)
dosdebug>
dosdebug>
02c5:0495 7207 jc 049E ($+7)
02c5:0497 833E4B0000 cmp word [004B],0000
02c5:049c 7305 jnc 04A3 ($+5)
02c5:049e A14B00 mov ax,[004B](xmsdsk_magic_word_1)
02c5:04a1 EB02 jmp short 04A5 ($+2)
02c5:04a3 33C0 xor ax,ax
02c5:04a5 A33E00 mov [003E],ax
02c5:04a8 8B164D00 mov dx,[004D]
02c5:04ac A14B00 mov ax,[004B](xmsdsk_magic_word_1)
02c5:04af B105 mov cl,05
02c5:04b1 E80C35 call 39C0 ($+350c)
02c5:04b4 8946E6 mov [bp-1A],ax
dosdebug>
dosdebug>
02c5:04b7 8956E8 mov [bp-18],dx
02c5:04ba 837EE800 cmp word [bp-18],0000
02c5:04be 720E jc 04CE ($+e)
02c5:04c0 7507 jne 04C9 ($+7)
02c5:04c2 817EE60002 cmp word [bp-1A],0200
02c5:04c7 7205 jc 04CE ($+5)
02c5:04c9 B80002 mov ax,0200
02c5:04cc EB09 jmp short 04D7 ($+9)
02c5:04ce 8B46E6 mov ax,[bp-1A]
02c5:04d1 051F00 add ax,001F
02c5:04d4 25E003 and ax,03E0
02c5:04d7 A33C00 mov [003C],ax
02c5:04da 833E8A3F00 cmp word [3F8A],0000
02c5:04df 742F je 0510 ($+2f)
02c5:04e1 EB04 jmp short 04E7 ($+4)
02c5:04e3 D0263800 shl byte [0038],1
02c5:04e7 A03800 mov al,[0038]
02c5:04ea 98 cbw
02c5:04eb 99 cwd
02c5:04ec 52 push dx
02c5:04ed 50 push ax
02c5:04ee FF364D00 push word [004D]
02c5:04f2 FF364B00 push word [004B]
02c5:04f6 E8FF33 call 38F8 ($+33ff)
dosdebug>
dosdebug>
02c5:04f9 8946EA mov [bp-16],ax
02c5:04fc 8956EC mov [bp-14],dx
02c5:04ff 0BD2 or dx,dx
02c5:0501 77E0 ja 04E3 ($-20)
02c5:0503 7303 jnc 0508 ($+3)
02c5:0505 E9A700 jmp 05AF ($+a7)
02c5:0508 3DF0FF cmp ax,FFF0
02c5:050b 73D6 jnc 04E3 ($-2a)
02c5:050d E99F00 jmp 05AF ($+9f)
02c5:0510 C746E60100 mov word [bp-1A],0001
02c5:0515 C746E80000 mov word [bp-18],0000
dosdebug>
dosdebug>
02c5:051a C746FE0000 mov word [bp-02],0000
02c5:051f EB31 jmp short 0552 ($+31)
02c5:0521 8B56E8 mov dx,[bp-18]
02c5:0524 8B46E6 mov ax,[bp-1A]
02c5:0527 8A4EFE mov cl,[bp-02]
02c5:052a E87234 call 399F ($+3472)
02c5:052d 52 push dx
02c5:052e 50 push ax
02c5:052f FF364D00 push word [004D]
02c5:0533 FF364B00 push word [004B]
02c5:0537 E8BE33 call 38F8 ($+33be)
dosdebug>
dosdebug>
02c5:053a 8946EA mov [bp-16],ax
02c5:053d 8956EC mov [bp-14],dx
02c5:0540 837EEC00 cmp word [bp-14],0000
02c5:0544 7709 ja 054F ($+9)
02c5:0546 7210 jc 0558 ($+10)
02c5:0548 817EEAF00F cmp word [bp-16],0FF0
02c5:054d 7209 jc 0558 ($+9)
02c5:054f FF46FE inc word [bp-02]
02c5:0552 837EFE05 cmp word [bp-02],0005
02c5:0556 7CC9 jl 0521 ($-37)
02c5:0558 837EEC00 cmp word [bp-14],0000
The change occurred at 02c5:0487
I suppose we need to compare 2 traces of init now.
Yes, but I'm wondering with FreeDOS how to break
somewhere between the driver load to memory and calling its init function.
For example by patching driver's code with 0xcc, and when it breaks, replace back by hands. Have you used hiew.exe or qview.exe for patching executables?
Have you used hiew.exe or qview.exe for patching executables?
Thanks, but i haven't tried either, so maybe next time as I just got lucky with dosemu/dosdebug's -H9 option. It didn't break exactly where i wanted it, but then clearing and resetting the bp got me to the start of xmsdsk's init. I did have to revert cpu_vm to unset as for some reason I was getting a segfault at startup. But here is the xmsdsk_init_FreeDOS.zip. I'll try to repeat with FDPP.
Here's the corresponding one for FDPP xmsdsk_init_FDPP.zip
Please report or debug a segfault.
Can you just check out hdr/device.h
and the definition / use of _r_cmdline as I notice it's the only use of MK_FAR_STR_OBJ()
in the whole of FDPP, please?
UBYTE _r_nunits; /* number of units */
__DOSFAR(BYTE)_r_endaddr; /* Ending Address */
union {
__DOSFAR(bpb) _r_bpbptr; /* ptr to BPB array */
__DOSFAR(char) _r_cmdline;
} _r_cmd;
UBYTE _r_firstunit;
Declared as __DOSFAR
and the FAR version
of macro is used. PTR_MEMB
definitions use
the NEAR version.
But what is the problem? This obj stuff may have
the bugs indeed.
I'm about to write a dosdebug extension to print the request_header easily, so noticed the difference in the structure between FDPP and my device drivers book / FreeDOS. This C++ stuff is all voodoo so of course I'm suspicious as it's not obviously right to me. I also remember that my emudsk.sys driver doesn't use the command line, but xmsdsk does.
Just looking for patterns...
Did you notice it in a definition, or in the
dump? The definition looks fine, __DOSFAR
is basically a seg/off far ptr.
C++ stuff here is indeed voodoo, and not only
for you: even g++ doesn't understand it. Only
clang++ can parse that kind of crap (and even
then, with lots of work-arounds).
Did you notice it in a definition
Yes, I haven't checked it from dosdebug yet, hence writing the nice print function.
Since the cmdline pointer occupies the same storage space with BPB pointer, does it matter to FDPP that block drivers overwrite that pointer value during the init routine so that it points at the drivers BPB?
I hope it doesn't matter much unless someone then uses that pointer as a pointer.
I was thinking more in terms of MK_FAR_STR_OBJ()
tidy up after use.
There are garbage collectors, so if things work correctly, nothing should go wrong.
Is there any way of validating a pointer obtained via FAR2PTR(x) before I dereference it?
It should be valid... What's the problem?
Just wondered if it was possible to segfault when dereferencing it, if I need to guard against that?
Nope because FAR ptr is always valid. Therefore the converted flat ptr should be. I believe that the special care is taken to fix up the permissions for the converted ptr, for example far ptr can point to R/O memory, but the converted flat ptr should point to R/W to avoid any segfaults. If not - likely a bug.
We check DPMI far pointers sometimes. Not the case here.
So checking the device driver request header with FDPP on xmsdsk init at entry and exit looks okay, although I do wonder why I didn't see the arguments as it was loaded as device=xmsdsk.exe 8000
.
dosdebug> usermap load-ms xmsdsk.map 0x02B2
dosdebug>
reading MSLINK map file 'xmsdsk.map'
symbol table now contains 274 symbol(s)
dosdebug> bp xmsdsk_interrupt
dosdebug> g
dosdebug>
Warning: code at breakpoint 0 has been overwritten (0x01)
Warning: code at breakpoint 0 has been overwritten (0x9c)
system state: emulated,stopped
AX=00b2 BX=12c9 CX=0000 DX=12ce SI=0000 DI=03e4 SP=03d6 BP=03de
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000b3206
CS:IP=02b2:00b2 SS:SP=9fbf:03d6
xmsdsk_interrupt:
02b2:00b2 9C pushf
dosdebug> d xmsdsk_rh_pointer
dosdebug>
02b2:0018 C9 12 D9 00 01 02 DE 00 F8 00 07 01 1A 01 DA 00 I.Y...^.x.....Z.
02b2:0028 DA 00 DA 00 16 01 16 01 DA 00 DA 00 DA 00 00 02 Z.Z.....Z.Z.Z...
02b2:0038 01 01 00 01 00 00 00 00 F8 00 00 08 00 01 00 00 ........x.......
02b2:0048 00 00 00 00 00 00 00 90 FF FF 00 00 00 00 00 00 ..............
02b2:0058 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0068 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0078 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0088 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
dosdebug> ddrh 00d9:12c9
dosdebug>
Request
length 30
unit 0
command 'Init'
nunits 22
break 8b46:fff0
At Entry
cmdline 00d9:12b8
=> 'C:\XMSDSK.EXE
'
At Exit
BPB 00d9:12b8
first_drive 6
status 0x0000
dosdebug> bp xmsdsk_interrupt_return
dosdebug> g
dosdebug>
system state: emulated,stopped
AX=00b2 BX=12c9 CX=0000 DX=12ce SI=0000 DI=03e4 SP=03d6 BP=03de
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000b3206
CS:IP=02b2:00d9 SS:SP=9fbf:03d6
02b2:00d9 CB retf
dosdebug> ddrh 00d9:12c9
dosdebug>
Request
length 30
unit 0
command 'Init'
nunits 1
break 02b2:0201
At Entry
cmdline 02b2:3db4
=> '6'
At Exit
BPB 02b2:3db4
first_drive 6
status 0x0100
Edited: BPB is FAR pointer to NEAR pointer (0036) so it's okay.
dosdebug> d 02b2:3db4
dosdebug>
02b2:3db4 36 00 EB FE 90 46 2E 55 42 45 52 54 4F 00 46 41 6.k~.F.UBERTO.FA
02b2:3dc4 54 20 20 20 20 20 00 4D 53 2D 52 41 4D 44 52 49 T .MS-RAMDRI
02b2:3dd4 56 45 00 44 4F 53 20 76 65 72 73 69 6F 6E 20 6E VE.DOS version n
02b2:3de4 6F 74 20 73 75 70 70 6F 72 74 65 64 2E 00 49 6E ot supported..In
02b2:3df4 76 61 6C 69 64 20 64 72 69 76 65 20 28 69 6E 63 valid drive (inc
02b2:3e04 72 65 61 73 65 20 4C 41 53 54 44 52 49 56 45 20 rease LASTDRIVE
02b2:3e14 3F 29 2E 00 58 4D 53 20 67 65 74 20 66 72 65 65 ?)..XMS get free
02b2:3e24 20 6D 65 6D 20 65 72 72 6F 72 2E 00 4F 6E 6C 79 mem error..Only
Proceeding to Media Check shows it fails, presumably every time
dosdebug> d xmsdsk_rh_pointer
dosdebug>
02b2:0018 7C 03 D9 00 01 02 DE 00 F8 00 07 01 1A 01 DA 00 |.Y...^.x.....Z.
02b2:0028 DA 00 DA 00 16 01 16 01 DA 00 DA 00 DA 00 00 02 Z.Z.....Z.Z.Z...
02b2:0038 01 01 00 01 00 00 00 00 F8 00 00 08 00 01 00 00 ........x.......
02b2:0048 00 00 00 00 00 00 00 90 06 FF 00 00 00 00 00 00 ...............
02b2:0058 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0068 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0078 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0088 00 00 00 00 00 00 00 00 00 00 17 F5 00 F0 00 00 ...........u.p..
dosdebug> ddrh 00d9:037c
dosdebug>
Request
length 30
unit 0
command 'Media Check'
media id 0x00
status 0
status 0x0000
dosdebug> g
dosdebug>
system state: emulated,stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f0 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000b3206
CS:IP=02b2:00d9 SS:SP=00d9:08f0
02b2:00d9 CB retf
dosdebug> ddrh 00d9:037c
dosdebug>
Request
length 30
unit 0
command 'Media Check'
media id 0x00
status -1
status 0x8101
dosdebug> g
Will try to repeat with FreeDOS 1.20
So it seems like we are losing the command line args and xmsdsk is not reacting well to that..
system state: emulated,stopped
AX=00b2 BX=2356 CX=0000 DX=1130 SI=0000 DI=0008 SP=2342 BP=234a
DS=02c5 ES=9dc0 FS=0000 GS=0000 FL=000b3202
CS:IP=02c5:00b2 SS:SP=9dc0:2342
xmsdsk_interrupt:
02c5:00b2 9C pushf
dosdebug> d xmsdsk_rh_pointer
dosdebug>
02c5:0018 56 23 C0 9D 01 02 DE 00 F8 00 07 01 1A 01 DA 00 V#@...^.x.....Z.
02c5:0028 DA 00 DA 00 16 01 16 01 DA 00 DA 00 DA 00 00 02 Z.Z.....Z.Z.Z...
02c5:0038 01 01 00 01 00 00 00 00 F8 00 00 08 00 01 00 00 ........x.......
02c5:0048 00 00 00 00 00 00 00 90 FF FF 00 00 00 00 00 00 ..............
02c5:0058 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0068 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0078 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0088 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
dosdebug> ddrh 9dc0:2356
dosdebug>
Request
length 30
unit 0
command 'Init'
nunits 0
break 7c66:fff0
At Entry
cmdline 9dc0:1126
=> 'XMSDSK.EXE 8000
'
At Exit
BPB 9dc0:1126
first_drive 6
status 0x0000
dosdebug> g
dosdebug>
system state: emulated,stopped
AX=00b2 BX=2356 CX=0000 DX=1130 SI=0000 DI=0008 SP=2342 BP=234a
DS=02c5 ES=9dc0 FS=0000 GS=0000 FL=000b3202
CS:IP=02c5:00d9 SS:SP=9dc0:2342
xmsdsk_interrupt_return:
02c5:00d9 CB retf
dosdebug> ddrh 9dc0:2356
dosdebug>
Request
length 30
unit 0
command 'Init'
nunits 1
break 02c5:0201
At Entry
cmdline 02c5:3db4
=> '6'
At Exit
BPB 02c5:3db4
first_drive 6
status 0x0100
BPB pointer is
dosdebug> d 02c5:3db4
dosdebug>
02c5:3db4 36 00 EB FE 90 46 2E 55 42 45 52 54 4F 00 46 41 6.k~.F.UBERTO.FA
02c5:3dc4 54 20 20 20 20 20 00 4D 53 2D 52 41 4D 44 52 49 T .MS-RAMDRI
02c5:3dd4 56 45 00 44 4F 53 20 76 65 72 73 69 6F 6E 20 6E VE.DOS version n
02c5:3de4 6F 74 20 73 75 70 70 6F 72 74 65 64 2E 00 49 6E ot supported..In
02c5:3df4 76 61 6C 69 64 20 64 72 69 76 65 20 28 69 6E 63 valid drive (inc
02c5:3e04 72 65 61 73 65 20 4C 41 53 54 44 52 49 56 45 20 rease LASTDRIVE
02c5:3e14 3F 29 2E 00 58 4D 53 20 67 65 74 20 66 72 65 65 ?)..XMS get free
02c5:3e24 20 6D 65 6D 20 65 72 72 6F 72 2E 00 4F 6E 6C 79 mem error..Only
and dereferenced as NEAR we see BPB
dosdebug> d 02c5:0036
dosdebug>
02c5:0036 00 02 04 01 00 01 00 02 80 3E F8 0C 00 08 00 01 .........>x.....
02c5:0046 00 00 00 00 00 80 3E 00 00 90 06 FF 01 00 00 00 ......>........
02c5:0056 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0066 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0076 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0086 00 00 00 00 00 00 00 00 00 00 00 00 17 F5 00 F0 .............u.p
02c5:0096 00 02 00 00 00 00 DE 49 C5 02 01 00 00 58 00 00 ......^IE....X..
02c5:00a6 2E 89 1E 18 00 2E 8C 06 1A 00 CB 90 9C 60 1E 06 ..........K..`..
dosdebug> g
dosdebug>
system state: emulated,stopped
AX=00b2 BX=037c CX=02e7 DX=02e7 SI=0000 DI=02e7 SP=0888 BP=0890
DS=02c5 ES=00d8 FS=0000 GS=0000 FL=000b3297
CS:IP=02c5:00b2 SS:SP=00d8:0888
xmsdsk_interrupt:
02c5:00b2 9C pushf
dosdebug> d xmsdsk_rh_pointer
dosdebug>
02c5:0018 7C 03 D8 00 01 02 DE 00 F8 00 07 01 1A 01 DA 00 |.X...^.x.....Z.
02c5:0028 DA 00 DA 00 16 01 16 01 DA 00 DA 00 DA 00 00 02 Z.Z.....Z.Z.Z...
02c5:0038 04 01 00 01 00 02 80 3E F8 0C 00 08 00 01 00 00 .......>x.......
02c5:0048 00 00 00 80 3E 00 00 90 06 FF 01 00 00 00 00 00 ....>..........
02c5:0058 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0068 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0078 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0088 00 00 00 00 00 00 00 00 00 00 17 F5 00 F0 00 02 ...........u.p..
dosdebug> ddrh 00d8:037c
dosdebug>
Request
length 30
unit 0
command 'Media Check'
media id 0x00
status -80
status 0x0000
dosdebug> g
dosdebug>
system state: emulated,stopped
AX=00b2 BX=037c CX=02e7 DX=02e7 SI=0000 DI=02e7 SP=0888 BP=0890
DS=02c5 ES=00d8 FS=0000 GS=0000 FL=000b3297
CS:IP=02c5:00d9 SS:SP=00d8:0888
xmsdsk_interrupt_return:
02c5:00d9 CB retf
dosdebug> ddrh 00d8:037c
dosdebug>
Request
length 30
unit 0
command 'Media Check'
media id 0x00
status -1
status 0x0100
xmsdsk_interrupt:
02c5:00b2 9C pushf
dosdebug> d xmsdsk_rh_pointer
dosdebug>
02c5:0018 7C 03 D8 00 01 02 DE 00 F8 00 07 01 1A 01 DA 00 |.X...^.x.....Z.
02c5:0028 DA 00 DA 00 16 01 16 01 DA 00 DA 00 DA 00 00 02 Z.Z.....Z.Z.Z...
02c5:0038 04 01 00 01 00 02 80 3E F8 0C 00 08 00 01 00 00 .......>x.......
02c5:0048 00 00 00 80 3E 00 00 90 06 FF 01 00 00 00 00 00 ....>..........
02c5:0058 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0068 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0078 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0088 00 00 00 00 00 00 00 00 00 00 17 F5 00 F0 00 02 ...........u.p..
dosdebug> ddrh 00d8:037c
dosdebug>
Request
length 30
unit 0
command 'Get BPB'
media id 0x00
buffer 00d8:0ab0
BPB 00d8:1aa8
status 0x0000
dosdebug> g
dosdebug>
system state: emulated,stopped
AX=00b2 BX=037c CX=02e7 DX=ffff SI=0000 DI=02e7 SP=0888 BP=0890
DS=02c5 ES=00d8 FS=0000 GS=0000 FL=000b3246
CS:IP=02c5:00d9 SS:SP=00d8:0888
xmsdsk_interrupt_return:
02c5:00d9 CB retf
dosdebug> ddrh 00d8:037c
dosdebug>
Request
length 30
unit 0
command 'Get BPB'
media id 0x00
buffer 00d8:0ab0
BPB 02c5:0036
status 0x0100
dosdebug> d 02c5:0036
dosdebug>
02c5:0036 00 02 04 01 00 01 00 02 80 3E F8 0C 00 08 00 01 .........>x.....
02c5:0046 00 00 00 00 00 80 3E 00 00 90 06 01 01 00 00 00 ......>.........
02c5:0056 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0066 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0076 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02c5:0086 00 00 00 00 00 00 00 00 00 00 00 00 17 F5 00 F0 .............u.p
02c5:0096 00 02 00 00 00 00 DE 49 C5 02 01 00 00 58 00 00 ......^IE....X..
02c5:00a6 2E 89 1E 18 00 2E 8C 06 1A 00 CB 90 9C 60 1E 06 ..........K..`..
Looks like this fragment looses the arguments
config.cc
1953 GetStringArg(pLine, szBuf + off);
(gdb) p pLine
$2 = 0xb72b1b57 <szLine+7> "dosemu\\emufs.sys /tmp"
(gdb) next
1957 eb.load.reloc = eb.load.load_seg = base;
(gdb) p szBuf
$3 = "C:\\dosemu\\emufs.sys", '\000' <repeats 236 times>
I think this commit ab57fb0fa3d01d788c278996874731734fe5e98c removed the rest of the arguments
Adding this back in made it work for me, but not sure if it matters that the arg0 no longer is fixed up with the boot drive.
diff --git a/kernel/config.c b/kernel/config.c
index 96f4a80..2d77b38 100644
--- a/kernel/config.c
+++ b/kernel/config.c
@@ -1966,6 +1966,7 @@ STATIC BOOL LoadDevice(char * pLine, char FAR *top, COUNT mode)
return result;
}
+ strcpy(szBuf, pLine);
/* uppercase the device driver command */
_strupr(szBuf);
With commit in #90 here's the transcript
xmsdsk_interrupt:
02b2:00b2 9C pushf
dosdebug> d xmsdsk_rh_pointer
dosdebug>
02b2:0018 CB 12 D9 00 01 02 DE 00 F8 00 07 01 1A 01 DA 00 K.Y...^.x.....Z.
02b2:0028 DA 00 DA 00 16 01 16 01 DA 00 DA 00 DA 00 00 02 Z.Z.....Z.Z.Z...
02b2:0038 01 01 00 01 00 00 00 00 F8 00 00 08 00 01 00 00 ........x.......
02b2:0048 00 00 00 00 00 00 00 90 FF FF 00 00 00 00 00 00 ..............
02b2:0058 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0068 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0078 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0088 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
dosdebug> ddrh 00d9:12cb
dosdebug>
Request
length 30
unit 0
command 'Init'
nunits 246
break 8b46:fff0
At Entry
cmdline 00d9:12b8
=> 'XMSDSK.EXE 8000
'
At Exit
BPB 00d9:12b8
first_drive 6
status 0x0000
dosdebug> g
dosdebug>
system state: emulated,stopped
AX=00b2 BX=12cb CX=0000 DX=12ce SI=0000 DI=03e4 SP=03d6 BP=03de
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000b3206
CS:IP=02b2:00d9 SS:SP=9fbf:03d6
xmsdsk_interrupt_return:
02b2:00d9 CB retf
dosdebug> ddrh 00d9:12cb
dosdebug>
Request
length 30
unit 0
command 'Init'
nunits 1
break 02b2:0201
At Entry
cmdline 02b2:3db4
=> '6'
At Exit
BPB 02b2:3db4
first_drive 6
status 0x0100
xmsdsk_interrupt:
02b2:00b2 9C pushf
dosdebug> d xmsdsk_rh_pointer
dosdebug>
02b2:0018 7C 03 D9 00 01 02 DE 00 F8 00 07 01 1A 01 DA 00 |.Y...^.x.....Z.
02b2:0028 DA 00 DA 00 16 01 16 01 DA 00 DA 00 DA 00 00 02 Z.Z.....Z.Z.Z...
02b2:0038 04 01 00 01 00 02 80 3E F8 0C 00 08 00 01 00 00 .......>x.......
02b2:0048 00 00 00 80 3E 00 00 90 06 FF 01 00 00 00 00 00 ....>..........
02b2:0058 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0068 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0078 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02b2:0088 00 00 00 00 00 00 00 00 00 00 17 F5 00 F0 00 02 ...........u.p..
dosdebug> ddrh 00d9:037c
dosdebug>
Request
length 30
unit 0
command 'Media Check'
media id 0x00
status 0
status 0x0000
dosdebug> g
dosdebug>
system state: emulated,stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f0 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000b3206
CS:IP=02b2:00d9 SS:SP=00d9:08f0
xmsdsk_interrupt_return:
02b2:00d9 CB retf
dosdebug> ddrh 00d9:037c
dosdebug>
Request
length 30
unit 0
command 'Media Check'
media id 0x00
status -1
status 0x0100
xmsdsk_interrupt:
02b2:00b2 9C pushf
dosdebug> ddrh 00d9:037c
dosdebug>
Request
length 30
unit 0
command 'Get BPB'
media id 0x00
buffer 02d9:0000
BPB 00d9:1966
status 0x0000
dosdebug> g
dosdebug>
system state: emulated,stopped
AX=00b2 BX=037c CX=0000 DX=091c SI=0000 DI=08fe SP=08f0 BP=08f8
DS=02b2 ES=00d9 FS=0000 GS=0000 FL=000b3206
CS:IP=02b2:00d9 SS:SP=00d9:08f0
xmsdsk_interrupt_return:
02b2:00d9 CB retf
dosdebug> ddrh 00d9:037c
dosdebug>
Request
length 30
unit 0
command 'Get BPB'
media id 0x00
buffer 02d9:0000
BPB 02b2:0036
status 0x0100
After installing a block device driver with
device=emudsk.sys
the drive is unavailable under FDPP, but is fine under FreeDOSCurrent FDPP
You can see that the driver is loaded as G:
Device driver was loaded okay and remains resident in memory
CDS entry seems to have the flags zeroed
And DPB for drive G: is missing
Now FreeDOS