在 DOS-BOX 程序集中直接从磁盘读取

问题描述 投票:0回答:1

我从 DOS-BOX 中安装了一个文件夹到我的电脑上

mount c c:\users\user\folder
。然后我删除了该文件夹中的一个文件,我的任务是恢复它。我有这个文件的字节掩码,所以我只需要在DOS-BOX中直接从磁盘读取数据来寻找这个掩码。但我该怎么办呢?

我使用int 13h,但结果是512个零字节,如果我在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
assembly nasm dos dosbox
1个回答
0
投票

您的程序正在使用 BIOS.ReadSectors 函数 02h (

int 13h
),驱动器号为 02h。所有未设置第 8 位的 BIOS 驱动器号均指软盘驱动器。所以您实际上是在请求访问系统上的第三个软盘驱动器。当然不是DOSBox挂载的C:盘。
此外,BIOS
int 13h
上的功能将磁盘作为物理实体来处理,而DOSBox为您安装的
c:\users\user\folder
目录成为了逻辑C:驱动器。
DOS 允许您使用
int 25h
(读)和
int 26h
(写)在扇区级别访问逻辑驱动器。请参阅 http://www.techhelpmanual.com/565-int_25h_26h__absolute_disk_read_write.html

我尝试使用 DOS.AbsoluteDiskRead

int 25h
和 DOS 驱动器号 2 作为 C:,但 DOSBox 不会返回任何内容,甚至没有成功或失败的进位标志。坦率地说,我不认为它会起作用,特别是知道 DOSBox 的创建者一再表示他们的模拟器应该只能运行旧的 DOS 游戏,仅此而已。也许衍生作品DOSBox-X做得更好?

© www.soinside.com 2019 - 2024. All rights reserved.