📄 vmm.h
字号:
/* ASM
??_CUR_CODE_SEG = 0
??_LCODE = 1
??_ICODE = 2
??_PCODE = 3
??_SCODE = 4
??_DBOCODE = 5
??_16ICODE = 6
??_RCODE = 7
??_LOCKABLECODE = 8
?_LCODE equ <(??_CUR_CODE_SEG MOD 16) - ??_LCODE>
?_ICODE equ <(??_CUR_CODE_SEG MOD 16) - ??_ICODE>
?_PCODE equ <(??_CUR_CODE_SEG MOD 16) - ??_PCODE>
?_SCODE equ <(??_CUR_CODE_SEG MOD 16) - ??_SCODE>
?_DBOCODE equ <(??_CUR_CODE_SEG MOD 16) - ??_DBOCODE>
?_16ICODE equ <(??_CUR_CODE_SEG MOD 16) - ??_16ICODE>
?_RCODE equ <(??_CUR_CODE_SEG MOD 16) - ??_RCODE>
?_LOCKABLECODE equ <(??_CUR_CODE_SEG MOD 16) - ??_LOCKABLECODE>
ifndef NO_SEGMENTS
;
; SEGMENT definitions and order
;
IFDEF MASM6
_FLAT EQU FLAT
ELSE
_FLAT EQU USE32
ENDIF
;* 32 bit locked code
_LTEXT SEGMENT DWORD PUBLIC _FLAT 'LCODE'
_LTEXT ENDS
_TEXT SEGMENT DWORD PUBLIC _FLAT 'LCODE'
_TEXT ENDS
;* 32 bit pageable code
_PTEXT SEGMENT DWORD PUBLIC _FLAT 'PCODE'
_PTEXT ENDS
MakeCodeSeg MACRO seglist, classname, grpname, iseg
IRP segname,<seglist> ;; For each name in the list
IFNB <classname>
segname SEGMENT DWORD PUBLIC _FLAT "&classname&CODE"
ELSE
segname SEGMENT DWORD PUBLIC _FLAT "&segname&CODE"
ENDIF
IFB <iseg>
VxD_&&segname&&_CODE_SEG MACRO
segname SEGMENT
??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 4 + ??_PCODE
ASSUME cs:FLAT, ds:FLAT, es:FLAT, ss:FLAT
ENDM
ELSE
VxD_&&segname&&_CODE_SEG MACRO
segname SEGMENT
??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 4 + iseg
ASSUME cs:FLAT, ds:FLAT, es:FLAT, ss:FLAT
ENDM
ENDIF
VxD_&&segname&&_CODE_ENDS MACRO
??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 4
segname ENDS
ENDM
segname ENDS
IFNDEF BLD_COFF
IFNB <grpname>
_&grpname GROUP segname
ELSE
_&&segname GROUP segname
ENDIF
ENDIF
ENDM ;; End for each segment
ENDM
MakeCodeSeg <L0CKABLE_BEGIN, LOCKABLE, LOCKABLE_END>, \
LOCKABLE, LOCKABLE, ??_LOCKABLECODE
MakeCodeSeg INT21
MakeCodeSeg SYSEXIT
MakeCodeSeg RARE
MakeCodeSeg W16
MakeCodeSeg W32
MakeCodeSeg VMCREATE
MakeCodeSeg VMDESTROY
MakeCodeSeg THCREATE
MakeCodeSeg THDESTROY
MakeCodeSeg VMSUSPEND
MakeCodeSeg VMRESUME
MakeCodeSeg PNP
MakeCodeSeg DOSVM
;*** DefLockableCodeBegin - define beginning of lockable code
;
; Defines a label with the given name to mark the beginning
; of the lockable code area for this VxD. In the debug version,
; also defines a DWORD containing DFS_TEST_BLOCK so that
; procedures in the lockable code segment defined with
; BeginProc may call _Debug_Flags_Service with flags appropriate
; to the code's current state.
DefLockableCodeBegin MACRO name, private
VxD_L0CKABLE_BEGIN_CODE_SEG
IFB <private>
PUBLIC name
ENDIF
name LABEL NEAR
ifdef BLD_COFF
DD ?
endif
VxD_L0CKABLE_BEGIN_CODE_ENDS
ifndef WIN31COMPAT
if DEBLEVEL
VxD_LOCKED_DATA_SEG
PUBLIC name&_Debug_Flags
name&_Debug_Flags DD DFS_TEST_BLOCK
VxD_LOCKED_DATA_ENDS
??_debug_flags equ <name&_Debug_Flags>
endif
endif
ENDM
;*** DefLockableCodeEnd - define end of lockable code
;
; Defines a label with the given name to mark the end
; of the lockable code area for this VxD. By subtracting
; the offset of the beginning label from the offset of
; the ending label, the VxD may determine how many bytes
; of memory to lock or unlock.
DefLockableCodeEnd MACRO name, private
VxD_LOCKABLE_END_CODE_SEG
IFB <private>
PUBLIC name
ENDIF
name LABEL NEAR
ifdef BLD_COFF
DD ?
endif
VxD_LOCKABLE_END_CODE_ENDS
ENDM
;*** CodeLockFlags - declare locked code debug flags
;
; This macro declares the locked code debug flags.
CodeLockFlags MACRO name
ifndef WIN31COMPAT
if DEBLEVEL
ifndef name&_Debug_Flags
VxD_LOCKED_DATA_SEG
extrn name&_Debug_Flags:dword
VxD_LOCKED_DATA_ENDS
??_debug_flags equ <name&_Debug_Flags>
endif
endif
endif
ENDM
;*** MarkCodeLocked - signify that lockable code is locked
;
; This macro clears DFS_TEST_BLOCK in the debug flags
; DWORD.
MarkCodeLocked MACRO
ifndef WIN31COMPAT
if DEBLEVEL
ifdef ??_debug_flags
pushfd
and ??_debug_flags,NOT DFS_TEST_BLOCK
popfd
endif
endif
endif
ENDM
;*** MarkCodeUnlocked - signify that lockable code is unlocked
;
; This macro sets DFS_TEST_BLOCK in the debug flags
; DWORD.
MarkCodeUnlocked MACRO
ifndef WIN31COMPAT
if DEBLEVEL
ifdef ??_debug_flags
pushfd
or ??_debug_flags,DFS_TEST_BLOCK
popfd
endif
endif
endif
ENDM
;* 32 bit initialization code
_ITEXT SEGMENT DWORD PUBLIC _FLAT 'ICODE'
_ITEXT ENDS
;* 32 bit locked data
_LDATA SEGMENT DWORD PUBLIC _FLAT 'LCODE'
_LDATA ENDS
_DATA SEGMENT DWORD PUBLIC _FLAT 'LCODE'
_DATA ENDS
;* 32 bit pageable data
_PDATA SEGMENT DWORD PUBLIC _FLAT 'PDATA'
_PDATA ENDS
;* 32 Bit initialization data
_IDATA SEGMENT DWORD PUBLIC _FLAT 'ICODE'
_IDATA ENDS
;* Created by C8
_BSS SEGMENT DWORD PUBLIC _FLAT 'LCODE'
_BSS ENDS
CONST SEGMENT DWORD PUBLIC _FLAT 'LCODE'
CONST ENDS
_TLS SEGMENT DWORD PUBLIC _FLAT 'LCODE'
_TLS ENDS
;* 32 Bit static code for DL-VxDs
_STEXT SEGMENT DWORD PUBLIC _FLAT 'SCODE'
_STEXT ENDS
;* 32 Bit static data for DL-VxDs
_SDATA SEGMENT DWORD PUBLIC _FLAT 'SCODE'
_SDATA ENDS
;* dummy segment for IsDebugOnlyLoaded
_DB0START SEGMENT DWORD PUBLIC _FLAT 'DBOCODE'
_DB0START ENDS
;* 32 bit debug only code; loaded only if debugger is present
_DB1CODE SEGMENT DWORD PUBLIC _FLAT 'DBOCODE'
_DB1CODE ENDS
;* 32 bit debug only data; loaded only if debugger is present
_DB2DATA SEGMENT DWORD PUBLIC _FLAT 'DBOCODE'
_DB2DATA ENDS
if DEBLEVEL
;* Start of 32 bit path coverage data
_PATHSTART SEGMENT DWORD PUBLIC _FLAT 'LCODE'
_PATHSTART ENDS
;* 32 bit path coverage data
_PATHDATA SEGMENT DWORD PUBLIC _FLAT 'LCODE'
_PATHDATA ENDS
;* End of 32 bit path coverage data
_PATHEND SEGMENT DWORD PUBLIC _FLAT 'LCODE'
_PATHEND ENDS
endif
;* 16 bit code/data that is put into IGROUP automaticly
_16ICODE SEGMENT WORD USE16 PUBLIC '16ICODE'
_16ICODE ENDS
;* Real Mode initialization code/data for devices
_RCODE SEGMENT WORD USE16 PUBLIC 'RCODE'
_RCODE ENDS
IFNDEF BLD_COFF
_LGROUP GROUP _LTEXT, _TEXT, _LDATA, _DATA, _BSS, CONST, _TLS
_IGROUP GROUP _ITEXT, _IDATA
_SGROUP GROUP _STEXT, _SDATA
_DBOGROUP GROUP _DB0START, _DB1CODE, _DB2DATA
IF DEBLEVEL
_PGROUP GROUP _PATHSTART, _PATHDATA, _PATHEND
ENDIF
ENDIF
endif ; NO_SEGMENTS
ASSUME CS:FLAT, DS:FLAT, ES:FLAT, SS:FLAT
OFFSET32 EQU <OFFSET FLAT:>
BeginDoc
;==============================================================================
; The following macros are used in defining the routines
; in a VxD which are going to be registered with VMM as callable entry
; points. Once registered, the entry points can be called by any other
; devices via the "VxDCall" macro, defined below. In the comments below,
; replace "VxD" with the appropriate device name.
;
;*******
; In the VxD.INC file, put the following lines, replacing <function_name>
; with an appropriate name describing the function of the routine.
;
; Begin_Service_Table VxD[,<segname>]
; VxD_Service <function_name>[,<local segname>]
; VxD_Service <function_name>[,<local segname>]
; . . .
; VxD_Service <function_name>[,<local segname>]
; End_Service_Table VxD[,<segname>]
;
; Note that <segname> is an optional argument and, if specified, the
; table is put in the segment defined by the macro "yyy_Data_Seg",
; where yyy=segname. Otherwise the segment is defined by the
; "VxD_Data_Seg" macro, defined below.
; Note that <local segname> is an optional argument and, if specified,
; the procedure's segment is defined by the macro "zzz_Code_Seg",
; where zzz=segname. Otherwise the segment is defined by the
; "VxD_Code_Seg" macro, defined below.
;
;*******
; One VxD module should have the following in order to define the entry points:
;Create_VxD_Service_Table = 1 ; Only in module where table is
; INCLUDE VxD.INC ; Include the table definition
;
;*******
; All modules that want to call the services defined in the table should include
; VxD.INC, but not define the label "Create_VxD_Service_Table". This
; will define the service names to be used with the VxDCall macro.
;
EndDoc
Begin_Service_Table MACRO Device_Name, Def_Segment
IFDEF Device_Name&_Name_Based
IFNDEF @@NextInternalID
@@NextInternalID = 0
ENDIF
@@NextInternalID = (@@NextInternalID + 1)
Device_Name&_Internal_ID = @@NextInternalID + BASEID_FOR_NAMEBASEDVXD
DefineVxDName Device_Name, %Device_Name&_Internal_ID
ENDIF
IFB <Def_Segment>
BST2 Device_Name, VxD
ELSE
BST2 Device_Name, Def_Segment
ENDIF
ENDM
DefineVxDName MACRO Device_Name, InternalID
@@VxDName&InternalID EQU <___&Device_Name&STable>
ENDM
BST2 MACRO Device_Name, Def_Segment
Num_&Device_Name&_Services = 0
IFDEF Create_&Device_Name&_Service_Table
Def_Segment&_LOCKED_DATA_SEG
Device_Name&_Service_Table LABEL DWORD
Device_Name&_Service MACRO Procedure, Local_Seg, Condition, StdCallBytes, fastcall
LOCAL $$&Procedure, extrnproc, tableproc
extrnproc MACRO
IFNB <fastcall>
IFB <StdCallBytes>
.err ;StdCallBytes required
ENDIF
EXTRN @&&Procedure&&@&&StdCallBytes:NEAR
ELSE
IFNB <StdCallBytes>
EXTRN _&&Procedure&&@&&StdCallBytes:NEAR
ELSE
EXTRN Procedure:NEAR
ENDIF
ENDIF
ENDM
tableproc MACRO
IFNB <fastcall>
dd OFFSET32 @&&Procedure&&@&&StdCallBytes
ELSE
IFNB <StdCallBytes>
dd OFFSET32 _&&Procedure&&@&&StdCallBytes
ELSE
dd OFFSET32 Procedure
ENDIF
ENDIF
ENDM
IFNB <Condition>
$$&&Procedure MACRO extern
IFDEF &Condition
IFNB <extern>
extrnproc
ELSE
tableproc
ENDIF
ELSE
IFB <extern>
dd 0
ENDIF
ENDIF
ENDM
ENDIF
IFDIFI <Procedure>, <RESERVED>
IFDIFI <Local_Seg>, <RESERVED>
PUBLIC _&&Procedure
IF1
_&&Procedure LABEL DWORD
IFNB <fastcall>
PUBLIC __&&Procedure
__&&Procedure LABEL DWORD
ENDIF
ENDIF
IFDIFI <Local_Seg>, <LOCAL>
IFNB <Local_Seg>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -