📄 int2f.asm
字号:
je ioctl_readsec
jmp ioctl_done ; Returning a positive value will cause the WIN32 DeviceIOControl call
; to return FALSE, the error code can then be retrieved via the WIN32 GetLastError
;** DIOC_OPEN ********************************************************
ioctl_open:
Trace_Out "INT2F_ioctl: DIOC_OPEN"
; Must return 0 to tell WIN32 that this VxD supports DEVIOCTL
mov ioctlerror, INT2F_ERROR_SUCCESS
jmp ioctl_done
;** DIOC_CLOSE *******************************************************
ioctl_close:
Trace_Out "INT2F_ioctl: DIOC_CLOSE"
mov ioctlerror, INT2F_ERROR_SUCCESS
jmp ioctl_done
ioctl_iscdrom:
;*** DIOC_ISCDROMDRIVE *********************************************
Trace_Out "INT2F_ioctl: DIOC_ISCDROMDRIVE"
mov edi,dword ptr [esi].lpvInBuffer
mov al,[edi]
Push_Client_State ; save all registers
VMMcall Begin_Nest_V86_Exec ; Enter nested execution in V86-mode (force VM to V86)
mov [ebp.Client_CL], al
mov [ebp.Client_CH], 0
mov [ebp.Client_AX], 150bh
mov [ebp.Client_BX], 0
mov eax, 2fh ; MSCDEX int 2f
VMMCall Exec_Int ; current VM to call MSCDEX
cmp [ebp.Client_BX], 0ADADh ; check MSCDEX signature
jne ioctl_no_cd
cmp [ebp.Client_AX], 0 ; check the drive type
je ioctl_no_cd ; 0 (zero) means not CD-ROM
mov al, 1 ; result = TRUE
jmp ioctl_chk_fin
ioctl_no_cd:
mov al, 0 ; result = FALSE
ioctl_chk_fin:
VMMcall End_Nest_Exec ; end of nested exec calls
Pop_Client_State ; restore all registers when done
mov edi, [esi].lpvOutBuffer
mov byte ptr [edi], al
mov [esi].cbOutBuffer, 1 ; number of bytes to return
mov ioctlerror, INT2F_ERROR_SUCCESS
jmp ioctl_done ; exit successfully
;*********** DIOC_READSECTOR *****************************************
ioctl_readsec:
Trace_Out "INT2F_ioctl: DIOC_READSECTOR"
mov ioctlerror, INT2F_ERROR_OUTOFMEMORY
mov edi,dword ptr [esi].lpvInBuffer
; 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 !!! DO NOT CHANGE EBX / EBP FROM HERE !!!
xor ax, ax
mov al, [edi].cd_Blocks
mov cx, 2048
mul cx ; dx:ax=result
xor ecx, ecx
mov cx, ax ; ecx = NumBytes
; mov ecx, 2048 ; ecx = NumBytes
clc ; carry clear => allocate only
VxDcall V86MMGR_Allocate_Buffer ; Result: edi = FarPtrBuffer (seg in hi, offset in low word of 'EDI' )
; needs EBX / EBP (VM handle / client reg struc of virtual machine)
jc ioctl_done
mov AllocLenBuf, ecx ; save size of PtrBuf
; execute INT2F...
mov ioctlerror, INT2F_ERROR_FAILED
;--------------------------------------------
Push_Client_State ; save all registers
VMMcall Begin_Nest_V86_Exec ; Enter nested execution in V86-mode
Trace_Out "Will now exec MSCDEX absolute read with..."
mov [ebp.Client_BX], di
Trace_Out "BX=#DI"
shr edi, 16
mov [ebp.Client_ES], di ; client es:bx=PtrBuf
Trace_Out "ES=#DI"
mov edi, dword ptr [esi].lpvInBuffer
xor ax, ax
mov al, byte ptr [edi].cd_drv
mov [ebp.Client_CX], ax
Trace_Out "CX=#AX"
mov [ebp.Client_AX], 01508h ; MSCDEX Absolute read
Trace_Out "AX=01508h"
xor ax, ax
mov al, [edi].cd_blocks
mov [ebp.Client_DX], ax ; number of sectors
Trace_Out "DX=#AX"
mov eax, [edi].cd_LBA
mov [ebp.Client_DI], ax ; sector low word
Trace_Out "DI=#AX"
shr eax, 16
mov [ebp.Client_SI], ax ; sector high word
Trace_Out "SI=#AX"
mov eax, 2fh ; MSCDEX int
VMMCall Exec_Int ; current VM to call MSCDEX
clc
test [ebp.Client_Flags], CARRY_FLAG
jnz ioctl_readerr
mov ioctlerror, INT2F_ERROR_SUCCESS
ioctl_readerr:
VMMcall End_Nest_Exec ; end of nested exec calls
Pop_Client_State ; restore all registers when done
;------------------------------
; copy and free sector buffer...
mov ecx, AllocLenBuf
mov edi, dword ptr [esi].lpvInBuffer
push esi ; save ESI
; mov esi, [edi].cd_buf ; get win32 destination buffer in ESI!
stc ; carry set=>copy
push ds
pop fs ; fs=ds (FS:ESI=
mov esi, dword ptr [edi].cd_buf ; FS:ESI = pointer to destination buffer
VxDcall V86MMGR_Free_Buffer
; needs EBX / EBP (VM handle / client reg struc of virtual machine)
pop esi ; restore ESI
jmp ioctl_done
; ------------------------------------------------------------------
ioctl_done:
mov eax, ioctlerror
clc
cmp eax, INT2F_ERROR_SUCCESS
je ioctl_fin
Trace_Out "INT2F_ioctl: error"
stc ; if error set carry!
ioctl_fin:
ret
EndProc INT2F_ioctl
;============================================================================
;
; INT2F_Device_Exit - Cleans up any hooks that are still installed before
; exiting.
;
;============================================================================
Public INT2F_Device_Exit
BeginProc INT2F_Device_Exit
Trace_Out "INT2F_Device_Exit"
clc
ret
EndProc INT2F_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 INT2F_Real_Init_Proc
Trace_Out "INT2F_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 INT2F_Real_Init_Proc
VxD_REAL_INIT_ENDS
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -