I mount a folder from DOS-BOX on my computer mount c c:\users\user\folder
. Then I delete a file in this folder and my task is to restore it. I have a byte mask of this file, so I just need to read data directly from disk in DOS-BOX to look for this mask. But how can I do it?
I use int 13h, but the result is 512 zero bytes, how can i find disk number, segment number if I'm on a mounted drive in DOS-BOX.
.model tiny
.code
org 100h
Begin:
jmp Start
FName db 'myfile.txt',0
Count dw 512
position dw 0
Buf db 512 dup(?)
Start:
;-------------------------------------------------
;Read from disk to Buf
push cx
push dx
push ds
xor ax, ax
mov ds, ax
cld
mov ah, 02h ; Function code for reading disk sectors
mov al, 1 ; Number of sectors to read
mov ch, 0 ; Cylinder number (starting from 0)
mov cl, 2 ; Sector number (starting from 1)
mov dh, 0 ; Head number
mov dl, 02h ; Drive number
;xor bx, bx
;mov es, bx
lea bx, Buf ; Buffer to store the sector data
int 13h
pop ds
pop dx
pop cx
;--------------------------------------------------
;Write Buf to file
mov ah, 3ch
mov cx, 1
mov dx, offset FName
int 21h
mov bx, ax
mov ah, 42h
mov al, 0
mov cx, 0
mov dx, position
int 21h
MOV CX, Count
MOV DX, offset Buf
MOV ah, 40h
int 21h
mov ah, 3eh
int 21h
;-----------------------------------------------------
Exit:
mov ah, 4ch
xor al, al
int 21h
end Begin
Your program is using the BIOS.ReadSectors function 02h (int 13h
) with drive number 02h. All BIOS drive numbers that don't have their 8th bit set refer to floppy drives. So you were actually requesting access to the third floppy drive on the system. Certainly not the DOSBox mounted C: drive.
Additionally, the functions on BIOS int 13h
deal with the disk as a physical entity, whereas the c:\users\user\folder
directory that DOSBox mounted for you became the logical C: drive.
DOS allows you to approach your logical drives on the sector level using int 25h
(read) and int 26h
(write). See http://www.techhelpmanual.com/565-int_25h_26h__absolute_disk_read_write.html
I have tried to use the DOS.AbsoluteDiskRead int 25h
with DOS drive number 2 for C:, but DOSBox does not return anything, not even a carry flag for success or failure. Frankly, I did not think that it would work, especially knowing that the creators of DOSBox have repeatedly said their emulator should only be able to run old DOS games and nothing more. Maybe that the derivative work DOSBox-X does it better?