📄 vmm.inc
字号:
; BeginProc is a macro for defining entry points to routines in VMM and in the
; VxDs. It correctly defines the procedure name for VxD services(it prepends
; a "@" to the procedure name), DWORD aligns the procedure, takes care of
; public declaration and does some calling verification for debug versions
; of the software. EndProc is a macro which defines the end of the procedure.
;
; Valid parameters to the BeginProc macro are:
; PUBLIC ; Routine used outside this module
; HIGH_FREQ ; DWORD align procedure
; SERVICE ; Routine is called via VxDCall
; ASYNC_SERVICE ; Same as "SERVICE" plus routine can
; ; be called under interrupt.
; After the routine header in which the routine entry conditions, exit
; conditions, side affects and functionality are specified, the BeginProc
; macro should be used to define the routine's entry point. It has up to
; four parameters as specified below. For example:
;
;BeginProc <Function_Name>,PUBLIC, HIGH_FREQ, ASYNC_SERVICE
;
; <code>
;
;EndProc <Function_Name>
;==============================================================================
EndDoc
BeginProc MACRO Name, P1, P2, P3, P4
LOCAL Profile_Data, Skip_Data
IF ?_RCODE
Process_Param MACRO P
IFNB <P>
IFIDNI <P>, <HIGH_FREQ>
Dword_Align
ELSE
IFIDNI <P>, <SERVICE>
??_SERVICE = 1
ELSE
IFIDNI <P>, <ASYNC_SERVICE>
??_ASYNC_SERVICE = 1
IF ?_LCODE
%OUT ERROR: ASYNC_SERVICE's must be in LOCKED code
;;.err
ENDIF
ELSE
IFIDNI <P>, <NO_LOG>
??_NO_LOG = 1
ELSE
IFDIFI <P>, <PUBLIC>
%OUT ERROR: Bad para "&P" to BeginProc
.ERR
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDM
??_SERVICE = 0
??_ASYNC_SERVICE = 0
??_NO_LOG = 0
Process_Param P1
Process_Param P2
Process_Param P3
Process_Param P4
IFE ??_SERVICE + ??_ASYNC_SERVICE
PUBLIC Name
Name PROC NEAR
IFDEF DEBUG
IFE ??_NO_LOG
IFNDEF VMMSYS
VMMcall Log_Proc_Call
ENDIF
ENDIF
ENDIF
ELSE
IFDEF DEBUG
jmp SHORT Skip_Data
Profile_Data LABEL DWORD
dd 0
Skip_Data:
ENDIF
PUBLIC @&Name
@&Name PROC NEAR
IFDEF DEBUG
IFE ??_NO_LOG
;;;;IFNDEF VMMSYS
VMMcall Log_Proc_Call
;;;;ENDIF
ENDIF
pushfd
inc [Profile_Data]
IFE ??_ASYNC_SERVICE
VMMcall Test_Reenter
ENDIF
popfd
ENDIF
ENDIF
ELSE
IFIDNI <P1>, <PUBLIC>
PUBLIC Name
ENDIF
Name PROC NEAR
ENDIF
ENDM
EndProc MACRO Name
IFDEF @&Name
@&Name ENDP
ELSE
IFDEF Name
Name ENDP
ELSE
.ERR
%OUT EndProc for &Name does not match BeginProc
ENDIF
ENDIF
ENDM
;******************************************************************************
; S C H E D U L E R B O O S T V A L U E S
;==============================================================================
Reserved_Low_Boost EQU 00000000000000000000000000000001b
Cur_Run_VM_Boost EQU 00000000000000000000000000000100b
Low_Pri_Device_Boost EQU 00000000000000000000000000010000b
High_Pri_Device_Boost EQU 00000000000000000001000000000000b
Critical_Section_Boost EQU 00000000000100000000000000000000b
Time_Critical_Boost EQU 00000000010000000000000000000000b
Reserved_High_Boost EQU 01000000000000000000000000000000b
;******************************************************************************
; F L A G S F O R C A L L _ P R I O R I T Y _ V M _ E V E N T
;==============================================================================
PEF_Wait_For_STI EQU 0000001b
PEF_Wait_For_STI_Bit EQU 0
PEF_Wait_Not_Crit EQU 0000010b
PEF_Wait_Not_Crit_Bit EQU 1
PEF_Dont_Unboost EQU 0000100b
PEF_Dont_Unboost_Bit EQU 2
PEF_Always_Sched EQU 0001000b
PEF_Always_Sched_Bit EQU 3
;******************************************************************************
; F L A G S F O R B E G I N _ C R I T I C A L _ S E C T I O N
; A N D W A I T _ S E M A P H O R E
;==============================================================================
Block_Svc_Ints EQU 0000001b
Block_Svc_Ints_Bit EQU 0
Block_Svc_If_Ints_Locked EQU 0000010b
Block_Svc_If_Ints_Locked_Bit EQU 1
Block_Enable_Ints EQU 0000100b
Block_Enable_Ints_Bit EQU 2
BeginDoc
;******************************************************************************
; The following structures are pointed to by EBP when VxD routines are entered,
; both for VxD control calls and traps(I/O traps, software INT traps, etc.).
; The first structure as DWORD values, the second WORD values and the last
; has BYTE values.
;
Client_Reg_Struc struc
Client_EDI dd ? ; Client's EDI
Client_ESI dd ? ; Client's ESI
Client_EBP dd ? ; Client's EBP
dd ? ; ESP at pushall
Client_EBX dd ? ; Client's EBX
Client_EDX dd ? ; Client's EDX
Client_ECX dd ? ; Client's ECX
Client_EAX dd ? ; Client's EAX
Client_Error dd ? ; Dword error code
Client_EIP dd ? ; EIP
Client_CS dw ? ; CS
dw ? ; (padding)
Client_EFlags dd ? ; EFLAGS
Client_ESP dd ? ; ESP
Client_SS dw ? ; SS
dw ? ; (padding)
Client_ES dw ? ; ES
dw ? ; (padding)
Client_DS dw ? ; DS
dw ? ; (padding)
Client_FS dw ? ; FS
dw ? ; (padding)
Client_GS dw ? ; GS
dw ? ; (padding)
Client_Alt_EIP dd ?
Client_Alt_CS dw ?
dw ?
Client_Alt_EFlags dd ?
Client_Alt_ESP dd ?
Client_Alt_SS dw ?
dw ?
Client_Alt_ES dw ?
dw ?
Client_Alt_DS dw ?
dw ?
Client_Alt_FS dw ?
dw ?
Client_Alt_GS dw ?
dw ?
Client_Reg_Struc ends
Client_Word_Reg_Struc struc
Client_DI dw ? ; Client's DI
dw ? ; (padding)
Client_SI dw ? ; Client's SI
dw ? ; (padding)
Client_BP dw ? ; Client's BP
dw ? ; (padding)
dd ? ; ESP at pushall
Client_BX dw ? ; Client's BX
dw ? ; (padding)
Client_DX dw ? ; Client's DX
dw ? ; (padding)
Client_CX dw ? ; Client's CX
dw ? ; (padding)
Client_AX dw ? ; Client's AX
dw ? ; (padding)
dd ? ; Dword error code
Client_IP dw ? ; Client's IP
dw ? ; (padding)
dd ? ; CS
Client_Flags dw ? ; Client's flags (low)
dw ? ; (padding)
Client_SP dw ? ; SP
dw ?
dd 5 dup (?)
Client_Alt_IP dw ?
dw ?
dd ?
Client_Alt_Flags dw ?
dw ?
Client_Alt_SP dw ?
Client_Word_Reg_Struc ends
Client_Byte_Reg_Struc struc
dd 4 dup (?) ; EDI, ESI, EBP, ESP at pushall
Client_BL db ? ; Client's BL
Client_BH db ? ; Client's BH
dw ? ; (padding)
Client_DL db ? ; Client's DL
Client_DH db ? ; Client's DH
dw ? ; (padding)
Client_CL db ? ; Client's CL
Client_CH db ? ; Client's CH
dw ? ; (padding)
Client_AL db ? ; Client's AL
Client_AH db ? ; Client's AH
Client_Byte_Reg_Struc ends
;==============================================================================
EndDoc
.ERRNZ Client_SP - Client_ESP
.ERRNZ Client_AL - Client_EAX
PushCParams MACRO P1, P2, P3, P4, P5, P6, P7, P8, P9, P10
IRP Param, <P10, P9, P8, P7, P6, P5, P4, P3, P2, P1>
IFNB <Param>
push Param
ENDIF
ENDM
ENDM
ClearCParams MACRO Count, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10
IFNB <P1>
ClearCParams %(Count+1), <P2>, <P3>, <P4>, <P5>, <P6>, <P7>, <P8>, <P9>, <P10>
ELSE
IF Count
add esp, Count*4
ENDIF
ENDIF
ENDM
Dyna_Link_Int EQU 20h
;
;
BeginDoc
;******************************************************************************
; The VMMCall and VxDCall macros provide a dynamic link to the VMM and VxD
; service routines. For example:
;
; VMMCall Enable_VM_Ints ; Equivalent to STI in VM code
;
; mov eax,[My_IRQ_Handle]
; VxDCall VPICD_Set_Int_Request ; Set IRQ for my device's interrupt
;
; Note that Enable_VM_Ints is defined in VMM.INC and VPICD_Set_Int_Request is
; defined in VPICD.INC
;
;==============================================================================
EndDoc
BeginDoc
;******************************************************************************
; VxDCall
;==============================================================================
EndDoc
VxDcall MACRO P, Param
PushCParams Param
int Dyna_Link_Int
dd P
ClearCParams 0, Param
ENDM
VxDjmp MACRO P, Param
IFNB <Param>
%OUT ERROR: Parameters may not be passed to VxDjmp or VMMjmp macros
.ERR
ENDIF
int Dyna_Link_Int
IFDEF DEBUG
dd P
ret
ELSE
dd P OR DL_Jmp_Mask
ENDIF
ENDM
DL_Jmp_Mask EQU 8000h
DL_Jmp_Bit EQU 0Fh
VMMcall MACRO P, Param
.ERRNZ (P SHR 16) - VMM_Device_ID
VxDcall <P>, <Param>
ENDM
VMMjmp MACRO P, Param
.ERRNZ (P SHR 16) - VMM_Device_ID
VxDjmp <P>, <Param>
ENDM
cCall MACRO P, Param
PushCParams Param
call P
ClearCParams 0, Param
ENDM
BeginDoc
;******************************************************************************
; Segment definition macros
;
; The segment definition macros are a convenience used in defining the
; segments used by the device driver. They are:
;VxD_ICODE_SEG defines start of initialization code segment
;VxD_ICODE_ENDS defines end of initialization code segment
;VxD_IDATA_SEG defines start of initialization data segment
;VxD_IDATA_ENDS defines end of initialization data segment
;VxD_CODE_SEG defines start of always present code segment
;VxD_CODE_ENDS defines end of always present code segment
;VxD_DATA_SEG defines start of always present data segment
;VxD_DATA_ENDS defines end of always present data segment
;==============================================================================
EndDoc
; Protected mode code
VxD_CODE_SEG EQU <VxD_LOCKED_CODE_SEG>
VxD_CODE_ENDS EQU <VxD_LOCKED_CODE_ENDS>
VxD_LOCKED_CODE_SEG MACRO
_LTEXT SEGMENT
??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 3 + ??_LCODE
ASSUME cs:FLAT, ds:FLAT, es:FLAT, ss:FLAT
ENDM
VxD_LOCKED_CODE_ENDS MACRO
??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 3
_LTEXT ENDS
ENDM
; Protected mode initialization code
VxD_ICODE_SEG MACRO
_ITEXT SEGMENT
??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 3 + ??_ICODE
ASSUME cs:FLAT, ds:FLAT, es:FLAT, ss:FLAT
ENDM
VxD_ICODE_ENDS MACRO
??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 3
_ITEXT ENDS
ENDM
; Protected mode data
VxD_DATA_SEG EQU <VxD_LOCKED_DATA_SEG>
VxD_DATA_ENDS EQU <VxD_LOCKED_DATA_ENDS>
VxD_LOCKED_DATA_SEG MACRO NO_ALIGN
_LDATA SEGMENT
IFB <NO_ALIGN>
ALIGN 4
ENDIF
ENDM
VxD_LOCKED_DATA_ENDS MACRO
_LDATA ENDS
ENDM
; Protected mode initialization data
VxD_IDATA_SEG MACRO
_IDATA SEGMENT
ENDM
VxD_IDATA_ENDS MACRO
_IDATA ENDS
ENDM
VxD_REAL_INIT_SEG MACRO
_RCODE SEGMENT
ASSUME CS:_RCODE, DS:_RCODE, ES:_RCODE, SS:_RCODE
??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 3 + ??_RCODE
ENDM
VxD_REAL_INIT_ENDS MACRO
??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 3
_RCODE ENDS
ENDM
ENDIF
DDK_Version equ 300h
VxD_Desc_Block STRUC
DDB_Next dd ? ; VMM RESERVED FIELD
DDB_SDK_Version dw DDK_Version ; VMM RESERVED FIELD
DDB_Req_Device_Number dw Undefined_Device_ID ; Required device number
DDB_Dev_Major_Version db 0 ; Major device number
DDB_Dev_Minor_Version db 0 ; Minor device number
DDB_Flags dw 0 ; Flags for init calls complete
DDB_Name db " " ; Device name
DDB_Init_Order dd Undefined_Init_Order; Initialization Order
DDB_Control_Proc dd ? ; Offset of control procedure
DDB_V86_API_Proc dd 0 ; Offset of API procedure (or 0)
DDB_PM_API_Proc dd 0 ; Offset of API procedure (or 0)
DDB_V86_API_CSIP dd 0 ; CS:IP of API entry point
DDB_PM_API_CSIP dd 0 ; CS:IP of API entry point
DDB_Reference_Data dd ? ; Reference data from real mode
DDB_Service_Table_Ptr dd 0 ; Pointer to service table
DDB_Service_Table_Size dd 0 ; Number of services
VxD_Desc_Block ENDS
IFNDEF Not_VxD
; flag values for DDB_Flags
DDB_Sys_Crit_Init_Done EQU 00000001b
DDB_Sys_Crit_Init_Done_Bit EQU 0
DDB_Device_Init_Done EQU 00000010b
DDB_Device_Init_Done_Bit EQU 1
BeginDoc
;******************************************************************************
;
; Declare_Virtual_Device macro
;
; ???? Write something here ????
;
;==============================================================================
EndDoc
Declare_Virtual_Device MACRO Name, Major_Ver, Minor_Ver, Ctrl_Proc, Device_Num, Init_Order, V86_Proc, PM_Proc
LOCAL V86_API_Offset, PM_API_Offset, Serv_Tab_Offset, Serv_Tab_Len
dev_id_err MACRO
%OUT Device ID required when providing services
.ERR
ENDM
IFB <V86_Proc>
V86_API_Offset EQU 0
ELSE
IFB <Device_Num>
dev_id_err
ENDIF
V86_API_Offset EQU <OFFSET32 V86_Proc>
ENDIF
IFB <PM_Proc>
PM_API_Offset EQU 0
ELSE
IFB <Device_Num>
dev_id_err
ENDIF
PM_API_Offset EQU <OFFSET32 PM_Proc>
ENDIF
IFDEF Name&_Service_Table
IFB <Device_Num>
dev_id_err
ELSE
IFE Device_Num - Undefined_Device_ID
dev_id_err
ENDIF
ENDIF
Serv_Tab_Offset EQU <OFFSET32 Name&_Service_Table>
Serv_Tab_Len EQU Num_&Name&_Services
ELSE
Serv_Tab_Offset EQU 0
Serv_Tab_Len EQU 0
ENDIF
VxD_LOCKED_DATA_SEG
PUBLIC Name&_DDB
Name&_DDB VxD_Desc_Block <,,Device_Num,Major_Ver,Minor_Ver,,"&Name",Init_Order,\
OFFSET32 Ctrl_Proc, V86_API_Offset, PM_API_Offset, \
,,,Serv_Tab_Offset, Serv_Tab_Len>
VxD_LOCKED_DATA_ENDS
ENDM
BeginDoc
;******************************************************************************
; The Begin_Control_Dispatch macro is used for building a table for dispatching
; messages passed to the VxD_Control procedure. It is used with
; Control_Dispatch and End_Control_Dispatch. The only parameter is used to
; contruct the procedure label by adding "_Control" to the end (normally the
; device name is used i.e. VKD results in creating the procedure VKD_Control,
; this created procedure label must be included in Declare_Virtual_Device)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -