📄 int13ext.bak
字号:
;****************************************************************************
; INT13 Extensions VxD
; Version: 1.0
; Copyright (C) 2001 Alexander Grau, All Rights Reserved
;****************************************************************************
.386p
;******************************************************************************
; I N C L U D E S
;******************************************************************************
DEBUG equ 1
.XLIST
INCLUDE VMM.Inc
INCLUDE Debug.Inc
INCLUDE v86mmgr.inc
include vwin32.inc
include shell.inc
.LIST
;******************************************************************************
; V I R T U A L D E V I C E D E C L A R A T I O N
;******************************************************************************
Declare_Virtual_Device INT13EXT, \
INT13EXT_MAJOR_VERSION, \
INT13EXT_MINOR_VERSION, \
INT13EXT_Control, , \
UNDEFINED_INIT_ORDER
;******************************************************************************
; E Q U A T E S
;******************************************************************************
INT13EXT_MAJOR_VERSION EQU 1
INT13EXT_MINOR_VERSION EQU 0
DIOC_CHECKEXTENSIONS EQU 1
DIOC_EXTENDEDREAD EQU 2
DIOC_EXTENDEDWRITE EQU 3
DIOC_GETDRIVEPARAMS EQU 4
INT13EXT_ERROR_SUCCESS EQU 0
INT13EXT_ERROR_NOSUCHSERVICE EQU 1
INT13EXT_ERROR_FAILED EQU 2
INT13EXT_ERROR_OUTOFMEMORY EQU 3
CARRY_FLAG EQU 1
;******************************************************************************
; S T R U C T U R E S
;******************************************************************************
extstruc struc
ext_Drv db ?
ext_LBA dd ?
ext_Blocks db ?
ext_Buf dd ?
ext_verify db ?
extstruc ends
diskaddrpacket struc
DAP_Packetsize db ?
DAP_Res db ?
DAP_Numblocks db ?
DAP_Res2 db ?
DAP_Transferbuf dd ?
DAP_BlocknumberLO dd ?
DAP_BlocknumberHI dd ?
diskaddrpacket ends
;******************************************************************************
; D A T A
;******************************************************************************
VxD_IDATA_SEG
; Initialization data here - discarded after Init_Complete
VxD_IDATA_ENDS
VxD_DATA_SEG
; Normal Data here
VxD_DATA_ENDS
VxD_LOCKED_DATA_SEG
; Pagelocked data here - try to keep this to a minimum.
ioctlerror dd 0
DAP diskaddrpacket <?>
PtrDAP dd ?
PtrBuf dd ?
AllocLenDAP dd ?
AllocLenBuf dd ?
VxD_LOCKED_DATA_ENDS
;******************************************************************************
; I N I T I A L I Z A T I O N C O D E
;------------------------------------------------------------------------------
; Code in the initialization segment is discarded after Init_Complete
;******************************************************************************
VxD_ICODE_SEG
;******************************************************************************
;
; INT13EXT_Device_Init
;
; DESCRIPTION:
; This is a shell for a routine that is called at system BOOT.
; Typically, a VxD would do its initialization in this routine.
;
; ENTRY:
; EBX = System VM handle
;
; EXIT:
; Carry clear to indicate load success
; Carry set to abort loading this VxD
;
; USES:
; flags
;
;==============================================================================
VxdCaption db "VxD Extensions",0
VxdMessage db " Loading...",0
BeginProc INT13EXT_Device_Init
Trace_Out "INT13EXT_Device_Init"
ifdef debugmsg
; Put up message box indicating we're loading
VMMcall Get_Cur_VM_Handle
mov eax, MB_OK
mov ecx, OFFSET32 VxdMessage
mov edi, OFFSET32 VxdCaption
VxDcall SHELL_SYSMODAL_Message
endif
clc ;no error - load VxD
ret
EndProc INT13EXT_Device_Init
VxD_ICODE_ENDS
;******************************************************************************
; C O D E
;------------------------------------------------------------------------------
; The 'body' of the VxD would typically be in the standard code segment.
;******************************************************************************
VxD_CODE_SEG
VxD_CODE_ENDS
;******************************************************************************
; P A G E L O C K E D C O D E
;------------------------------------------------------------------------------
; Memory is a scarce resource. Use this only where necessary.
;******************************************************************************
VxD_LOCKED_CODE_SEG
;******************************************************************************
;
; INT13EXT_Control
;
; DESCRIPTION:
; This is a call-back routine to handle the messages that are sent
;
; ENTRY:
; EAX = Message number
; EBX = VM Handle
;
;==============================================================================
public INT13EXT_control
BeginProc INT13EXT_Control
Control_Dispatch SYS_DYNAMIC_DEVICE_INIT, INT13EXT_Device_Init
Control_Dispatch SYS_DYNAMIC_DEVICE_EXIT, INT13EXT_Device_Exit
Control_Dispatch W32_DEVICEIOCONTROL, INT13EXT_ioctl
clc
ret
EndProc INT13EXT_Control
;******************************************************************************
;
; INT13EXT_ioctl - Respond to DeviceIOcontrol messages sent by Win32 program.
;
; Entry: esi -> DIOC block
; DIOCParams STRUC
; Internal1 DD ?
; VMHandle DD ?
; Internal2 DD ?
; dwIoControlCode DD ? ; 0=CheckExtensions
; lpvInBuffer DD ?
; cbInBuffer DD ?
; lpvOutBuffer DD ?
; cbOutBuffer DD ?
; lpcbBytesReturned DD
; lpoOverlapped DD ?
; hDevice DD ?
; tagProcess DD ?
; DIOCParams ENDS
;
; Exit:
;
;******************************************************************************
BeginProc INT13EXT_ioctl
Trace_Out "INT13EXT_ioctl..."
mov ioctlerror, INT13EXT_ERROR_NOSUCHSERVICE
mov ecx,[esi].dwIoControlCode ; get ioctl code
cmp ecx, DIOC_OPEN ; DIOC_OPEN is sent when VxD is loaded w/ CreateFile
je ioctl_open
cmp ecx, DIOC_CLOSEHANDLE ; DIOC_CLOSEHANDLE is sent when VxD is unloaded w/ CloseHandle
je ioctl_close
cmp ecx, DIOC_CHECKEXTENSIONS
je ioctl_chkext
cmp ecx, DIOC_EXTENDEDREAD
je ioctl_extread
cmp ecx, DIOC_EXTENDEDWRITE
je ioctl_extwrite
cmp ecx, DIOC_GETDRIVEPARAMS
je ioctrl_getparams
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 "INT13EXT_ioctl: DIOC_OPEN"
; Must return 0 to tell WIN32 that this VxD supports DEVIOCTL
mov ioctlerror, INT13EXT_ERROR_SUCCESS
jmp ioctl_done
;** DIOC_CLOSE *******************************************************
ioctl_close:
Trace_Out "INT13EXT_ioctl: DIOC_CLOSE"
mov ioctlerror, INT13EXT_ERROR_SUCCESS
jmp ioctl_done
ioctl_chkext:
;*** DIOC_CHECKEXTENSIONS *********************************************
Trace_Out "INT13EXT_ioctl: DIOC_CHECKEXTENSIONS"
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_AH], 41h
mov [ebp.Client_BX], 55AAh
mov [ebp.Client_DL], al
mov eax, 13h
VMMCall Exec_Int ; current VM to call BIOS
test [ebp.Client_Flags], CARRY_FLAG
jnz ioctl_no_ext
cmp [ebp.Client_BX], 0AA55h
jne ioctl_no_ext
mov al, 1
jmp ioctl_chk_fin
ioctl_no_ext:
mov al, 0
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
mov ioctlerror, INT13EXT_ERROR_SUCCESS
jmp ioctl_done ; exit successfully
;*********** DIOC_EXTENDEDREAD *****************************************
ioctl_extread:
Trace_Out "INT13EXT_ioctl: DIOC_EXTENDEDREAD"
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 bl, [edi].ext_Blocks
mov DAP.DAP_numblocks, bl
mov DAP.DAP_blocknumberHI, 0
mov DAP.DAP_res, 0
mov DAP.DAP_res2, 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -