代码之家  ›  专栏  ›  技术社区  ›  bad

在dosbox中打开文件句柄将清除文件的数据

  •  3
  • bad  · 技术社区  · 6 年前

    在dosbox 0.74中,当我试图使用int 21h的函数3ch打开任何文件的文件句柄时,该文件的数据将被清除,其大小将永久地减少到0字节。

    我测试过的文件都位于windows 10的documents目录中,该目录在dosbox中安装为驱动器e。

    这是导致问题的代码。它应该打开,然后关闭一个文件句柄。CF从未设置,因此没有错误代码。ax中的文件句柄设置为5。

        mov ax, varData                            
        mov ds, ax               ;Load the variable segment into ds   
                                 ;word variable handle is defined here
                                 ;string fname is defined here                                         
    
        mov ah, 3ch              ;select open file handle function
        lea dx, fname            ;dx points to file's name ("TESTFILE")
        mov cl, 1                ;read only
        int 21h                  ;open the file handle
        mov handle, ax           ;copy handle into variable 
    
        mov ah, 3eh              ;close handle function
        mov bx, handle           ;closing previously opened file handle
        int 21h                  ;close handle
    
    1 回复  |  直到 6 年前
        1
  •  5
  •   David Wohlferd    6 年前

    this :

    ah=0x3c是“创建文件”。您需要0x3d(打开文件)。