📄 int13ext.asm
字号:
mov DAP.DAP_res, 0
mov DAP.DAP_res2, 0
mov DAP.DAP_packetsize, size diskaddrpacket
; allocate sector buffer...
VMMcall Get_Sys_VM_Handle ; ebx = handle of system VM (address of VM control block)
mov ebp, [ebx].CB_Client_Pointer ; ebp = Address of a Client_Reg_Struc structure
push eax ; save eax
xor ax, ax
mov al, [edi].ext_Blocks
mov cx, 512
mul cx
xor ecx, ecx
mov cx, ax ; ecx = NumBytes
pop eax ; restore eax
; mov ecx, 512 ; ecx = NumBytes
clc ; carry clear => allocate only
VxDcall V86MMGR_Allocate_Buffer ; Result: edi = FarPtrBuffer
jc ioctl_done
mov PtrBuf, edi
mov AllocLenBuf, ecx
mov DAP.DAP_transferbuf, edi
; allocate DAP buffer...
mov ecx, size diskaddrpacket
push esi ; save ESI
mov esi, OFFSET32 DAP ; extended memory to copy if carry set
push ds
pop fs
stc ; set carry flag to copy
VxDcall V86MMGR_Allocate_Buffer ; edi = FarPtrBuffer
pop esi ; restore ESI
jc ioctl_done
mov AllocLenDAP, ecx
mov PtrDAP, edi
; execute INT13...
mov ioctlerror, INT13EXT_ERROR_FAILED
Push_Client_State ; save all registers
VMMcall Begin_Nest_V86_Exec ; Enter nested execution in V86-mode
mov edx, PtrDAP
mov [ebp.Client_SI], dx
shr edx, 16
mov [ebp.Client_DS], dx ; client ds:si=PtrDAP
mov [ebp.Client_AH], 42h
mov [ebp.Client_DL], al
mov eax, 13h
VMMCall Exec_Int ; current VM to call BIOS
clc
test [ebp.Client_Flags], CARRY_FLAG
jnz ioctl_readerr
cmp [ebp.Client_AH], 0
jne ioctl_readerr
mov ioctlerror, INT13EXT_ERROR_SUCCESS
ioctl_readerr:
VMMcall End_Nest_Exec ; end of nested exec calls
Pop_Client_State ; restore all registers when done
; free DAP buffer...
mov ecx, AllocLenDAP
clc ; carry cleared=>no copy
VxDcall V86MMGR_Free_Buffer
; copy and free sector buffer...
mov ecx, AllocLenBuf
mov edi,dword ptr [esi].lpvInBuffer
push esi ; save ESI
mov esi, [edi].ext_buf
stc ; carry set=>copy
push ds
pop fs ; fs=ds
VxDcall V86MMGR_Free_Buffer
pop esi ; restore ESI
jmp ioctl_done
;*********** DIOC_EXTENDEDWRITE *****************************************
ioctl_extwrite:
Trace_Out "INT13EXT_ioctl: DIOC_EXTENDEDWRITE"
mov ioctlerror, INT13EXT_ERROR_OUTOFMEMORY
mov edi,dword ptr [esi].lpvInBuffer
mov al, byte ptr [edi].ext_drv
mov ebx, [edi].ext_LBA
mov DAP.DAP_blocknumberLO, ebx
mov DAP.DAP_numblocks, 1
mov DAP.DAP_blocknumberHI, 0
mov DAP.DAP_res, 0
mov DAP.DAP_res2, 0
mov DAP.DAP_packetsize, size diskaddrpacket
; allocate sector buffer...
VMMcall Get_Sys_VM_Handle ; ebx = handle of system VM (address of VM control block)
mov ebp, [ebx].CB_Client_Pointer ; ebp = Address of a Client_Reg_Struc structure
mov ecx, 512 ; ecx = NumBytes
mov edi,dword ptr [esi].lpvInBuffer
push esi ; save ESI
mov esi, [edi].ext_buf
stc ; carry flag set: copy extended memory from fs:esi
push ds
pop fs ; fs=ds
VxDcall V86MMGR_Allocate_Buffer ; edi = FarPtrBuffer, ecx=BytesCopied
pop esi ; restore ESI
jc ioctl_done
mov PtrBuf, edi
mov AllocLenBuf, ecx
mov DAP.DAP_transferbuf, edi
; allocate DAP buffer...
mov ecx, size diskaddrpacket
push esi ; save ESI
mov esi, OFFSET32 DAP ; extended memory to copy if carry set
push ds
pop fs
stc ; set carry flag to copy
VxDcall V86MMGR_Allocate_Buffer ; edi = FarPtrBuffer
pop esi ; restore ESI
jc ioctl_done
mov AllocLenDAP, ecx
mov PtrDAP, edi
; execute INT13...
mov ioctlerror, INT13EXT_ERROR_FAILED
Push_Client_State ; save all registers
VMMcall Begin_Nest_V86_Exec ; Enter nested execution in V86-mode
mov edx, PtrDAP
mov [ebp.Client_SI], dx
shr edx, 16
mov [ebp.Client_DS], dx ; client ds:si=PtrDAP
mov [ebp.Client_AH], 43h ; extended write
mov [ebp.Client_AL], 0 ; write with verify off
mov edi,dword ptr [esi].lpvInBuffer
cmp byte ptr [edi].ext_verify, 1
jne wr_no_verify
mov [ebp.Client_AL], 2 ; write with verify on
wr_no_verify:
mov [ebp.Client_DL], al
mov eax, 13h
VMMCall Exec_Int ; current VM to call BIOS
clc
test [ebp.Client_Flags], CARRY_FLAG
jnz ioctl_readerr
cmp [ebp.Client_AH], 0
jne ioctl_writeerr
mov ioctlerror, INT13EXT_ERROR_SUCCESS
ioctl_writeerr:
VMMcall End_Nest_Exec ; end of nested exec calls
Pop_Client_State ; restore all registers when done
; free DAP buffer...
mov ecx, AllocLenDAP
clc
VxDcall V86MMGR_Free_Buffer ; ebp=OFFSET ClientRegs, ebx=VMHandle, ecx=NumBytes
; free sector buffer...
mov ecx, AllocLenBuf
clc
VxDcall V86MMGR_Free_Buffer
jmp ioctl_done
;*********** DIOC_GETDRIVEPARAMS *****************************************
ioctrl_getparams:
Trace_Out "INT13EXT_ioctl: DIOC_GETDRIVEPARAMS"
mov ioctlerror, INT13EXT_ERROR_OUTOFMEMORY
mov edi,dword ptr [esi].lpvInBuffer
mov al, byte ptr [edi].ext_drv
; allocate result buffer...
VMMcall Get_Sys_VM_Handle ; ebx = handle of system VM (address of VM control block)
mov ebp, [ebx].CB_Client_Pointer ; ebp = Address of a Client_Reg_Struc structure
mov ecx, 30 ; ecx = NumBytes
mov edi,dword ptr [esi].lpvInBuffer
push esi ; save ESI
mov esi, [edi].ext_buf
stc ; carry flag set: copy extended memory from fs:esi
push ds
pop fs ; fs=ds
VxDcall V86MMGR_Allocate_Buffer ; edi = FarPtrBuffer, ecx=BytesCopied
pop esi ; restore ESI
jc ioctl_done
mov PtrBuf, edi
mov AllocLenBuf, ecx
; execute INT13...
mov ioctlerror, INT13EXT_ERROR_FAILED
Push_Client_State ; save all registers
VMMcall Begin_Nest_V86_Exec ; Enter nested execution in V86-mode
mov edx, PtrBuf
mov [ebp.Client_SI], dx
shr edx, 16
mov [ebp.Client_DS], dx ; client ds:si=PtrBuf
mov [ebp.Client_AH], 48h
mov [ebp.Client_DL], al
mov eax, 13h
VMMCall Exec_Int ; current VM to call BIOS
clc
test [ebp.Client_Flags], CARRY_FLAG
jnz ioctl_getparamerr
cmp [ebp.Client_AH], 0
jne ioctl_getparamerr
mov ioctlerror, INT13EXT_ERROR_SUCCESS
ioctl_getparamerr:
VMMcall End_Nest_Exec ; end of nested exec calls
Pop_Client_State ; restore all registers when done
; copy and free result buffer...
push esi ; save ESI
mov esi, dword ptr [esi].lpvInBuffer
mov esi, [esi].ext_buf
stc ; carry set=>copy
push ds
pop fs ; fs=ds
VxDcall V86MMGR_Free_Buffer ; first copy to fs:esi
pop esi ; restore ESI
jmp ioctl_done
; ------------------------------------------------------------------
ioctl_done:
mov eax, ioctlerror
clc
cmp eax, INT13EXT_ERROR_SUCCESS
je ioctl_fin
Trace_Out "INT13EXT_ioctl: error"
stc
ioctl_fin:
ret
EndProc INT13EXT_ioctl
;============================================================================
;
; INT13EXT_Device_Exit - Cleans up any hooks that are still installed before
; exiting.
;
;============================================================================
Public INT13EXT_Device_Exit
BeginProc INT13EXT_Device_Exit
Trace_Out "INT13EXT_Device_Exit"
clc
ret
EndProc INT13EXT_Device_Exit
VxD_LOCKED_CODE_ENDS
;******************************************************************************
; R E A L M O D E C O D E
;******************************************************************************
;******************************************************************************
;
; Real mode initialization code
;
; DESCRIPTION:
; This code is called when the system is still in real mode, and
; the VxDs are being loaded.
;
; This routine as coded shows how a VxD (with a defined VxD ID)
; could check to see if it was being loaded twice, and abort the
; second without an error message. Note that this would require
; that the VxD have an ID other than Undefined_Device_ID. See
; the file VXDID.TXT more details.
;
; ENTRY:
; AX = VMM Version
; BX = Flags
; Bit 0: duplicate device ID already loaded
; Bit 1: duplicate ID was from the INT 2F device list
; Bit 2: this device is from the INT 2F device list
; EDX = Reference data from INT 2F response, or 0
; SI = Environment segment, passed from MS-DOS
;
; EXIT:
; BX = ptr to list of pages to exclude (0, if none)
; SI = ptr to list of instance data items (0, if none)
; EDX = DWORD of reference data to be passed to protect mode init
;
;==============================================================================
VxD_REAL_INIT_SEG
BeginProc INT13EXT_Real_Init_Proc
Trace_Out "INT13EXT_Real_Init_Proc"
test bx, Duplicate_Device_ID ; check for already loaded
jnz short duplicate ; jump if so
xor bx, bx ; no exclusion table
xor si, si ; no instance data table
xor edx, edx ; no reference data
mov ax, Device_Load_Ok
ret
duplicate:
mov ax, Abort_Device_Load + No_Fail_Message
ret
EndProc INT13EXT_Real_Init_Proc
VxD_REAL_INIT_ENDS
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -