📄 wrappers.asm
字号:
; Source: Writing Windows VxDs and Device Drivers, 2nd Edition
; by Karen Hazzah, R&D Books, Miller Freeman, Inc. 1996
include local.inc
include ifsmgr.inc
include vdmad.inc
include vpicd.inc
include vwin32.inc
include shell.inc
R0_OPENCREATFILE equ 0D500h ; Open/Create a file
R0_OPENCREAT_IN_CONTEXT equ 0D501h ; Open/Create file in current context
R0_READFILE equ 0D600h ; Read a file, no context
R0_WRITEFILE equ 0D601h ; Write to a file, no context
R0_READFILE_IN_CONTEXT equ 0D602h ; Read a file, in thread context
R0_WRITEFILE_IN_CONTEXT equ 0D603h ; Write to a file, in thread context
R0_CLOSEFILE equ 0D700h ; Close a file
R0_GETFILESIZE equ 0D800h ; Get size of a file
StartStdCall MACRO Name, Param
StartCDecl Name&@&Param
ENDM
EndStdCall MACRO Name, Param
EndCDecl Name&@&Param
ENDM
MakeCDecl _ModifyPageBits
MakeCDecl _Assign_Device_V86_Pages
MakeCDecl _DeAssign_Device_V86_Pages
MakeCDecl _PhysIntoV86
MakeCDecl _MapIntoV86
MakeCDecl _GetNulPageHandle
MakeCDecl _PageReserve
MakeCDecl _PageCommitPhys
MakeCDecl _PageDecommit
; void cdecl _Deallocate_Device_CB_Area( DWORD NumBytes,
; DWORD Flags ))
;
MakeCDecl _Deallocate_Device_CB_Area
; EVENTHANDLE Call_Priority_VM_Event(DWORD PriorityBoost,
; VMHANDLE hVM, DWORD Flags,
; void * Refdata,
; CALLBACK EventCallback, DWORD Timeout );
StartCDecl Call_Priority_VM_Event
PriorityBoost EQU [ebp+8]
hVM EQU [ebp+12]
Flags EQU [ebp+16]
Refdata EQU [ebp+20]
EventCallback EQU[ebp+24]
Timeout EQU [ebp+28]
push ebp
mov ebp, esp
mov eax, DWORD PTR PriorityBoost
mov ebx, DWORD PTR hVM
mov ecx, DWORD PTR Flags
mov edx, DWORD PTR Refdata
mov esi, DWORD PTR EventCallback
mov edi, DWORD PTR Timeout
VMMCall Call_Priority_VM_Event
mov eax, esi ; eax=event handle
pop ebp
ret
EndCDecl Call_Priority_VM_Event
; void * _stdcall Map_Flat( BYTE SegOffset, BYTE OffOffset )
;
;
StartStdCall Map_Flat, 8
pop edx ; save ret addr in unused reg
pop ebx ; segment
xor bh,bh ; BL=segment
mov ah,bl ; AH=segment
pop ebx ; offset
xor bh,bh ; BL=offset
mov al,bl ; AL=offset
VMMcall Map_Flat ; AH=seg AL=off
jmp edx ; jump to caller's ret addr
EndStdCall Map_Flat, 8
; BOOL _stdcall Hook_V86_Page( DWORD PageNum,
; CALLBACK Callback )
;
StartStdCall Hook_V86_Page, 8
pop edx ; save ret addr in unused reg
pop eax ; PageNum
pop esi ; Callback
VMMCall Hook_V86_Page
mov eax, 1 ; assume TRUE ret val
jnc @f
xor eax, eax ; carry set, error, so FALSE ret val
@@:
jmp edx ; jump to caller's ret addr
EndStdCall Hook_V86_Page, 8
; BOOL _stdcall Unhook_V86_Page( DWORD PageNum,
; CALLBACK Callback )
;
StartStdCall Unhook_V86_Page, 8
pop edx ; save ret addr in unused reg
pop eax ; PageNum
pop esi ; Callback
VMMCall Unhook_V86_Page
mov eax, 1 ; assume TRUE ret val
jnc @f
xor eax, eax ; carry set, error, so FALSE ret val
@@:
jmp edx ; jump to caller's ret addr
EndStdCall Unhook_V86_Page, 8
; PTCB _stdcall Get_Initial_Thread_Handle( VMHANDLE hVM )
StartStdCall Get_Initial_Thread_Handle, 4
pop edx ; Get return address
pop ebx ; Get VMHandle
VxDCall Get_Initial_Thread_Handle
mov eax, edi ; move thread hnd into return
jmp edx ; return addr still in edx
EndStdCall Get_Initial_Thread_Handle, 4
; BOOL _stdcall Install_IO_Handler( PortNum, Callback )
StartStdCall Install_IO_Handler, 8
pop ebx ; save ret addr in unused reg
pop edx ; PortNum
pop esi ; Callback
VMMCall Install_IO_Handler
mov eax, 1 ; assume TRUE ret val
jnc @f
xor eax, eax ; carry set, error, so FALSE ret val
@@:
jmp ebx ; jump to caller's ret addr
EndStdCall Install_IO_Handler, 8
; BOOL _stdcall Remove_IO_Handler( PortNum )
;
StartStdCall Remove_IO_Handler, 4
pop ebx ; save ret addr in unused reg
pop edx ; PortNum
VMMCall Remove_IO_Handler
mov eax, 1 ; assume TRUE ret val
jnc @f
xor eax, eax ; carry set, error, so FALSE ret val
@@:
jmp ebx ; jump to caller's ret addr
EndStdCall Remove_IO_Handler, 4
; void _stdcall Enable_Local_Trapping( VMHANDLE hVM, DWORD PortNum )
;
StartStdCall Enable_Local_Trapping, 8
pop ecx ; save ret addr in unused reg
pop ebx ; hVM
pop edx ; PortNum
VMMcall Enable_Local_Trapping
jmp ecx
EndStdCall Enable_Local_Trapping, 8
; void _stdcall Disable_Local_Trapping( VMHANDLE hVM, DWORD PortNum )
;
StartStdCall Disable_Local_Trapping, 8
pop ecx ; save ret addr in unused reg
pop ebx ; hVM
pop edx ; PortNum
VMMcall Disable_Local_Trapping
jmp ecx
EndStdCall Disable_Local_Trapping, 8
; void cdecl Save_Client_State( CLIENT_STRUCT * pSavedRegs
;
StartCdecl Save_Client_State
pSavedRegs EQU [ebp+8]
push ebp
mov ebp, esp
pushad ; service doesn't claim to save any regs
mov edi, pSavedRegs
VMMcall Save_Client_State
popad
pop ebp
ret
EndCdecl Save_Client_State
; void cdecl Restore_Client_State( CLIENT_STRUCT * pRestoredRegs
;
StartCdecl Restore_Client_State
pSavedRegs EQU [ebp+8]
push ebp
mov ebp, esp
pushad ; service doesn't claim to save any regs
mov edi, pSavedRegs
VMMcall Restore_Client_State
popad
pop ebp
ret
EndCdecl Restore_Client_State
; void cdecl Begin_Nest_Exec( void )
;
StartCdecl Begin_Nest_Exec
push ebp
mov ebp, esp
pushad ; service doesn't claim to save any regs
VMMcall Begin_Nest_Exec
popad
pop ebp
ret
EndCdecl Begin_Nest_Exec
; void cdecl End_Nest_Exec( void )
;
StartCdecl End_Nest_Exec
push ebp
mov ebp, esp
pushad ; service doesn't claim to save any regs
VMMcall End_Nest_Exec
popad
pop ebp
ret
EndCdecl End_Nest_Exec
; void _stdcall Simulate_Far_Call( WORD seg, WORD off )
;
StartStdCall Simulate_Far_Call, 8
pop eax ; save ret addr in unused reg
pop ecx ; segment
pop edx ; offset
VMMcall Simulate_Far_Call
jmp eax
EndStdCall Simulate_Far_Call, 8
; void _stdcall Simulate_Push( DWORD val )
;
StartStdCall Simulate_Push, 4
pop edx ; save ret addr in unused reg
pop eax ; val
VMMcall Simulate_Push
jmp edx
EndStdCall Simulate_Push, 4
; HANDLE cdecl IFSMgr_Ring0_OpenCreateFile( BOOL bInContext, PCHAR filename,
; WORD mode, WORD attrib,
; BYTE action, BYTE flags,
; WORD *pError, BYTE *pAction)
StartCdecl IFSMgr_Ring0_OpenCreateFile
bInContext EQU [ebp+8]
filename EQU [ebp+12]
mode EQU [ebp+16]
attrib EQU [ebp+20]
action EQU[ebp+24]
flags EQU [ebp+28]
pError EQU [ebp+32]
pAction EQU [ebp+36]
push ebp
mov ebp, esp
mov dl, action
mov dh, flags
mov cx, attrib
mov bx, mode
mov esi, filename
mov eax, R0_OPENCREATFILE
cmp WORD PTR bInContext, 0
je @f
mov eax, R0_OPENCREAT_IN_CONTEXT
@@:
VxDCall IFSMgr_Ring0_FileIO
mov esi, pError ; esi->error code
jnc @f
mov WORD PTR [esi], ax ;give caller error code
xor eax, eax ;return failure to caller
@@:
mov esi, pAction
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -