Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6583 lines
178 KiB

  1. /*****************************************************************************
  2. *
  3. * (C) Copyright MICROSOFT Corp., 1988-1990
  4. *
  5. * Title: VMM.H - Include file for Virtual Machine Manager
  6. *
  7. * Version: 1.00
  8. *
  9. * Date: 05-May-1988
  10. *
  11. * Author: RAL
  12. *
  13. *-----------------------------------------------------------------------------
  14. *
  15. * Change log:
  16. *
  17. * DATE REV DESCRIPTION
  18. * ----------- --- -----------------------------------------------------------
  19. * 05-May-1988 RAL Original
  20. * 13-Nov-1991 PBS C version
  21. * 17-Dec-1993 Adds East Asia VxDs identifiers
  22. */
  23. #ifndef _VMM_
  24. #define _VMM_
  25. /*
  26. * NON Windows/386 Virtual Device sources can include this file to get
  27. * some useful equates by declaring the symbol "Not_VxD" If this symbol
  28. * is defined, then everything that has to do with the specifics of the
  29. * 32 bit environment for virtual devices is removed. Useful equates
  30. * include: device ID's, pushad structure, BeginDoc, EndDoc, BeginMsg,
  31. * EndMsg, page table equates, etc.
  32. */
  33. #define FALSE 0 // False
  34. #define VMM_TRUE (~FALSE) // The opposite of False!
  35. #define DEBLEVELRETAIL 0
  36. #define DEBLEVELNORMAL 1
  37. #define DEBLEVELMAX 2
  38. #ifndef DEBLEVEL
  39. #ifdef DEBUG
  40. #define DEBLEVEL DEBLEVELNORMAL
  41. #else
  42. #define DEBLEVEL DEBLEVELRETAIL
  43. #endif
  44. #endif
  45. #ifndef WIN31COMPAT
  46. #define WIN40SERVICES
  47. #define WIN403SERVICES /*OPK-3 Services*/
  48. #endif
  49. #ifndef WIN40COMPAT
  50. #define WIN41SERVICES
  51. #endif
  52. /* ASM
  53. ifdef MASM6
  54. ifndef NO_MASM6_OPTIONS
  55. ;
  56. ; option switches necessary to build VMM/VxD sources with MASM 6
  57. ;
  58. option oldmacros
  59. ifndef NEWSTRUCTS ; define NEWSTRUCTS for MASM6 struct semantics
  60. option oldstructs
  61. endif
  62. option noscoped
  63. option segment:flat
  64. option offset:flat
  65. option proc:private
  66. endif
  67. endif
  68. ;
  69. ; These null macros are recognized by a utility program that produces
  70. ; documentation files.
  71. ;
  72. IFDEF MASM6
  73. BeginDoc MACRO
  74. ENDM
  75. EndDoc MACRO
  76. ENDM
  77. BeginMsg MACRO
  78. ENDM
  79. EndMsg MACRO
  80. ENDM
  81. ELSE
  82. BeginDoc EQU <>
  83. EndDoc EQU <>
  84. BeginMsg EQU <>
  85. EndMsg EQU <>
  86. ENDIF
  87. */
  88. /******************************************************************************
  89. *
  90. * EQUATES FOR REQUIRED DEVICES
  91. *
  92. * Device ID formulation note:
  93. *
  94. * The high bit of the device ID is reserved for future use.
  95. * Microsoft reserves the device ID's 0-1FFh for standard devices. If
  96. * an OEM VxD is a replacement for a standard VxD, then it must use the
  97. * standard VxD ID.
  98. *
  99. * OEMS WHO WANT A VXD DEVICE ID ASSIGNED TO THEM,
  100. * PLEASE CONTACT MICROSOFT PRODUCT SUPPORT. ID's are only required for
  101. * devices which provide services, V86 API's or PM API's. Also, calling
  102. * services or API's by VxD name is now supported in version 4.0, so an
  103. * ID may not be necessary as long as a unique 8 character name is used.
  104. *
  105. *****************************************************************************/
  106. #define UNDEFINED_DEVICE_ID 0x00000
  107. #define VMM_DEVICE_ID 0x00001 /* Used for dynalink table */
  108. #define DEBUG_DEVICE_ID 0x00002
  109. #define VPICD_DEVICE_ID 0x00003
  110. #define VDMAD_DEVICE_ID 0x00004
  111. #define VTD_DEVICE_ID 0x00005
  112. #define V86MMGR_DEVICE_ID 0x00006
  113. #define PAGESWAP_DEVICE_ID 0x00007
  114. #define PARITY_DEVICE_ID 0x00008
  115. #define REBOOT_DEVICE_ID 0x00009
  116. #define VDD_DEVICE_ID 0x0000A
  117. #define VSD_DEVICE_ID 0x0000B
  118. #define VMD_DEVICE_ID 0x0000C
  119. #define VKD_DEVICE_ID 0x0000D
  120. #define VCD_DEVICE_ID 0x0000E
  121. #define VPD_DEVICE_ID 0x0000F
  122. #define BLOCKDEV_DEVICE_ID 0x00010
  123. #define VMCPD_DEVICE_ID 0x00011
  124. #define EBIOS_DEVICE_ID 0x00012
  125. #define BIOSXLAT_DEVICE_ID 0x00013
  126. #define VNETBIOS_DEVICE_ID 0x00014
  127. #define DOSMGR_DEVICE_ID 0x00015
  128. #define WINLOAD_DEVICE_ID 0x00016
  129. #define SHELL_DEVICE_ID 0x00017
  130. #define VMPOLL_DEVICE_ID 0x00018
  131. #define VPROD_DEVICE_ID 0x00019
  132. #define DOSNET_DEVICE_ID 0x0001A
  133. #define VFD_DEVICE_ID 0x0001B
  134. #define VDD2_DEVICE_ID 0x0001C /* Secondary display adapter */
  135. #define WINDEBUG_DEVICE_ID 0x0001D
  136. #define TSRLOAD_DEVICE_ID 0x0001E /* TSR instance utility ID */
  137. #define BIOSHOOK_DEVICE_ID 0x0001F /* Bios interrupt hooker VxD */
  138. #define INT13_DEVICE_ID 0x00020
  139. #define PAGEFILE_DEVICE_ID 0x00021 /* Paging File device */
  140. #define SCSI_DEVICE_ID 0x00022 /* SCSI device */
  141. #define MCA_POS_DEVICE_ID 0x00023 /* MCA_POS device */
  142. #define SCSIFD_DEVICE_ID 0x00024 /* SCSI FastDisk device */
  143. #define VPEND_DEVICE_ID 0x00025 /* Pen device */
  144. #define APM_DEVICE_ID 0x00026 /* Power Management device */
  145. #define VPOWERD_DEVICE_ID APM_DEVICE_ID /* We overload APM since we replace it */
  146. #define VXDLDR_DEVICE_ID 0x00027 /* VxD Loader device */
  147. #define NDIS_DEVICE_ID 0x00028 /* NDIS wrapper */
  148. #define BIOS_EXT_DEVICE_ID 0x00029 /* Fix Broken BIOS device */
  149. #define VWIN32_DEVICE_ID 0x0002A /* for new WIN32-VxD */
  150. #define VCOMM_DEVICE_ID 0x0002B /* New COMM device driver */
  151. #define SPOOLER_DEVICE_ID 0x0002C /* Local Spooler */
  152. #define WIN32S_DEVICE_ID 0x0002D /* Win32S on Win 3.1 driver */
  153. #define DEBUGCMD_DEVICE_ID 0x0002E /* Debug command extensions */
  154. /* #define RESERVED_DEVICE_ID 0x0002F /* Not currently in use */
  155. /* #define ATI_HELPER_DEVICE_ID 0x00030 /* grabbed by ATI */
  156. /* 31-32 USED BY WFW NET COMPONENTS */
  157. /* #define VNB_DEVICE_ID 0x00031 /* Netbeui of snowball */
  158. /* #define SERVER_DEVICE_ID 0x00032 /* Server of snowball */
  159. #define CONFIGMG_DEVICE_ID 0x00033 /* Configuration manager (Plug&Play) */
  160. #define DWCFGMG_DEVICE_ID 0x00034 /* Configuration manager for win31 and DOS */
  161. #define SCSIPORT_DEVICE_ID 0x00035 /* Dragon miniport loader/driver */
  162. #define VFBACKUP_DEVICE_ID 0x00036 /* allows backup apps to work with NEC */
  163. #define ENABLE_DEVICE_ID 0x00037 /* for access VxD */
  164. #define VCOND_DEVICE_ID 0x00038 /* Virtual Console Device - check vcond.inc */
  165. /* 39 used by WFW VFat Helper device */
  166. /* 3A used by WFW E-FAX */
  167. /* #define EFAX_DEVICE_ID 0x0003A /* EFAX VxD ID */
  168. /* 3B used by MS-DOS 6.1 for the DblSpace VxD which has APIs */
  169. /* #define DSVXD_DEVICE_ID 0x0003B /* Dbl Space VxD ID */
  170. #define ISAPNP_DEVICE_ID 0x0003C /* ISA P&P Enumerator */
  171. #define BIOS_DEVICE_ID 0x0003D /* BIOS P&P Enumerator */
  172. /* #define WINSOCK_DEVICE_ID 0x0003E /* WinSockets */
  173. /* #define WSIPX_DEVICE_ID 0x0003F /* WinSockets for IPX */
  174. #define IFSMgr_Device_ID 0x00040 /* Installable File System Manager */
  175. #define VCDFSD_DEVICE_ID 0x00041 /* Static CDFS ID */
  176. #define MRCI2_DEVICE_ID 0x00042 /* DrvSpace compression engine */
  177. #define PCI_DEVICE_ID 0x00043 /* PCI P&P Enumerator */
  178. #define PELOADER_DEVICE_ID 0x00044 /* PE Image Loader */
  179. #define EISA_DEVICE_ID 0x00045 /* EISA P&P Enumerator */
  180. #define DRAGCLI_DEVICE_ID 0x00046 /* Dragon network client */
  181. #define DRAGSRV_DEVICE_ID 0x00047 /* Dragon network server */
  182. #define PERF_DEVICE_ID 0x00048 /* Config/stat info */
  183. #define AWREDIR_DEVICE_ID 0x00049 /* AtWork Network FSD */
  184. #define DDS_DEVICE_ID 0x0004A /* Device driver services */
  185. #define NTKERN_DEVICE_ID 0x0004B /* NT kernel device id */
  186. #define VDOSKEYD_DEVICE_ID 0x0004B /* DOSKEY device id */
  187. #define ACPI_DEVICE_ID 0x0004C /* Advanced Configuration and Power Interfacec */
  188. #define UDF_DEVICE_ID 0x0004D /* UDF FSD device id */
  189. #define SMCLIB_DEVICE_ID 0x0004E /* Smart Card port driver */
  190. /*
  191. * East Asia DOS support VxD ID
  192. */
  193. #define ETEN_Device_ID 0x00060 /* ETEN DOS (Taiwan) driver */
  194. #define CHBIOS_Device_ID 0x00061 /* CHBIOS DOS (Korean) driver */
  195. #define VMSGD_Device_ID 0x00062 /* DBCS Message Mode driver */
  196. #define VPPID_Device_ID 0x00063 /* PC-98 System Control PPI */
  197. #define VIME_Device_ID 0x00064 /* Virtual DOS IME */
  198. #define VHBIOSD_Device_ID 0x00065 /* HBIOS (Korean) for HWin31 driver */
  199. #define BASEID_FOR_NAMEBASEDVXD 0xf000 /* Name based VxD IDs start here */
  200. #define BASEID_FOR_NAMEBASEDVXD_MASK 0x0fff /* Mask to get the real vxd id */
  201. /*
  202. * Initialization order equates. Devices are initialized in order from
  203. * LOWEST to HIGHEST. If 2 or more devices have the same initialization
  204. * order value, then they are initialized in order of occurance, so a
  205. * specific order is not guaranteed. Holes have been left to allow maximum
  206. * flexibility in ordering devices.
  207. */
  208. #define VMM_INIT_ORDER 0x000000000
  209. #define DEBUG_INIT_ORDER 0x000000000 /* normally using 0 is bad */
  210. #define DEBUGCMD_INIT_ORDER 0x000000000 /* but debug must be first */
  211. #define PERF_INIT_ORDER 0x000900000
  212. #define APM_INIT_ORDER 0x001000000
  213. #define VPOWERD_INIT_ORDER APM_INIT_ORDER /* We overload APM since we replace it */
  214. #define BIOSHOOK_INIT_ORDER 0x006000000
  215. #define VPROD_INIT_ORDER 0x008000000
  216. #define VPICD_INIT_ORDER 0x00C000000
  217. #define VTD_INIT_ORDER 0x014000000
  218. #define VWIN32_INIT_ORDER 0x014100000
  219. #define VXDLDR_INIT_ORDER 0x016000000
  220. #define NTKERN_INIT_ORDER 0x016200000 /* Must be after VxDLdr and before configmg */
  221. #define CONFIGMG_INIT_ORDER 0x016400000 /* Must now be before enumerators */
  222. #define ENUMERATOR_INIT_ORDER 0x016800000 /* Should be before IOS */
  223. #define ISAPNP_INIT_ORDER ENUMERATOR_INIT_ORDER
  224. #define EISA_INIT_ORDER ENUMERATOR_INIT_ORDER
  225. #define PCI_INIT_ORDER ENUMERATOR_INIT_ORDER
  226. #define BIOS_INIT_ORDER ENUMERATOR_INIT_ORDER+1 /* To simplify reenumeration */
  227. #define ACPI_INIT_ORDER ENUMERATOR_INIT_ORDER+2 /* To simplify reenumeration */
  228. #define VCDFSD_INIT_ORDER 0x016F00000
  229. #define IOS_INIT_ORDER 0x017000000
  230. #define PAGEFILE_INIT_ORDER 0x018000000
  231. #define PAGESWAP_INIT_ORDER 0x01C000000
  232. #define PARITY_INIT_ORDER 0x020000000
  233. #define REBOOT_INIT_ORDER 0x024000000
  234. #define EBIOS_INIT_ORDER 0x026000000
  235. #define VDD_INIT_ORDER 0x028000000
  236. #define VSD_INIT_ORDER 0x02C000000
  237. #define VCD_INIT_ORDER 0x030000000
  238. #define COMMDRVR_INIT_ORDER (VCD_INIT_ORDER - 1)
  239. #define PRTCL_INIT_ORDER (COMMDRVR_INIT_ORDER - 2)
  240. #define MODEM_INIT_ORDER (COMMDRVR_INIT_ORDER - 3)
  241. #define PORT_INIT_ORDER (COMMDRVR_INIT_ORDER - 4)
  242. #define VMD_INIT_ORDER 0x034000000
  243. #define VKD_INIT_ORDER 0x038000000
  244. #define VPD_INIT_ORDER 0x03C000000
  245. #define BLOCKDEV_INIT_ORDER 0x040000000
  246. #define MCA_POS_INIT_ORDER 0x041000000
  247. #define SCSIFD_INIT_ORDER 0x041400000
  248. #define SCSIMASTER_INIT_ORDER 0x041800000
  249. #define INT13_INIT_ORDER 0x042000000
  250. #define VMCPD_INIT_ORDER 0x048000000
  251. #define BIOSXLAT_INIT_ORDER 0x050000000
  252. #define VNETBIOS_INIT_ORDER 0x054000000
  253. #define DOSMGR_INIT_ORDER 0x058000000
  254. #define DOSNET_INIT_ORDER 0x05C000000
  255. #define WINLOAD_INIT_ORDER 0x060000000
  256. #define VMPOLL_INIT_ORDER 0x064000000
  257. #define UNDEFINED_INIT_ORDER 0x080000000
  258. #define VCOND_INIT_ORDER UNDEFINED_INIT_ORDER
  259. #define WINDEBUG_INIT_ORDER 0x081000000
  260. #define VDMAD_INIT_ORDER 0x090000000
  261. #define V86MMGR_INIT_ORDER 0x0A0000000
  262. #define IFSMgr_Init_Order 0x10000 + V86MMGR_Init_Order
  263. #define FSD_Init_Order 0x00100 + IFSMgr_Init_Order
  264. #define VFD_INIT_ORDER 0x50000 + IFSMgr_Init_Order
  265. /* Device that must touch memory in 1st Mb at crit init (after V86mmgr) */
  266. #define UNDEF_TOUCH_MEM_INIT_ORDER 0x0A8000000
  267. #define SHELL_INIT_ORDER 0x0B0000000
  268. /* ASM
  269. ;******************************************************************************
  270. ;
  271. ; Macro to cause a delay in between I/O accesses to the same device.
  272. ;
  273. ;------------------------------------------------------------------------------
  274. IO_Delay macro
  275. jmp $+2
  276. ENDM
  277. */
  278. #define VXD_FAILURE 0
  279. #define VXD_SUCCESS 1
  280. typedef ULONG HVM; /* VM handle typedef */
  281. /*
  282. * Registers as they appear on the stack after a PUSHAD.
  283. */
  284. struct Pushad_Struc {
  285. ULONG Pushad_EDI; /* Client's EDI */
  286. ULONG Pushad_ESI; /* Client's ESI */
  287. ULONG Pushad_EBP; /* Client's EBP */
  288. ULONG Pushad_ESP; /* ESP before pushad */
  289. ULONG Pushad_EBX; /* Client's EBX */
  290. ULONG Pushad_EDX; /* Client's EDX */
  291. ULONG Pushad_ECX; /* Client's ECX */
  292. ULONG Pushad_EAX; /* Client's EAX */
  293. };
  294. /* XLATOFF */
  295. #ifdef RC_INVOKED
  296. #define NOBASEDEFS
  297. #endif
  298. #ifndef NOBASEDEFS
  299. #pragma warning (disable:4209) // turn off redefinition warning
  300. typedef unsigned char UCHAR;
  301. typedef unsigned short USHORT;
  302. #pragma warning (default:4209) // turn off redefinition warning
  303. #endif
  304. #define GetVxDServiceOrdinal(service) __##service
  305. #define Begin_Service_Table(device, seg) \
  306. enum device##_SERVICES { \
  307. device##_dummy = (device##_DEVICE_ID << 16) - 1,
  308. #define Declare_Service(service, local) \
  309. GetVxDServiceOrdinal(service),
  310. #define Declare_SCService(service, args, local) \
  311. GetVxDServiceOrdinal(service),
  312. #define End_Service_Table(device, seg) \
  313. Num_##device##_Services};
  314. #define VXDINLINE static __inline
  315. /* XLATON */
  316. #ifndef Not_VxD
  317. /* XLATOFF */
  318. #define VxD_LOCKED_CODE_SEG code_seg("_LTEXT", "LCODE")
  319. #define VxD_LOCKED_DATA_SEG data_seg("_LDATA", "LCODE")
  320. #define VxD_INIT_CODE_SEG code_seg("_ITEXT", "ICODE")
  321. #define VxD_INIT_DATA_SEG data_seg("_IDATA", "ICODE")
  322. #define VxD_ICODE_SEG code_seg("_ITEXT", "ICODE")
  323. #define VxD_IDATA_SEG data_seg("_IDATA", "ICODE")
  324. #define VxD_PAGEABLE_CODE_SEG code_seg("_PTEXT", "PCODE")
  325. #define VxD_PAGEABLE_DATA_SEG data_seg("_PDATA", "PDATA")
  326. #define VxD_STATIC_CODE_SEG code_seg("_STEXT", "SCODE")
  327. #define VxD_STATIC_DATA_SEG data_seg("_SDATA", "SCODE")
  328. #define VxD_DEBUG_ONLY_CODE_SEG code_seg("_DB1CODE", "DBOCODE")
  329. #define VxD_DEBUG_ONLY_DATA_SEG data_seg("_DB2DATA", "DBOCODE")
  330. #define VxD_SYSEXIT_CODE_SEG code_seg("SYSEXIT", "SYSEXITCODE")
  331. #define VxD_INT21_CODE_SEG code_seg("INT21", "INT21CODE")
  332. #define VxD_RARE_CODE_SEG code_seg("RARE", "RARECODE")
  333. #define VxD_W16_CODE_SEG code_seg("W16", "W16CODE")
  334. #define VxD_W32_CODE_SEG code_seg("W32", "W32CODE")
  335. #define VxD_VMCREATE_CODE_SEG code_seg("VMCREATE", "VMCREATECODE")
  336. #define VxD_VMDESTROY_CODE_SEG code_seg("VMDESTROY", "VMDESTROYCODE")
  337. #define VxD_THCREATE_CODE_SEG code_seg("THCREATE", "THCREATECODE")
  338. #define VxD_THDESTROY_CODE_SEG code_seg("THDESTROY", "THDESTROYCODE")
  339. #define VxD_VMSUSPEND_CODE_SEG code_seg("VMSUSPEND", "VMSUSPENDCODE")
  340. #define VxD_VMRESUME_CODE_SEG code_seg("VMRESUME", "VMRESUMECODE")
  341. #define VxD_PNP_CODE_SEG code_seg("PNP", "PNPCODE")
  342. #define VxD_DOSVM_CODE_SEG code_seg("DOSVM", "DOSVMCODE")
  343. #define VxD_LOCKABLE_CODE_SEG code_seg("LOCKABLE", "LOCKABLECODE")
  344. #define VxD_LOCKABLE_DATA_SEG data_seg("LOCKABLE_DATA", "LOCKABLECODE")
  345. /* XLATON */
  346. /* ASM
  347. ??_CUR_CODE_SEG = 0
  348. ??_LCODE = 1
  349. ??_ICODE = 2
  350. ??_PCODE = 3
  351. ??_SCODE = 4
  352. ??_DBOCODE = 5
  353. ??_16ICODE = 6
  354. ??_RCODE = 7
  355. ??_LOCKABLECODE = 8
  356. ?_LCODE equ <(??_CUR_CODE_SEG MOD 16) - ??_LCODE>
  357. ?_ICODE equ <(??_CUR_CODE_SEG MOD 16) - ??_ICODE>
  358. ?_PCODE equ <(??_CUR_CODE_SEG MOD 16) - ??_PCODE>
  359. ?_SCODE equ <(??_CUR_CODE_SEG MOD 16) - ??_SCODE>
  360. ?_DBOCODE equ <(??_CUR_CODE_SEG MOD 16) - ??_DBOCODE>
  361. ?_16ICODE equ <(??_CUR_CODE_SEG MOD 16) - ??_16ICODE>
  362. ?_RCODE equ <(??_CUR_CODE_SEG MOD 16) - ??_RCODE>
  363. ?_LOCKABLECODE equ <(??_CUR_CODE_SEG MOD 16) - ??_LOCKABLECODE>
  364. ifndef NO_SEGMENTS
  365. ;
  366. ; SEGMENT definitions and order
  367. ;
  368. IFDEF MASM6
  369. _FLAT EQU FLAT
  370. ELSE
  371. _FLAT EQU USE32
  372. ENDIF
  373. ;* 32 bit locked code
  374. _LTEXT SEGMENT DWORD PUBLIC _FLAT 'LCODE'
  375. _LTEXT ENDS
  376. _TEXT SEGMENT DWORD PUBLIC _FLAT 'LCODE'
  377. _TEXT ENDS
  378. ;* 32 bit pageable code
  379. _PTEXT SEGMENT DWORD PUBLIC _FLAT 'PCODE'
  380. _PTEXT ENDS
  381. MakeCodeSeg MACRO seglist, classname, grpname, iseg
  382. IRP segname,<seglist> ;; For each name in the list
  383. IFNB <classname>
  384. segname SEGMENT DWORD PUBLIC _FLAT "&classname&CODE"
  385. ELSE
  386. segname SEGMENT DWORD PUBLIC _FLAT "&segname&CODE"
  387. ENDIF
  388. IFB <iseg>
  389. VxD_&&segname&&_CODE_SEG MACRO
  390. segname SEGMENT
  391. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 4 + ??_PCODE
  392. ASSUME cs:FLAT, ds:FLAT, es:FLAT, ss:FLAT
  393. ENDM
  394. ELSE
  395. VxD_&&segname&&_CODE_SEG MACRO
  396. segname SEGMENT
  397. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 4 + iseg
  398. ASSUME cs:FLAT, ds:FLAT, es:FLAT, ss:FLAT
  399. ENDM
  400. ENDIF
  401. VxD_&&segname&&_CODE_ENDS MACRO
  402. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 4
  403. segname ENDS
  404. ENDM
  405. segname ENDS
  406. IFNDEF BLD_COFF
  407. IFNB <grpname>
  408. _&grpname GROUP segname
  409. ELSE
  410. _&&segname GROUP segname
  411. ENDIF
  412. ENDIF
  413. ENDM ;; End for each segment
  414. ENDM
  415. MakeCodeSeg <L0CKABLE_BEGIN, LOCKABLE, LOCKABLE_END>, \
  416. LOCKABLE, LOCKABLE, ??_LOCKABLECODE
  417. MakeCodeSeg INT21
  418. MakeCodeSeg SYSEXIT
  419. MakeCodeSeg RARE
  420. MakeCodeSeg W16
  421. MakeCodeSeg W32
  422. MakeCodeSeg VMCREATE
  423. MakeCodeSeg VMDESTROY
  424. MakeCodeSeg THCREATE
  425. MakeCodeSeg THDESTROY
  426. MakeCodeSeg VMSUSPEND
  427. MakeCodeSeg VMRESUME
  428. MakeCodeSeg PNP
  429. MakeCodeSeg DOSVM
  430. ;*** DefLockableCodeBegin - define beginning of lockable code
  431. ;
  432. ; Defines a label with the given name to mark the beginning
  433. ; of the lockable code area for this VxD. In the debug version,
  434. ; also defines a DWORD containing DFS_TEST_BLOCK so that
  435. ; procedures in the lockable code segment defined with
  436. ; BeginProc may call _Debug_Flags_Service with flags appropriate
  437. ; to the code's current state.
  438. DefLockableCodeBegin MACRO name, private
  439. VxD_L0CKABLE_BEGIN_CODE_SEG
  440. IFB <private>
  441. PUBLIC name
  442. ENDIF
  443. name LABEL NEAR
  444. ifdef BLD_COFF
  445. DD ?
  446. endif
  447. VxD_L0CKABLE_BEGIN_CODE_ENDS
  448. ifndef WIN31COMPAT
  449. if DEBLEVEL
  450. VxD_LOCKED_DATA_SEG
  451. PUBLIC name&_Debug_Flags
  452. name&_Debug_Flags DD DFS_TEST_BLOCK
  453. VxD_LOCKED_DATA_ENDS
  454. ??_debug_flags equ <name&_Debug_Flags>
  455. endif
  456. endif
  457. ENDM
  458. ;*** DefLockableCodeEnd - define end of lockable code
  459. ;
  460. ; Defines a label with the given name to mark the end
  461. ; of the lockable code area for this VxD. By subtracting
  462. ; the offset of the beginning label from the offset of
  463. ; the ending label, the VxD may determine how many bytes
  464. ; of memory to lock or unlock.
  465. DefLockableCodeEnd MACRO name, private
  466. VxD_LOCKABLE_END_CODE_SEG
  467. IFB <private>
  468. PUBLIC name
  469. ENDIF
  470. name LABEL NEAR
  471. ifdef BLD_COFF
  472. DD ?
  473. endif
  474. VxD_LOCKABLE_END_CODE_ENDS
  475. ENDM
  476. ;*** CodeLockFlags - declare locked code debug flags
  477. ;
  478. ; This macro declares the locked code debug flags.
  479. CodeLockFlags MACRO name
  480. ifndef WIN31COMPAT
  481. if DEBLEVEL
  482. ifndef name&_Debug_Flags
  483. VxD_LOCKED_DATA_SEG
  484. extrn name&_Debug_Flags:dword
  485. VxD_LOCKED_DATA_ENDS
  486. ??_debug_flags equ <name&_Debug_Flags>
  487. endif
  488. endif
  489. endif
  490. ENDM
  491. ;*** MarkCodeLocked - signify that lockable code is locked
  492. ;
  493. ; This macro clears DFS_TEST_BLOCK in the debug flags
  494. ; DWORD.
  495. MarkCodeLocked MACRO
  496. ifndef WIN31COMPAT
  497. if DEBLEVEL
  498. ifdef ??_debug_flags
  499. pushfd
  500. and ??_debug_flags,NOT DFS_TEST_BLOCK
  501. popfd
  502. endif
  503. endif
  504. endif
  505. ENDM
  506. ;*** MarkCodeUnlocked - signify that lockable code is unlocked
  507. ;
  508. ; This macro sets DFS_TEST_BLOCK in the debug flags
  509. ; DWORD.
  510. MarkCodeUnlocked MACRO
  511. ifndef WIN31COMPAT
  512. if DEBLEVEL
  513. ifdef ??_debug_flags
  514. pushfd
  515. or ??_debug_flags,DFS_TEST_BLOCK
  516. popfd
  517. endif
  518. endif
  519. endif
  520. ENDM
  521. ;* 32 bit initialization code
  522. _ITEXT SEGMENT DWORD PUBLIC _FLAT 'ICODE'
  523. _ITEXT ENDS
  524. ;* 32 bit locked data
  525. _LDATA SEGMENT DWORD PUBLIC _FLAT 'LCODE'
  526. _LDATA ENDS
  527. _DATA SEGMENT DWORD PUBLIC _FLAT 'LCODE'
  528. _DATA ENDS
  529. ;* 32 bit pageable data
  530. _PDATA SEGMENT DWORD PUBLIC _FLAT 'PDATA'
  531. _PDATA ENDS
  532. ;* 32 Bit initialization data
  533. _IDATA SEGMENT DWORD PUBLIC _FLAT 'ICODE'
  534. _IDATA ENDS
  535. ;* Created by C8
  536. _BSS SEGMENT DWORD PUBLIC _FLAT 'LCODE'
  537. _BSS ENDS
  538. CONST SEGMENT DWORD PUBLIC _FLAT 'LCODE'
  539. CONST ENDS
  540. _TLS SEGMENT DWORD PUBLIC _FLAT 'LCODE'
  541. _TLS ENDS
  542. ;* 32 Bit static code for DL-VxDs
  543. _STEXT SEGMENT DWORD PUBLIC _FLAT 'SCODE'
  544. _STEXT ENDS
  545. ;* 32 Bit static data for DL-VxDs
  546. _SDATA SEGMENT DWORD PUBLIC _FLAT 'SCODE'
  547. _SDATA ENDS
  548. ;* dummy segment for IsDebugOnlyLoaded
  549. _DB0START SEGMENT DWORD PUBLIC _FLAT 'DBOCODE'
  550. _DB0START ENDS
  551. ;* 32 bit debug only code; loaded only if debugger is present
  552. _DB1CODE SEGMENT DWORD PUBLIC _FLAT 'DBOCODE'
  553. _DB1CODE ENDS
  554. ;* 32 bit debug only data; loaded only if debugger is present
  555. _DB2DATA SEGMENT DWORD PUBLIC _FLAT 'DBOCODE'
  556. _DB2DATA ENDS
  557. if DEBLEVEL
  558. ;* Start of 32 bit path coverage data
  559. _PATHSTART SEGMENT DWORD PUBLIC _FLAT 'LCODE'
  560. _PATHSTART ENDS
  561. ;* 32 bit path coverage data
  562. _PATHDATA SEGMENT DWORD PUBLIC _FLAT 'LCODE'
  563. _PATHDATA ENDS
  564. ;* End of 32 bit path coverage data
  565. _PATHEND SEGMENT DWORD PUBLIC _FLAT 'LCODE'
  566. _PATHEND ENDS
  567. endif
  568. ;* 16 bit code/data that is put into IGROUP automaticly
  569. _16ICODE SEGMENT WORD USE16 PUBLIC '16ICODE'
  570. _16ICODE ENDS
  571. ;* Real Mode initialization code/data for devices
  572. _RCODE SEGMENT WORD USE16 PUBLIC 'RCODE'
  573. _RCODE ENDS
  574. IFNDEF BLD_COFF
  575. _LGROUP GROUP _LTEXT, _TEXT, _LDATA, _DATA, _BSS, CONST, _TLS
  576. _IGROUP GROUP _ITEXT, _IDATA
  577. _SGROUP GROUP _STEXT, _SDATA
  578. _DBOGROUP GROUP _DB0START, _DB1CODE, _DB2DATA
  579. IF DEBLEVEL
  580. _PGROUP GROUP _PATHSTART, _PATHDATA, _PATHEND
  581. ENDIF
  582. ENDIF
  583. endif ; NO_SEGMENTS
  584. ASSUME CS:FLAT, DS:FLAT, ES:FLAT, SS:FLAT
  585. OFFSET32 EQU <OFFSET FLAT:>
  586. BeginDoc
  587. ;==============================================================================
  588. ; The following macros are used in defining the routines
  589. ; in a VxD which are going to be registered with VMM as callable entry
  590. ; points. Once registered, the entry points can be called by any other
  591. ; devices via the "VxDCall" macro, defined below. In the comments below,
  592. ; replace "VxD" with the appropriate device name.
  593. ;
  594. ;*******
  595. ; In the VxD.INC file, put the following lines, replacing <function_name>
  596. ; with an appropriate name describing the function of the routine.
  597. ;
  598. ; Begin_Service_Table VxD[,<segname>]
  599. ; VxD_Service <function_name>[,<local segname>]
  600. ; VxD_Service <function_name>[,<local segname>]
  601. ; . . .
  602. ; VxD_Service <function_name>[,<local segname>]
  603. ; End_Service_Table VxD[,<segname>]
  604. ;
  605. ; Note that <segname> is an optional argument and, if specified, the
  606. ; table is put in the segment defined by the macro "yyy_Data_Seg",
  607. ; where yyy=segname. Otherwise the segment is defined by the
  608. ; "VxD_Data_Seg" macro, defined below.
  609. ; Note that <local segname> is an optional argument and, if specified,
  610. ; the procedure's segment is defined by the macro "zzz_Code_Seg",
  611. ; where zzz=segname. Otherwise the segment is defined by the
  612. ; "VxD_Code_Seg" macro, defined below.
  613. ;
  614. ;*******
  615. ; One VxD module should have the following in order to define the entry points:
  616. ;Create_VxD_Service_Table = 1 ; Only in module where table is
  617. ; INCLUDE VxD.INC ; Include the table definition
  618. ;
  619. ;*******
  620. ; All modules that want to call the services defined in the table should include
  621. ; VxD.INC, but not define the label "Create_VxD_Service_Table". This
  622. ; will define the service names to be used with the VxDCall macro.
  623. ;
  624. EndDoc
  625. Begin_Service_Table MACRO Device_Name, Def_Segment
  626. IFDEF Device_Name&_Name_Based
  627. IFNDEF @@NextInternalID
  628. @@NextInternalID = 0
  629. ENDIF
  630. @@NextInternalID = (@@NextInternalID + 1)
  631. Device_Name&_Internal_ID = @@NextInternalID + BASEID_FOR_NAMEBASEDVXD
  632. DefineVxDName Device_Name, %Device_Name&_Internal_ID
  633. ENDIF
  634. IFB <Def_Segment>
  635. BST2 Device_Name, VxD
  636. ELSE
  637. BST2 Device_Name, Def_Segment
  638. ENDIF
  639. ENDM
  640. DefineVxDName MACRO Device_Name, InternalID
  641. @@VxDName&InternalID EQU <___&Device_Name&STable>
  642. ENDM
  643. BST2 MACRO Device_Name, Def_Segment
  644. Num_&Device_Name&_Services = 0
  645. IFDEF Create_&Device_Name&_Service_Table
  646. Def_Segment&_LOCKED_DATA_SEG
  647. Device_Name&_Service_Table LABEL DWORD
  648. Device_Name&_Service MACRO Procedure, Local_Seg, Condition, StdCallBytes, fastcall
  649. LOCAL $$&Procedure, extrnproc, tableproc
  650. extrnproc MACRO
  651. IFNB <fastcall>
  652. IFB <StdCallBytes>
  653. .err ;StdCallBytes required
  654. ENDIF
  655. EXTRN @&&Procedure&&@&&StdCallBytes:NEAR
  656. ELSE
  657. IFNB <StdCallBytes>
  658. EXTRN _&&Procedure&&@&&StdCallBytes:NEAR
  659. ELSE
  660. EXTRN Procedure:NEAR
  661. ENDIF
  662. ENDIF
  663. ENDM
  664. tableproc MACRO
  665. IFNB <fastcall>
  666. dd OFFSET32 @&&Procedure&&@&&StdCallBytes
  667. ELSE
  668. IFNB <StdCallBytes>
  669. dd OFFSET32 _&&Procedure&&@&&StdCallBytes
  670. ELSE
  671. dd OFFSET32 Procedure
  672. ENDIF
  673. ENDIF
  674. ENDM
  675. IFNB <Condition>
  676. $$&&Procedure MACRO extern
  677. IFDEF &Condition
  678. IFNB <extern>
  679. extrnproc
  680. ELSE
  681. tableproc
  682. ENDIF
  683. ELSE
  684. IFB <extern>
  685. dd 0
  686. ENDIF
  687. ENDIF
  688. ENDM
  689. ENDIF
  690. IFDIFI <Procedure>, <RESERVED>
  691. PUBLIC _&&Procedure
  692. IF1
  693. _&&Procedure LABEL DWORD
  694. IFNB <fastcall>
  695. PUBLIC __&&Procedure
  696. __&&Procedure LABEL DWORD
  697. ENDIF
  698. ENDIF
  699. IFDIFI <Local_Seg>, <LOCAL>
  700. IFNB <Local_Seg>
  701. Local_Seg&&_SEG
  702. ELSE
  703. Def_Segment&_CODE_SEG
  704. ENDIF
  705. IFNB <Condition>
  706. $$&&Procedure extern
  707. ELSE
  708. extrnproc
  709. ENDIF
  710. IFNB <Local_Seg>
  711. Local_Seg&&_ENDS
  712. ELSE
  713. Def_Segment&_CODE_ENDS
  714. ENDIF
  715. ENDIF
  716. IFNB <Condition>
  717. $$&&Procedure
  718. ELSE
  719. tableproc
  720. ENDIF
  721. IFDEF Device_Name&_Name_Based
  722. @@&&Procedure = (Device_Name&_Internal_ID SHL 16) + Num_&Device_Name&_Services
  723. ELSE
  724. @@&&Procedure = (Device_Name&_Device_ID SHL 16) + Num_&Device_Name&_Services
  725. ENDIF
  726. ELSE
  727. dd 0
  728. ENDIF
  729. Num_&Device_Name&_Services = Num_&Device_Name&_Services + 1
  730. IFNB <Condition>
  731. Purge $$&&Procedure
  732. ENDIF
  733. Purge extrnproc
  734. Purge tableproc
  735. ENDM
  736. Device_Name&_StdCall_Service MACRO Procedure, Args, Local_Seg, Condition
  737. Device_Name&_Service Procedure, Local_Seg, Condition, %Args*4
  738. ??_standardccall&&_Procedure = Args
  739. ENDM
  740. Device_Name&_FastCall_Service MACRO Procedure, Args, Local_Seg, Condition
  741. Device_Name&_Service Procedure, Local_Seg, Condition, %Args*4, TRUE
  742. ??_fastcall&&_Procedure = Args
  743. ENDM
  744. ELSE
  745. ; Local_Seg and Condition are placeholders only in this form
  746. IFDEF Device_Name&_Name_Based
  747. Device_Name&_Service MACRO Procedure, Local_Seg, Condition
  748. IFDIFI <Procedure>, <RESERVED>
  749. @@&&Procedure = (Device_Name&_Internal_ID SHL 16) + Num_&Device_Name&_Services
  750. ENDIF
  751. Num_&Device_Name&_Services = Num_&Device_Name&_Services + 1
  752. ENDM
  753. ELSE
  754. Device_Name&_Service MACRO Procedure, Local_Seg, Condition
  755. IFDIFI <Procedure>, <RESERVED>
  756. @@&&Procedure = (Device_Name&_Device_ID SHL 16) + Num_&Device_Name&_Services
  757. ENDIF
  758. Num_&Device_Name&_Services = Num_&Device_Name&_Services + 1
  759. ENDM
  760. ENDIF
  761. Device_Name&_StdCall_Service MACRO Procedure, Args, Local_Seg, Condition
  762. Device_Name&_Service Procedure, Local_Seg, Condition
  763. ??_standardccall_&&Procedure = Args
  764. ENDM
  765. Device_Name&_FastCall_Service MACRO Procedure, Args, Local_Seg, Condition
  766. Device_Name&_Service Procedure, Local_Seg, Condition
  767. ??_fastcall_&&Procedure = Args
  768. ENDM
  769. ENDIF
  770. ENDM
  771. ;------------------------------------------------------------------------------
  772. End_Service_Table MACRO Device_Name, Def_Segment
  773. PURGE Device_Name&_Service
  774. IFDEF Create_&Device_Name&_Service_Table
  775. IFB <Def_Segment>
  776. VxD_LOCKED_DATA_ENDS
  777. ELSE
  778. Def_Segment&_LOCKED_DATA_ENDS
  779. ENDIF
  780. ENDIF
  781. ENDM
  782. GetVxDServiceOrdinal macro reg,service
  783. mov reg,@@&service
  784. endm
  785. GetVxDServiceAddress macro reg,service
  786. mov reg,OFFSET32 service
  787. endm
  788. ;*** Begin_Win32_Services - begin defining Win32 Service Table
  789. ;
  790. ; This macro is used to begin the definition of the Win32
  791. ; Service table. It is modelled after, but not identical
  792. ; to, the Begin_Service_Table macro. If the the special
  793. ; symbol Create_Win32_Services is defined to be true, then
  794. ; the actual table is emitted. Otherwise, only the service
  795. ; numbers are defined.
  796. ;
  797. ; ENTRY VxDName - the name of the VxD; it is assumed
  798. ; that a corresponding Device_ID is
  799. ; also defined.
  800. ; EXIT The macro VxDName&_Win32_Sevice is defined; it
  801. ; accepts a service name as its only parameter.
  802. ; This macro is then used to define each service.
  803. Begin_Win32_Services MACRO VxDName
  804. ifndef Create_Win32_Services
  805. Create_Win32_Services = 0
  806. endif
  807. .errb <VxDName>, <VxD name missing>
  808. ??w32svcno = 0
  809. if Create_Win32_Services
  810. VxDName&_Win32_Services label dword
  811. dd csvc&VxDName, 0
  812. endif
  813. ??inw32svc = 1
  814. VxDName&_Win32_Service MACRO Name
  815. .erre ??inw32svc, <Missing Begin_Win32_Services>
  816. if Create_Win32_Services
  817. dd OFFSET32 Name,cparm&&Name
  818. endif
  819. @32&&Name equ ((VxDName&_Device_ID SHL 16) + ??w32svcno)
  820. ??w32svcno = ??w32svcno + 1
  821. ENDM
  822. ENDM
  823. ;*** End_Win32_Services - mark end of Win32 Service Table
  824. ;
  825. ; This macro completes initialization of the Win32
  826. ; Service table.
  827. ;
  828. ; ENTRY VxDName - the same name passed to
  829. ; Begin_Win32_services
  830. End_Win32_Services MACRO VxDName
  831. .errb <VxDName>, <VxD name misssing>
  832. if Create_Win32_Services
  833. csvc&VxDName equ ($ - VxDName&_Win32_Services)/8 - 1
  834. endif
  835. ??inw32svc = 0
  836. PURGE VxDName&_Win32_Service
  837. ENDM
  838. ;*** Declare_Win32_Service - declare an external Win32 Service
  839. ;
  840. ; This macro is used to declare a Win32 service that
  841. ; is defined elsewhere, perhaps in a C module.
  842. ;
  843. ; ENTRY Name - the service name
  844. ; cParms - the number of DWORD parameters
  845. ; EXIT The name is defined as external
  846. Declare_Win32_Service MACRO Name, cParms
  847. ifndef Create_Win32_Services
  848. Create_Win32_Services = 0
  849. endif
  850. if Create_Win32_Services
  851. ?merge <Name>,,,,<EQU>,<_>,<Name>,<@>,%(cParms*4 + 8)
  852. ?merge <cparm>,<Name>,,,<EQU>,<cParms>
  853. VxD_CODE_SEG
  854. ?merge <EXTRN>,,,,,<_>,<Name>,<@>,%(cParms*4 + 8),<:NEAR>
  855. VxD_CODE_ENDS
  856. endif
  857. ENDM
  858. ;*** Win32call - call a Win32 service from a ring 3 thunk
  859. ;
  860. ; This macro is used to call a Win32 service from
  861. ; a ring 3 thunk. Note that control will not return
  862. ; to the instruction following the call, but to the
  863. ; instruction following the call to the thunk.
  864. ;
  865. ; ENTRY Service - the name of the service
  866. ; CallBack - the fword containing the callback
  867. Win32call MACRO Service, CallBack
  868. ifndef Create_Win32_Services
  869. Create_Win32_Services = 0
  870. endif
  871. ife Create_Win32_Services
  872. mov eax,@32&Service
  873. ifdef IS_16
  874. movzx esp,sp
  875. endif
  876. call fword ptr [CallBack]
  877. ifdef DEBUG
  878. int 3
  879. endif
  880. endif
  881. ENDM
  882. */
  883. /*XLATOFF*/
  884. #define GetVxDServiceAddress(service) service
  885. #define VxDCall(service) \
  886. _asm _emit 0xcd \
  887. _asm _emit 0x20 \
  888. _asm _emit (GetVxDServiceOrdinal(service) & 0xff) \
  889. _asm _emit (GetVxDServiceOrdinal(service) >> 8) & 0xff \
  890. _asm _emit (GetVxDServiceOrdinal(service) >> 16) & 0xff \
  891. _asm _emit (GetVxDServiceOrdinal(service) >> 24) & 0xff \
  892. #define VMMCall VxDCall
  893. #define VxDJmp(service) \
  894. _asm _emit 0xcd \
  895. _asm _emit 0x20 \
  896. _asm _emit (GetVxDServiceOrdinal(service) & 0xff) \
  897. _asm _emit ((GetVxDServiceOrdinal(service) >> 8) & 0xff) | 0x80 \
  898. _asm _emit (GetVxDServiceOrdinal(service) >> 16) & 0xff \
  899. _asm _emit (GetVxDServiceOrdinal(service) >> 24) & 0xff \
  900. #define VMMJmp VxDJmp
  901. #define SERVICE __cdecl
  902. #define ASYNC_SERVICE __cdecl
  903. #define WIN32_SERVICE void __stdcall
  904. #ifndef FASTCALL
  905. #define FASTCALL __fastcall
  906. #endif
  907. /*XLATON*/
  908. /* ASM
  909. ;******************************************************************************
  910. ;
  911. ; Dword_Align -- Aligns code to dword boundry by inserting nops
  912. ;
  913. ;------------------------------------------------------------------------------
  914. Dword_Align MACRO Seg_Name
  915. LOCAL segn
  916. IFDEF MASM6
  917. align 4
  918. ELSE
  919. IFNB <Seg_Name>
  920. segn equ Seg_Name
  921. ELSE
  922. IFE ?_LCODE
  923. segn equ <_LTEXT>
  924. ELSE
  925. IFE ?_ICODE
  926. segn equ <_ITEXT>
  927. ELSE
  928. IFE ?_PCODE
  929. segn equ <_PTEXT>
  930. ELSE
  931. IFE ?_SCODE
  932. segn equ <_STEXT>
  933. ELSE
  934. .err <Dword_Align not supported>
  935. ENDIF
  936. ENDIF
  937. ENDIF
  938. ENDIF
  939. ENDIF
  940. IF (($-OFFSET segn:0) MOD 4)
  941. db 4 - (($-OFFSET segn:0) MOD 4) DUP (90h)
  942. ENDIF
  943. ENDIF
  944. ENDM
  945. BeginDoc
  946. ;******************************************************************************
  947. ;
  948. ; Fatal_Error
  949. ;
  950. ; DESCRIPTION:
  951. ; This macro is used to crash Windows/386 when an unrecoverable error
  952. ; is detected. If Msg_Ptr is ommitted then no error message will be
  953. ; displayed, otherwise Msg_Ptr is the address
  954. ; when the
  955. ;
  956. ; PARAMETERS:
  957. ; Msg_Ptr (OPTIONAL) - Points to an ASCIIZ string to display.
  958. ;
  959. ; EXIT:
  960. ; To DOS (hopefully). This macro never returns.
  961. ;
  962. ;==============================================================================
  963. EndDoc
  964. Fatal_Error MACRO Msg_Ptr, Exit_Flags
  965. pushad
  966. IFB <Msg_Ptr>
  967. xor esi, esi
  968. ELSE
  969. mov esi, Msg_Ptr
  970. IFB <Exit_Flags>
  971. xor eax, eax
  972. ELSE
  973. mov eax, Exit_Flags
  974. ENDIF
  975. ENDIF
  976. VMMCall Fatal_Error_Handler
  977. ENDM
  978. EF_Hang_On_Exit EQU 1h
  979. */
  980. /******************************************************************************
  981. *
  982. * The following are control block headers and flags of interest to VxDs.
  983. *
  984. *****************************************************************************/
  985. struct cb_s {
  986. ULONG CB_VM_Status; /* VM status flags */
  987. ULONG CB_High_Linear; /* Address of VM mapped high */
  988. ULONG CB_Client_Pointer;
  989. ULONG CB_VMID;
  990. ULONG CB_Signature;
  991. };
  992. #define VMCB_ID 0x62634D56 /* VMcb */
  993. /*
  994. * VM status indicates globally interesting VM states
  995. */
  996. #define VMSTAT_EXCLUSIVE_BIT 0x00 /* VM is exclusive mode */
  997. #define VMSTAT_EXCLUSIVE (1L << VMSTAT_EXCLUSIVE_BIT)
  998. #define VMSTAT_BACKGROUND_BIT 0x01 /* VM runs in background */
  999. #define VMSTAT_BACKGROUND (1L << VMSTAT_BACKGROUND_BIT)
  1000. #define VMSTAT_CREATING_BIT 0x02 /* In process of creating */
  1001. #define VMSTAT_CREATING (1L << VMSTAT_CREATING_BIT)
  1002. #define VMSTAT_SUSPENDED_BIT 0x03 /* VM not scheduled */
  1003. #define VMSTAT_SUSPENDED (1L << VMSTAT_SUSPENDED_BIT)
  1004. #define VMSTAT_NOT_EXECUTEABLE_BIT 0x04 /* VM partially destroyed */
  1005. #define VMSTAT_NOT_EXECUTEABLE (1L << VMSTAT_NOT_EXECUTEABLE_BIT)
  1006. #define VMSTAT_PM_EXEC_BIT 0x05 /* Currently in PM app */
  1007. #define VMSTAT_PM_EXEC (1L << VMSTAT_PM_EXEC_BIT)
  1008. #define VMSTAT_PM_APP_BIT 0x06 /* PM app present in VM */
  1009. #define VMSTAT_PM_APP (1L << VMSTAT_PM_APP_BIT)
  1010. #define VMSTAT_PM_USE32_BIT 0x07 /* PM app is 32-bit */
  1011. #define VMSTAT_PM_USE32 (1L << VMSTAT_PM_USE32_BIT)
  1012. #define VMSTAT_VXD_EXEC_BIT 0x08 /* Call from VxD */
  1013. #define VMSTAT_VXD_EXEC (1L << VMSTAT_VXD_EXEC_BIT)
  1014. #define VMSTAT_HIGH_PRI_BACK_BIT 0x09 /* High pri background */
  1015. #define VMSTAT_HIGH_PRI_BACK (1L << VMSTAT_HIGH_PRI_BACK_BIT)
  1016. #define VMSTAT_BLOCKED_BIT 0x0A /* Blocked on semaphore */
  1017. #define VMSTAT_BLOCKED (1L << VMSTAT_BLOCKED_BIT)
  1018. #define VMSTAT_AWAKENING_BIT 0x0B /* Woke up after blocked */
  1019. #define VMSTAT_AWAKENING (1L << VMSTAT_AWAKENING_BIT)
  1020. #define VMSTAT_PAGEABLEV86BIT 0x0C /* part of V86 is pageable (PM app) */
  1021. #define VMSTAT_PAGEABLEV86_BIT VMSTAT_PAGEABLEV86BIT
  1022. #define VMSTAT_PAGEABLEV86 (1L << VMSTAT_PAGEABLEV86BIT)
  1023. #define VMSTAT_V86INTSLOCKEDBIT 0x0D /* Locked regardless of pager type */
  1024. #define VMSTAT_V86INTSLOCKED_BIT VMSTAT_V86INTSLOCKEDBIT
  1025. #define VMSTAT_V86INTSLOCKED (1L << VMSTAT_V86INTSLOCKEDBIT)
  1026. #define VMSTAT_IDLE_TIMEOUT_BIT 0x0E /* Scheduled by time-slicer */
  1027. #define VMSTAT_IDLE_TIMEOUT (1L << VMSTAT_IDLE_TIMEOUT_BIT)
  1028. #define VMSTAT_IDLE_BIT 0x0F /* VM has released time slice */
  1029. #define VMSTAT_IDLE (1L << VMSTAT_IDLE_BIT)
  1030. #define VMSTAT_CLOSING_BIT 0x10 /* Close_VM called for VM */
  1031. #define VMSTAT_CLOSING (1L << VMSTAT_CLOSING_BIT)
  1032. #define VMSTAT_TS_SUSPENDED_BIT 0x11 /* VM suspended by */
  1033. #define VMSTAT_TS_SUSPENDED (1L << VMSTAT_TS_SUSPENDED_BIT)
  1034. #define VMSTAT_TS_MAXPRI_BIT 0x12 /* this is fgd_pri 10,000 internally*/
  1035. #define VMSTAT_TS_MAXPRI (1L << VMSTAT_TS_MAXPRI_BIT)
  1036. #define VMSTAT_USE32_MASK (VMSTAT_PM_USE32 | VMSTAT_VXD_EXEC)
  1037. struct tcb_s {
  1038. ULONG TCB_Flags; /* Thread status flags */
  1039. ULONG TCB_Reserved1; /* Used internally by VMM */
  1040. ULONG TCB_Reserved2; /* Used internally by VMM */
  1041. ULONG TCB_Signature;
  1042. ULONG TCB_ClientPtr; /* Client registers of thread */
  1043. ULONG TCB_VMHandle; /* VM that thread is part of */
  1044. USHORT TCB_ThreadId; /* Unique Thread ID */
  1045. USHORT TCB_PMLockOrigSS; /* Original SS:ESP before lock stack */
  1046. ULONG TCB_PMLockOrigESP;
  1047. ULONG TCB_PMLockOrigEIP; /* Original CS:EIP before lock stack */
  1048. ULONG TCB_PMLockStackCount;
  1049. USHORT TCB_PMLockOrigCS;
  1050. USHORT TCB_PMPSPSelector;
  1051. ULONG TCB_ThreadType; /* dword passed to VMMCreateThread */
  1052. USHORT TCB_pad1; /* reusable; for dword align */
  1053. UCHAR TCB_pad2; /* reusable; for dword align */
  1054. UCHAR TCB_extErrLocus; /* extended error Locus */
  1055. USHORT TCB_extErr; /* extended error Code */
  1056. UCHAR TCB_extErrAction; /* " " Action */
  1057. UCHAR TCB_extErrClass; /* " " Class */
  1058. ULONG TCB_extErrPtr; /* " pointer */
  1059. };
  1060. typedef struct tcb_s TCB;
  1061. typedef TCB *PTCB;
  1062. #define SCHED_OBJ_ID_THREAD 0x42434854 // THCB in ASCII
  1063. /*
  1064. * Thread status indicates globally interesting thread states.
  1065. * Flags are for information only and must not be modified.
  1066. */
  1067. #define THFLAG_SUSPENDED_BIT 0x03 // Thread not scheduled
  1068. #define THFLAG_SUSPENDED (1L << THFLAG_SUSPENDED_BIT)
  1069. #define THFLAG_NOT_EXECUTEABLE_BIT 0x04 // Thread partially destroyed
  1070. #define THFLAG_NOT_EXECUTEABLE (1L << THFLAG_NOT_EXECUTEABLE_BIT)
  1071. #define THFLAG_THREAD_CREATION_BIT 0x08 // Thread in status nascendi
  1072. #define THFLAG_THREAD_CREATION (1L << THFLAG_THREAD_CREATION_BIT)
  1073. #define THFLAG_THREAD_BLOCKED_BIT 0x0A // Blocked on semaphore
  1074. #define THFLAG_THREAD_BLOCKED (1L << THFLAG_THREAD_BLOCKED_BIT)
  1075. #define THFLAG_RING0_THREAD_BIT 0x1C // thread runs only at ring 0
  1076. #define THFLAG_RING0_THREAD (1L << THFLAG_RING0_THREAD_BIT)
  1077. #define THFLAG_ASYNC_THREAD_BIT 0x1F // thread is asynchronous
  1078. #define THFLAG_ASYNC_THREAD (1L << THFLAG_ASYNC_THREAD_BIT)
  1079. #define THFLAG_CHARSET_BITS 0x10 // Default character set
  1080. #define THFLAG_CHARSET_MASK (3L << THFLAG_CHARSET_BITS)
  1081. #define THFLAG_ANSI (0L << THFLAG_CHARSET_BITS)
  1082. #define THFLAG_OEM (1L << THFLAG_CHARSET_BITS)
  1083. #define THFLAG_UNICODE (2L << THFLAG_CHARSET_BITS)
  1084. #define THFLAG_RESERVED (3L << THFLAG_CHARSET_BITS)
  1085. #define THFLAG_EXTENDED_HANDLES_BIT 0x12 // Thread uses extended file handles
  1086. #define THFLAG_EXTENDED_HANDLES (1L << THFLAG_EXTENDED_HANDLES_BIT)
  1087. /* the win32 loader opens win32 exes with this bit set to notify IFS
  1088. * so a defragger won't move these files
  1089. * the bit is turned off once the open completes.
  1090. * file open flags are overloaded which is why this is here
  1091. */
  1092. #define THFLAG_OPEN_AS_IMMOVABLE_FILE_BIT 0x13 // File thus opened not moved
  1093. #define THFLAG_OPEN_AS_IMMOVABLE_FILE (1L << THFLAG_OPEN_AS_IMMOVABLE_FILE_BIT)
  1094. /*
  1095. * Protected mode application control blocks
  1096. */
  1097. struct pmcb_s {
  1098. ULONG PMCB_Flags;
  1099. ULONG PMCB_Parent;
  1100. };
  1101. /*
  1102. * The reference data for fault error codes 1-5 (GSDVME_PRIVINST through
  1103. * GSDVME_INVALFLT) is a pointer to the following fault information structure.
  1104. */
  1105. struct VMFaultInfo {
  1106. ULONG VMFI_EIP; // faulting EIP
  1107. WORD VMFI_CS; // faulting CS
  1108. WORD VMFI_Ints; // interrupts in service, if any
  1109. };
  1110. typedef struct VMFaultInfo *PVMFaultInfo;
  1111. /******************************************************************************
  1112. * V M M S E R V I C E S
  1113. ******************************************************************************/
  1114. /*XLATOFF*/
  1115. #define VMM_Service Declare_Service
  1116. #define VMM_StdCall_Service Declare_SCService
  1117. #define VMM_FastCall_Service Declare_SCService
  1118. #pragma warning (disable:4003) // turn off not enough params warning
  1119. /*XLATON*/
  1120. /*MACROS*/
  1121. Begin_Service_Table(VMM, VMM)
  1122. VMM_Service (Get_VMM_Version, LOCAL) // MUST REMAIN SERVICE 0!
  1123. VMM_Service (Get_Cur_VM_Handle)
  1124. VMM_Service (Test_Cur_VM_Handle)
  1125. VMM_Service (Get_Sys_VM_Handle)
  1126. VMM_Service (Test_Sys_VM_Handle)
  1127. VMM_Service (Validate_VM_Handle)
  1128. VMM_Service (Get_VMM_Reenter_Count)
  1129. VMM_Service (Begin_Reentrant_Execution)
  1130. VMM_Service (End_Reentrant_Execution)
  1131. VMM_Service (Install_V86_Break_Point)
  1132. VMM_Service (Remove_V86_Break_Point)
  1133. VMM_Service (Allocate_V86_Call_Back)
  1134. VMM_Service (Allocate_PM_Call_Back)
  1135. VMM_Service (Call_When_VM_Returns)
  1136. VMM_Service (Schedule_Global_Event)
  1137. VMM_Service (Schedule_VM_Event)
  1138. VMM_Service (Call_Global_Event)
  1139. VMM_Service (Call_VM_Event)
  1140. VMM_Service (Cancel_Global_Event)
  1141. VMM_Service (Cancel_VM_Event)
  1142. VMM_Service (Call_Priority_VM_Event)
  1143. VMM_Service (Cancel_Priority_VM_Event)
  1144. VMM_Service (Get_NMI_Handler_Addr)
  1145. VMM_Service (Set_NMI_Handler_Addr)
  1146. VMM_Service (Hook_NMI_Event)
  1147. VMM_Service (Call_When_VM_Ints_Enabled)
  1148. VMM_Service (Enable_VM_Ints)
  1149. VMM_Service (Disable_VM_Ints)
  1150. VMM_Service (Map_Flat)
  1151. VMM_Service (Map_Lin_To_VM_Addr)
  1152. // Scheduler services
  1153. VMM_Service (Adjust_Exec_Priority)
  1154. VMM_Service (Begin_Critical_Section)
  1155. VMM_Service (End_Critical_Section)
  1156. VMM_Service (End_Crit_And_Suspend)
  1157. VMM_Service (Claim_Critical_Section)
  1158. VMM_Service (Release_Critical_Section)
  1159. VMM_Service (Call_When_Not_Critical)
  1160. VMM_Service (Create_Semaphore)
  1161. VMM_Service (Destroy_Semaphore)
  1162. VMM_Service (Wait_Semaphore)
  1163. VMM_Service (Signal_Semaphore)
  1164. VMM_Service (Get_Crit_Section_Status)
  1165. VMM_Service (Call_When_Task_Switched)
  1166. VMM_Service (Suspend_VM)
  1167. VMM_Service (Resume_VM)
  1168. VMM_Service (No_Fail_Resume_VM)
  1169. VMM_Service (Nuke_VM)
  1170. VMM_Service (Crash_Cur_VM)
  1171. VMM_Service (Get_Execution_Focus)
  1172. VMM_Service (Set_Execution_Focus)
  1173. VMM_Service (Get_Time_Slice_Priority)
  1174. VMM_Service (Set_Time_Slice_Priority)
  1175. VMM_Service (Get_Time_Slice_Granularity)
  1176. VMM_Service (Set_Time_Slice_Granularity)
  1177. VMM_Service (Get_Time_Slice_Info)
  1178. VMM_Service (Adjust_Execution_Time)
  1179. VMM_Service (Release_Time_Slice)
  1180. VMM_Service (Wake_Up_VM)
  1181. VMM_Service (Call_When_Idle)
  1182. VMM_Service (Get_Next_VM_Handle)
  1183. // Time-out and system timer services
  1184. VMM_Service (Set_Global_Time_Out)
  1185. VMM_Service (Set_VM_Time_Out)
  1186. VMM_Service (Cancel_Time_Out)
  1187. VMM_Service (Get_System_Time)
  1188. VMM_Service (Get_VM_Exec_Time)
  1189. VMM_Service (Hook_V86_Int_Chain)
  1190. VMM_Service (Get_V86_Int_Vector)
  1191. VMM_Service (Set_V86_Int_Vector)
  1192. VMM_Service (Get_PM_Int_Vector)
  1193. VMM_Service (Set_PM_Int_Vector)
  1194. VMM_Service (Simulate_Int)
  1195. VMM_Service (Simulate_Iret)
  1196. VMM_Service (Simulate_Far_Call)
  1197. VMM_Service (Simulate_Far_Jmp)
  1198. VMM_Service (Simulate_Far_Ret)
  1199. VMM_Service (Simulate_Far_Ret_N)
  1200. VMM_Service (Build_Int_Stack_Frame)
  1201. VMM_Service (Simulate_Push)
  1202. VMM_Service (Simulate_Pop)
  1203. // Heap Manager
  1204. VMM_Service (_HeapAllocate)
  1205. VMM_Service (_HeapReAllocate)
  1206. VMM_Service (_HeapFree)
  1207. VMM_Service (_HeapGetSize)
  1208. /*ENDMACROS*/
  1209. /****************************************************
  1210. *
  1211. * Flags for heap allocator calls
  1212. *
  1213. * NOTE: HIGH 8 BITS (bits 24-31) are reserved
  1214. *
  1215. ***************************************************/
  1216. //
  1217. // Flags affecting the returned block
  1218. //
  1219. #define HEAPZEROINIT 0x00000001
  1220. #define HEAPZEROREINIT 0x00000002
  1221. #define HEAPNOCOPY 0x00000004
  1222. //
  1223. // Alignment flags
  1224. //
  1225. #define HEAPALIGN_SHIFT 16
  1226. #define HEAPALIGN_MASK 0x000F0000
  1227. #define HEAPALIGN_4 0x00000000 // dword aligned
  1228. #define HEAPALIGN_8 0x00000000 // quadword aligned
  1229. #define HEAPALIGN_16 0x00000000 // paragraph aligned
  1230. #define HEAPALIGN_32 0x00010000 // etc.
  1231. #define HEAPALIGN_64 0x00020000
  1232. #define HEAPALIGN_128 0x00030000
  1233. #define HEAPALIGN_256 0x00040000
  1234. #define HEAPALIGN_512 0x00050000
  1235. #define HEAPALIGN_1K 0x00060000
  1236. #define HEAPALIGN_2K 0x00070000
  1237. #define HEAPALIGN_4K 0x00080000
  1238. #define HEAPALIGN_8K 0x00090000
  1239. #define HEAPALIGN_16K 0x000A0000
  1240. #define HEAPALIGN_32K 0x000B0000
  1241. #define HEAPALIGN_64K 0x000C0000
  1242. #define HEAPALIGN_128K 0x000D0000
  1243. //
  1244. // Flags indicating which system heap to use. There are four bits reserved
  1245. // to identify the heap to use. Four are currently defined by the system.
  1246. //
  1247. #define HEAPTYPESHIFT 8
  1248. #define HEAPTYPEMASK 0x00000700
  1249. #define HEAPLOCKEDHIGH 0x00000000
  1250. #define HEAPLOCKEDIFDP 0x00000100
  1251. #define HEAPSWAP 0x00000200
  1252. #define HEAPINIT 0x00000400 // will be automatically freed after
  1253. // init complete
  1254. //
  1255. // other flags
  1256. //
  1257. #define HEAPCLEAN 0x00000800
  1258. #define HEAPCONTIG 0x00001000 // memory must be physically contiguous
  1259. #define HEAPFORGET 0x00002000 // this memory will never be freed
  1260. //
  1261. // Combinations of flags understood by HeapAllocateEx
  1262. //
  1263. #define HEAPLOCKEDLOW 0x00000300
  1264. #define HEAPSYSVM 0x00000500
  1265. #define HEAPPREEMPT 0x00000600 // code in this heap is preemptable
  1266. // Page Manager
  1267. /*MACROS*/
  1268. VMM_Service (_PageAllocate)
  1269. VMM_Service (_PageReAllocate)
  1270. VMM_Service (_PageFree)
  1271. VMM_Service (_PageLock)
  1272. VMM_Service (_PageUnLock)
  1273. VMM_Service (_PageGetSizeAddr)
  1274. VMM_Service (_PageGetAllocInfo)
  1275. VMM_Service (_GetFreePageCount)
  1276. VMM_Service (_GetSysPageCount)
  1277. VMM_Service (_GetVMPgCount)
  1278. VMM_Service (_MapIntoV86)
  1279. VMM_Service (_PhysIntoV86)
  1280. VMM_Service (_TestGlobalV86Mem)
  1281. VMM_Service (_ModifyPageBits)
  1282. VMM_Service (_CopyPageTable)
  1283. VMM_Service (_LinMapIntoV86)
  1284. VMM_Service (_LinPageLock)
  1285. VMM_Service (_LinPageUnLock)
  1286. VMM_Service (_SetResetV86Pageable)
  1287. VMM_Service (_GetV86PageableArray)
  1288. VMM_Service (_PageCheckLinRange)
  1289. VMM_Service (_PageOutDirtyPages)
  1290. VMM_Service (_PageDiscardPages)
  1291. /*ENDMACROS*/
  1292. /****************************************************
  1293. *
  1294. * Flags for other page allocator calls
  1295. *
  1296. * NOTE: HIGH 8 BITS (bits 24-31) are reserved
  1297. *
  1298. ***************************************************/
  1299. #define PAGEZEROINIT 0x00000001
  1300. #define PAGEUSEALIGN 0x00000002
  1301. #define PAGECONTIG 0x00000004
  1302. #define PAGEFIXED 0x00000008
  1303. #define PAGEDEBUGNULFAULT 0x00000010
  1304. #define PAGEZEROREINIT 0x00000020
  1305. #define PAGENOCOPY 0x00000040
  1306. #define PAGELOCKED 0x00000080
  1307. #define PAGELOCKEDIFDP 0x00000100
  1308. #define PAGESETV86PAGEABLE 0x00000200
  1309. #define PAGECLEARV86PAGEABLE 0x00000400
  1310. #define PAGESETV86INTSLOCKED 0x00000800
  1311. #define PAGECLEARV86INTSLOCKED 0x00001000
  1312. #define PAGEMARKPAGEOUT 0x00002000
  1313. #define PAGEPDPSETBASE 0x00004000
  1314. #define PAGEPDPCLEARBASE 0x00008000
  1315. #define PAGEDISCARD 0x00010000
  1316. #define PAGEPDPQUERYDIRTY 0x00020000
  1317. #define PAGEMAPFREEPHYSREG 0x00040000
  1318. #define PAGEPHYSONLY 0x04000000
  1319. //efine PAGEDONTUSE 0x08000000 // ;Internal
  1320. #define PAGENOMOVE 0x10000000
  1321. #define PAGEMAPGLOBAL 0x40000000
  1322. #define PAGEMARKDIRTY 0x80000000
  1323. /****************************************************
  1324. *
  1325. * Flags for _PhysIntoV86,
  1326. * _MapIntoV86, and _LinMapIntoV86
  1327. *
  1328. ***************************************************/
  1329. #define MAPV86_IGNOREWRAP 0x00000001
  1330. /****************************************************
  1331. *
  1332. * Flags for MapPhysToLinear
  1333. *
  1334. *
  1335. ***************************************************/
  1336. #define MPL_NonCached 0x00000000
  1337. #define MPL_HardwareCoherentCached 0x00000001
  1338. #define MPL_FrameBufferCached 0x00000002
  1339. #define MPL_Cached 0x00000004
  1340. // Informational services
  1341. /*MACROS*/
  1342. VMM_Service (_GetNulPageHandle)
  1343. VMM_Service (_GetFirstV86Page)
  1344. VMM_Service (_MapPhysToLinear)
  1345. VMM_Service (_GetAppFlatDSAlias)
  1346. VMM_Service (_SelectorMapFlat)
  1347. VMM_Service (_GetDemandPageInfo)
  1348. VMM_Service (_GetSetPageOutCount)
  1349. /*ENDMACROS*/
  1350. /*
  1351. * Flags bits for _GetSetPageOutCount
  1352. */
  1353. #define GSPOC_F_GET 0x00000001
  1354. // Device VM page manager
  1355. /*MACROS*/
  1356. VMM_Service (Hook_V86_Page)
  1357. VMM_Service (_Assign_Device_V86_Pages)
  1358. VMM_Service (_DeAssign_Device_V86_Pages)
  1359. VMM_Service (_Get_Device_V86_Pages_Array)
  1360. VMM_Service (MMGR_SetNULPageAddr)
  1361. // GDT/LDT management
  1362. VMM_Service (_Allocate_GDT_Selector)
  1363. VMM_Service (_Free_GDT_Selector)
  1364. VMM_Service (_Allocate_LDT_Selector)
  1365. VMM_Service (_Free_LDT_Selector)
  1366. VMM_Service (_BuildDescriptorDWORDs)
  1367. VMM_Service (_GetDescriptor)
  1368. VMM_Service (_SetDescriptor)
  1369. /*ENDMACROS*/
  1370. /*
  1371. * Flag equates for _Allocate_GDT_Selector
  1372. */
  1373. #define ALLOCFROMEND 0x40000000
  1374. /*
  1375. * Flag equates for _BuildDescriptorDWORDs
  1376. */
  1377. #define BDDEXPLICITDPL 0x00000001
  1378. /*
  1379. * Flag equates for _Allocate_LDT_Selector
  1380. */
  1381. #define ALDTSPECSEL 0x00000001
  1382. /*MACROS*/
  1383. VMM_Service (_MMGR_Toggle_HMA)
  1384. /*ENDMACROS*/
  1385. /*
  1386. * Flag equates for _MMGR_Toggle_HMA
  1387. */
  1388. #define MMGRHMAPHYSICAL 0x00000001
  1389. #define MMGRHMAENABLE 0x00000002
  1390. #define MMGRHMADISABLE 0x00000004
  1391. #define MMGRHMAQUERY 0x00000008
  1392. /*MACROS*/
  1393. VMM_Service (Get_Fault_Hook_Addrs)
  1394. VMM_Service (Hook_V86_Fault)
  1395. VMM_Service (Hook_PM_Fault)
  1396. VMM_Service (Hook_VMM_Fault)
  1397. VMM_Service (Begin_Nest_V86_Exec)
  1398. VMM_Service (Begin_Nest_Exec)
  1399. VMM_Service (Exec_Int)
  1400. VMM_Service (Resume_Exec)
  1401. VMM_Service (End_Nest_Exec)
  1402. VMM_Service (Allocate_PM_App_CB_Area, VMM_ICODE)
  1403. VMM_Service (Get_Cur_PM_App_CB)
  1404. VMM_Service (Set_V86_Exec_Mode)
  1405. VMM_Service (Set_PM_Exec_Mode)
  1406. VMM_Service (Begin_Use_Locked_PM_Stack)
  1407. VMM_Service (End_Use_Locked_PM_Stack)
  1408. VMM_Service (Save_Client_State)
  1409. VMM_Service (Restore_Client_State)
  1410. VMM_Service (Exec_VxD_Int)
  1411. VMM_Service (Hook_Device_Service)
  1412. VMM_Service (Hook_Device_V86_API)
  1413. VMM_Service (Hook_Device_PM_API)
  1414. VMM_Service (System_Control)
  1415. // I/O and software interrupt hooks
  1416. VMM_Service (Simulate_IO)
  1417. VMM_Service (Install_Mult_IO_Handlers)
  1418. VMM_Service (Install_IO_Handler)
  1419. VMM_Service (Enable_Global_Trapping)
  1420. VMM_Service (Enable_Local_Trapping)
  1421. VMM_Service (Disable_Global_Trapping)
  1422. VMM_Service (Disable_Local_Trapping)
  1423. // Linked List Abstract Data Type Services
  1424. VMM_Service (List_Create)
  1425. VMM_Service (List_Destroy)
  1426. VMM_Service (List_Allocate)
  1427. VMM_Service (List_Attach)
  1428. VMM_Service (List_Attach_Tail)
  1429. VMM_Service (List_Insert)
  1430. VMM_Service (List_Remove)
  1431. VMM_Service (List_Deallocate)
  1432. VMM_Service (List_Get_First)
  1433. VMM_Service (List_Get_Next)
  1434. VMM_Service (List_Remove_First)
  1435. /*ENDMACROS*/
  1436. /*
  1437. * Flags used by List_Create
  1438. */
  1439. #define LF_ASYNC_BIT 0
  1440. #define LF_ASYNC (1 << LF_ASYNC_BIT)
  1441. #define LF_USE_HEAP_BIT 1
  1442. #define LF_USE_HEAP (1 << LF_USE_HEAP_BIT)
  1443. #define LF_ALLOC_ERROR_BIT 2
  1444. #define LF_ALLOC_ERROR (1 << LF_ALLOC_ERROR_BIT)
  1445. /*
  1446. * Swappable lists must use the heap.
  1447. */
  1448. #define LF_SWAP (LF_USE_HEAP + (1 << 3))
  1449. /******************************************************************************
  1450. * I N I T I A L I Z A T I O N P R O C E D U R E S
  1451. ******************************************************************************/
  1452. // Instance data manager
  1453. /*MACROS*/
  1454. VMM_Service (_AddInstanceItem)
  1455. // System structure data manager
  1456. VMM_Service (_Allocate_Device_CB_Area)
  1457. VMM_Service (_Allocate_Global_V86_Data_Area, VMM_ICODE)
  1458. VMM_Service (_Allocate_Temp_V86_Data_Area)
  1459. VMM_Service (_Free_Temp_V86_Data_Area)
  1460. /*ENDMACROS*/
  1461. /*
  1462. * Flag bits for _Allocate_Global_V86_Data_Area
  1463. */
  1464. #define GVDAWordAlign 0x00000001
  1465. #define GVDADWordAlign 0x00000002
  1466. #define GVDAParaAlign 0x00000004
  1467. #define GVDAPageAlign 0x00000008
  1468. #define GVDAInstance 0x00000100
  1469. #define GVDAZeroInit 0x00000200
  1470. #define GVDAReclaim 0x00000400
  1471. #define GVDAInquire 0x00000800
  1472. #define GVDAHighSysCritOK 0x00001000
  1473. #define GVDAOptInstance 0x00002000
  1474. #define GVDAForceLow 0x00004000
  1475. /*
  1476. * Flag bits for _Allocate_Temp_V86_Data_Area
  1477. */
  1478. #define TVDANeedTilInitComplete 0x00000001
  1479. // Initialization information calls (win.ini and environment parameters)
  1480. /*MACROS*/
  1481. VMM_Service (Get_Profile_Decimal_Int, VMM_ICODE)
  1482. VMM_Service (Convert_Decimal_String, VMM_ICODE)
  1483. VMM_Service (Get_Profile_Fixed_Point, VMM_ICODE)
  1484. VMM_Service (Convert_Fixed_Point_String, VMM_ICODE)
  1485. VMM_Service (Get_Profile_Hex_Int, VMM_ICODE)
  1486. VMM_Service (Convert_Hex_String, VMM_ICODE)
  1487. VMM_Service (Get_Profile_Boolean, VMM_ICODE)
  1488. VMM_Service (Convert_Boolean_String, VMM_ICODE)
  1489. VMM_Service (Get_Profile_String, VMM_ICODE)
  1490. VMM_Service (Get_Next_Profile_String, VMM_ICODE)
  1491. VMM_Service (Get_Environment_String, VMM_ICODE)
  1492. VMM_Service (Get_Exec_Path, VMM_ICODE)
  1493. VMM_Service (Get_Config_Directory, VMM_ICODE)
  1494. VMM_Service (OpenFile, VMM_ICODE)
  1495. /*ENDMACROS*/
  1496. // OpenFile, if called after init, must point EDI to a buffer of at least
  1497. // this size.
  1498. #define VMM_OPENFILE_BUF_SIZE 260
  1499. /*MACROS*/
  1500. VMM_Service (Get_PSP_Segment, VMM_ICODE)
  1501. VMM_Service (GetDOSVectors, VMM_ICODE)
  1502. VMM_Service (Get_Machine_Info)
  1503. /*ENDMACROS*/
  1504. #define GMIF_80486_BIT 0x10
  1505. #define GMIF_80486 (1 << GMIF_80486_BIT)
  1506. #define GMIF_PCXT_BIT 0x11
  1507. #define GMIF_PCXT (1 << GMIF_PCXT_BIT)
  1508. #define GMIF_MCA_BIT 0x12
  1509. #define GMIF_MCA (1 << GMIF_MCA_BIT)
  1510. #define GMIF_EISA_BIT 0x13
  1511. #define GMIF_EISA (1 << GMIF_EISA_BIT)
  1512. #define GMIF_CPUID_BIT 0x14
  1513. #define GMIF_CPUID (1 << GMIF_CPUID_BIT)
  1514. #define GMIF_80586_BIT 0x15
  1515. #define GMIF_80586 (1 << GMIF_80586_BIT)
  1516. #define GMIF_4MEGPG_BIT 0x16 // cpu supports 4 meg pages
  1517. #define GMIF_4MEGPG (1 << GMIF_4MEGPG_BIT)
  1518. #define GMIF_RDTSC_BIT 0x17
  1519. #define GMIF_RDTSC ( 1 << GMIF_RDTSC_BIT )
  1520. // Following service is not restricted to initialization
  1521. /*MACROS*/
  1522. VMM_Service (GetSet_HMA_Info)
  1523. VMM_Service (Set_System_Exit_Code)
  1524. VMM_Service (Fatal_Error_Handler)
  1525. VMM_Service (Fatal_Memory_Error)
  1526. // Called by VTD only
  1527. VMM_Service (Update_System_Clock)
  1528. /******************************************************************************
  1529. * D E B U G G I N G E X T E R N S
  1530. ******************************************************************************/
  1531. VMM_Service (Test_Debug_Installed) // Valid call in retail also
  1532. VMM_Service (Out_Debug_String)
  1533. VMM_Service (Out_Debug_Chr)
  1534. VMM_Service (In_Debug_Chr)
  1535. VMM_Service (Debug_Convert_Hex_Binary)
  1536. VMM_Service (Debug_Convert_Hex_Decimal)
  1537. VMM_Service (Debug_Test_Valid_Handle)
  1538. VMM_Service (Validate_Client_Ptr)
  1539. VMM_Service (Test_Reenter)
  1540. VMM_Service (Queue_Debug_String)
  1541. VMM_Service (Log_Proc_Call)
  1542. VMM_Service (Debug_Test_Cur_VM)
  1543. VMM_Service (Get_PM_Int_Type)
  1544. VMM_Service (Set_PM_Int_Type)
  1545. VMM_Service (Get_Last_Updated_System_Time)
  1546. VMM_Service (Get_Last_Updated_VM_Exec_Time)
  1547. VMM_Service (Test_DBCS_Lead_Byte) // for DBCS Enabling
  1548. /*ENDMACROS*/
  1549. /* ASM
  1550. .errnz @@Test_DBCS_Lead_Byte - 100D1h ; VMM service table changed above this service
  1551. */
  1552. /*************************************************************************
  1553. *************************************************************************
  1554. * END OF 3.00 SERVICE TABLE MUST NOT SHUFFLE SERVICES BEFORE THIS POINT
  1555. * FOR COMPATIBILITY.
  1556. *************************************************************************
  1557. *************************************************************************/
  1558. /*MACROS*/
  1559. VMM_Service (_AddFreePhysPage, VMM_ICODE)
  1560. VMM_Service (_PageResetHandlePAddr)
  1561. VMM_Service (_SetLastV86Page, VMM_ICODE)
  1562. VMM_Service (_GetLastV86Page)
  1563. VMM_Service (_MapFreePhysReg)
  1564. VMM_Service (_UnmapFreePhysReg)
  1565. VMM_Service (_XchgFreePhysReg)
  1566. VMM_Service (_SetFreePhysRegCalBk, VMM_ICODE)
  1567. VMM_Service (Get_Next_Arena, VMM_ICODE)
  1568. VMM_Service (Get_Name_Of_Ugly_TSR, VMM_ICODE)
  1569. VMM_Service (Get_Debug_Options, VMM_ICODE)
  1570. /*ENDMACROS*/
  1571. /*
  1572. * Flags for AddFreePhysPage
  1573. */
  1574. #define AFPP_SWAPOUT 0x0001 // physical memory that must be swapped out
  1575. // and subsequently restored at system exit
  1576. /*
  1577. * Flags for PageChangePager
  1578. */
  1579. #define PCP_CHANGEPAGER 0x1 // change the pager for the page range
  1580. #define PCP_CHANGEPAGERDATA 0x2 // change the pager data dword for the pages
  1581. #define PCP_VIRGINONLY 0x4 // make the above changes to virgin pages only
  1582. /*
  1583. * Bits for the ECX return of Get_Next_Arena
  1584. */
  1585. #define GNA_HIDOSLINKED 0x0002 // High DOS arenas linked when WIN386 started
  1586. #define GNA_ISHIGHDOS 0x0004 // High DOS arenas do exist
  1587. /*MACROS*/
  1588. VMM_Service (Set_Physical_HMA_Alias, VMM_ICODE)
  1589. VMM_Service (_GetGlblRng0V86IntBase, VMM_ICODE)
  1590. VMM_Service (_Add_Global_V86_Data_Area, VMM_ICODE)
  1591. VMM_Service (GetSetDetailedVMError)
  1592. /*ENDMACROS*/
  1593. /*
  1594. * Error code values for the GetSetDetailedVMError service. PLEASE NOTE
  1595. * that all of these error code values need to have bits set in the high
  1596. * word. This is to prevent collisions with other VMDOSAPP standard errors.
  1597. * Also, the low word must be non-zero.
  1598. *
  1599. * First set of errors (high word = 0001) are intended to be used
  1600. * when a VM is CRASHED (VNE_Crashed or VNE_Nuked bit set on
  1601. * VM_Not_Executeable).
  1602. *
  1603. * PLEASE NOTE that each of these errors (high word == 0001) actually
  1604. * has two forms:
  1605. *
  1606. * 0001xxxxh
  1607. * 8001xxxxh
  1608. *
  1609. * The device which sets the error initially always sets the error with
  1610. * the high bit CLEAR. The system will then optionally set the high bit
  1611. * depending on the result of the attempt to "nicely" crash the VM. This
  1612. * bit allows the system to tell the user whether the crash is likely or
  1613. * unlikely to destabalize the system.
  1614. */
  1615. #define GSDVME_PRIVINST 0x00010001 /* Privledged instruction */
  1616. #define GSDVME_INVALINST 0x00010002 /* Invalid instruction */
  1617. #define GSDVME_INVALPGFLT 0x00010003 /* Invalid page fault */
  1618. #define GSDVME_INVALGPFLT 0x00010004 /* Invalid GP fault */
  1619. #define GSDVME_INVALFLT 0x00010005 /* Unspecified invalid fault */
  1620. #define GSDVME_USERNUKE 0x00010006 /* User requested NUKE of VM */
  1621. #define GSDVME_DEVNUKE 0x00010007 /* Device specific problem */
  1622. #define GSDVME_DEVNUKEHDWR 0x00010008 /* Device specific problem:
  1623. * invalid hardware fiddling
  1624. * by VM (invalid I/O)
  1625. */
  1626. #define GSDVME_NUKENOMSG 0x00010009 /* Supress standard messages:
  1627. * SHELL_Message used for
  1628. * custom msg.
  1629. */
  1630. #define GSDVME_OKNUKEMASK 0x80000000 /* "Nice nuke" bit */
  1631. /*
  1632. * Second set of errors (high word = 0002) are intended to be used
  1633. * when a VM start up is failed (VNE_CreateFail, VNE_CrInitFail, or
  1634. * VNE_InitFail bit set on VM_Not_Executeable).
  1635. */
  1636. #define GSDVME_INSMEMV86 0x00020001 /* base V86 mem - V86MMGR */
  1637. #define GSDVME_INSV86SPACE 0x00020002 /* Kb Req too large - V86MMGR */
  1638. #define GSDVME_INSMEMXMS 0x00020003 /* XMS Kb Req - V86MMGR */
  1639. #define GSDVME_INSMEMEMS 0x00020004 /* EMS Kb Req - V86MMGR */
  1640. #define GSDVME_INSMEMV86HI 0x00020005 /* Hi DOS V86 mem - DOSMGR
  1641. * V86MMGR
  1642. */
  1643. #define GSDVME_INSMEMVID 0x00020006 /* Base Video mem - VDD */
  1644. #define GSDVME_INSMEMVM 0x00020007 /* Base VM mem - VMM
  1645. * CB, Inst Buffer
  1646. */
  1647. #define GSDVME_INSMEMDEV 0x00020008 /* Couldn't alloc base VM
  1648. * memory for device.
  1649. */
  1650. #define GSDVME_CRTNOMSG 0x00020009 /* Supress standard messages:
  1651. * SHELL_Message used for
  1652. * custom msg.
  1653. */
  1654. /*MACROS*/
  1655. VMM_Service (Is_Debug_Chr)
  1656. // Mono_Out services
  1657. VMM_Service (Clear_Mono_Screen)
  1658. VMM_Service (Out_Mono_Chr)
  1659. VMM_Service (Out_Mono_String)
  1660. VMM_Service (Set_Mono_Cur_Pos)
  1661. VMM_Service (Get_Mono_Cur_Pos)
  1662. VMM_Service (Get_Mono_Chr)
  1663. // Service locates a byte in ROM
  1664. VMM_Service (Locate_Byte_In_ROM, VMM_ICODE)
  1665. VMM_Service (Hook_Invalid_Page_Fault)
  1666. VMM_Service (Unhook_Invalid_Page_Fault)
  1667. /*ENDMACROS*/
  1668. /*
  1669. * Flag bits of IPF_Flags
  1670. */
  1671. #define IPF_PGDIR 0x00000001 /* Page directory entry not-present */
  1672. #define IPF_V86PG 0x00000002 /* Unexpected not present Page in V86 */
  1673. #define IPF_V86PGH 0x00000004 /* Like IPF_V86PG at high linear */
  1674. #define IPF_INVTYP 0x00000008 /* page has invalid not present type */
  1675. #define IPF_PGERR 0x00000010 /* pageswap device failure */
  1676. #define IPF_REFLT 0x00000020 /* re-entrant page fault */
  1677. #define IPF_VMM 0x00000040 /* Page fault caused by a VxD */
  1678. #define IPF_PM 0x00000080 /* Page fault by VM in Prot Mode */
  1679. #define IPF_V86 0x00000100 /* Page fault by VM in V86 Mode */
  1680. /*MACROS*/
  1681. VMM_Service (Set_Delete_On_Exit_File)
  1682. VMM_Service (Close_VM)
  1683. /*ENDMACROS*/
  1684. /*
  1685. * Flags for Close_VM service
  1686. */
  1687. #define CVF_CONTINUE_EXEC_BIT 0
  1688. #define CVF_CONTINUE_EXEC (1 << CVF_CONTINUE_EXEC_BIT)
  1689. /*MACROS*/
  1690. VMM_Service (Enable_Touch_1st_Meg) // Debugging only
  1691. VMM_Service (Disable_Touch_1st_Meg) // Debugging only
  1692. VMM_Service (Install_Exception_Handler)
  1693. VMM_Service (Remove_Exception_Handler)
  1694. VMM_Service (Get_Crit_Status_No_Block)
  1695. /*ENDMACROS*/
  1696. /* ASM
  1697. ; Check if VMM service table has changed above this service
  1698. .errnz @@Get_Crit_Status_No_Block - 100F1h
  1699. */
  1700. #ifdef WIN40SERVICES
  1701. /*************************************************************************
  1702. *************************************************************************
  1703. *
  1704. * END OF 3.10 SERVICE TABLE MUST NOT SHUFFLE SERVICES BEFORE THIS POINT
  1705. * FOR COMPATIBILITY.
  1706. *************************************************************************
  1707. *************************************************************************/
  1708. /*MACROS*/
  1709. VMM_Service (_GetLastUpdatedThreadExecTime)
  1710. VMM_Service (_Trace_Out_Service)
  1711. VMM_Service (_Debug_Out_Service)
  1712. VMM_Service (_Debug_Flags_Service)
  1713. /*ENDMACROS*/
  1714. #endif /* WIN40SERVICES */
  1715. /*
  1716. * Flags for _Debug_Flags_Service service.
  1717. *
  1718. * Don't change these unless you really really know what you're doing.
  1719. * We need to define these even if we are in WIN31COMPAT mode.
  1720. */
  1721. #define DFS_LOG_BIT 0
  1722. #define DFS_LOG (1 << DFS_LOG_BIT)
  1723. #define DFS_PROFILE_BIT 1
  1724. #define DFS_PROFILE (1 << DFS_PROFILE_BIT)
  1725. #define DFS_TEST_CLD_BIT 2
  1726. #define DFS_TEST_CLD (1 << DFS_TEST_CLD_BIT)
  1727. #define DFS_NEVER_REENTER_BIT 3
  1728. #define DFS_NEVER_REENTER (1 << DFS_NEVER_REENTER_BIT)
  1729. #define DFS_TEST_REENTER_BIT 4
  1730. #define DFS_TEST_REENTER (1 << DFS_TEST_REENTER_BIT)
  1731. #define DFS_NOT_SWAPPING_BIT 5
  1732. #define DFS_NOT_SWAPPING (1 << DFS_NOT_SWAPPING_BIT)
  1733. #define DFS_TEST_BLOCK_BIT 6
  1734. #define DFS_TEST_BLOCK (1 << DFS_TEST_BLOCK_BIT)
  1735. #define DFS_RARE_SERVICES 0xFFFFFF80
  1736. #define DFS_EXIT_NOBLOCK (DFS_RARE_SERVICES+0)
  1737. #define DFS_ENTER_NOBLOCK (DFS_RARE_SERVICES+DFS_TEST_BLOCK)
  1738. #define DFS_TEST_NEST_EXEC (DFS_RARE_SERVICES+1)
  1739. #define DFS_WIMP_DEBUG (DFS_RARE_SERVICES+2)
  1740. #ifdef WIN40SERVICES
  1741. /*MACROS*/
  1742. VMM_Service (VMMAddImportModuleName)
  1743. VMM_Service (VMM_Add_DDB)
  1744. VMM_Service (VMM_Remove_DDB)
  1745. VMM_Service (Test_VM_Ints_Enabled)
  1746. VMM_Service (_BlockOnID)
  1747. VMM_Service (Schedule_Thread_Event)
  1748. VMM_Service (Cancel_Thread_Event)
  1749. VMM_Service (Set_Thread_Time_Out)
  1750. VMM_Service (Set_Async_Time_Out)
  1751. VMM_Service (_AllocateThreadDataSlot)
  1752. VMM_Service (_FreeThreadDataSlot)
  1753. /*ENDMACROS*/
  1754. /*
  1755. * Flag equates for _CreateMutex
  1756. */
  1757. #define MUTEX_MUST_COMPLETE 1L
  1758. #define MUTEX_NO_CLEANUP_THREAD_STATE 2L
  1759. /*MACROS*/
  1760. VMM_Service (_CreateMutex)
  1761. VMM_Service (_DestroyMutex)
  1762. VMM_Service (_GetMutexOwner)
  1763. VMM_Service (Call_When_Thread_Switched)
  1764. VMM_Service (VMMCreateThread)
  1765. VMM_Service (_GetThreadExecTime)
  1766. VMM_Service (VMMTerminateThread)
  1767. VMM_Service (Get_Cur_Thread_Handle)
  1768. VMM_Service (Test_Cur_Thread_Handle)
  1769. VMM_Service (Get_Sys_Thread_Handle)
  1770. VMM_Service (Test_Sys_Thread_Handle)
  1771. VMM_Service (Validate_Thread_Handle)
  1772. VMM_Service (Get_Initial_Thread_Handle)
  1773. VMM_Service (Test_Initial_Thread_Handle)
  1774. VMM_Service (Debug_Test_Valid_Thread_Handle)
  1775. VMM_Service (Debug_Test_Cur_Thread)
  1776. VMM_Service (VMM_GetSystemInitState)
  1777. VMM_Service (Cancel_Call_When_Thread_Switched)
  1778. VMM_Service (Get_Next_Thread_Handle)
  1779. VMM_Service (Adjust_Thread_Exec_Priority)
  1780. VMM_Service (_Deallocate_Device_CB_Area)
  1781. VMM_Service (Remove_IO_Handler)
  1782. VMM_Service (Remove_Mult_IO_Handlers)
  1783. VMM_Service (Unhook_V86_Int_Chain)
  1784. VMM_Service (Unhook_V86_Fault)
  1785. VMM_Service (Unhook_PM_Fault)
  1786. VMM_Service (Unhook_VMM_Fault)
  1787. VMM_Service (Unhook_Device_Service)
  1788. VMM_Service (_PageReserve)
  1789. VMM_Service (_PageCommit)
  1790. VMM_Service (_PageDecommit)
  1791. VMM_Service (_PagerRegister)
  1792. VMM_Service (_PagerQuery)
  1793. VMM_Service (_PagerDeregister)
  1794. VMM_Service (_ContextCreate)
  1795. VMM_Service (_ContextDestroy)
  1796. VMM_Service (_PageAttach)
  1797. VMM_Service (_PageFlush)
  1798. VMM_Service (_SignalID)
  1799. VMM_Service (_PageCommitPhys)
  1800. VMM_Service (_Register_Win32_Services)
  1801. VMM_Service (Cancel_Call_When_Not_Critical)
  1802. VMM_Service (Cancel_Call_When_Idle)
  1803. VMM_Service (Cancel_Call_When_Task_Switched)
  1804. VMM_Service (_Debug_Printf_Service)
  1805. VMM_Service (_EnterMutex)
  1806. VMM_Service (_LeaveMutex)
  1807. VMM_Service (Simulate_VM_IO)
  1808. VMM_Service (Signal_Semaphore_No_Switch)
  1809. VMM_Service (_ContextSwitch)
  1810. VMM_Service (_PageModifyPermissions)
  1811. VMM_Service (_PageQuery)
  1812. VMM_Service (_EnterMustComplete)
  1813. VMM_Service (_LeaveMustComplete)
  1814. VMM_Service (_ResumeExecMustComplete)
  1815. /*ENDMACROS*/
  1816. /*
  1817. * Flag equates for _GetThreadTerminationStatus
  1818. */
  1819. #define THREAD_TERM_STATUS_CRASH_PEND 1L
  1820. #define THREAD_TERM_STATUS_NUKE_PEND 2L
  1821. #define THREAD_TERM_STATUS_SUSPEND_PEND 4L
  1822. /*MACROS*/
  1823. VMM_Service (_GetThreadTerminationStatus)
  1824. VMM_Service (_GetInstanceInfo)
  1825. /*ENDMACROS*/
  1826. /*
  1827. * Return values for _GetInstanceInfo
  1828. */
  1829. #define INSTINFO_NONE 0 /* no data instanced in range */
  1830. #define INSTINFO_SOME 1 /* some data instanced in range */
  1831. #define INSTINFO_ALL 2 /* all data instanced in range */
  1832. /*MACROS*/
  1833. VMM_Service (_ExecIntMustComplete)
  1834. VMM_Service (_ExecVxDIntMustComplete)
  1835. VMM_Service (Begin_V86_Serialization)
  1836. VMM_Service (Unhook_V86_Page)
  1837. VMM_Service (VMM_GetVxDLocationList)
  1838. VMM_Service (VMM_GetDDBList)
  1839. VMM_Service (Unhook_NMI_Event)
  1840. VMM_Service (Get_Instanced_V86_Int_Vector)
  1841. VMM_Service (Get_Set_Real_DOS_PSP)
  1842. /*ENDMACROS*/
  1843. #define GSRDP_Set 0x0001
  1844. /*MACROS*/
  1845. VMM_Service (Call_Priority_Thread_Event)
  1846. VMM_Service (Get_System_Time_Address)
  1847. VMM_Service (Get_Crit_Status_Thread)
  1848. VMM_Service (Get_DDB)
  1849. VMM_Service (Directed_Sys_Control)
  1850. /*ENDMACROS*/
  1851. // Registry APIs for VxDs
  1852. /*MACROS*/
  1853. VMM_Service (_RegOpenKey)
  1854. VMM_Service (_RegCloseKey)
  1855. VMM_Service (_RegCreateKey)
  1856. VMM_Service (_RegDeleteKey)
  1857. VMM_Service (_RegEnumKey)
  1858. VMM_Service (_RegQueryValue)
  1859. VMM_Service (_RegSetValue)
  1860. VMM_Service (_RegDeleteValue)
  1861. VMM_Service (_RegEnumValue)
  1862. VMM_Service (_RegQueryValueEx)
  1863. VMM_Service (_RegSetValueEx)
  1864. /*ENDMACROS*/
  1865. #ifndef REG_SZ // define only if not there already
  1866. #define REG_SZ 0x0001
  1867. #define REG_BINARY 0x0003
  1868. #endif
  1869. #ifndef HKEY_LOCAL_MACHINE // define only if not there already
  1870. #define HKEY_CLASSES_ROOT 0x80000000
  1871. #define HKEY_CURRENT_USER 0x80000001
  1872. #define HKEY_LOCAL_MACHINE 0x80000002
  1873. #define HKEY_USERS 0x80000003
  1874. #define HKEY_PERFORMANCE_DATA 0x80000004
  1875. #define HKEY_CURRENT_CONFIG 0x80000005
  1876. #define HKEY_DYN_DATA 0x80000006
  1877. #endif
  1878. /*MACROS*/
  1879. VMM_Service (_CallRing3)
  1880. VMM_Service (Exec_PM_Int)
  1881. VMM_Service (_RegFlushKey)
  1882. VMM_Service (_PageCommitContig)
  1883. VMM_Service (_GetCurrentContext)
  1884. VMM_Service (_LocalizeSprintf)
  1885. VMM_Service (_LocalizeStackSprintf)
  1886. VMM_Service (Call_Restricted_Event)
  1887. VMM_Service (Cancel_Restricted_Event)
  1888. VMM_Service (Register_PEF_Provider, VMM_ICODE)
  1889. VMM_Service (_GetPhysPageInfo)
  1890. VMM_Service (_RegQueryInfoKey)
  1891. VMM_Service (MemArb_Reserve_Pages)
  1892. /*ENDMACROS*/
  1893. /*
  1894. * Return values for _GetPhysPageInfo
  1895. */
  1896. #define PHYSINFO_NONE 0 /* no pages in the specified range exist */
  1897. #define PHYSINFO_SOME 1 /* some pages in the specified range exist */
  1898. #define PHYSINFO_ALL 2 /* all pages in the specified range exist */
  1899. // New timeslicer services
  1900. /*MACROS*/
  1901. VMM_Service (Time_Slice_Sys_VM_Idle)
  1902. VMM_Service (Time_Slice_Sleep)
  1903. VMM_Service (Boost_With_Decay)
  1904. VMM_Service (Set_Inversion_Pri)
  1905. VMM_Service (Reset_Inversion_Pri)
  1906. VMM_Service (Release_Inversion_Pri)
  1907. VMM_Service (Get_Thread_Win32_Pri)
  1908. VMM_Service (Set_Thread_Win32_Pri)
  1909. VMM_Service (Set_Thread_Static_Boost)
  1910. VMM_Service (Set_VM_Static_Boost)
  1911. VMM_Service (Release_Inversion_Pri_ID)
  1912. VMM_Service (Attach_Thread_To_Group)
  1913. VMM_Service (Detach_Thread_From_Group)
  1914. VMM_Service (Set_Group_Static_Boost)
  1915. VMM_Service (_GetRegistryPath, VMM_ICODE)
  1916. VMM_Service (_GetRegistryKey)
  1917. /*ENDMACROS*/
  1918. // TYPE definitions for _GetRegistryKey
  1919. #define REGTYPE_ENUM 0
  1920. #define REGTYPE_CLASS 1
  1921. #define REGTYPE_VXD 2
  1922. // Flag definitions for _GetRegistryKey
  1923. #define REGKEY_OPEN 0
  1924. #define REGKEY_CREATE_IFNOTEXIST 1
  1925. // Flag definitions for _Assert_Range
  1926. #define ASSERT_RANGE_NULL_BAD 0x00000000
  1927. #define ASSERT_RANGE_NULL_OK 0x00000001
  1928. #define ASSERT_RANGE_IS_ASCIIZ 0x00000002
  1929. #define ASSERT_RANGE_IS_NOT_ASCIIZ 0x00000000
  1930. #define ASSERT_RANGE_NO_DEBUG 0x80000000
  1931. #define ASSERT_RANGE_BITS 0x80000003
  1932. /*MACROS*/
  1933. VMM_Service (Cleanup_Thread_State)
  1934. VMM_Service (_RegRemapPreDefKey)
  1935. VMM_Service (End_V86_Serialization)
  1936. VMM_Service (_Assert_Range)
  1937. VMM_Service (_Sprintf)
  1938. VMM_Service (_PageChangePager)
  1939. VMM_Service (_RegCreateDynKey)
  1940. VMM_Service (_RegQueryMultipleValues)
  1941. // Additional timeslicer services
  1942. VMM_Service (Boost_Thread_With_VM)
  1943. /*ENDMACROS*/
  1944. // Flag definitions for Get_Boot_Flags
  1945. #define BOOT_CLEAN 0x00000001
  1946. #define BOOT_DOSCLEAN 0x00000002
  1947. #define BOOT_NETCLEAN 0x00000004
  1948. #define BOOT_INTERACTIVE 0x00000008
  1949. /*MACROS*/
  1950. VMM_Service (Get_Boot_Flags)
  1951. VMM_Service (Set_Boot_Flags)
  1952. // String and memory services
  1953. VMM_Service (_lstrcpyn)
  1954. VMM_Service (_lstrlen)
  1955. VMM_Service (_lmemcpy)
  1956. VMM_Service (_GetVxDName)
  1957. // For vwin32 use only
  1958. VMM_Service (Force_Mutexes_Free)
  1959. VMM_Service (Restore_Forced_Mutexes)
  1960. /*ENDMACROS*/
  1961. // Reclaimable low memory services
  1962. /*MACROS*/
  1963. VMM_Service (_AddReclaimableItem)
  1964. VMM_Service (_SetReclaimableItem)
  1965. VMM_Service (_EnumReclaimableItem)
  1966. /*ENDMACROS*/
  1967. // completely wake sys VM from idle state
  1968. /*MACROS*/
  1969. VMM_Service (Time_Slice_Wake_Sys_VM)
  1970. VMM_Service (VMM_Replace_Global_Environment)
  1971. VMM_Service (Begin_Non_Serial_Nest_V86_Exec)
  1972. VMM_Service (Get_Nest_Exec_Status)
  1973. /*ENDMACROS*/
  1974. // Bootlogging services
  1975. /*MACROS*/
  1976. VMM_Service (Open_Boot_Log)
  1977. VMM_Service (Write_Boot_Log)
  1978. VMM_Service (Close_Boot_Log)
  1979. VMM_Service (EnableDisable_Boot_Log)
  1980. VMM_Service (_Call_On_My_Stack)
  1981. /*ENDMACROS*/
  1982. // Another instance data service
  1983. /*MACROS*/
  1984. VMM_Service (Get_Inst_V86_Int_Vec_Base)
  1985. /*ENDMACROS*/
  1986. // Case insensitive functions -- SEE WARNINGS IN DOCS BEFORE USING!
  1987. /*MACROS*/
  1988. VMM_Service (_lstrcmpi)
  1989. VMM_Service (_strupr)
  1990. /*ENDMACROS*/
  1991. /*MACROS*/
  1992. VMM_Service (Log_Fault_Call_Out)
  1993. VMM_Service (_AtEventTime)
  1994. /*ENDMACROS*/
  1995. #endif /* WIN40SERVICES */
  1996. #ifdef WIN403SERVICES
  1997. //
  1998. // 4.03 Services
  1999. //
  2000. /*MACROS*/
  2001. VMM_Service (_PageOutPages)
  2002. /*ENDMACROS*/
  2003. // Flag definitions for _PageOutPages
  2004. #define PAGEOUT_PRIVATE 0x00000001
  2005. #define PAGEOUT_SHARED 0x00000002
  2006. #define PAGEOUT_SYSTEM 0x00000004
  2007. #define PAGEOUT_REGION 0x00000008
  2008. #define PAGEOUT_ALL (PAGEOUT_PRIVATE | PAGEOUT_SHARED | PAGEOUT_SYSTEM)
  2009. /*MACROS*/
  2010. VMM_Service (_Call_On_My_Not_Flat_Stack)
  2011. VMM_Service (_LinRegionLock)
  2012. VMM_Service (_LinRegionUnLock)
  2013. VMM_Service (_AttemptingSomethingDangerous)
  2014. VMM_Service (_Vsprintf)
  2015. VMM_Service (_Vsprintfw)
  2016. VMM_Service (Load_FS_Service)
  2017. VMM_Service (Assert_FS_Service)
  2018. VMM_StdCall_Service (ObsoleteRtlUnwind, 4)
  2019. VMM_StdCall_Service (ObsoleteRtlRaiseException, 1)
  2020. VMM_StdCall_Service (ObsoleteRtlRaiseStatus, 1)
  2021. VMM_StdCall_Service (ObsoleteKeGetCurrentIrql, 0)
  2022. VMM_FastCall_Service (ObsoleteKfRaiseIrql, 1)
  2023. VMM_FastCall_Service (ObsoleteKfLowerIrql, 1)
  2024. VMM_Service (_Begin_Preemptable_Code)
  2025. VMM_Service (_End_Preemptable_Code)
  2026. VMM_FastCall_Service (Set_Preemptable_Count, 1)
  2027. VMM_StdCall_Service (ObsoleteKeInitializeDpc, 3)
  2028. VMM_StdCall_Service (ObsoleteKeInsertQueueDpc, 3)
  2029. VMM_StdCall_Service (ObsoleteKeRemoveQueueDpc, 1)
  2030. VMM_StdCall_Service (HeapAllocateEx, 4)
  2031. VMM_StdCall_Service (HeapReAllocateEx, 5)
  2032. VMM_StdCall_Service (HeapGetSizeEx, 2)
  2033. VMM_StdCall_Service (HeapFreeEx, 2)
  2034. VMM_Service (_Get_CPUID_Flags)
  2035. VMM_StdCall_Service (KeCheckDivideByZeroTrap, 1)
  2036. /*ENDMACROS*/
  2037. #endif /* WIN403SERVICES */
  2038. #ifdef WIN41SERVICES
  2039. /*MACROS*/
  2040. VMM_Service (_RegisterGARTHandler)
  2041. VMM_Service (_GARTReserve)
  2042. VMM_Service (_GARTCommit)
  2043. VMM_Service (_GARTUnCommit)
  2044. VMM_Service (_GARTFree)
  2045. VMM_Service (_GARTMemAttributes)
  2046. VMM_StdCall_Service (KfRaiseIrqlToDpcLevel, 0)
  2047. VMM_Service (VMMCreateThreadEx)
  2048. VMM_Service (_FlushCaches)
  2049. /*ENDMACROS*/
  2050. /*
  2051. * Flags for the VMM GART services.
  2052. * WARNING: THESE FLAGS SHOULD HAVE SAME VALUE AS THE VMM FLAGS DEFINED IN PCI.H
  2053. * IF YOU CHANGE THE VALUE AT EITHER PLACE, YOU NEED TO UPDATE THE OTHER.
  2054. */
  2055. #define PG_UNCACHED 0x00000001 // Uncached memory
  2056. #define PG_WRITECOMBINED 0x00000002 // Write combined memory
  2057. /*
  2058. * Flags for the FlushCaches service.
  2059. */
  2060. #define FLUSHCACHES_NORMAL 0x00000000
  2061. #define FLUSHCACHES_GET_CACHE_LINE_PTR 0x00000001
  2062. #define FLUSHCACHES_GET_CACHE_SIZE_PTR 0x00000002
  2063. #define FLUSHCACHES_TAKE_OVER 0x00000003
  2064. #define FLUSHCACHES_FORCE_PAGES_OUT 0x00000004
  2065. #define FLUSHCACHES_LOCK_LOCKABLE 0x00000005
  2066. #define FLUSHCACHES_UNLOCK_LOCKABLE 0x00000006
  2067. /*MACROS*/
  2068. VMM_Service (Set_Thread_Win32_Pri_NoYield)
  2069. VMM_Service (_FlushMappedCacheBlock)
  2070. VMM_Service (_ReleaseMappedCacheBlock)
  2071. VMM_Service (Run_Preemptable_Events)
  2072. VMM_Service (_MMPreSystemExit)
  2073. VMM_Service (_MMPageFileShutDown)
  2074. VMM_Service (_Set_Global_Time_Out_Ex)
  2075. VMM_Service (Query_Thread_Priority)
  2076. /*ENDMACROS*/
  2077. #endif /* WIN41SERVICES */
  2078. /*MACROS*/
  2079. End_Service_Table(VMM, VMM)
  2080. /*ENDMACROS*/
  2081. /*XLATOFF*/
  2082. #pragma warning (default:4003) // turn on not enough params warning
  2083. #ifndef try
  2084. #define try __try
  2085. #define except __except
  2086. #define finally __finally
  2087. #define leave __leave
  2088. #ifndef exception_code
  2089. #define exception_code __exception_code
  2090. #endif
  2091. #endif
  2092. #ifndef EXCEPTION_EXECUTE_HANDLER
  2093. #define EXCEPTION_EXECUTE_HANDLER 1
  2094. #define EXCEPTION_CONTINUE_SEARCH 0
  2095. #define EXCEPTION_CONTINUE_EXECUTION -1
  2096. #endif
  2097. /*XLATON*/
  2098. #define COMNFS_FLAT 0xFFFFFFFF
  2099. // Flag definitions for _Add/_Set/_EnumReclaimableItem
  2100. #define RS_RECLAIM 0x00000001
  2101. #define RS_RESTORE 0x00000002
  2102. #define RS_DOSARENA 0x00000004
  2103. // Structure definition for _EnumReclaimableItem
  2104. struct ReclaimStruc {
  2105. ULONG RS_Linear; // low (< 1meg) address of item
  2106. ULONG RS_Bytes; // size of item in bytes
  2107. ULONG RS_CallBack; // callback, if any (zero if none)
  2108. ULONG RS_RefData; // reference data for callback, if any
  2109. ULONG RS_HookTable; // real-mode hook table (zero if none)
  2110. ULONG RS_Flags; // 0 or more of the RS_* equates
  2111. };
  2112. typedef struct ReclaimStruc *PReclaimStruc;
  2113. //
  2114. // Structures for Force_Mutexes_Free/Restore_Forced_Mutexes
  2115. //
  2116. typedef struct frmtx {
  2117. struct frmtx *frmtx_pfrmtxNext;
  2118. DWORD frmtx_hmutex;
  2119. DWORD frmtx_cEnterCount;
  2120. DWORD frmtx_pthcbOwner;
  2121. DWORD frmtx_htimeout;
  2122. } FRMTX;
  2123. typedef struct vmmfrinfo {
  2124. struct frmtx vmmfrinfo_frmtxDOS;
  2125. struct frmtx vmmfrinfo_frmtxV86;
  2126. struct frmtx vmmfrinfo_frmtxOther;
  2127. } VMMFRINFO;
  2128. /*
  2129. * Data structure for _GetDemandPageInfo
  2130. */
  2131. struct DemandInfoStruc {
  2132. ULONG DILin_Total_Count; /* # pages in linear address space */
  2133. ULONG DIPhys_Count; /* Count of phys pages */
  2134. ULONG DIFree_Count; /* Count of free phys pages */
  2135. ULONG DIUnlock_Count; /* Count of unlocked Phys Pages */
  2136. ULONG DILinear_Base_Addr; /* Base of pageable address space */
  2137. ULONG DILin_Total_Free; /* Total Count of free linear pages */
  2138. /*
  2139. * The following 5 fields are all running totals, kept from the time
  2140. * the system was started
  2141. */
  2142. ULONG DIPage_Faults; /* total page faults */
  2143. ULONG DIPage_Ins; /* calls to pagers to page in a page */
  2144. ULONG DIPage_Outs; /* calls to pagers to page out a page*/
  2145. ULONG DIPage_Discards; /* pages discarded w/o calling pager */
  2146. ULONG DIInstance_Faults; /* instance page faults */
  2147. ULONG DIPagingFileMax; /* maximum # of pages that could be in paging file */
  2148. ULONG DIPagingFileInUse; /* # of pages of paging file currently in use */
  2149. ULONG DICommit_Count; /* Total committed memory, in pages */
  2150. ULONG DIReserved[2]; /* Reserved for expansion */
  2151. };
  2152. /*
  2153. * Data structure for _AddInstanceItem
  2154. */
  2155. struct InstDataStruc {
  2156. ULONG InstLinkF; /* INIT <0> RESERVED */
  2157. ULONG InstLinkB; /* INIT <0> RESERVED */
  2158. ULONG InstLinAddr; /* Linear address of start of block */
  2159. ULONG InstSize; /* Size of block in bytes */
  2160. ULONG InstType; /* Type of block */
  2161. };
  2162. /*
  2163. * Values for InstType
  2164. */
  2165. #define INDOS_FIELD 0x100 /* Bit indicating INDOS switch requirements */
  2166. #define ALWAYS_FIELD 0x200 /* Bit indicating ALWAYS switch requirements */
  2167. #define OPTIONAL_FIELD 0x400 /* Bit indicating optional instancing requirements */
  2168. /*
  2169. * Data structure for Hook_Invalid_Page_Fault handlers.
  2170. *
  2171. * This is the structure of the "invalid page fault information"
  2172. * which is pointed to by EDI when Invalid page fault hookers
  2173. * are called.
  2174. *
  2175. * Page faults can occur on a VM which is not current by touching the VM at
  2176. * its high linear address. In this case, IPF_FaultingVM may not be the
  2177. * current VM, it will be set to the VM whos high linear address was touched.
  2178. */
  2179. struct IPF_Data {
  2180. ULONG IPF_LinAddr; /* CR2 address of fault */
  2181. ULONG IPF_MapPageNum; /* Possible converted page # of fault */
  2182. ULONG IPF_PTEEntry; /* Contents of PTE that faulted */
  2183. ULONG IPF_FaultingVM; /* May not = Current VM (IPF_V86PgH set) */
  2184. ULONG IPF_Flags; /* Flags */
  2185. };
  2186. /*
  2187. *
  2188. * Install_Exception_Handler data structure
  2189. *
  2190. */
  2191. struct Exception_Handler_Struc {
  2192. ULONG EH_Reserved;
  2193. ULONG EH_Start_EIP;
  2194. ULONG EH_End_EIP;
  2195. ULONG EH_Handler;
  2196. };
  2197. /*
  2198. * Flags passed in new memory manager functions
  2199. */
  2200. /* PageReserve arena values */
  2201. #define PR_PRIVATE 0x80000400 /* anywhere in private arena */
  2202. #define PR_SHARED 0x80060000 /* anywhere in shared arena */
  2203. #define PR_SYSTEM 0x80080000 /* anywhere in system arena */
  2204. /* PageReserve flags */
  2205. #define PR_FIXED 0x00000008 /* don't move during PageReAllocate */
  2206. #define PR_4MEG 0x00000001 /* allocate on 4mb boundary */
  2207. #define PR_STATIC 0x00000010 /* see PageReserve documentation */
  2208. /* PageCommit default pager handle values */
  2209. #define PD_ZEROINIT 0x00000001 /* swappable zero-initialized pages */
  2210. #define PD_NOINIT 0x00000002 /* swappable uninitialized pages */
  2211. #define PD_FIXEDZERO 0x00000003 /* fixed zero-initialized pages */
  2212. #define PD_FIXED 0x00000004 /* fixed uninitialized pages */
  2213. /* PageCommit flags */
  2214. #define PC_FIXED 0x00000008 /* pages are permanently locked */
  2215. #define PC_LOCKED 0x00000080 /* pages are made present and locked*/
  2216. #define PC_LOCKEDIFDP 0x00000100 /* pages are locked if swap via DOS */
  2217. #define PC_WRITEABLE 0x00020000 /* make the pages writeable */
  2218. #define PC_USER 0x00040000 /* make the pages ring 3 accessible */
  2219. #define PC_INCR 0x40000000 /* increment "pagerdata" each page */
  2220. #define PC_PRESENT 0x80000000 /* make pages initially present */
  2221. #define PC_STATIC 0x20000000 /* allow commit in PR_STATIC object */
  2222. #define PC_DIRTY 0x08000000 /* make pages initially dirty */
  2223. #define PC_CACHEDIS 0x00100000 /* Allocate uncached pages - new for WDM */
  2224. #define PC_CACHEWT 0x00080000 /* Allocate write through cache pages - new for WDM */
  2225. #define PC_PAGEFLUSH 0x00008000 /* Touch device mapped pages on alloc - new for WDM */
  2226. #ifdef WRITE_WATCH
  2227. #define PC_WRITE_WATCH 0x00200000 /* to request write_watch in this region */
  2228. #endif // WRITE_WATCH
  2229. /* PageCommitContig additional flags */
  2230. #define PCC_ZEROINIT 0x00000001 /* zero-initialize new pages */
  2231. #define PCC_NOLIN 0x10000000 /* don't map to any linear address */
  2232. /*MTRR type flags */
  2233. #define MTRR_UC 0
  2234. #define MTRR_WC 1
  2235. #define MTRR_WT 4
  2236. #define MTRR_WP 5
  2237. #define MTRR_WB 6
  2238. /*
  2239. * Structure and flags for PageQuery
  2240. */
  2241. #ifndef _WINNT_
  2242. typedef struct _MEMORY_BASIC_INFORMATION {
  2243. ULONG mbi_BaseAddress;
  2244. ULONG mbi_AllocationBase;
  2245. ULONG mbi_AllocationProtect;
  2246. ULONG mbi_RegionSize;
  2247. ULONG mbi_State;
  2248. ULONG mbi_Protect;
  2249. ULONG mbi_Type;
  2250. } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
  2251. #define PAGE_NOACCESS 0x01
  2252. #define PAGE_READONLY 0x02
  2253. #define PAGE_READWRITE 0x04
  2254. #define MEM_COMMIT 0x1000
  2255. #define MEM_RESERVE 0x2000
  2256. #define MEM_FREE 0x10000
  2257. #define MEM_PRIVATE 0x20000
  2258. #endif
  2259. /***ET+ PD - Pager Descriptor
  2260. *
  2261. * A PD describes a set of routines to call to bring a page into
  2262. * the system or to get it out. Each committed page in the system
  2263. * has an associated PD, a handle to which is stored in the page's
  2264. * VP.
  2265. *
  2266. * For any field that is 0, the pager will not be notified
  2267. * when that action takes place.
  2268. *
  2269. * For the purpose of pagers, a page can be in one of the two states
  2270. * describing its current contents:
  2271. *
  2272. * clean - page has not been written to since its last page out
  2273. * dirty - page has been written to since its last page out
  2274. *
  2275. * A page also is in one of two persistent states:
  2276. *
  2277. * virgin - page has never been written to since it was committed
  2278. * tainted - page has been written to since it was committed
  2279. *
  2280. * Note that a tainted page may be either dirty or clean, but a
  2281. * virgin page is by definition clean.
  2282. *
  2283. * Examples of PDs:
  2284. *
  2285. * For 32-bit EXE code or read-only data:
  2286. *
  2287. * pd_virginin = routine to load page from an exe file
  2288. * pd_taintedin = 0
  2289. * pd_cleanout = 0
  2290. * pd_dirtyout = 0
  2291. * pd_virginfree = 0
  2292. * pd_taintedfree = 0
  2293. * pd_dirty = 0
  2294. * pd_type = PD_PAGERONLY
  2295. *
  2296. * For 32-bit EXE writeable data:
  2297. *
  2298. * pd_virginin = routine to load page from an exe file
  2299. * pd_taintedin = routine to load page from swap file
  2300. * pd_cleanout = 0
  2301. * pd_dirtyout = routine to write a page out to the swap file
  2302. * pd_virginfree = 0
  2303. * pd_taintedfree = routine to free page from the swap file
  2304. * pd_dirty = routine to free page from the swap file
  2305. * pd_type = PD_SWAPPER
  2306. *
  2307. * For zero-initialized swappable data:
  2308. *
  2309. * pd_virginin = routine to zero-fill a page
  2310. * pd_taintedin = routine to load page from swap file
  2311. * pd_cleanout = 0
  2312. * pd_dirtyout = routine to write a page out to the swap file
  2313. * pd_virginfree = 0
  2314. * pd_taintedfree = routine to free page from the swap file
  2315. * pd_dirty = routine to free page from the swap file
  2316. * pd_type = PD_SWAPPER
  2317. */
  2318. /* typedefs for various pager functions */
  2319. typedef ULONG _cdecl FUNPAGE(PULONG ppagerdata, PVOID ppage, ULONG faultpage);
  2320. typedef FUNPAGE * PFUNPAGE;
  2321. struct pd_s {
  2322. /*
  2323. * The following four fields are entry points in the pager which
  2324. * we call to page in or page out a page. The following parameters
  2325. * are passed to the pager during these calls:
  2326. *
  2327. * ppagerdata - pointer to the pager-specific dword of data
  2328. * stored with the virtual page. The pager is
  2329. * free to modify the contents of this dword
  2330. * DURING the page in or out, but not afterwards.
  2331. *
  2332. * ppage - pointer to page going in or out (a ring 0 alias
  2333. * to the physical page). The pager should use this
  2334. * address to access the contents of the page.
  2335. *
  2336. * faultpage - faulting linear page number for page-ins, -1 for
  2337. * page-outs. This address should not be accessed
  2338. * by the pager. It is provided for information
  2339. * only. Note that a single page can be mapped at
  2340. * more than one linear address because of the
  2341. * MapIntoV86 and LinMapIntoV86 services.
  2342. *
  2343. * The pager should return non-0 if the page was successfully
  2344. * paged, or 0 if it failed.
  2345. */
  2346. PFUNPAGE pd_virginin; /* in - while page has never been written to */
  2347. PFUNPAGE pd_taintedin; /* in - page written to at least once */
  2348. PFUNPAGE pd_cleanout; /* out - page not written to since last out */
  2349. PFUNPAGE pd_dirtyout; /* out - page was written to since last out */
  2350. /*
  2351. * The pd_*free routines are used to inform the pager when the last
  2352. * reference to a virtual page controlled by the pager is
  2353. * decommitted. A common use of this notification is to
  2354. * free space in a backing file, or write the page contents
  2355. * into the backing file.
  2356. *
  2357. * These calls take the same parameters as the page-out and -in
  2358. * functions, but no return value is recognized. The "ppage"
  2359. * and "faultpage" parameters will always be 0.
  2360. */
  2361. PFUNPAGE pd_virginfree; /* decommit of never-written-to page */
  2362. PFUNPAGE pd_taintedfree; /* decommit of page written to at least once*/
  2363. /*
  2364. * The pd_dirty routine is used to inform the pager when the
  2365. * memory manager detects that a page has been written to. The memory
  2366. * manager does not detect the write at the instant it occurs, so
  2367. * the pager should not depend upon prompt notification. A common
  2368. * use of this notification might be to invalidate cached data.
  2369. * If the page was dirtied in more than one memory context,
  2370. * the pager's pd_dirty routine will be called once for each
  2371. * context.
  2372. *
  2373. * These calls take the same parameters as the page-out and -in
  2374. * functions except that the "ppage" parameter isn't valid and
  2375. * no return value is recognized.
  2376. */
  2377. PFUNPAGE pd_dirty;
  2378. /*
  2379. * The pd_type field gives the sytem information about the
  2380. * overcommit characteristics of pages controlled by this pager.
  2381. * The following are allowable values for the field:
  2382. *
  2383. * PD_SWAPPER - under some conditions, pages of this type
  2384. * may be paged out into the swap file
  2385. * PD_PAGERONLY - pages controlled by this pager will never
  2386. * be paged out to the swap file
  2387. *
  2388. * In addition, the following value may be or'ed in to the pd_type field:
  2389. *
  2390. * PD_NESTEXEC - must be specified if either the pd_cleanout or pd_dirtyout
  2391. * functions perform nested excecution or block using the
  2392. * BLOCK_SVC_INTS flag. To be safe, this flag should always be
  2393. * specified if the pager does any sort of file i/o to anything
  2394. * other than the default paging file.
  2395. */
  2396. ULONG pd_type;
  2397. };
  2398. typedef struct pd_s PD;
  2399. typedef PD * PPD;
  2400. /* values for pd_type */
  2401. #define PD_SWAPPER 0 /* pages need direct accounting in swap file */
  2402. #define PD_PAGERONLY 1 /* pages will never be swapped */
  2403. #define PD_NESTEXEC 2 /* page out funtion uses nested execution */
  2404. #endif // Not_VxD
  2405. /*
  2406. * The size of a page of memory
  2407. */
  2408. #define PAGESHIFT 12
  2409. #define PAGESIZE (1 << PAGESHIFT)
  2410. #define PAGEMASK (PAGESIZE - 1)
  2411. /* XLATOFF */
  2412. #ifndef PAGE
  2413. #define PAGE(p) ((DWORD)(p) >> PAGESHIFT)
  2414. #endif
  2415. /* XLATON */
  2416. #define NPAGES(cb) (((DWORD)(cb) + PAGEMASK) >> PAGESHIFT)
  2417. /*
  2418. * Address space (arena) boundaries
  2419. */
  2420. #define MAXSYSTEMLADDR ((ULONG) 0xffbfffff) /* 4 gig - 4meg */
  2421. #define MINSYSTEMLADDR ((ULONG) 0xc0000000) /* 3 gig */
  2422. #define MAXSHAREDLADDR ((ULONG) 0xbfffffff)
  2423. #define MINSHAREDLADDR ((ULONG) 0x80000000) /* 2 gig */
  2424. #define MAXPRIVATELADDR ((ULONG) 0x7fffffff)
  2425. #define MINPRIVATELADDR ((ULONG) 0x00400000) /* 4 meg */
  2426. #define MAXDOSLADDR ((ULONG) 0x003fffff)
  2427. #define MINDOSLADDR ((ULONG) 0x00000000)
  2428. #define MAXSYSTEMPAGE (MAXSYSTEMLADDR >> PAGESHIFT)
  2429. #define MINSYSTEMPAGE (MINSYSTEMLADDR >> PAGESHIFT)
  2430. #define MAXSHAREDPAGE (MAXSHAREDLADDR >> PAGESHIFT)
  2431. #define MINSHAREDPAGE (MINSHAREDLADDR >> PAGESHIFT)
  2432. #define MAXPRIVATEPAGE (MAXPRIVATELADDR >> PAGESHIFT)
  2433. #define MINPRIVATEPAGE (MINPRIVATELADDR >> PAGESHIFT)
  2434. #define MAXDOSPAGE (MAXDOSLADDR >> PAGESHIFT)
  2435. #define MINDOSPAGE (MINDOSLADDR >> PAGESHIFT)
  2436. #define CBPRIVATE (1 + MAXPRIVATELADDR - MINPRIVATELADDR)
  2437. #define CBSHARED (1 + MAXSHAREDLADDR - MINSHAREDLADDR)
  2438. #define CBSYSTEM (1 + MAXSYSTEMLADDR - MINSYSTEMLADDR)
  2439. #define CBDOS (1 + MAXDOSLADDR - MINDOSLADDR)
  2440. #define CPGPRIVATE (1 + MAXPRIVATEPAGE - MINPRIVATEPAGE)
  2441. #define CPGSHARED (1 + MAXSHAREDPAGE - MINSHAREDPAGE)
  2442. #define CPGSYSTEM (1 + MAXSYSTEMPAGE - MINSYSTEMPAGE)
  2443. #define CPGDOS (1 + MAXDOSPAGE - MINDOSPAGE)
  2444. /*XLATOFF*/
  2445. /*
  2446. * Largest object that could theoretically be allocated
  2447. */
  2448. #define CBMAXALLOC (max(CBSHARED,max(CBPRIVATE, CBSYSTEM)))
  2449. #define CPGMAXALLOC (max(CPGSHARED,max(CPGPRIVATE, CPGSYSTEM)))
  2450. /*XLATON*/
  2451. /* ASM
  2452. IFDEF DEBUG
  2453. DebFar EQU NEAR PTR
  2454. ELSE
  2455. DebFar EQU SHORT
  2456. ENDIF
  2457. */
  2458. #define ASD_MAX_REF_DATA 256 // If bigger than this, a checksum is used
  2459. struct _vmmguid {
  2460. unsigned long Data1;
  2461. unsigned short Data2;
  2462. unsigned short Data3;
  2463. unsigned char Data4[8];
  2464. };
  2465. typedef struct _vmmguid VMMGUID;
  2466. typedef VMMGUID *VMMREFIID;
  2467. typedef DWORD ASD_RESULT;
  2468. #define ASD_ERROR_NONE 0x00000000
  2469. #define ASD_CHECK_FAIL 0x00000001 // The flag is set that this failed before
  2470. #define ASD_CHECK_SUCCESS 0x00000002 // The flag is set that this succeeded before
  2471. #define ASD_CHECK_UNKNOWN 0x00000003 // No flag is set
  2472. #define ASD_ERROR_BAD_TIME 0x00000004 // Under cli
  2473. #define ASD_REGISTRY_ERROR 0x00000005 // Unknown registry error
  2474. #define ASD_CLEAN_BOOT 0x00000006 // Clean booting fails everything
  2475. #define ASD_OUT_OF_MEMORY 0x00000007 // Ran out of memory (extremely rare)
  2476. #define ASD_FILE_ERROR 0x00000008 // Int 21 to flush the info file failed
  2477. #define ASD_ALREADY_SET 0x00000009 // ASD_CHECK* done twice on same vgOperation/pRefData
  2478. #define ASD_MISSING_CHECK 0x0000000A // ASD_DONE* on something not set
  2479. #define ASD_BAD_PARAMETER 0x0000000B // Invalid operation, refiid or ref pointer
  2480. #define ASD_OP_CHECK_AND_WRITE_FAIL_IF_UNKNOWN 0x00000000
  2481. #define ASD_OP_CHECK_AND_ALWAYS_WRITE_FAIL 0x00000001
  2482. #define ASD_OP_CHECK 0x00000002
  2483. #define ASD_OP_DONE_AND_SET_SUCCESS 0x00000003
  2484. #define ASD_OP_SET_FAIL 0x00000004
  2485. #define ASD_OP_SET_SUCCESS 0x00000005
  2486. #define ASD_OP_SET_UNKNOWN 0x00000006
  2487. #define ASD_OP_DONE 0x00000007
  2488. #define ASD_FLAG_STRING 0x00000001
  2489. #ifndef Not_VxD
  2490. /******************************************************************************
  2491. *
  2492. * EQUATES FOR SYSTEM_CONTROL CALLS
  2493. *
  2494. *****************************************************************************/
  2495. /*
  2496. * SYS_CRITICAL_INIT is a device init call. Devices that have a
  2497. * critical function that needs initializing before interrupts are
  2498. * enabled should do it at Sys_Critical_Init. Devices which REQUIRE a
  2499. * certain range of V86 pages to operate (such as the VDD video memory)
  2500. * should claim them at Sys_Critical_Init. SYS VM Simulate_Int,
  2501. * Exec_Int ACTIVITY IS NOT ALLOWED. Returning carry aborts device
  2502. * load only.
  2503. */
  2504. #define SYS_CRITICAL_INIT 0x0000 /* Devices req'd for virt mode */
  2505. /*
  2506. * DEVICE_INIT is where most devices do the bulk of their initialization.
  2507. * SYS VM Simulate_Int, Exec_Int activity is allowed. Returning carry
  2508. * aborts device load only.
  2509. */
  2510. #define DEVICE_INIT 0x0001 /* All other devices init */
  2511. /*
  2512. * INIT_COMPLETE is the final phase of device init called just before the
  2513. * WIN386 INIT pages are released and the Instance snapshot is taken.
  2514. * Devices which wish to search for a region of V86 pages >= A0h to use
  2515. * should do it at INIT_COMPLETE.
  2516. * SYS VM Simulate_Int, Exec_Int activity is allowed. Returning carry
  2517. * aborts device load only.
  2518. */
  2519. #define INIT_COMPLETE 0x0002 /* All devices initialized */
  2520. /* --------------- INITIALIZATION CODE AND DATA DISCARDED ------------------ */
  2521. /*
  2522. * Same as VM_Init, except for SYS VM.
  2523. */
  2524. #define SYS_VM_INIT 0x0003 /* Execute the system VM */
  2525. /*
  2526. * Same as VM_Terminate, except for SYS VM (Normal WIN386 exit ONLY, on a crash
  2527. * exit this call is not made). SYS VM Simulate_Int, Exec_Int activity is
  2528. * allowed. This and Sys_VM_Terminate2 are your last chances to access
  2529. * and/or lock pageable data.
  2530. */
  2531. #define SYS_VM_TERMINATE 0x0004 /* System VM terminated */
  2532. /*
  2533. * System_Exit call is made when WIN386 is exiting either normally or via
  2534. * a crash. INTERRUPTS ARE ENABLED. Instance snapshot has been restored.
  2535. * SYS VM Simulate_Int, Exec_Int ACTIVITY IS NOT ALLOWED.
  2536. */
  2537. #define SYSTEM_EXIT 0x0005 /* Devices prepare to exit */
  2538. /*
  2539. * SYS_CRITICAL_EXIT call is made when WIN386 is exiting either normally or via
  2540. * a crash. INTERRUPTS ARE DISABLED. SYS VM Simulate_Int, Exec_Int ACTIVITY
  2541. * IS NOT ALLOWED.
  2542. */
  2543. #define SYS_CRITICAL_EXIT 0x0006 /* System critical devices reset */
  2544. /*
  2545. * Create_VM creates a new VM. EBX = VM handle of new VM. Returning
  2546. * Carry will fail the Create_VM.
  2547. */
  2548. #define CREATE_VM 0x0007
  2549. /*
  2550. * Second phase of Create_VM. EBX = VM handle of new VM. Returning
  2551. * Carry will cause the VM to go Not_Executeable, then be destroyed.
  2552. * VM Simulate_Int, Exec_Int activity is NOT allowed.
  2553. */
  2554. #define VM_CRITICAL_INIT 0x0008
  2555. /*
  2556. * Third phase of Create_VM. EBX = VM handle of new VM. Returning
  2557. * Carry will cause the VM to go Not_Executeable, then be destroyed.
  2558. * VM Simulate_Int, Exec_Int activity is allowed.
  2559. */
  2560. #define VM_INIT 0x0009
  2561. /*
  2562. * NORMAL (First phase) of Destroy_VM. EBX = VM Hanlde. This occurs
  2563. * on normal termination of the VM. Call cannot be failed. VM
  2564. * Simulate_Int, Exec_Int activity is allowed.
  2565. */
  2566. #define VM_TERMINATE 0x000A /* Still in VM -- About to die */
  2567. /*
  2568. * Second phase of Destroy_VM. EBX = VM Handle, EDX = Flags (see
  2569. * below). Note that in the case of destroying a running VM, this is
  2570. * the first call made (VM_Terminate call does not occur). Call cannot
  2571. * be failed. VM Simulate_Int, Exec_Int activity is NOT allowed.
  2572. */
  2573. #define VM_NOT_EXECUTEABLE 0x000B /* Most devices die (except VDD) */
  2574. /*
  2575. * Final phase of Destroy_VM. EBX = VM Handle. Note that considerable
  2576. * time can elaps between the VM_Not_Executeable call and this call.
  2577. * Call cannot be failed. VM Simulate_Int, Exec_Int activity is NOT
  2578. * allowed.
  2579. */
  2580. #define DESTROY_VM 0x000C /* VM's control block about to go */
  2581. /*
  2582. * Flags for VM_Not_Executeable control call (passed in EDX)
  2583. */
  2584. #define VNE_CRASHED_BIT 0x00 /* VM was crashed */
  2585. #define VNE_CRASHED (1 << VNE_CRASHED_BIT)
  2586. #define VNE_NUKED_BIT 0x01 /* VM was destroyed while active */
  2587. #define VNE_NUKED (1 << VNE_NUKED_BIT)
  2588. #define VNE_CREATEFAIL_BIT 0x02 /* Some device failed Create_VM */
  2589. #define VNE_CREATEFAIL (1 << VNE_CREATEFAIL_BIT)
  2590. #define VNE_CRINITFAIL_BIT 0x03 /* Some device failed VM_Critical_Init */
  2591. #define VNE_CRINITFAIL (1 << VNE_CRINITFAIL_BIT)
  2592. #define VNE_INITFAIL_BIT 0x04 /* Some device failed VM_Init */
  2593. #define VNE_INITFAIL (1 << VNE_INITFAIL_BIT)
  2594. #define VNE_CLOSED_BIT 0x05
  2595. #define VNE_CLOSED (1 << VNE_CLOSED_BIT)
  2596. /*
  2597. * EBX = VM Handle. Call cannot be failed.
  2598. */
  2599. #define VM_SUSPEND 0x000D /* VM not runnable until resume */
  2600. /*
  2601. * EBX = VM Handle. Returning carry fails and backs out the resume.
  2602. */
  2603. #define VM_RESUME 0x000E /* VM is leaving suspended state */
  2604. /*
  2605. * EBX = VM Handle to set device focus to. EDX = Device ID if device
  2606. * specific setfocus, == 0 if device critical setfocus (all devices).
  2607. * THIS CALL CANNOT BE FAILED.
  2608. *
  2609. * NOTE: In case where EDX == 0, ESI is a FLAG word that indicates
  2610. * special functions. Currently Bit 0 being set indicates that this
  2611. * Device critical set focus is also "VM critical". It means that we
  2612. * do not want some other VM to take the focus from this app now. This
  2613. * is primarily used when doing a device critical set focus to Windows
  2614. * (the SYS VM) it is interpreted by the SHELL to mean "if an old app
  2615. * currently has the Windows activation, set the activation to the
  2616. * Windows Shell, not back to the old app". ALSO in the case where Bit
  2617. * 0 is set, EDI = The VM handle of the VM that is "having trouble".
  2618. * Set this to 0 if there is no specific VM associated with the
  2619. * problem.
  2620. */
  2621. #define SET_DEVICE_FOCUS 0x000F
  2622. /*
  2623. * EBX = VM Handle going into message mode. THIS CALL CANNOT BE FAILED.
  2624. */
  2625. #define BEGIN_MESSAGE_MODE 0x0010
  2626. /*
  2627. * EBX = VM Handle leaving message mode. THIS CALL CANNOT BE FAILED.
  2628. */
  2629. #define END_MESSAGE_MODE 0x0011
  2630. /* ----------------------- SPECIAL CONTROL CALLS --------------------------- */
  2631. /*
  2632. * Request for reboot. Call cannot be failed.
  2633. */
  2634. #define REBOOT_PROCESSOR 0x0012 /* Request a machine reboot */
  2635. /*
  2636. * Query_Destroy is an information call made by the SHELL device before
  2637. * an attempt is made to initiate a destroy VM sequence on a running VM
  2638. * which has not exited normally. EBX = VM Handle. Returning carry
  2639. * indicates that a device "has a problem" with allowing this. THE
  2640. * DESTROY SEQUENCE CANNOT BE ABORTED HOWEVER, this decision is up to
  2641. * the user. All this does is indicate that there is a "problem" with
  2642. * allowing the destroy. The device which returns carry should call
  2643. * the SHELL_Message service to post an informational dialog about the
  2644. * reason for the problem.
  2645. */
  2646. #define QUERY_DESTROY 0x0013 /* OK to destroy running VM? */
  2647. /* ----------------------- DEBUGGING CONTROL CALL -------------------------- */
  2648. /*
  2649. * Special call for device specific DEBUG information display and activity.
  2650. */
  2651. #define DEBUG_QUERY 0x0014
  2652. /* -------- CALLS FOR BEGIN/END OF PROTECTED MODE VM EXECUTION ------------- */
  2653. /*
  2654. * About to run a protected mode application.
  2655. * EBX = Current VM handle.
  2656. * EDX = Flags
  2657. * EDI -> Application Control Block
  2658. * Returning with carry set fails the call.
  2659. */
  2660. #define BEGIN_PM_APP 0x0015
  2661. /*
  2662. * Flags for Begin_PM_App (passed in EDX)
  2663. */
  2664. #define BPA_32_BIT 0x01
  2665. #define BPA_32_BIT_FLAG 1
  2666. /*
  2667. * Protected mode application is terminating.
  2668. * EBX = Current VM handle. THIS CALL CAN NOT FAIL.
  2669. * EDI -> Application Control Block
  2670. */
  2671. #define END_PM_APP 0x0016
  2672. /*
  2673. * Called whenever system is about to be rebooted. Allows VxDs to clean
  2674. * up in preperation for reboot.
  2675. */
  2676. #define DEVICE_REBOOT_NOTIFY 0x0017
  2677. #define CRIT_REBOOT_NOTIFY 0x0018
  2678. /*
  2679. * Called when VM is about to be terminated using the Close_VM service
  2680. * EBX = Current VM handle (Handle of VM to close)
  2681. * EDX = Flags
  2682. * CVNF_CRIT_CLOSE = 1 if VM is in critical section while closing
  2683. */
  2684. #define CLOSE_VM_NOTIFY 0x0019
  2685. #define CVNF_CRIT_CLOSE_BIT 0
  2686. #define CVNF_CRIT_CLOSE (1 << CVNF_CRIT_CLOSE_BIT)
  2687. /*
  2688. * Power management event notification.
  2689. * EBX = 0
  2690. * ESI = event notification message
  2691. * EDI -> DWORD return value; VxD's modify the DWORD to return info, not EDI
  2692. * EDX is reserved
  2693. */
  2694. #define POWER_EVENT 0x001A
  2695. #define SYS_DYNAMIC_DEVICE_INIT 0x001B
  2696. #define SYS_DYNAMIC_DEVICE_EXIT 0x001C
  2697. /*
  2698. * Create_THREAD creates a new thread. EDI = handle of new thread.
  2699. * Returning Carry will fail the Create_THREAD. Message is sent in the
  2700. * context of the creating thread.
  2701. *
  2702. */
  2703. #define CREATE_THREAD 0x001D
  2704. /*
  2705. * Second phase of creating a thread. EDI = handle of new thread. Call cannot
  2706. * be failed. VM Simulate_Int, Exec_Int activity is not allowed (because
  2707. * never allowed in non-initial threads). Message is sent in the context
  2708. * of the newly created thread.
  2709. *
  2710. */
  2711. #define THREAD_INIT 0x001E
  2712. /*
  2713. * Normal (first) phase of Destroy_THREAD. EDI = handle of thread.
  2714. * This occurs on normal termination of the thread. Call cannot be failed.
  2715. * Simulate_Int, Exec_Int activity is allowed.
  2716. */
  2717. #define TERMINATE_THREAD 0x001F
  2718. /*
  2719. * Second phase of Destroy_THREAD. EDI = Handle of thread,
  2720. * EDX = flags (see below). Note that in the case of destroying a
  2721. * running thread, this is the first call made (THREAD_Terminate call
  2722. * does not occur). Call cannot be failed. VM Simulate_Int, Exec_Int
  2723. * activity is NOT allowed.
  2724. *
  2725. */
  2726. #define THREAD_Not_Executeable 0x0020
  2727. /*
  2728. * Final phase of Destroy_THREAD. EDI = Thread Handle. Note that considerable
  2729. * time can elapse between the THREAD_Not_Executeable call and this call.
  2730. * Call cannot be failed. VM Simulate_Int, Exec_Int activity is NOT
  2731. * allowed.
  2732. *
  2733. */
  2734. #define DESTROY_THREAD 0x0021
  2735. /* -------------------- CALLS FOR PLUG&PLAY ------------------------- */
  2736. /*
  2737. * Configuration manager or a devloader is telling a DLVxD that a new devnode
  2738. * has been created. EBX is the handle of the new devnode and EDX is the load
  2739. * type (one of the DLVxD_LOAD_* defined in CONFIGMG.H). This is a 'C'
  2740. * system control call. Contrarily to the other calls, carry flags must be
  2741. * set if any error code other than CR_SUCCESS is to be return.
  2742. *
  2743. */
  2744. #define PNP_NEW_DEVNODE 0x0022
  2745. /* -------------------- CALLS FOR Win32 ------------------------- */
  2746. /* vWin32 communicates with Vxds on behalf of Win32 apps thru this mechanism.
  2747. * BUGBUG: need more doc here, describing the interface
  2748. */
  2749. #define W32_DEVICEIOCONTROL 0x0023
  2750. /* sub-functions */
  2751. #define DIOC_GETVERSION 0x0
  2752. #define DIOC_OPEN DIOC_GETVERSION
  2753. #define DIOC_CLOSEHANDLE -1
  2754. /* -------------------- MORE SYSTEM CALLS ------------------------- */
  2755. /*
  2756. * All these messages are sent immediately following the corresponding
  2757. * message of the same name, except that the "2" messages are sent
  2758. * in *reverse* init order.
  2759. */
  2760. #define SYS_VM_TERMINATE2 0x0024
  2761. #define SYSTEM_EXIT2 0x0025
  2762. #define SYS_CRITICAL_EXIT2 0x0026
  2763. #define VM_TERMINATE2 0x0027
  2764. #define VM_NOT_EXECUTEABLE2 0x0028
  2765. #define DESTROY_VM2 0x0029
  2766. #define VM_SUSPEND2 0x002A
  2767. #define END_MESSAGE_MODE2 0x002B
  2768. #define END_PM_APP2 0x002C
  2769. #define DEVICE_REBOOT_NOTIFY2 0x002D
  2770. #define CRIT_REBOOT_NOTIFY2 0x002E
  2771. #define CLOSE_VM_NOTIFY2 0x002F
  2772. /*
  2773. * VCOMM gets Address of Contention handler from VxDs by sending this
  2774. * control message
  2775. */
  2776. #define GET_CONTENTION_HANDLER 0x0030
  2777. #define KERNEL32_INITIALIZED 0x0031
  2778. #define KERNEL32_SHUTDOWN 0x0032
  2779. #define CREATE_PROCESS 0x0033
  2780. #define DESTROY_PROCESS 0x0034
  2781. #ifndef WIN40COMPAT
  2782. #define SYS_DYNAMIC_DEVICE_REINIT 0x0035
  2783. #endif
  2784. #define SYS_POWER_DOWN 0x0036
  2785. #define MAX_SYSTEM_CONTROL 0x0036
  2786. /*
  2787. * Dynamic VxD's can communicate with each other using Directed_Sys_Control
  2788. * and a private control message in the following range:
  2789. */
  2790. #define BEGIN_RESERVED_PRIVATE_SYSTEM_CONTROL 0x70000000
  2791. #define END_RESERVED_PRIVATE_SYSTEM_CONTROL 0x7FFFFFFF
  2792. #endif // Not_VxD
  2793. /*
  2794. * Values returned from VMM_GetSystemInitState in EAX.
  2795. *
  2796. * Comments represent operations performed by VMM; #define's indicate
  2797. * what VMM_GetSystemInitState will return if you call it between the
  2798. * previous operation and the next.
  2799. *
  2800. * Future versions of Windows may have additional init states between the
  2801. * ones defined here, so you should be careful to use range checks instead
  2802. * of test for equality.
  2803. */
  2804. /* Protected mode is entered */
  2805. #define SYSSTATE_PRESYSCRITINIT 0x00000000
  2806. /* SYS_CRITICAL_INIT is broadcast */
  2807. #define SYSSTATE_PREDEVICEINIT 0x10000000
  2808. /* DEVICE_INIT is broadcast */
  2809. #define SYSSTATE_PREINITCOMPLETE 0x20000000
  2810. /* INIT_COMPLETE is broadcast */
  2811. /* VxD initialization complete */
  2812. #define SYSSTATE_VXDINITCOMPLETED 0x40000000
  2813. /* KERNEL32_INITIALIZED is broadcast */
  2814. #define SYSSTATE_KERNEL32INITED 0x50000000
  2815. /* All initialization completed */
  2816. /* System running normally */
  2817. /* System shutdown initiated */
  2818. /* KERNEL32_SHUTDOWN is broadcast */
  2819. #define SYSSTATE_KERNEL32TERMINATED 0xA0000000
  2820. /* System shutdown continues */
  2821. #define SYSSTATE_PRESYSVMTERMINATE 0xB0000000
  2822. /* SYS_VM_TERMINATE is broadcast */
  2823. #define SYSSTATE_PRESYSTEMEXIT 0xE0000000
  2824. /* SYSTEM_EXIT is broadcast */
  2825. #define SYSSTATE_PRESYSTEMEXIT2 0xE4000000
  2826. /* SYSTEM_EXIT2 is broadcast */
  2827. #define SYSSTATE_PRESYSCRITEXIT 0xF0000000
  2828. /* SYS_CRITICAL_EXIT is broadcast */
  2829. #define SYSSTATE_PRESYSCRITEXIT2 0xF4000000
  2830. /* SYS_CRITICAL_EXIT2 is broadcast */
  2831. #define SYSSTATE_POSTSYSCRITEXIT2 0xFFF00000
  2832. /* Return to real mode */
  2833. /* Alternate path: CAD reboot */
  2834. #define SYSSTATE_PREDEVICEREBOOT 0xFFFF0000
  2835. /* DEVICE_REBOOT_NOTIFY is broadcast */
  2836. #define SYSSTATE_PRECRITREBOOT 0xFFFFF000
  2837. /* CRIT_REBOOT_NOTIFY is broadcast */
  2838. #define SYSSTATE_PREREBOOTCPU 0xFFFFFF00
  2839. /* REBOOT_PROCESSOR is broadcast */
  2840. /* Return to real mode */
  2841. /* ASM
  2842. BeginDoc
  2843. ;******************************************************************************
  2844. ; BeginProc is a macro for defining entry points to routines in VMM and in the
  2845. ; VxDs. It correctly defines the procedure name for VxD services, DWORD
  2846. ; aligns the procedure, takes care of public declaration and does some
  2847. ; calling verification for debug versions of the software. EndProc is a
  2848. ; macro which defines the end of the procedure.
  2849. ;
  2850. ; Valid parameters to the BeginProc macro are:
  2851. ; PUBLIC ; Used outside this module (default)
  2852. ; LOCAL ; Local to this module
  2853. ; HIGH_FREQ ; DWORD align procedure
  2854. ; SERVICE ; Routine is called via VxDCall
  2855. ; ASYNC_SERVICE ; Same as "SERVICE" plus routine can
  2856. ; ; be called under interrupt.
  2857. ; HOOK_PROC ; Proc is a handler installed with
  2858. ; ; with a call to Hook_xxx_Fault
  2859. ; ; or Hook_Device_Service. The
  2860. ; ; following parameter must be
  2861. ; ; the label of a DWORD location
  2862. ; ; which will hold the ptr to next
  2863. ; ; hook proc. e.g.
  2864. ;
  2865. ; ;BeginProc foo, SERVICE, HOOK_PROC, foo_next_ptr
  2866. ;
  2867. ; NO_LOG ; Disable Queue_Out call logging
  2868. ; NO_PROFILE ; Disable DynaLink profile counts
  2869. ; NO_TEST_CLD ; Disable direction flag check
  2870. ;
  2871. ; TEST_BLOCK ; Trap if in NOBLOCK state
  2872. ; ; (default if in pageable code seg)
  2873. ; TEST_REENTER ; Trap if Get_VMM_Reenter_Count != 0
  2874. ; ; (default for non-async services)
  2875. ; NEVER_REENTER ; Trap if VMM has been reentered
  2876. ; NOT_SWAPPING ; Trap if this thread is swapping
  2877. ;
  2878. ; NO_PROLOG ; Disable all prolog tests
  2879. ;
  2880. ; ESP ; Use ESP instead of EBP for stack
  2881. ; ; frame base
  2882. ; PCALL ; pascal calling convention
  2883. ; SCALL ; stdcall calling convention
  2884. ; FASTCALL ; stdcall, but first 2 parameters are passed in ECX & EDX
  2885. ; CCALL ; "C" calling convention
  2886. ; ICALL ; default calling convention
  2887. ; W32SVC ; Win32 service
  2888. ;
  2889. ; segment type ; Place function in specified segment
  2890. ;
  2891. ; The NO_PROFILE flag merely suppresses incrementing the profile count.
  2892. ; The DWORD of profiling information will still be emitted to appease
  2893. ; the debugger. If you want to increment the profile count manually,
  2894. ; use the IncProfileCount macro.
  2895. ;
  2896. ; TEST_REENTER and NEVER_REENTER differ in that the VMM reentry count
  2897. ; returned by Get_VMM_Reenter_Count is artifically forced to zero by
  2898. ; Begin_Reentrant_Execution, whereas the counter checked by NEVER_REENTER
  2899. ; reflects the genuine count of VMM reentry.
  2900. ;
  2901. ; A segment type (such as LOCKED, PAGEABLE, STATIC, INIT, DEBUG_ONLY) can be
  2902. ; provided, in which case the BeginProc and EndProc macros will
  2903. ; automatically place the appropriate segment directives around the
  2904. ; definition of the function.
  2905. ;
  2906. ; segment type ; Place function in specified segment
  2907. ;
  2908. ; After the routine header in which the routine entry conditions, exit
  2909. ; conditions, side affects and functionality are specified, the BeginProc
  2910. ; macro should be used to define the routine's entry point. It has up to
  2911. ; four parameters as specified below. For example:
  2912. ;
  2913. ;BeginProc <Function_Name>,PUBLIC, HIGH_FREQ, SERVICE, ASYNC_SERVICE, ESP
  2914. ;
  2915. ; <code>
  2916. ;
  2917. ;EndProc <Function_Name>
  2918. ;==============================================================================
  2919. EndDoc
  2920. ;
  2921. ; BeginProc handling takes place in the following phases:
  2922. ;
  2923. ; Phase 1: Parsing the arguments.
  2924. ; Phase 2: Setting default flags.
  2925. ; Phase 3: Combining the flags.
  2926. ; Phase 4: Code emitted before the label
  2927. ; Phase 5: Munge the name as exported to C/Pascal/whoever
  2928. ; Phase 6: _Debug_Flags_Service prolog
  2929. ; Phase 7: Code emitted after the label
  2930. ;
  2931. ??_pf_Check equ 1 ;; Do Enter/LeaveProc checking?
  2932. ??_pf_ArgsUsed equ 2 ;; ArgVars were used
  2933. ??_pf_Entered equ 4 ;; EnterProc performed
  2934. ??_pf_Left equ 8 ;; LeaveProc performed
  2935. ??_pf_Returned equ 16 ;; Return performed
  2936. ??_pushed = 0 ;; For WIN31COMPAT
  2937. ??_align = 0 ;; For WIN31COMPAT
  2938. ??_ends equ <> ;; BeginProc segment
  2939. BeginProc macro Name, P1, P2, P3, P4, P5, P6, P7, LastArg
  2940. local Profile_Data, prelabeldata, ??_hookvar
  2941. ??_frame = 0 ;; local frame base
  2942. ??_aframe = 0 ;; argument frame base
  2943. ??_taframe = 0 ;; true argument frame base
  2944. ??_initaframe = 0 ;; initial aframe value
  2945. ??_numargs = 0 ;; number of argvars
  2946. ??_numlocals = 0 ;; number of localvars
  2947. ??_numlocalsymbols = 0 ;; number of local symbols
  2948. ??_procflags = 0 ;; misc. Enter/LeaveProc flags
  2949. ??_esp = 0 ;; if VMM_TRUE, use esp instead of ebp
  2950. ??_pushed = 0 ;; number of bytes pushed
  2951. ??_align = 0 ;; set if proc should be dword aligned
  2952. ??_hook = 0 ;; set if proc is a Hook_Proc
  2953. ??_hookarg = 0
  2954. ??_service = 0
  2955. ??_async_service = 0
  2956. IF DEBLEVEL GT DEBLEVELNORMAL
  2957. ??_log = DFS_LOG ;; logging on by default
  2958. ??_profile = DFS_PROFILE ;; service profiling on by default
  2959. ??_test_cld = DFS_TEST_CLD ;; test that direction is clear
  2960. ELSE
  2961. ??_log = 0 ;; logging off
  2962. IFDEF DEBUG
  2963. IFDEF profileall
  2964. IF ?_ICODE
  2965. ??_profile = DFS_PROFILE ;; service profiling on by default
  2966. ELSE
  2967. ??_profile = 0 ;; service profiling off
  2968. ENDIF
  2969. ELSE
  2970. ??_profile = 0 ;; service profiling off
  2971. ENDIF
  2972. ELSE
  2973. ??_profile = 0 ;; service profiling off
  2974. ENDIF
  2975. ??_test_cld = 0 ;; test that direction is clear
  2976. ENDIF
  2977. ??_might_block = 0 ;; entering fn might cause VM to block
  2978. ??_test_reenter = 0 ;; don't test for VMM reentry
  2979. ??_never_reenter = 0 ;; don't test for genuine VMM reentry
  2980. ??_not_swapping = 0 ;; don't test that we're not swapping
  2981. ??_prolog_disabled = 0 ;; use a prolog by default
  2982. ??_public = 1 ;; everything's public by default
  2983. ??_cleanoff = 0 ;; don't cleanoff parameters
  2984. ??_ccall = 0
  2985. ??_pcall = 0
  2986. ??_scall = 0
  2987. ??_fastcall = 0
  2988. ??_w32svc = 0
  2989. ??_fleave = FALSE
  2990. ; ??_dfs = 0 ;; parm for _Debug_Flags_Service
  2991. ??_name equ <Name>
  2992. .errnb ??_ends, <Cannot nest functions with named segments>
  2993. .errnb <LastArg>, <Too many arguments to BeginProc>
  2994. ;; Phase 1: Parsing the arguments
  2995. irp arg, <P1, P2, P3, P4, P5, P6, P7>
  2996. if ??_hookarg
  2997. ??_hookarg = 0
  2998. ??_hookvar equ <arg>
  2999. elseifdef ?&&arg&&_BeginProc
  3000. ?&&arg&&_BeginProc
  3001. elseifdef VxD_&&arg&&_CODE_SEG
  3002. ??_ends textequ <VxD_&&arg&&_CODE_ENDS>
  3003. VxD_&&arg&&_CODE_SEG
  3004. else
  3005. .err <Bad param "&arg" to BeginProc>
  3006. endif
  3007. endm
  3008. ;; Phase 2: Setting default flags
  3009. ifndef Not_VxD
  3010. ife ??_service
  3011. ifndef profileall
  3012. ??_profile = 0 ;; only services can be profiled
  3013. endif
  3014. ifdef VMMSYS
  3015. ??_prolog_disabled = 1
  3016. endif
  3017. else
  3018. ??_test_cld = DFS_TEST_CLD
  3019. endif ; ife ??_service
  3020. ife ?_16ICODE
  3021. ??_prolog_disabled = 1
  3022. else
  3023. ife ?_RCODE ;; if real-mode code segment
  3024. ??_prolog_disabled = 1 ;; don't do anything stupid
  3025. else ;; else protected mode code segment
  3026. ife ?_PCODE ;; if swappable code
  3027. ??_might_block = DFS_TEST_BLOCK
  3028. endif
  3029. if ??_service
  3030. ife ??_async_service
  3031. ??_test_reenter = DFS_TEST_REENTER
  3032. endif
  3033. endif
  3034. endif ; ife ?_RCODE
  3035. endif ; ife ?_16ICODE
  3036. endif ; Not_VxD
  3037. if ??_esp
  3038. ;; just return address on stack
  3039. ??_basereg equ <esp+??_pushed>
  3040. ??_initaframe = 4
  3041. else
  3042. ;; ret addr and EBP on stack
  3043. ??_basereg equ <ebp>
  3044. ??_initaframe = 8
  3045. endif
  3046. @Caller equ <dword ptr [??_basereg+??_initaframe-4]>
  3047. ??_cleanoff = ??_pcall or ??_scall or ??_fastcall
  3048. ;; Phase 3: Combining the flags
  3049. ??_dfs = ??_never_reenter + ??_test_reenter + ??_not_swapping + \
  3050. ??_log + ??_profile + ??_test_cld + ??_might_block
  3051. if ??_prolog_disabled
  3052. ??_dfs = 0
  3053. endif
  3054. ;; Phase 4: Pre-label code
  3055. ifndef Not_VxD
  3056. if ??_hook
  3057. if ??_align
  3058. Dword_Align
  3059. endif
  3060. prelabeldata:
  3061. ifndef ??_hookvar
  3062. .err <HOOK_PROC requires next arg to be name of dword location>
  3063. endif
  3064. jmp short Name
  3065. jmp [??_hookvar]
  3066. ifdef DEBUG
  3067. Profile_Data dd 0
  3068. endif
  3069. if ??_align
  3070. .errnz ($ - prelabeldata) mod 4
  3071. endif
  3072. endif
  3073. ifdef DEBUG
  3074. ?prolog_&Name label near
  3075. if (??_service OR ??_profile) AND (??_hook EQ 0)
  3076. jmp short Name
  3077. if ??_align
  3078. Dword_Align ; This also aligns the proc
  3079. endif ; since Profile_Data is a dd
  3080. IF ?_ICODE
  3081. ifdef profileall
  3082. ?ProfileHeader_BeginProc Profile_Data, %@filename
  3083. else
  3084. Profile_Data dd 0
  3085. endif
  3086. ELSE
  3087. Profile_Data dd 0
  3088. ENDIF
  3089. endif
  3090. endif
  3091. if ??_align
  3092. Dword_Align
  3093. endif
  3094. endif ; Not_VxD
  3095. Name proc near ;; The label
  3096. ;; Phase 5: Munge the name as exported to C/Pascal/whoever
  3097. ;; Warning! Phase 5 cannot emit code!
  3098. ife ??_pcall or ??_ccall or ??_scall or ??_fastcall ;; if no munging
  3099. if ??_public
  3100. public Name
  3101. else
  3102. ifdef DEBUG
  3103. % ?merge @FileName,$,Name,:
  3104. % ?merge public,,,,,@FileName,$,Name
  3105. endif
  3106. endif
  3107. endif
  3108. if ??_ccall
  3109. if ??_public
  3110. _&Name equ Name
  3111. ifdef Not_VxD
  3112. public C Name
  3113. else
  3114. public _&Name
  3115. endif
  3116. endif
  3117. endif
  3118. if ??_pcall
  3119. if ??_public
  3120. ?toupper Name
  3121. ?merge public,,,,%?upper
  3122. endif
  3123. endif
  3124. ;; Phase 6: _Debug_Flags_Service prolog
  3125. ;; DO NOT CHANGE UNTIL YOU UNDERSTAND _Debug_Flags_Service
  3126. ife ??_scall or ??_fastcall
  3127. ?_BeginProc_Debug_Prologue
  3128. endif
  3129. ;; Phase 7: Post-label code
  3130. ;; <none>
  3131. endm
  3132. ?_BeginProc_Debug_Prologue MACRO
  3133. ifndef Not_VxD
  3134. ifdef DEBUG
  3135. if ??_dfs EQ DFS_LOG
  3136. VMMCall Log_Proc_Call ;; no test, just log
  3137. else
  3138. if ??_dfs EQ DFS_TEST_REENTER
  3139. VMMCall Test_Reenter ;; no log, just reenter
  3140. else
  3141. if ??_dfs or ?_LOCKABLECODE eq 0
  3142. ifdef WIN31COMPAT
  3143. if ??_dfs AND DFS_LOG
  3144. VMMCall Log_Proc_Call
  3145. endif
  3146. if ??_dfs AND DFS_TEST_REENTER
  3147. VMMCall Test_Reenter
  3148. endif
  3149. else
  3150. ife ?_LOCKABLECODE
  3151. ifdef ??_debug_flags
  3152. push ??_debug_flags
  3153. if ??_dfs
  3154. pushfd
  3155. or dword ptr [esp+4],??_dfs
  3156. popfd
  3157. endif
  3158. VMMCall _Debug_Flags_Service
  3159. elseif ??_dfs
  3160. push ??_dfs
  3161. VMMCall _Debug_Flags_Service
  3162. endif
  3163. else
  3164. push ??_dfs
  3165. VMMCall _Debug_Flags_Service
  3166. endif
  3167. endif
  3168. else
  3169. ifdef profileall
  3170. IncProfileCount
  3171. endif
  3172. endif ;if ??_dfs
  3173. endif ; if ??_dfs EQ DFS_TEST_REENTER
  3174. endif ; if ??_dfs EQ DFS_LOG
  3175. endif ; DEBUG
  3176. endif ; Not_VxD
  3177. ENDM
  3178. ;
  3179. ; For each BeginProc keyword, there is a corresponding macro ?XX_BeginProc.
  3180. ;
  3181. ; The macro ?_BeginProc is so that the null keyword is not an error.
  3182. ?_BeginProc macro
  3183. endm
  3184. ?PUBLIC_BeginProc macro
  3185. ??_public = 1
  3186. endm
  3187. ?LOCAL_BeginProc macro
  3188. ??_public = 0
  3189. endm
  3190. ?HIGH_FREQ_BeginProc macro
  3191. ??_align = 1
  3192. endm
  3193. ?HOOK_PROC_BeginProc macro
  3194. ??_hook = 1
  3195. ??_hookarg = 1 ; next arg is dword storage location
  3196. endm
  3197. ?SERVICE_BeginProc macro
  3198. ??_service = 1
  3199. .erre ?_16ICODE, <SERVICEs must be in 32 bit code>
  3200. .erre ?_RCODE, <SERVICEs must be in 32 bit code>
  3201. endm
  3202. ?ASYNC_SERVICE_BeginProc macro
  3203. ??_service = 1
  3204. ??_async_service = 1
  3205. .errnz ?_LCODE, <ASYNC_SERVICE's must be in LOCKED code>
  3206. endm
  3207. ?NO_LOG_BeginProc macro
  3208. ??_log = 0
  3209. endm
  3210. ?NO_PROFILE_BeginProc macro
  3211. ??_profile = 0
  3212. endm
  3213. ?NO_TEST_CLD_BeginProc macro
  3214. ??_test_cld = 0
  3215. endm
  3216. ?TEST_BLOCK_BeginProc macro
  3217. ??_might_block = DFS_TEST_BLOCK
  3218. endm
  3219. ?TEST_REENTER_BeginProc macro
  3220. ??_test_reenter = DFS_TEST_REENTER
  3221. endm
  3222. ?NEVER_REENTER_BeginProc macro
  3223. ??_never_reenter = DFS_NEVER_REENTER
  3224. endm
  3225. ?NOT_SWAPPING_BeginProc macro
  3226. ??_not_swapping = DFS_NOT_SWAPPING
  3227. endm
  3228. ?NO_PROLOG_BeginProc macro
  3229. ??_prolog_disabled = 1
  3230. endm
  3231. ?ESP_BeginProc macro
  3232. ??_esp = VMM_TRUE
  3233. ifndef Not_VxD
  3234. .erre ?_16ICODE, <Beginproc ESP attribute invalid in 16 bit seg.>
  3235. .erre ?_RCODE, <Beginproc ESP attribute invalid in real-mode seg.>
  3236. endif
  3237. endm
  3238. ?CCALL_BeginProc macro
  3239. ??_ccall = 1
  3240. endm
  3241. ?PCALL_BeginProc macro
  3242. ??_pcall = 1
  3243. endm
  3244. ?SCALL_BeginProc macro
  3245. ??_scall = 1
  3246. endm
  3247. ?FASTCALL_BeginProc macro
  3248. ??_fastcall = 1
  3249. endm
  3250. ?ICALL_BeginProc macro
  3251. ??_scall = 1 ;; internal calling convention is StdCall
  3252. endm
  3253. ?W32SVC_BeginProc macro
  3254. ??_scall = 1
  3255. ??_w32svc = 1
  3256. endm
  3257. ifdef DEBUG
  3258. ifdef profileall
  3259. ?ProfileHeader_BeginProc macro PL, filename
  3260. ifndef _&filename&__proc_list
  3261. _&filename&__proc_list = 0
  3262. PUBLIC _&filename&__proc_list
  3263. endif
  3264. dd OFFSET32 _&filename&__proc_list
  3265. PL dd 0
  3266. _&filename&__proc_list = PL
  3267. endm
  3268. endif
  3269. IncProfileCount macro
  3270. if ??_service OR ??_profile
  3271. inc dword ptr [??_name-4]
  3272. else
  3273. ifndef profileall
  3274. .err <IncProfileCount can be used only in services.>
  3275. endif
  3276. endif
  3277. endm
  3278. else
  3279. IncProfileCount macro
  3280. endm
  3281. endif
  3282. ;*** ArgVar - declares stack arguments
  3283. ;
  3284. ; Usage:
  3285. ;
  3286. ; name = name of argument.
  3287. ; length = a numeric expression denoting the size (in bytes)
  3288. ; of the argument. The symbols BYTE, WORD, and DWORD
  3289. ; are synonyms for 1, 2, and 4 respectively.
  3290. ; NB! All arguments sizes are rounded up to the nearest
  3291. ; multiple of 4.
  3292. ; used = usually blank, but can be the symbol NOTUSED
  3293. ; to indicate that the argument will not be used
  3294. ; by the procedure.
  3295. ;
  3296. ArgVar macro name,length,used
  3297. ??_numargs = ??_numargs + 1
  3298. if ??_pcall
  3299. ?mkarg <name>, <length>, <used>, %??_numargs
  3300. else
  3301. ?arg <name>, <length>, <used>
  3302. endif
  3303. ??_procflags = ??_procflags OR ??_pf_Check
  3304. endm
  3305. ?mkarg macro name, length, used, num
  3306. .xcref ?MKA&num
  3307. ?deflocal <name>
  3308. ?MKA&num &macro
  3309. ?argvar <name>, <length>, <used>
  3310. &endm
  3311. ??_aframe = ??_aframe + 4
  3312. endm
  3313. .xcref ?mkarg
  3314. ?argvar macro name,length,used
  3315. local a
  3316. a = ??_taframe
  3317. ??_aframe = ??_aframe + 4
  3318. ??_taframe = ??_taframe + 4
  3319. ifidni <length>,<BYTE>
  3320. ?setname <name>, <byte ptr [??_basereg+??_initaframe+a]>, <used>
  3321. elseifidni <length>,<WORD>
  3322. ?setname <name>, <word ptr [??_basereg+??_initaframe+a]>, <used>
  3323. elseifidni <length>,<DWORD>
  3324. ?setname <name>, <dword ptr [??_basereg+??_initaframe+a]>, <used>
  3325. ?setname <name&l>,<word ptr [??_basereg+??_initaframe+a]>, <used>
  3326. ?setname <name&ll>,<byte ptr [??_basereg+??_initaframe+a]>, <used>
  3327. ?setname <name&lh>,<byte ptr [??_basereg+??_initaframe+a+1]>, <used>
  3328. ?setname <name&h>,<word ptr [??_basereg+??_initaframe+a+2]>, <used>
  3329. ?setname <name&hl>,<byte ptr [??_basereg+??_initaframe+a+2]>, <used>
  3330. ?setname <name&hh>,<byte ptr [??_basereg+??_initaframe+a+3]>, <used>
  3331. else
  3332. ??_aframe = ??_aframe - 4 + ((length + 3)/4)*4
  3333. ??_taframe = ??_taframe - 4 + ((length + 3)/4)*4
  3334. ?setname <name>, <[??_basereg+??_initaframe+a]>, <used>
  3335. endif
  3336. endm
  3337. ?arg macro name,length,used
  3338. if ??_fastcall
  3339. if ??_numargs le 2
  3340. if length gt 4
  3341. .err <First 2 parameters are dwords (ecx,edx) for fastcall functions>
  3342. endif
  3343. ??_aframe = ??_aframe + 4
  3344. if ??_numargs eq 1
  3345. ?merge ecx_,name,,,equ,ecx
  3346. else
  3347. ?merge edx_,name,,,equ,edx
  3348. endif
  3349. else
  3350. ?argvar name, length, used
  3351. endif
  3352. else
  3353. ?argvar name, length, used
  3354. endif
  3355. endm
  3356. ;*** ?setname - optionally creates the name of an ArgVar
  3357. ;
  3358. ; If <used> is <NOTUSED>, then the name is defined to something
  3359. ; bogus.
  3360. ?setname macro name, value, used
  3361. ?deflocal <name>
  3362. ifidni <used>, <NOTUSED>
  3363. name equ _inaccessible_NOTUSED_
  3364. else
  3365. name equ value
  3366. ??_procflags = ??_procflags OR ??_pf_ArgsUsed OR ??_pf_Check
  3367. endif
  3368. endm
  3369. ;*** LocalVar - declares local stack variables
  3370. ;
  3371. ; Usage:
  3372. ;
  3373. ; name = name of local variable
  3374. ; length = a numeric expression denoting the size (in bytes)
  3375. ; of the argument. The symbols BYTE, WORD, and DWORD
  3376. ; are synonyms for 1, 2, and 4 respectively.
  3377. ; NB! All arguments sizes are rounded up to the nearest
  3378. ; multiple of 4 (unless PACK is indicated)
  3379. ; flag = usually blank, but can be the symbol PACK
  3380. ; to suppress the usual padding and aligning of variables
  3381. ; PACK is typically used when declaring a bunch of
  3382. ; byte or word variables. Make sure that the total
  3383. ; size of PACKed variables is a multiple of 4.
  3384. ;
  3385. LocalVar macro name,length,flag
  3386. local a
  3387. ??_numlocals = ??_numlocals + 1
  3388. ??_pad = 1
  3389. ifidni <flag>, <PACK>
  3390. ??_pad = 0
  3391. endif
  3392. ifidni <length>,<BYTE>
  3393. ??_frame = ??_frame + 1 + 3 * ??_pad
  3394. a = ??_frame
  3395. ?deflocal <name>
  3396. name equ byte ptr [??_basereg-a]
  3397. elseifidni <length>,<WORD>
  3398. ??_frame = ??_frame + 2 + 2 * ??_pad
  3399. a = ??_frame
  3400. ?deflocal <name>
  3401. name equ word ptr [??_basereg-a]
  3402. elseifidni <length>,<DWORD>
  3403. ??_frame = ??_frame + 4
  3404. a = ??_frame
  3405. ?deflocal <name, name&l, name&ll, name&lh, name&h, name&hl, name&hh>
  3406. name equ dword ptr [??_basereg-a]
  3407. name&l equ word ptr [??_basereg-a]
  3408. name&ll equ byte ptr [??_basereg-a]
  3409. name&lh equ byte ptr [??_basereg-a+1]
  3410. name&h equ word ptr [??_basereg-a+2]
  3411. name&hl equ byte ptr [??_basereg-a+2]
  3412. name&hh equ byte ptr [??_basereg-a+3]
  3413. else
  3414. ??_frame = ??_frame + ((length + 3)/4)*4
  3415. a = ??_frame
  3416. ?deflocal <name>
  3417. name equ [??_basereg-a]
  3418. endif
  3419. ??_procflags = ??_procflags OR ??_pf_Check
  3420. endm
  3421. ?deflocal macro name
  3422. irp nm, <name>
  3423. ??_numlocalsymbols = ??_numlocalsymbols + 1
  3424. ?dodeflocal <nm>, %(??_numlocalsymbols)
  3425. endm
  3426. endm
  3427. .xcref ?deflocal
  3428. ?dodeflocal macro name, num
  3429. .xcref ?LOC&num
  3430. ?LOC&num &macro
  3431. name equ <__inaccessible__NOTINSCOPE__>
  3432. &endm
  3433. endm
  3434. .xcref ?dodeflocal
  3435. ;*** EnterProc - generates stack frame on entry
  3436. EnterProc macro
  3437. .errnz ??_frame and 3, <Total size of local variables not a multiple of 4.>
  3438. if ??_scall
  3439. if ??_public
  3440. ifdef Not_VxD
  3441. ?merge %??_name,@,%(??_aframe),,label,near
  3442. ?merge public,,,,C,%??_name,@,%(??_aframe)
  3443. else
  3444. ?merge _,%??_name,@,%(??_aframe),label,near
  3445. ?merge public,,,,,_,%??_name,@,%(??_aframe)
  3446. endif
  3447. endif
  3448. ?_BeginProc_Debug_Prologue
  3449. endif
  3450. if ??_fastcall
  3451. if ??_public
  3452. ifdef Not_VxD
  3453. ?merge %??_name,@,%(??_aframe),,label,near
  3454. ?merge public,,,,C,%??_name,@,%(??_aframe)
  3455. else
  3456. ?merge @,%??_name,@,%(??_aframe),label,near
  3457. ?merge public,,,,,@,%??_name,@,%(??_aframe)
  3458. endif
  3459. endif
  3460. ?_BeginProc_Debug_Prologue
  3461. endif
  3462. if ??_pcall
  3463. ??_aframe = 0
  3464. ?count = ??_numargs
  3465. rept ??_numargs
  3466. ?invprg <?MKA>,%?count
  3467. ?count = ?count - 1
  3468. endm
  3469. endif
  3470. ??_fleave = FALSE
  3471. if ??_esp
  3472. if ??_frame
  3473. sub esp, ??_frame
  3474. ??_pushed = ??_pushed + ??_frame
  3475. ??_fleave = VMM_TRUE
  3476. endif
  3477. else
  3478. if ??_frame eq 0
  3479. if (??_taframe eq 0) OR ((??_procflags AND ??_pf_ArgsUsed) EQ 0)
  3480. ifdef DEBUG
  3481. push ebp
  3482. mov ebp,esp
  3483. ??_fleave = VMM_TRUE
  3484. endif
  3485. else
  3486. push ebp
  3487. mov ebp,esp
  3488. ??_fleave = VMM_TRUE
  3489. endif
  3490. else
  3491. enter ??_frame, 0
  3492. ??_fleave = VMM_TRUE
  3493. endif
  3494. endif
  3495. ??_procflags = ??_procflags OR ??_pf_Entered
  3496. endm
  3497. ;*** LeaveProc - removes stack frame on exit
  3498. ;
  3499. ; NOTE: If there are localvar and ESP kind of stack frame
  3500. ; LeaveProc will destroy flags unless the "PRESERVE_FLAGS"
  3501. ; flag is given. PRESERVE_FLAGS generates bigger, slower
  3502. ; code, so use it only when necessary.
  3503. ;
  3504. ; WARNING: For "ESP" type stack frames, this macro DOES NOT adjust
  3505. ; the internal stack depth for the local frame. This is
  3506. ; to allow jumping around the LeaveProc/Return to code
  3507. ; after the LeaveProc/Return to use args/local variables,
  3508. ; but code that uses the stack frame executed after the
  3509. ; LeaveProc won't work.
  3510. LeaveProc macro flags
  3511. if ??_fleave
  3512. if ??_esp
  3513. ifidni <flags>,<PRESERVE_FLAGS>
  3514. lea esp,[esp + ??_frame]
  3515. else
  3516. add esp,??_frame
  3517. endif
  3518. else
  3519. leave
  3520. endif
  3521. endif
  3522. ??_procflags = ??_procflags OR ??_pf_Left
  3523. endm
  3524. ;*** Return - return appropriately from a procedure
  3525. ;
  3526. ; For "ccall" functions it's just a ret; for "pcall" and "scall"
  3527. ; it cleans the parameters off.
  3528. ;
  3529. Return macro
  3530. if ??_cleanoff OR ??_w32svc
  3531. if ??_w32svc AND (??_taframe LT 8)
  3532. ret 8
  3533. else
  3534. ret ??_taframe
  3535. endif
  3536. else
  3537. ret
  3538. endif
  3539. ??_procflags = ??_procflags OR ??_pf_Returned
  3540. endm
  3541. ;*** EndProc - end the procedure
  3542. ;
  3543. EndProc macro Name, Flag
  3544. Name endp ;; Masm will provide error msg for us
  3545. if ??_w32svc
  3546. if ??_taframe lt 8
  3547. cparm&Name equ 0
  3548. else
  3549. cparm&Name equ (??_taframe/4 - 2)
  3550. endif
  3551. endif
  3552. if ??_procflags AND ??_pf_Left
  3553. if ??_fleave
  3554. if ??_esp
  3555. ??_pushed = ??_pushed - ??_frame
  3556. endif
  3557. endif
  3558. endif
  3559. ifdifi <Flag>,<NOCHECK>
  3560. if ??_pushed ne 0
  3561. %out Warning: stack not balanced in Name
  3562. endif
  3563. if ??_procflags AND ??_pf_Check
  3564. ife ??_procflags AND ??_pf_Entered
  3565. %out Warning: ArgVar/LocalVar without EnterProc in Name
  3566. endif
  3567. ife ??_procflags AND ??_pf_Left
  3568. %out Warning: ArgVar/LocalVar without LeaveProc in Name
  3569. endif
  3570. ife ??_procflags AND ??_pf_Returned
  3571. %out Warning: ArgVar/LocalVar without Return in Name
  3572. endif
  3573. endif
  3574. endif
  3575. ifdifi <Flag>,<KEEPFRAMEVARS>
  3576. ?count = 0
  3577. rept ??_numlocalsymbols
  3578. ?count = ?count + 1
  3579. ?invprg <?LOC>,%?count
  3580. endm
  3581. endif
  3582. ??_ends
  3583. ??_ends equ <>
  3584. endm
  3585. ;*** cCall - "C" call
  3586. ;
  3587. ; Arguments pushed in "C" order, caller cleans stack
  3588. ;
  3589. ; USES: Flags.
  3590. cCall macro name, arglst, flags
  3591. ife .TYPE name
  3592. CondExtern name, near
  3593. endif
  3594. ifdef ??_nonstandardccall_&name
  3595. PushCParams <arglst>, <FAST>
  3596. else
  3597. PushCParams <arglst>, <flags>
  3598. endif
  3599. call name
  3600. ifdef ??_nonstandardccall_&name
  3601. ClearCParams PRESERVE_FLAGS
  3602. else
  3603. ClearCParams <flags>
  3604. endif
  3605. endm
  3606. .xcref cCall
  3607. ;*** pCall - pascal call
  3608. ;
  3609. ; Arguments pushed in pascal order, callee cleans stack
  3610. ;
  3611. pCall macro name, arglst
  3612. local ??saved
  3613. ife .TYPE name
  3614. ?toupper name
  3615. else
  3616. ?upper equ <name>
  3617. endif
  3618. CondExtern %?upper, near
  3619. ??saved = ??_pushed
  3620. irp x,<arglst>
  3621. push x
  3622. ??_pushed = ??_pushed + 4
  3623. endm
  3624. call ?upper
  3625. ??_pushed = ??saved
  3626. endm
  3627. .xcref pCall
  3628. ;*** sCall - standard call
  3629. ;
  3630. ; Arguments pushed in "C" order, callee cleans stack,
  3631. ; @argc appended to name
  3632. ;
  3633. sCall macro name, arglst
  3634. local ??saved
  3635. ??saved = ??_pushed
  3636. PushCParams <arglst>
  3637. ?scall _, name, %(??_argc * 4)
  3638. ??_pushed = ??saved
  3639. endm
  3640. .xcref sCall
  3641. ;*** fCall - fastcall call
  3642. ;
  3643. ; Arguments pushed in "C" order (except first two parms,
  3644. ; which are passed in ECX and EDX), callee cleans stack, and
  3645. ; @argc appended to name.
  3646. ;
  3647. ; The only useful value for flags is PRESERVE_FLAGS,
  3648. ; which can also be achieved by simply declaring the function
  3649. ; as non-standard, like so:
  3650. ;
  3651. ; DeclareNonstandardCcallService <functionname>
  3652. ;
  3653. fCall macro name, arglst, flags
  3654. local ??saved
  3655. ??saved = ??_pushed
  3656. ife .TYPE name
  3657. CondExtern name, near
  3658. endif
  3659. PushCParams <arglst>, <FASTCALL>
  3660. ?scall @, name, %(??_argc * 4)
  3661. ifdef ??_nonstandardccall_&name
  3662. ClearCParams PRESERVE_FLAGS
  3663. else
  3664. ClearCParams <flags>
  3665. endif
  3666. ??_pushed = ??saved
  3667. endm
  3668. .xcref fCall
  3669. ;*** iCall - internal routine call
  3670. ;
  3671. ; Set to whatever type we want to use as a default.
  3672. iCall equ <sCall>
  3673. ;*** PushCParams
  3674. ;
  3675. ; Processes argument list
  3676. ;
  3677. ; arglist = <arg1, arg2, arg3, ...>
  3678. ; flags = the word SMALL if we should prefer size over speed
  3679. ; the word FAST if we should prefer speed over size
  3680. ;
  3681. ; The default flag is SMALL, unless the current procedure
  3682. ; is High_Freq, in which case we default to FAST.
  3683. ;
  3684. ; To disable this optimization, define the symbol NONSTANDARD_CCALL.
  3685. ;
  3686. IFNDEF STANDARD_CCALL
  3687. NONSTANDARD_CCALL = 1 ;; disabled by default for now
  3688. ENDIF
  3689. PushCParams macro arglst, flags
  3690. LOCAL ??_pushedargs
  3691. ??_argc = 0 ;; number of dwords on stack (global)
  3692. IFDEF NONSTANDARD_CCALL
  3693. ??_popargs = 0 ;; establish default
  3694. ELSE
  3695. ??_popargs = ??_align EQ 0 ;; establish default
  3696. ENDIF
  3697. ifidni <flags>, <SMALL>
  3698. ??_popargs = 1 ;; size, not speed
  3699. elseifidni <flags>, <FAST>
  3700. ??_popargs = 0 ;; speed, not size
  3701. elseifidni <flags>, <FASTCALL>
  3702. ??_popargs = 0 ;; speed, not size
  3703. endif
  3704. irp x,<arglst>
  3705. ??_argc = ??_argc + 1
  3706. ifidni <flags>, <FASTCALL>
  3707. if ??_argc eq 1
  3708. ifdifi <x>, <ecx>
  3709. .err <first parameter must be ECX for fastcall functions>
  3710. endif
  3711. elseif ??_argc eq 2
  3712. ifdifi <x>, <edx>
  3713. .err <first parameter must be EDX for fastcall functions>
  3714. endif
  3715. else
  3716. ?marg <x>,%??_argc
  3717. endif
  3718. else
  3719. ?marg <x>,%??_argc
  3720. endif
  3721. endm
  3722. ?count = ??_argc
  3723. ifidni <flags>, <FASTCALL>
  3724. ??_pushedargs = ??_argc-2
  3725. else
  3726. ??_pushedargs = ??_argc
  3727. endif
  3728. if ??_pushedargs GT 0
  3729. rept ??_argc
  3730. ?invprg <?AM>,%?count
  3731. ?count = ?count - 1
  3732. endm
  3733. endif
  3734. endm
  3735. ;*** ClearCParams
  3736. ;
  3737. ; Processes stack clean up
  3738. ;
  3739. ; This routine will trade size for speed (if requested)
  3740. ; by using `pop ecx' to clean off one or two arguments.
  3741. ; This relies on the convention that C-call routines do
  3742. ; not return useful information in ECX.
  3743. ;
  3744. ; To disable this optimization, define the symbol NONSTANDARD_CCALL.
  3745. ;
  3746. ; If flags must be preserved, pass PRESERVE_FLAGS as an argument.
  3747. ; This will generate bigger, slower code, so use it only when
  3748. ; necessary.
  3749. ClearCParams macro fPreserveFlags
  3750. if ??_argc ne 0
  3751. if (??_popargs) AND (??_argc LE 2)
  3752. rept ??_argc
  3753. pop ecx
  3754. endm
  3755. elseifidni <fPreserveFlags>, <PRESERVE_FLAGS>
  3756. lea esp, [esp][??_argc * 4]
  3757. else
  3758. add esp,??_argc * 4
  3759. endif
  3760. endif
  3761. ??_pushed = ??_pushed - (??_argc * 4)
  3762. endm
  3763. ; Makes a macro that will push argment when invoke - used by cCall only
  3764. ?marg macro name, num
  3765. .xcref
  3766. .xcref ?AM&num
  3767. .cref
  3768. ?AM&num &macro
  3769. push name
  3770. ??_pushed = ??_pushed + 4
  3771. &endm
  3772. endm
  3773. .xcref ?marg
  3774. ; Concatenates, invokes and purges a macro name - used by PushCParams
  3775. ?invprg macro name1, name2
  3776. name1&name2
  3777. purge name1&name2
  3778. endm
  3779. .xcref ?invprg
  3780. ; Calls a concatenated standard call name and makes it external
  3781. ?scall macro prefix, name1, name2
  3782. CondExtern prefix&name1&@&name2, near
  3783. call prefix&name1&@&name2
  3784. endm
  3785. .xcref ?scall
  3786. ; Equates name to a name
  3787. ?merge macro l1, l2, l3, l4, op, r1, r2, r3, r4, r5, r6, r7, r8, r9
  3788. l1&l2&l3&l4 op r1&r2&r3&r4&r5&r6&r7&r8&r9
  3789. endm
  3790. ; Converts string to upper-case, returned in ?upper
  3791. ?toupper macro s
  3792. ?upper equ <>
  3793. irpc x,<s>
  3794. if '&x' GE 'a'
  3795. if '&x' LE 'z'
  3796. ?t1 substr <ABCDEFGHIJKLMNOPQRSTUVWXYZ>,'&x'-'a'+1,1
  3797. ?upper catstr ?upper,?t1
  3798. else
  3799. ?upper catstr ?upper,<&x>
  3800. endif
  3801. else
  3802. ?upper catstr ?upper,<&x>
  3803. endif
  3804. endm
  3805. endm
  3806. .xcref
  3807. ;*** CondExtern - Make name external if not already defined
  3808. ;
  3809. ; This operation is quite different between MASM 5.1 and 6.0.
  3810. ;
  3811. CondExtern macro name,dist
  3812. ifdef MASM6
  3813. ifndef name
  3814. externdef name:dist
  3815. endif
  3816. else
  3817. if2
  3818. ifndef name
  3819. extrn name:dist
  3820. endif
  3821. endif
  3822. endif
  3823. endm
  3824. ;*** SaveReg - Save register, "fd" pushes flags, "ad" pushes all
  3825. SaveReg macro reglist ;; push those registers
  3826. irp reg,<reglist>
  3827. ifidni <reg>, <fd>
  3828. pushfd
  3829. ??_pushed = ??_pushed + 4
  3830. else
  3831. ifidni <reg>, <ad>
  3832. pushad
  3833. ??_pushed = ??_pushed + SIZE Pushad_Struc
  3834. else
  3835. push reg
  3836. ??_pushed = ??_pushed + 4
  3837. endif
  3838. endif
  3839. endm
  3840. endm
  3841. ;*** RestoreReg - Restore register, "fd" pops flags, "ad" pops all
  3842. ;
  3843. ; Note that registers must be restored in reverse order that they
  3844. ; were saved.
  3845. ;
  3846. RestoreReg macro reglist ;; pop those registers
  3847. irp reg,<reglist>
  3848. ifidni <reg>, <fd>
  3849. popfd
  3850. ??_pushed = ??_pushed - 4
  3851. else
  3852. ifidni <reg>, <ad>
  3853. popad
  3854. ??_pushed = ??_pushed - SIZE Pushad_Struc
  3855. else
  3856. pop reg
  3857. ??_pushed = ??_pushed - 4
  3858. endif
  3859. endif
  3860. endm
  3861. endm
  3862. */
  3863. #ifdef DEBUG
  3864. /******************************************************************************
  3865. * The following macros are for enabling procedure call profile counting
  3866. * of VxD's written in assembler.
  3867. *
  3868. * Begin_Profile_List needs to be used in the file that declares the device
  3869. * immediately after the Declare_Virtual_Device line. Then one Profile_Link
  3870. * line is required for each individual source file. The list is ended with
  3871. * the End_Profile_List macro. Profiling only works for debug builds and
  3872. * the sources must all be built with "-Dprofileall" masm switch.
  3873. ******************************************************************************/
  3874. /* ASM
  3875. Begin_Profile_List macro devname
  3876. ifdef profileall
  3877. VxD_DATA_SEG
  3878. db 'PROCLIST'
  3879. PUBLIC devname&_Proc_Profile_List
  3880. devname&_Proc_Profile_List label dword
  3881. endif
  3882. endm
  3883. Profile_Link macro modname
  3884. ifdef profileall
  3885. ifdifi <modname>,@filename
  3886. EXTRN _&modname&__proc_list:near
  3887. endif
  3888. dd OFFSET32 _&modname&__proc_list
  3889. endif
  3890. endm
  3891. End_Profile_List macro
  3892. ifdef profileall
  3893. dd 0
  3894. VxD_DATA_ENDS
  3895. endif
  3896. endm
  3897. */
  3898. #endif
  3899. #ifndef Not_VxD
  3900. /******************************************************************************
  3901. * S C H E D U L E R B O O S T V A L U E S
  3902. *****************************************************************************/
  3903. #define RESERVED_LOW_BOOST 0x00000001
  3904. #define CUR_RUN_VM_BOOST 0x00000004
  3905. #define LOW_PRI_DEVICE_BOOST 0x00000010
  3906. #define HIGH_PRI_DEVICE_BOOST 0x00001000
  3907. #define CRITICAL_SECTION_BOOST 0x00100000
  3908. #define TIME_CRITICAL_BOOST 0x00400000
  3909. #define RESERVED_HIGH_BOOST 0x40000000
  3910. /******************************************************************************
  3911. * 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
  3912. *****************************************************************************/
  3913. #define PEF_WAIT_FOR_STI_BIT 0
  3914. #define PEF_WAIT_FOR_STI (1 << PEF_WAIT_FOR_STI_BIT)
  3915. #define PEF_WAIT_NOT_CRIT_BIT 1
  3916. #define PEF_WAIT_NOT_CRIT (1 << PEF_WAIT_NOT_CRIT_BIT)
  3917. #define PEF_DONT_UNBOOST_BIT 2
  3918. #define PEF_DONT_UNBOOST (1 << PEF_DONT_UNBOOST_BIT)
  3919. #define PEF_ALWAYS_SCHED_BIT 3
  3920. #define PEF_ALWAYS_SCHED (1 << PEF_ALWAYS_SCHED_BIT)
  3921. #define PEF_TIME_OUT_BIT 4
  3922. #define PEF_TIME_OUT (1 << PEF_TIME_OUT_BIT)
  3923. #define PEF_WAIT_NOT_HW_INT_BIT 5
  3924. #define PEF_WAIT_NOT_HW_INT (1 << PEF_WAIT_NOT_HW_INT_BIT)
  3925. #define PEF_WAIT_NOT_NESTED_EXEC_BIT 6
  3926. #define PEF_WAIT_NOT_NESTED_EXEC (1 << PEF_WAIT_NOT_NESTED_EXEC_BIT)
  3927. #define PEF_WAIT_IN_PM_BIT 7
  3928. #define PEF_WAIT_IN_PM (1 << PEF_WAIT_IN_PM_BIT)
  3929. #define PEF_THREAD_EVENT_BIT 8
  3930. #define PEF_THREAD_EVENT (1 << PEF_THREAD_EVENT_BIT)
  3931. #define PEF_WAIT_FOR_THREAD_STI_BIT 9
  3932. #define PEF_WAIT_FOR_THREAD_STI (1 << PEF_WAIT_FOR_THREAD_STI_BIT)
  3933. #define PEF_RING0_EVENT_BIT 10
  3934. #define PEF_RING0_EVENT (1 << PEF_RING0_EVENT_BIT)
  3935. #define PEF_WAIT_CRIT_BIT 11
  3936. #define PEF_WAIT_CRIT (1 << PEF_WAIT_CRIT_BIT)
  3937. #define PEF_WAIT_CRIT_VM_BIT 12
  3938. #define PEF_WAIT_CRIT_VM (1 << PEF_WAIT_CRIT_VM_BIT)
  3939. #define PEF_PROCESS_LAST_BIT 13
  3940. #define PEF_PROCESS_LAST (1 << PEF_PROCESS_LAST_BIT)
  3941. #define PEF_WAIT_PREEMPTABLE_BIT 14
  3942. #define PEF_WAIT_PREEMPTABLE (1 << PEF_WAIT_PREEMPTABLE_BIT)
  3943. #define PEF_WAIT_FOR_PASSIVE_BIT 15
  3944. #define PEF_WAIT_FOR_PASSIVE (1 << PEF_WAIT_FOR_PASSIVE_BIT)
  3945. //
  3946. // The next two are equivalent of SHELL_Call_At_Appy_Time and ExQueueWorkItem,
  3947. // they are mostly to be used by _Set_Global_Time_Out_Ex. No other flag can be
  3948. // set with them. Note that the dispatching of the callback of these two new
  3949. // PEF (with both Call_Restricted_Event and _Set_Global_Time_Out_Ex) follow
  3950. // the original convention but EDX (the ref data) is CDECL pushed/pop on the
  3951. // stack, so that the callback function can be a standard
  3952. // VOID CDECL FOO(ULONG BAR);
  3953. //
  3954. #define PEF_WAIT_FOR_APPY_BIT 16
  3955. #define PEF_WAIT_FOR_APPY (1 << PEF_WAIT_FOR_APPY_BIT)
  3956. #define PEF_WAIT_FOR_WORKER_BIT 17
  3957. #define PEF_WAIT_FOR_WORKER (1 << PEF_WAIT_FOR_WORKER_BIT)
  3958. // synonyms for event restrictions above
  3959. #define PEF_WAIT_NOT_TIME_CRIT_BIT PEF_WAIT_NOT_HW_INT_BIT
  3960. #define PEF_WAIT_NOT_TIME_CRIT PEF_WAIT_NOT_HW_INT
  3961. #define PEF_WAIT_NOT_PM_LOCKED_STACK_BIT PEF_WAIT_NOT_NESTED_EXEC_BIT
  3962. #define PEF_WAIT_NOT_PM_LOCKED_STACK PEF_WAIT_NOT_NESTED_EXEC
  3963. //
  3964. // If you may want to call CONFIGMG synchronously at some point.
  3965. //
  3966. #define PEF_WAIT_FOR_CONFIGMG_CALLABLE PEF_WAIT_FOR_WORKER
  3967. //
  3968. // If you will want to call CONFIGMG synchronously (slower callback, but no
  3969. // context switch in CONFIGMG).
  3970. //
  3971. #define PEF_WAIT_FOR_CONFIGMG_QUICK PEF_WAIT_FOR_APPY
  3972. /******************************************************************************
  3973. * 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,
  3974. * E N T E R _ M U T E X
  3975. * A N D W A I T _ S E M A P H O R E
  3976. *****************************************************************************/
  3977. #define BLOCK_SVC_INTS_BIT 0
  3978. #define BLOCK_SVC_INTS (1 << BLOCK_SVC_INTS_BIT)
  3979. #define BLOCK_SVC_IF_INTS_LOCKED_BIT 1
  3980. #define BLOCK_SVC_IF_INTS_LOCKED (1 << BLOCK_SVC_IF_INTS_LOCKED_BIT)
  3981. #define BLOCK_ENABLE_INTS_BIT 2
  3982. #define BLOCK_ENABLE_INTS (1 << BLOCK_ENABLE_INTS_BIT)
  3983. #define BLOCK_POLL_BIT 3
  3984. #define BLOCK_POLL (1 << BLOCK_POLL_BIT)
  3985. #define BLOCK_THREAD_IDLE_BIT 4
  3986. #define BLOCK_THREAD_IDLE (1 << BLOCK_THREAD_IDLE_BIT)
  3987. #define BLOCK_FORCE_SVC_INTS_BIT 5
  3988. #define BLOCK_FORCE_SVC_INTS (1 << BLOCK_FORCE_SVC_INTS_BIT)
  3989. /******************************************************************************
  3990. * The following structures are pointed to by EBP when VxD routines are
  3991. * entered, both for VxD control calls and traps(I/O traps, software INT
  3992. * traps, etc.). The first structure as DWORD values, the second WORD
  3993. * values and the last has BYTE values.
  3994. *****************************************************************************/
  3995. struct Client_Reg_Struc {
  3996. ULONG Client_EDI; /* Client's EDI */
  3997. ULONG Client_ESI; /* Client's ESI */
  3998. ULONG Client_EBP; /* Client's EBP */
  3999. ULONG Client_res0; /* ESP at pushall */
  4000. ULONG Client_EBX; /* Client's EBX */
  4001. ULONG Client_EDX; /* Client's EDX */
  4002. ULONG Client_ECX; /* Client's ECX */
  4003. ULONG Client_EAX; /* Client's EAX */
  4004. ULONG Client_Error; /* Dword error code */
  4005. ULONG Client_EIP; /* EIP */
  4006. USHORT Client_CS; /* CS */
  4007. USHORT Client_res1; /* (padding) */
  4008. ULONG Client_EFlags; /* EFLAGS */
  4009. ULONG Client_ESP; /* ESP */
  4010. USHORT Client_SS; /* SS */
  4011. USHORT Client_res2; /* (padding) */
  4012. USHORT Client_ES; /* ES */
  4013. USHORT Client_res3; /* (padding) */
  4014. USHORT Client_DS; /* DS */
  4015. USHORT Client_res4; /* (padding) */
  4016. USHORT Client_FS; /* FS */
  4017. USHORT Client_res5; /* (padding) */
  4018. USHORT Client_GS; /* GS */
  4019. USHORT Client_res6; /* (padding) */
  4020. ULONG Client_Alt_EIP;
  4021. USHORT Client_Alt_CS;
  4022. USHORT Client_res7;
  4023. ULONG Client_Alt_EFlags;
  4024. ULONG Client_Alt_ESP;
  4025. USHORT Client_Alt_SS;
  4026. USHORT Client_res8;
  4027. USHORT Client_Alt_ES;
  4028. USHORT Client_res9;
  4029. USHORT Client_Alt_DS;
  4030. USHORT Client_res10;
  4031. USHORT Client_Alt_FS;
  4032. USHORT Client_res11;
  4033. USHORT Client_Alt_GS;
  4034. USHORT Client_res12;
  4035. };
  4036. struct Client_Word_Reg_Struc {
  4037. USHORT Client_DI; /* Client's DI */
  4038. USHORT Client_res13; /* (padding) */
  4039. USHORT Client_SI; /* Client's SI */
  4040. USHORT Client_res14; /* (padding) */
  4041. USHORT Client_BP; /* Client's BP */
  4042. USHORT Client_res15; /* (padding) */
  4043. ULONG Client_res16; /* ESP at pushall */
  4044. USHORT Client_BX; /* Client's BX */
  4045. USHORT Client_res17; /* (padding) */
  4046. USHORT Client_DX; /* Client's DX */
  4047. USHORT Client_res18; /* (padding) */
  4048. USHORT Client_CX; /* Client's CX */
  4049. USHORT Client_res19; /* (padding) */
  4050. USHORT Client_AX; /* Client's AX */
  4051. USHORT Client_res20; /* (padding) */
  4052. ULONG Client_res21; /* Dword error code */
  4053. USHORT Client_IP; /* Client's IP */
  4054. USHORT Client_res22; /* (padding) */
  4055. ULONG Client_res23; /* CS */
  4056. USHORT Client_Flags; /* Client's flags (low) */
  4057. USHORT Client_res24; /* (padding) */
  4058. USHORT Client_SP; /* SP */
  4059. USHORT Client_res25;
  4060. ULONG Client_res26[5];
  4061. USHORT Client_Alt_IP;
  4062. USHORT Client_res27;
  4063. ULONG Client_res28;
  4064. USHORT Client_Alt_Flags;
  4065. USHORT Client_res29;
  4066. USHORT Client_Alt_SP;
  4067. };
  4068. struct Client_Byte_Reg_Struc {
  4069. ULONG Client_res30[4]; /* EDI, ESI, EBP, ESP at pushall */
  4070. UCHAR Client_BL; /* Client's BL */
  4071. UCHAR Client_BH; /* Client's BH */
  4072. USHORT Client_res31;
  4073. UCHAR Client_DL; /* Client's DL */
  4074. UCHAR Client_DH; /* Client's DH */
  4075. USHORT Client_res32;
  4076. UCHAR Client_CL; /* Client's CL */
  4077. UCHAR Client_CH; /* Client's CH */
  4078. USHORT Client_res33;
  4079. UCHAR Client_AL; /* Client's AL */
  4080. UCHAR Client_AH; /* Client's AH */
  4081. };
  4082. typedef union tagCLIENT_STRUC { /* */
  4083. struct Client_Reg_Struc CRS;
  4084. struct Client_Word_Reg_Struc CWRS;
  4085. struct Client_Byte_Reg_Struc CBRS;
  4086. } CLIENT_STRUCT;
  4087. typedef struct Client_Reg_Struc CRS;
  4088. typedef CRS *PCRS;
  4089. #if 0 /* causes problems with MASM 6 */
  4090. /* ASM
  4091. .ERRNZ Client_SP - Client_ESP
  4092. .ERRNZ Client_AL - Client_EAX
  4093. */
  4094. #endif
  4095. #define DYNA_LINK_INT 0x20
  4096. /* ASM
  4097. ;*** DeclareNonstandardCcallService
  4098. ;
  4099. ; Declare services as conforming to the C calling convention
  4100. ; for parameter-passing, but *not* conforming to the C calling
  4101. ; convention for register usage.
  4102. ;
  4103. ; Services which do not use the C calling convention for
  4104. ; parameter-passing need not be declared as nonstandard.
  4105. ;
  4106. ; arglst - list of services to declare as nonstandard
  4107. ;
  4108. DeclareNonstandardCcallService macro arglst
  4109. irp x,<arglst>
  4110. ??_nonstandardccall_&&x = 1
  4111. endm
  4112. endm
  4113. ;
  4114. ; The following VMM services are nonstandard:
  4115. ; _BlockOnID and _LocalizeSprintf modify no registers except flags.
  4116. ; _SetLastV86Page modifies no registers except EAX and flags.
  4117. ;
  4118. DeclareNonstandardCcallService <_BlockOnID, _LocalizeSprintf>
  4119. DeclareNonstandardCcallService <_SetLastV86Page>
  4120. BeginDoc
  4121. ;******************************************************************************
  4122. ; The VMMCall and VxDCall macros provide a dynamic link to the VMM and VxD
  4123. ; service routines. For example:
  4124. ;
  4125. ; VMMCall Enable_VM_Ints ; Equivalent to STI in VM code
  4126. ;
  4127. ; mov eax,[My_IRQ_Handle]
  4128. ; VxDCall VPICD_Set_Int_Request ; Set IRQ for my device's interrupt
  4129. ;
  4130. ; Note that Enable_VM_Ints is defined in VMM.INC and VPICD_Set_Int_Request is
  4131. ; defined in VPICD.INC
  4132. ;
  4133. ;==============================================================================
  4134. EndDoc
  4135. BeginDoc
  4136. ;******************************************************************************
  4137. ; VxDCall
  4138. ;==============================================================================
  4139. ;
  4140. ; BlockOnID is always FAST because it doesn't
  4141. ; conform to the C calling convention. (It preserves
  4142. ; all registers.)
  4143. EndDoc
  4144. DefTable MACRO vt, vn
  4145. vt EQU <vn>
  4146. ENDM
  4147. GenDD2 MACRO vt, sn, jf
  4148. dd OFFSET32 vt[sn+jf]
  4149. ENDM
  4150. GenDD MACRO P, vid, snum, jflag
  4151. LOCAL vtable
  4152. IFDEF @@VxDName&vid
  4153. Deftable vtable, %@@VxDName&vid
  4154. EXTRN vtable:DWORD
  4155. GenDD2 %vtable, snum, jflag
  4156. ELSE
  4157. dd @@&P+jflag
  4158. ENDIF
  4159. ENDM
  4160. VxDCall MACRO P, Param, flags
  4161. ??_vxdid = (@@&P SHR 16)
  4162. ??_servicenum = (@@&P AND 0FFFFh)
  4163. ifdef ??_standardccall_&P
  4164. PushCParams <Param>, <FAST>
  4165. .errnz ??_argc ne ??_standardccall_&P, <wrong # of parameters passed to &P&>
  4166. else
  4167. ifdef ??_fastcall_&P
  4168. PushCParams <Param>, <FASTCALL>
  4169. .errnz ??_argc ne (??_fastcall_&P), <wrong # of parameters passed to fastcall function &P&>
  4170. else
  4171. ifdef ??_nonstandardccall_&P
  4172. PushCParams <Param>, <flags>
  4173. else
  4174. PushCParams <Param>, <FAST>
  4175. endif
  4176. endif
  4177. endif
  4178. int Dyna_Link_Int
  4179. GenDD P, %??_vxdid, %??_servicenum, 0
  4180. ifndef ??_standardccall_&P
  4181. ifndef ??_fastcall_&P
  4182. ifdef ??_nonstandardccall_&P
  4183. ClearCParams PRESERVE_FLAGS
  4184. else
  4185. ClearCParams
  4186. endif
  4187. else
  4188. if(??_argc gt 2)
  4189. ??_pushed = ??_pushed - ((??_argc - 2) * 4)
  4190. endif
  4191. endif
  4192. else
  4193. ??_pushed = ??_pushed - (??_argc * 4)
  4194. endif
  4195. ENDM
  4196. VxDJmp MACRO P, Param
  4197. ??_vxdid = (@@&P SHR 16)
  4198. ??_servicenum = (@@&P AND 0FFFFh)
  4199. ifdef ??_fastcall_&P
  4200. PushCParams <Param>, <FASTCALL>
  4201. .errnz ??_argc gt 2, <More than 2 parameters may not be passed to fastcall functions thru VxDJmp>
  4202. else
  4203. .errnb <Param>, <Parameters may not be passed to VxDJmp or VMMJmp>
  4204. endif
  4205. int Dyna_Link_Int
  4206. GenDD P, %??_vxdid, %??_servicenum, DL_Jmp_Mask
  4207. ENDM
  4208. DL_Jmp_Mask EQU 8000h
  4209. DL_Jmp_Bit EQU 0Fh
  4210. VMMCall MACRO P, Param
  4211. .ERRNZ (@@&P SHR 16) - VMM_DEVICE_ID
  4212. VxDCall <P>, <Param>
  4213. ENDM
  4214. VMMJmp MACRO P, Param
  4215. .ERRNZ (@@&P SHR 16) - VMM_DEVICE_ID
  4216. VxDJmp <P>, <Param>
  4217. ENDM
  4218. WDMCall MACRO P, Param, flags
  4219. ifdef ??_standardccall_&P
  4220. PushCParams <Param>, <FAST>
  4221. .errnz ??_argc ne ??_standardccall_&P, <wrong # of parameters passed to &P&>
  4222. else
  4223. ifdef ??_fastcall_&P
  4224. PushCParams <Param>, <FASTCALL>
  4225. .errnz ??_argc ne (??_fastcall_&P), <wrong # of parameters passed to fastcall function &P&>
  4226. else
  4227. ifdef ??_nonstandardccall_&P
  4228. PushCParams <Param>, <flags>
  4229. else
  4230. PushCParams <Param>, <FAST>
  4231. endif
  4232. endif
  4233. endif
  4234. mov eax,WDM@@&P
  4235. int WDM_DynaLink_Int
  4236. nop
  4237. nop
  4238. nop
  4239. ifndef ??_standardccall_&P
  4240. ifndef ??_fastcall_&P
  4241. ifdef ??_nonstandardccall_&P
  4242. ClearCParams PRESERVE_FLAGS
  4243. else
  4244. ClearCParams
  4245. endif
  4246. else
  4247. if(??_argc gt 2)
  4248. ??_pushed = ??_pushed - ((??_argc - 2) * 4)
  4249. endif
  4250. endif
  4251. else
  4252. ??_pushed = ??_pushed - (??_argc * 4)
  4253. endif
  4254. ENDM
  4255. WDMJmp MACRO P, Param
  4256. ifdef ??_fastcall_&P
  4257. PushCParams <Param>, <FASTCALL>
  4258. .errnz ??_argc gt 2, <More than 2 parameters may not be passed to fastcall functions thru VxDJmp>
  4259. else
  4260. .errnb <Param>, <Parameters may not be passed to WDMJmp>
  4261. endif
  4262. mov eax, WDM@@&P+WDM_DL_Jmp_Mask
  4263. int WDM_DynaLink_Int
  4264. nop
  4265. nop
  4266. nop
  4267. ENDM
  4268. WDM_DL_Jmp_Mask EQU 80000000h
  4269. WDM_DL_Jmp_Bit EQU 31
  4270. BeginDoc
  4271. ;******************************************************************************
  4272. ; Segment definition macros
  4273. ;
  4274. ; The segment definition macros are a convenience used in defining the
  4275. ; segments used by the device driver. They are:
  4276. ;VxD_INIT_CODE_SEG defines start of initialization code segment
  4277. ;VxD_INIT_CODE_ENDS defines end of initialization code segment
  4278. ;VxD_ICODE_SEG is an alias for VxD_INIT_CODE_SEG
  4279. ;VxD_ICODE_ENDS is an alias for VxD_INIT_CODE_ENDS
  4280. ;VxD_IDATA_SEG defines start of initialization data segment
  4281. ;VxD_IDATA_ENDS defines end of initialization data segment
  4282. ;VxD_CODE_SEG defines start of always present code segment
  4283. ;VxD_CODE_ENDS defines end of always present code segment
  4284. ;VxD_DATA_SEG defines start of always present data segment
  4285. ;VxD_DATA_ENDS defines end of always present data segment
  4286. ;VxD_LOCKED_CODE_SEG defines start of always present code segment
  4287. ;VxD_LOCKED_CODE_ENDS defines end of always present code segment
  4288. ;VxD_PAGEABLE_CODE_SEG defines start of swappable code segment
  4289. ;VxD_PAGEABLE_CODE_ENDS defines end of swappable code segment
  4290. ;VxD_DEBUG_ONLY_CODE_SEG defines code only loaded if debugger is present
  4291. ;VxD_DEBUG_ONLY_CODE_ENDS
  4292. ;VxD_DEBUG_ONLY_DATA_SEG defines data only loaded if debugger is present
  4293. ;VxD_DEBUG_ONLY_DATA_ENDS
  4294. ;==============================================================================
  4295. EndDoc
  4296. ; Resident protected mode code
  4297. VxD_CODE_SEG EQU <VxD_LOCKED_CODE_SEG>
  4298. VxD_CODE_ENDS EQU <VxD_LOCKED_CODE_ENDS>
  4299. VxD_LOCKED_CODE_SEG MACRO
  4300. _LTEXT SEGMENT
  4301. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 4 + ??_LCODE
  4302. ASSUME cs:FLAT, ds:FLAT, es:FLAT, ss:FLAT
  4303. ENDM
  4304. VxD_LOCKED_CODE_ENDS MACRO
  4305. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 4
  4306. _LTEXT ENDS
  4307. ENDM
  4308. ; Pageable protected mode code
  4309. VxD_PAGEABLE_CODE_SEG MACRO
  4310. _PTEXT SEGMENT
  4311. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 4 + ??_PCODE
  4312. ASSUME cs:FLAT, ds:FLAT, es:FLAT, ss:FLAT
  4313. ENDM
  4314. VxD_PAGEABLE_CODE_ENDS MACRO
  4315. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 4
  4316. _PTEXT ENDS
  4317. ENDM
  4318. ; Debug only protected mode code
  4319. VxD_DEBUG_ONLY_CODE_SEG MACRO
  4320. _DB1CODE SEGMENT
  4321. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 4 + ??_DBOCODE
  4322. ASSUME cs:FLAT, ds:FLAT, es:FLAT, ss:FLAT
  4323. ENDM
  4324. VxD_DEBUG_ONLY_CODE_ENDS MACRO
  4325. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 4
  4326. _DB1CODE ENDS
  4327. ENDM
  4328. ; Protected mode initialization code
  4329. VxD_INIT_CODE_SEG MACRO
  4330. _ITEXT SEGMENT
  4331. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 4 + ??_ICODE
  4332. ASSUME cs:FLAT, ds:FLAT, es:FLAT, ss:FLAT
  4333. ENDM
  4334. VxD_INIT_CODE_ENDS MACRO
  4335. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 4
  4336. _ITEXT ENDS
  4337. ENDM
  4338. VxD_ICODE_SEG equ VxD_INIT_CODE_SEG
  4339. VxD_ICODE_ENDS equ VxD_INIT_CODE_ENDS
  4340. ; Resident protected mode data
  4341. VxD_DATA_SEG EQU <VxD_LOCKED_DATA_SEG>
  4342. VxD_DATA_ENDS EQU <VxD_LOCKED_DATA_ENDS>
  4343. VxD_LOCKED_DATA_SEG MACRO NO_ALIGN
  4344. _LDATA SEGMENT
  4345. IFB <NO_ALIGN>
  4346. ALIGN 4
  4347. ENDIF
  4348. ENDM
  4349. VxD_LOCKED_DATA_ENDS MACRO
  4350. _LDATA ENDS
  4351. ENDM
  4352. ; Protected mode initialization data
  4353. VxD_IDATA_SEG MACRO
  4354. _IDATA SEGMENT
  4355. ENDM
  4356. VxD_IDATA_ENDS MACRO
  4357. _IDATA ENDS
  4358. ENDM
  4359. ; Pageable protected mode data
  4360. VxD_PAGEABLE_DATA_SEG MACRO NO_ALIGN
  4361. _PDATA SEGMENT
  4362. IFB <NO_ALIGN>
  4363. ALIGN 4
  4364. ENDIF
  4365. ENDM
  4366. VxD_PAGEABLE_DATA_ENDS MACRO
  4367. _PDATA ENDS
  4368. ENDM
  4369. ; Static code segment for DL-VxDs
  4370. VxD_STATIC_CODE_SEG MACRO
  4371. _STEXT SEGMENT
  4372. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 4 + ??_SCODE
  4373. ASSUME cs:FLAT, ds:FLAT, es:FLAT, ss:FLAT
  4374. ENDM
  4375. VxD_STATIC_CODE_ENDS MACRO
  4376. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 4
  4377. _STEXT ENDS
  4378. ENDM
  4379. ; Static data segment for DL-VxDs
  4380. VxD_STATIC_DATA_SEG MACRO NO_ALIGN
  4381. _SDATA SEGMENT
  4382. IFB <NO_ALIGN>
  4383. ALIGN 4
  4384. ENDIF
  4385. ENDM
  4386. VxD_STATIC_DATA_ENDS MACRO
  4387. _SDATA ENDS
  4388. ENDM
  4389. ; Debug only protected mode data
  4390. VxD_DEBUG_ONLY_DATA_SEG MACRO NO_ALIGN
  4391. _DB2DATA SEGMENT
  4392. IFB <NO_ALIGN>
  4393. ALIGN 4
  4394. ENDIF
  4395. ENDM
  4396. VxD_DEBUG_ONLY_DATA_ENDS MACRO
  4397. _DB2DATA ENDS
  4398. ENDM
  4399. ; 16 bit code/data put in the init group (IGROUP)
  4400. VxD_16BIT_INIT_SEG MACRO
  4401. _16ICODE SEGMENT
  4402. ASSUME CS:_16ICODE, DS:NOTHING, ES:NOTHING, SS:NOTHING
  4403. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 4 + ??_16ICODE
  4404. ENDM
  4405. VxD_16BIT_INIT_ENDS MACRO
  4406. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 4
  4407. _16ICODE ENDS
  4408. ENDM
  4409. ; Real mode segment (16 bit)
  4410. VxD_REAL_INIT_SEG MACRO
  4411. _RCODE SEGMENT
  4412. ASSUME CS:_RCODE, DS:_RCODE, ES:_RCODE, SS:_RCODE
  4413. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHL 4 + ??_RCODE
  4414. ENDM
  4415. VxD_REAL_INIT_ENDS MACRO
  4416. ??_CUR_CODE_SEG = ??_CUR_CODE_SEG SHR 4
  4417. _RCODE ENDS
  4418. ENDM
  4419. */
  4420. #endif // Not_VxD
  4421. #ifndef DDK_VERSION
  4422. #ifdef WIN31COMPAT
  4423. #define DDK_VERSION 0x30A /* 3.10 */
  4424. #else // WIN31COMPAT
  4425. #ifdef WIN40COMPAT
  4426. #define DDK_VERSION 0x400 /* 4.00 */
  4427. #else // WIN40COMPAT
  4428. #define DDK_VERSION 0x40A /*Memphis is 4.1 */
  4429. #endif // WIN40COMPAT
  4430. #endif // WIN31COMPAT
  4431. #endif // DDK_VERSION
  4432. struct VxD_Desc_Block {
  4433. ULONG DDB_Next; /* VMM RESERVED FIELD */
  4434. USHORT DDB_SDK_Version; /* INIT <DDK_VERSION> RESERVED FIELD */
  4435. USHORT DDB_Req_Device_Number; /* INIT <UNDEFINED_DEVICE_ID> */
  4436. UCHAR DDB_Dev_Major_Version; /* INIT <0> Major device number */
  4437. UCHAR DDB_Dev_Minor_Version; /* INIT <0> Minor device number */
  4438. USHORT DDB_Flags; /* INIT <0> for init calls complete */
  4439. UCHAR DDB_Name[8]; /* AINIT <" "> Device name */
  4440. ULONG DDB_Init_Order; /* INIT <UNDEFINED_INIT_ORDER> */
  4441. ULONG DDB_Control_Proc; /* Offset of control procedure */
  4442. ULONG DDB_V86_API_Proc; /* INIT <0> Offset of API procedure */
  4443. ULONG DDB_PM_API_Proc; /* INIT <0> Offset of API procedure */
  4444. ULONG DDB_V86_API_CSIP; /* INIT <0> CS:IP of API entry point */
  4445. ULONG DDB_PM_API_CSIP; /* INIT <0> CS:IP of API entry point */
  4446. ULONG DDB_Reference_Data; /* Reference data from real mode */
  4447. ULONG DDB_Service_Table_Ptr; /* INIT <0> Pointer to service table */
  4448. ULONG DDB_Service_Table_Size; /* INIT <0> Number of services */
  4449. ULONG DDB_Win32_Service_Table; /* INIT <0> Pointer to Win32 services */
  4450. ULONG DDB_Prev; /* INIT <'Prev'> Ptr to prev 4.0 DDB */
  4451. ULONG DDB_Size; /* INIT <SIZE(VxD_Desc_Block)> Reserved */
  4452. ULONG DDB_Reserved1; /* INIT <'Rsv1'> Reserved */
  4453. ULONG DDB_Reserved2; /* INIT <'Rsv2'> Reserved */
  4454. ULONG DDB_Reserved3; /* INIT <'Rsv3'> Reserved */
  4455. };
  4456. typedef struct VxD_Desc_Block *PVMMDDB;
  4457. typedef PVMMDDB *PPVMMDDB;
  4458. #ifndef Not_VxD
  4459. /* XLATOFF */
  4460. typedef (_cdecl * VXD_C_SERVICE)();
  4461. typedef VXD_C_SERVICE VXD_SERVICE_TABLE[];
  4462. #define Declare_Virtual_Device(quote_name, name, ctrl_proc, device_num, init_order, V86_proc, PM_proc, ref_data) \
  4463. struct VxD_Desc_Block name##_DDB={ \
  4464. 0, \
  4465. 0, \
  4466. device_num, \
  4467. DDK_VERSION >> 8, \
  4468. DDK_VERSION & 0XFF, \
  4469. 0, \
  4470. quote_name, \
  4471. init_order, \
  4472. (ULONG)ctrl_proc, \
  4473. (ULONG)V86_proc, \
  4474. (ULONG)PM_proc, \
  4475. 0, \
  4476. 0, \
  4477. ref_data, \
  4478. 0, \
  4479. 0, \
  4480. 0, \
  4481. 0, \
  4482. sizeof(struct VxD_Desc_Block), \
  4483. 'Rsv1', \
  4484. 'Rsv2', \
  4485. 'Rsv3' \
  4486. };
  4487. #define Declare_Virtual_Device_With_Table(quote_name, name, ctrl_proc, device_num, init_order, V86_proc, PM_proc, ref_data, table_ptr) \
  4488. struct VxD_Desc_Block name##_DDB={ \
  4489. 0, \
  4490. DDK_VERSION, \
  4491. device_num, \
  4492. DDK_VERSION >> 8, \
  4493. DDK_VERSION & 0XFF, \
  4494. 0, \
  4495. quote_name, \
  4496. init_order, \
  4497. (ULONG)ctrl_proc, \
  4498. (ULONG)V86_proc, \
  4499. (ULONG)PM_proc, \
  4500. 0, \
  4501. 0, \
  4502. ref_data, \
  4503. (ULONG)table_ptr, \
  4504. (ULONG)(sizeof(table_ptr)/sizeof(VXD_C_SERVICE)), \
  4505. 0, \
  4506. 0, \
  4507. sizeof(struct VxD_Desc_Block), \
  4508. 'Rsv1', \
  4509. 'Rsv2', \
  4510. 'Rsv3' \
  4511. };
  4512. /* XLATON */
  4513. /*
  4514. * Flag values for DDB_Flags
  4515. */
  4516. #define DDB_SYS_CRIT_INIT_DONE_BIT 0
  4517. #define DDB_SYS_CRIT_INIT_DONE (1 << DDB_SYS_CRIT_INIT_DONE_BIT)
  4518. #define DDB_DEVICE_INIT_DONE_BIT 1
  4519. #define DDB_DEVICE_INIT_DONE (1 << DDB_DEVICE_INIT_DONE_BIT)
  4520. #define DDB_HAS_WIN32_SVCS_BIT 14
  4521. #define DDB_HAS_WIN32_SVCS (1 << DDB_HAS_WIN32_SVCS_BIT)
  4522. #define DDB_DYNAMIC_VXD_BIT 15
  4523. #define DDB_DYNAMIC_VXD (1 << DDB_DYNAMIC_VXD_BIT)
  4524. #define DDB_DEVICE_DYNALINKED_BIT 13
  4525. #define DDB_DEVICE_DYNALINKED (1 << DDB_DEVICE_DYNALINKED_BIT)
  4526. /* ASM
  4527. BeginDoc
  4528. ;******************************************************************************
  4529. ;
  4530. ; Declare_Virtual_Device macro
  4531. ;
  4532. ; ???? Write something here ????
  4533. ;
  4534. ;==============================================================================
  4535. EndDoc
  4536. Declare_Virtual_Device MACRO Name, Major_Ver, Minor_Ver, Ctrl_Proc, Device_Num, Init_Order, V86_Proc, PM_Proc, Reference_Data
  4537. LOCAL V86_API_Offset, PM_API_Offset, Serv_Tab_Offset, Serv_Tab_Len, Ref_Data_Offset
  4538. dev_id_err MACRO
  4539. IFNDEF Name&_Name_Based
  4540. .err <Device ID required when providing services>
  4541. ENDIF
  4542. ENDM
  4543. IFB <V86_Proc>
  4544. V86_API_Offset EQU 0
  4545. ELSE
  4546. IFB <Device_Num>
  4547. dev_id_err
  4548. ENDIF
  4549. V86_API_Offset EQU <OFFSET32 V86_Proc>
  4550. ENDIF
  4551. IFB <PM_Proc>
  4552. PM_API_Offset EQU 0
  4553. ELSE
  4554. IFB <Device_Num>
  4555. dev_id_err
  4556. ENDIF
  4557. PM_API_Offset EQU <OFFSET32 PM_Proc>
  4558. ENDIF
  4559. IFDEF Name&_Service_Table
  4560. IFB <Device_Num>
  4561. dev_id_err
  4562. ELSE
  4563. IFE Device_Num - UNDEFINED_DEVICE_ID
  4564. dev_id_err
  4565. ENDIF
  4566. ENDIF
  4567. Serv_Tab_Offset EQU <OFFSET32 Name&_Service_Table>
  4568. Serv_Tab_Len EQU Num_&Name&_Services
  4569. ELSE
  4570. Serv_Tab_Offset EQU 0
  4571. Serv_Tab_Len EQU 0
  4572. ENDIF
  4573. IFNB <Device_Num>
  4574. .erre (Device_Num LT BASEID_FOR_NAMEBASEDVXD), <Device ID must be less than BASEID_FOR_NAMEBASEDVXD>
  4575. ENDIF
  4576. IFB <Reference_Data>
  4577. Ref_Data_Offset EQU 0
  4578. ELSE
  4579. Ref_Data_Offset EQU <OFFSET32 Reference_Data>
  4580. ENDIF
  4581. IFDEF DEBUG
  4582. VxD_IDATA_SEG
  4583. db 0dh, 0ah, 'D_E_B_U_G===>'
  4584. db "&Name", '<===', 0dh, 0ah
  4585. VxD_IDATA_ENDS
  4586. ENDIF
  4587. VxD_LOCKED_DATA_SEG
  4588. PUBLIC Name&_DDB
  4589. Name&_DDB VxD_Desc_Block <,,Device_Num,Major_Ver,Minor_Ver,,"&Name",Init_Order,\
  4590. OFFSET32 Ctrl_Proc, V86_API_Offset, PM_API_Offset, \
  4591. ,,Ref_Data_Offset,Serv_Tab_Offset, Serv_Tab_Len>
  4592. VxD_LOCKED_DATA_ENDS
  4593. ENDM
  4594. ;BeginDoc ; comment out to make masm work ???
  4595. ;******************************************************************************
  4596. ; The Begin_Control_Dispatch macro is used for building a table for dispatching
  4597. ; messages passed to the VxD_Control procedure. It is used with
  4598. ; Control_Dispatch and End_Control_Dispatch. The only parameter is used to
  4599. ; contruct the procedure label by adding "_Control" to the end (normally the
  4600. ; device name is used i.e. VKD results in creating the procedure VKD_Control,
  4601. ; this created procedure label must be included in Declare_Virtual_Device)
  4602. ;
  4603. ; An example of building a complete dispatch table:
  4604. ;
  4605. ; Begin_Control_Dispatch MyDevice
  4606. ; Control_Dispatch Device_Init, MyDeviceInitProcedure
  4607. ; Control_Dispatch Sys_VM_Init, MyDeviceSysInitProcedure
  4608. ; Control_Dispatch Create_VM, MyDeviceCreateVMProcedure
  4609. ; End_Control_Dispatch MyDevice
  4610. ;
  4611. ; (NOTE: Control_Dispatch can be used without Begin_Control_Dispatch, but
  4612. ; then it is the programmer's responsibility for declaring a procedure
  4613. ; in locked code (VxD_LOCKED_CODE_SEG) and returning Carry clear for
  4614. ; any messages not processed. The advantage in using
  4615. ; Begin_Control_Dispatch is when a large # of messages are processed by
  4616. ; a device, because a jump table is built which will usually require
  4617. ; less code space then the compares and jumps that are done when
  4618. ; Control_Dispatch is used alone.
  4619. ;
  4620. ;==============================================================================
  4621. ;EndDoc
  4622. Begin_Control_Dispatch MACRO VxD_Name, p1, p2
  4623. ??_cd_low = 0FFFFFFFFh
  4624. ??_cd_high = 0
  4625. BeginProc VxD_Name&_Control, p1, p2, LOCKED
  4626. ENDM
  4627. End_Control_Dispatch MACRO VxD_Name
  4628. LOCAL ignore, table
  4629. procoff MACRO num
  4630. IFDEF ??_cd_&&num
  4631. dd OFFSET32 ??_cd_&&num
  4632. ELSE
  4633. dd OFFSET32 ignore
  4634. ENDIF
  4635. ENDM
  4636. IF ??_cd_low EQ ??_cd_high
  4637. cmp eax, ??_cd_low
  4638. ?merge <jz>,,,,,<??_cd_>, %(??_cd_low)
  4639. clc
  4640. ret
  4641. ELSE
  4642. IF ??_cd_low GT 0
  4643. sub eax, ??_cd_low
  4644. ENDIF ; ??cd_low GT 0
  4645. cmp eax, ??_cd_high - ??_cd_low + 1
  4646. jae short ignore
  4647. jmp [eax*4+table]
  4648. ignore:
  4649. clc ;; this is not redundant
  4650. ret
  4651. table label dword
  4652. REPT ??_cd_high - ??_cd_low + 1
  4653. procoff %(??_cd_low)
  4654. ??_cd_low = ??_cd_low + 1
  4655. ENDM
  4656. ENDIF
  4657. EndProc VxD_Name&_Control
  4658. PURGE procoff
  4659. PURGE Begin_Control_Dispatch
  4660. PURGE Control_Dispatch
  4661. PURGE End_Control_Dispatch
  4662. ENDM
  4663. BeginDoc
  4664. ;******************************************************************************
  4665. ; The Control_Dispatch macro is used for dispatching based on message
  4666. ; passed to the VxD_Control procedure. E.G.:
  4667. ;
  4668. ; Control_Dispatch Device_Init, MyDeviceInitProcedure
  4669. ;
  4670. ; For "C" control functions:
  4671. ;
  4672. ; Control_Dispatch Device_Init, MyDeviceInitProcedure, sCall, <arglst>
  4673. ;
  4674. ; The "callc" can be sCall, cCall or pCall depending on the calling
  4675. ; convention. "arglst" is the list of registers to pass as parameters
  4676. ; to "C" control procedure. The "C" control procedure returns VXD_SUCCESS
  4677. ; or VXD_FAILURE and the carry flag gets set appropriately.
  4678. ;
  4679. ; (NOTE: Control_Dispatch can be used with Begin_Control_Dispatch and
  4680. ; End_Control_Dispatch to create a jump table for dispatching messages,
  4681. ; when a large # of messages are processed.)
  4682. ;
  4683. ;==============================================================================
  4684. EndDoc
  4685. Control_Dispatch MACRO Service, Procedure, callc, arglst
  4686. LOCAL Skip_Interseg_Jump
  4687. .errnz ?_LCODE, <Control_Dispatch must be in VxD_LOCKED_CODE_SEG.>
  4688. IFB <callc>
  4689. IFDEF ??_cd_low
  4690. Equate_Service MACRO Serv
  4691. ??_cd_&&Serv equ Procedure
  4692. ENDM
  4693. Equate_Service %(Service)
  4694. IF Service LT ??_cd_low
  4695. ??_cd_low = Service
  4696. ENDIF
  4697. IF Service GT ??_cd_high
  4698. ??_cd_high = Service
  4699. ENDIF
  4700. PURGE Equate_Service
  4701. ELSE
  4702. cmp eax, Service
  4703. jz Procedure
  4704. ENDIF
  4705. ELSE ; ifb callc
  4706. cmp eax, Service
  4707. jne SHORT Skip_Interseg_Jump
  4708. callc Procedure, <arglst>
  4709. IF Service EQ PNP_NEW_DEVNODE
  4710. stc
  4711. ELSE
  4712. cmp eax,1
  4713. ENDIF
  4714. ret
  4715. Skip_Interseg_Jump:
  4716. ENDIF ; ifb callc
  4717. ENDM
  4718. */
  4719. /******************************************************************************
  4720. * The following are the definitions for the "type of I/O" parameter passed
  4721. * to a I/O trap routine.
  4722. *****************************************************************************/
  4723. #define BYTE_INPUT 0x000
  4724. #define BYTE_OUTPUT 0x004
  4725. #define WORD_INPUT 0x008
  4726. #define WORD_OUTPUT 0x00C
  4727. #define DWORD_INPUT 0x010
  4728. #define DWORD_OUTPUT 0x014
  4729. #define OUTPUT_BIT 2
  4730. #define OUTPUT (1 << OUTPUT_BIT)
  4731. #define WORD_IO_BIT 3
  4732. #define WORD_IO (1 << WORD_IO_BIT)
  4733. #define DWORD_IO_BIT 4
  4734. #define DWORD_IO (1 << DWORD_IO_BIT)
  4735. #define STRING_IO_BIT 5
  4736. #define STRING_IO (1 << STRING_IO_BIT)
  4737. #define REP_IO_BIT 6
  4738. #define REP_IO (1 << REP_IO_BIT)
  4739. #define ADDR_32_IO_BIT 7
  4740. #define ADDR_32_IO (1 << ADDR_32_IO_BIT)
  4741. #define REVERSE_IO_BIT 8
  4742. #define REVERSE_IO (1 << REVERSE_IO_BIT)
  4743. #define IO_SEG_MASK 0x0FFFF0000 /* Use this to get segment */
  4744. #define IO_SEG_SHIFT 0x10 /* Must shift right this many */
  4745. /* ASM
  4746. BeginDoc
  4747. ;******************************************************************************
  4748. ;
  4749. ; Dispatch_Byte_IO macro
  4750. ;
  4751. ; Dispatch_Byte_IO Byte_In_Proc, Byte_Out_Proc
  4752. ;==============================================================================
  4753. EndDoc
  4754. Dispatch_Byte_IO MACRO In_Proc, Out_Proc
  4755. LOCAL Byte_IO
  4756. cmp ecx, Byte_Output
  4757. jbe SHORT Byte_IO
  4758. VMMJmp Simulate_IO
  4759. Byte_IO:
  4760. IFIDNI <In_Proc>, <Fall_Through>
  4761. je Out_Proc
  4762. ELSE
  4763. IFIDNI <Out_Proc>, <Fall_Through>
  4764. jb In_Proc
  4765. ELSE
  4766. je Out_Proc
  4767. jmp In_Proc
  4768. ENDIF
  4769. ENDIF
  4770. ENDM
  4771. BeginDoc
  4772. ;******************************************************************************
  4773. ;
  4774. ; Emulate_Non_Byte_IO
  4775. ;
  4776. ; Emulate_Non_Byte_IO
  4777. ;
  4778. ;==============================================================================
  4779. EndDoc
  4780. Emulate_Non_Byte_IO MACRO
  4781. LOCAL Byte_IO
  4782. cmp ecx, Byte_Output
  4783. jbe SHORT Byte_IO
  4784. VMMJmp Simulate_IO
  4785. Byte_IO:
  4786. ENDM
  4787. */
  4788. /* ASM
  4789. BeginDoc
  4790. ;******************************************************************************
  4791. ;
  4792. ; Begin_VxD_IO_Table
  4793. ;
  4794. ; Example:
  4795. ; Begin_VxD_IO_Table MyTableName
  4796. ;
  4797. ;==============================================================================
  4798. EndDoc
  4799. */
  4800. struct VxD_IOT_Hdr {
  4801. USHORT VxD_IO_Ports;
  4802. };
  4803. struct VxD_IO_Struc {
  4804. USHORT VxD_IO_Port;
  4805. ULONG VxD_IO_Proc;
  4806. };
  4807. /* ASM
  4808. .ERRNZ SIZE VxD_IOT_Hdr - 2 ; Begin_VxD_IO_Table creates a 1 word count hdr
  4809. Begin_VxD_IO_Table MACRO Table_Name
  4810. PUBLIC Table_Name
  4811. Table_Name LABEL WORD
  4812. ifndef MASM6
  4813. IF2
  4814. IFNDEF Table_Name&_Entries
  4815. .err <No End_VxD_IO_Table for &Table_Name>
  4816. ENDIF
  4817. dw Table_Name&_Entries
  4818. ELSE
  4819. dw ?
  4820. ENDIF
  4821. ELSE ; MASM6 - skip the warning message - we'll get it anyway
  4822. dw Table_Name&_Entries
  4823. ENDIF ; MASM6
  4824. ENDM
  4825. .ERRNZ SIZE VxD_IO_Struc - 6 ; VxD_IO creates 6 byte I/O port entries
  4826. VxD_IO MACRO Port, Proc_Name
  4827. dw Port
  4828. dd OFFSET32 Proc_Name
  4829. ENDM
  4830. End_VxD_IO_Table MACRO Table_Name
  4831. IFNDEF Table_Name
  4832. .err <No Begin_VxD_IO_Table for &Table_Name>
  4833. ELSE
  4834. Table_Name&_Entries EQU (($-Table_Name)-2) / (SIZE VxD_IO_Struc)
  4835. IF Table_Name&_Entries LE 0
  4836. .err <Invalid number of port traps in &Table_Name>
  4837. ENDIF
  4838. ENDIF
  4839. ENDM
  4840. ;******************************************************************************
  4841. ;
  4842. ; Push_Client_State takes an optional argument which if equal to the symbol
  4843. ; USES_EDI saves code size by suppressing the preservation of the EDI register.
  4844. ;
  4845. ; Similarly, Pop_Client_State takes an optional argument which if equal to
  4846. ; the symbol USES_ESI saves code size by suppressing the preservation of
  4847. ; the ESI register.
  4848. ;
  4849. ;******************************************************************************
  4850. Push_Client_State MACRO Can_Trash_EDI
  4851. sub esp, SIZE Client_Reg_Struc
  4852. ??_pushed = ??_pushed + SIZE Client_Reg_Struc
  4853. ifidni <Can_Trash_EDI>, <USES_EDI>
  4854. mov edi, esp
  4855. VMMCall Save_Client_State
  4856. else
  4857. push edi
  4858. lea edi, [esp+4]
  4859. VMMCall Save_Client_State
  4860. pop edi
  4861. endif
  4862. ENDM
  4863. Pop_Client_State MACRO Can_Trash_ESI
  4864. ifdifi <Can_Trash_ESI>, <USES_ESI>
  4865. push esi
  4866. lea esi, [esp+4]
  4867. VMMCall Restore_Client_State
  4868. pop esi
  4869. else
  4870. mov esi, esp
  4871. VMMCall Restore_Client_State
  4872. endif
  4873. add esp, SIZE Client_Reg_Struc
  4874. ??_pushed = ??_pushed - SIZE Client_Reg_Struc
  4875. ENDM
  4876. BeginDoc
  4877. ;******************************************************************************
  4878. ;
  4879. ; CallRet -- Call procedure and return. For debugging purposes only.
  4880. ; If compiled with debugging then this will generate a call
  4881. ; followed by a return. If non-debugging version then the
  4882. ; specified label will be jumped to.
  4883. ;
  4884. ; PARAMETERS:
  4885. ; Label_Name = Procedure to be called
  4886. ;
  4887. ; EXIT:
  4888. ; Return from current procedure
  4889. ;
  4890. ;------------------------------------------------------------------------------
  4891. EndDoc
  4892. CallRet MACRO P1, P2
  4893. IFDEF DEBUG
  4894. IFIDNI <P1>, <SHORT>
  4895. call P2
  4896. ELSE
  4897. call P1
  4898. ENDIF
  4899. ret
  4900. ELSE
  4901. jmp P1 P2
  4902. ENDIF
  4903. ENDM
  4904. BeginDoc
  4905. ;******************************************************************************
  4906. ;
  4907. ; CallJmp -- Call procedure then jump to label. For debugging purposes only.
  4908. ; If compiled with debugging then this will generate a call
  4909. ; followed by a jmp. If non-debugging version then the desired return
  4910. ; address will be pushed on the stack and the specified label will
  4911. ; be jumped to.
  4912. ;
  4913. ; PARAMETERS:
  4914. ; Function_Name = Procedure to be called
  4915. ; Return_Label = Address to return to
  4916. ;
  4917. ; EXIT:
  4918. ;
  4919. ;------------------------------------------------------------------------------
  4920. EndDoc
  4921. CallJmp MACRO Function_Name, Return_Label
  4922. IFDEF DEBUG
  4923. call Function_Name
  4924. jmp Return_Label
  4925. ELSE
  4926. push Return_Label
  4927. jmp Function_Name
  4928. ENDIF
  4929. ENDM
  4930. BeginDoc
  4931. ;******************************************************************************
  4932. ;
  4933. ; VxDCallRet
  4934. ; VMMCallRet -- CallRet for VxDCall and VMMCall.
  4935. ;
  4936. ;------------------------------------------------------------------------------
  4937. EndDoc
  4938. IFDEF DEBUG
  4939. VxDCallRet macro p:req
  4940. VxDCall p
  4941. ret
  4942. endm
  4943. VMMCallRet macro p:req
  4944. VMMCall p
  4945. ret
  4946. endm
  4947. ELSE ; RETAIL
  4948. VxDCallRet equ <VxDJmp>
  4949. VMMCallRet equ <VMMJmp>
  4950. ENDIF
  4951. ; ebp offsets to segments pushed by PMode_Fault in Fault_Dispatch
  4952. PClient_DS equ WORD PTR -4
  4953. PClient_ES equ WORD PTR -8
  4954. PClient_FS equ WORD PTR -12
  4955. PClient_GS equ WORD PTR -16
  4956. ;******************************************************************************
  4957. ;
  4958. ; Client_Ptr_Flat takes an optional third argument which if equal to the
  4959. ; symbol USES_EAX saves code size by supressing the preservation of the
  4960. ; EAX register. The USES_EAX flag is ignored if the destination register
  4961. ; is itself EAX.
  4962. ;
  4963. ;******************************************************************************
  4964. Client_Ptr_Flat MACRO Reg_32, Cli_Seg, Cli_Off, Can_Trash_EAX
  4965. IFDIFI <Reg_32>, <EAX>
  4966. IFDIFI <Can_Trash_EAX>, <USES_EAX>
  4967. xchg Reg_32, eax
  4968. ENDIF
  4969. ENDIF
  4970. IFB <Cli_Off>
  4971. mov ax, (Client_&Cli_Seg * 100h) + 0FFh
  4972. ELSE
  4973. mov ax, (Client_&Cli_Seg * 100h) + Client_&Cli_Off
  4974. ENDIF
  4975. VMMCall Map_Flat
  4976. IFDIFI <Reg_32>, <EAX>
  4977. xchg Reg_32, eax
  4978. ENDIF
  4979. ENDM
  4980. ;------------------------------------------------------------------------------
  4981. VxDint MACRO Int_Number
  4982. if (OPATTR Int_Number) AND 4
  4983. push Int_Number
  4984. else
  4985. push DWORD PTR Int_Number
  4986. endif
  4987. VMMCall Exec_VxD_Int
  4988. ENDM
  4989. VxDintMustComplete MACRO Int_Number
  4990. if (OPATTR Int_Number) AND 4
  4991. push Int_Number
  4992. else
  4993. push DWORD PTR Int_Number
  4994. endif
  4995. VMMCall _ExecVxDIntMustComplete
  4996. ENDM
  4997. Load_FS macro
  4998. VMMCall Load_FS_Service
  4999. endm
  5000. */
  5001. /*XLATOFF*/
  5002. #define Load_FS VMMCall(Load_FS_Service)
  5003. /*XLATON*/
  5004. #endif // Not_VxD
  5005. /******************************************************************************
  5006. *
  5007. * The following equates are for flags sent to the real mode
  5008. * initialization portion of a device driver:
  5009. *
  5010. *****************************************************************************/
  5011. #define DUPLICATE_DEVICE_ID_BIT 0 /* loaded */
  5012. #define DUPLICATE_DEVICE_ID (1 << DUPLICATE_DEVICE_ID_BIT)
  5013. #define DUPLICATE_FROM_INT2F_BIT 1 /* loaded from INT 2F list */
  5014. #define DUPLICATE_FROM_INT2F (1 << DUPLICATE_FROM_INT2F_BIT)
  5015. #define LOADING_FROM_INT2F_BIT 2 /* in the INT 2F device list */
  5016. #define LOADING_FROM_INT2F (1 << LOADING_FROM_INT2F_BIT)
  5017. /******************************************************************************
  5018. *
  5019. * The following equates are used to indicate the result of the real mode
  5020. * initialization portion of a device driver:
  5021. *
  5022. *****************************************************************************/
  5023. #define DEVICE_LOAD_OK 0 /* load protected mode portion */
  5024. #define ABORT_DEVICE_LOAD 1 /* don't load protected mode portion */
  5025. #define ABORT_WIN386_LOAD 2 /* fatal-error: abort load of Win386 */
  5026. #define DEVICE_NOT_NEEDED 3 /* don't load protected mode portion */
  5027. /* b/c the driver's presence is not needed */
  5028. #define NO_FAIL_MESSAGE_BIT 15 /* set bit to suppress error message */
  5029. #define NO_FAIL_MESSAGE (1 << NO_FAIL_MESSAGE_BIT)
  5030. /******************************************************************************
  5031. *
  5032. * The following equates define the loader services available to the real-mode
  5033. * initialization portion of a device driver:
  5034. *
  5035. *****************************************************************************/
  5036. #define LDRSRV_GET_PROFILE_STRING 0 /* search SYSTEM.INI for string */
  5037. #define LDRSRV_GET_NEXT_PROFILE_STRING 1 /* search for next string */
  5038. #define LDRSRV_RESERVED 2 /* RESERVED */
  5039. #define LDRSRV_GET_PROFILE_BOOLEAN 3 /* search SYSTEM.INI for boolean */
  5040. #define LDRSRV_GET_PROFILE_DECIMAL_INT 4 /* search SYSTEM.INI for integer */
  5041. #define LDRSRV_GET_PROFILE_HEX_INT 5 /* search SYSTEM.INI for hex int */
  5042. #define LDRSRV_COPY_EXTENDED_MEMORY 6 /* allocate/init extended memory */
  5043. #define LDRSRV_GET_MEMORY_INFO 7 /* get info about machine memory */
  5044. /* Add the new loader services contiguously here */
  5045. /****** Registry services for Real mode init time *************
  5046. * The parameters for these are as defined in Windows.h for the
  5047. * corresponding Win Reg API and should be on Stack. These are
  5048. * C Callable except that the function no has to be in AX
  5049. * ************************************************************
  5050. */
  5051. #define LDRSRV_RegOpenKey 0x100
  5052. #define LDRSRV_RegCreateKey 0x101
  5053. #define LDRSRV_RegCloseKey 0x102
  5054. #define LDRSRV_RegDeleteKey 0x103
  5055. #define LDRSRV_RegSetValue 0x104
  5056. #define LDRSRV_RegQueryValue 0x105
  5057. #define LDRSRV_RegEnumKey 0x106
  5058. #define LDRSRV_RegDeleteValue 0x107
  5059. #define LDRSRV_RegEnumValue 0x108
  5060. #define LDRSRV_RegQueryValueEx 0x109
  5061. #define LDRSRV_RegSetValueEx 0x10A
  5062. #define LDRSRV_RegFlushKey 0x10B
  5063. /*
  5064. * For the Copy_Extended_Memory service, the following types of memory can be
  5065. * requested:
  5066. */
  5067. #define LDRSRV_COPY_INIT 1 /* memory discarded after init */
  5068. #define LDRSRV_COPY_LOCKED 2 /* locked memory */
  5069. #define LDRSRV_COPY_PAGEABLE 3 /* pageable memory */
  5070. /****************************************************************************
  5071. *
  5072. * Object types supported by the vxd loader
  5073. *
  5074. * Notes : Low bit of all CODE type objects should be set (VXDLDR uses this)
  5075. * Also Init type objects should be added to the second part of the
  5076. * list (which starts with ICODE_OBJ).
  5077. *
  5078. *****************************************************************************/
  5079. #define RCODE_OBJ -1
  5080. #define LCODE_OBJ 0x01
  5081. #define LDATA_OBJ 0x02
  5082. #define PCODE_OBJ 0x03
  5083. #define PDATA_OBJ 0x04
  5084. #define SCODE_OBJ 0x05
  5085. #define SDATA_OBJ 0x06
  5086. #define CODE16_OBJ 0x07
  5087. #define LMSG_OBJ 0x08
  5088. #define PMSG_OBJ 0x09
  5089. #define DBOC_OBJ 0x0B
  5090. #define DBOD_OBJ 0x0C
  5091. #define PLCODE_OBJ 0x0D
  5092. #define PPCODE_OBJ 0x0F
  5093. #define ICODE_OBJ 0x11
  5094. #define IDATA_OBJ 0x12
  5095. #define ICODE16_OBJ 0x13
  5096. #define IMSG_OBJ 0x14
  5097. struct ObjectLocation {
  5098. ULONG OL_LinearAddr ;
  5099. ULONG OL_Size ;
  5100. UCHAR OL_ObjType ;
  5101. } ;
  5102. #define MAXOBJECTS 25
  5103. /*****************************************************************************
  5104. *
  5105. * Device_Location structure
  5106. *
  5107. *****************************************************************************/
  5108. struct Device_Location_List {
  5109. ULONG DLL_DDB ;
  5110. UCHAR DLL_NumObjects ;
  5111. struct ObjectLocation DLL_ObjLocation[1];
  5112. };
  5113. /* ========================================================================= */
  5114. /*
  5115. * CR0 bit assignments
  5116. */
  5117. #define PE_BIT 0 /* 1 = Protected Mode */
  5118. #define PE_MASK (1 << PE_BIT)
  5119. #define MP_BIT 1 /* 1 = Monitor Coprocessor */
  5120. #define MP_MASK (1 << MP_BIT)
  5121. #define EM_BIT 2 /* 1 = Emulate Math Coprocessor */
  5122. #define EM_MASK (1 << EM_BIT)
  5123. #define TS_BIT 3 /* 1 = Task Switch occured */
  5124. #define TS_MASK (1 << TS_BIT)
  5125. #define ET_BIT 4 /* 1 = 387 present, 0 = 287 present */
  5126. #define ET_MASK (1 << ET_BIT)
  5127. #define PG_BIT 31 /* 1 = paging enabled, 0 = paging disabled */
  5128. #define PG_MASK (1 << PG_BIT)
  5129. /*
  5130. * EFLAGs bit assignments
  5131. */
  5132. #define CF_BIT 0
  5133. #define CF_MASK (1 << CF_BIT)
  5134. #define PF_BIT 2
  5135. #define PF_MASK (1 << PF_BIT)
  5136. #define AF_BIT 4
  5137. #define AF_MASK (1 << AF_BIT)
  5138. #define ZF_BIT 6
  5139. #define ZF_MASK (1 << ZF_BIT)
  5140. #define SF_BIT 7
  5141. #define SF_MASK (1 << SF_BIT)
  5142. #define TF_BIT 8
  5143. #define TF_MASK (1 << TF_BIT)
  5144. #define IF_BIT 9
  5145. #define IF_MASK (1 << IF_BIT)
  5146. #define DF_BIT 10
  5147. #define DF_MASK (1 << DF_BIT)
  5148. #define OF_BIT 11 /* Overflow flag */
  5149. #define OF_MASK (1 << OF_BIT)
  5150. #define IOPL_MASK 0x3000 /* IOPL flags */
  5151. #define IOPL_BIT0 12
  5152. #define IOPL_BIT1 13
  5153. #define NT_BIT 14 /* Nested task flag */
  5154. #define NT_MASK (1 << NT_BIT)
  5155. #define RF_BIT 16 /* Resume flag */
  5156. #define RF_MASK (1 << RF_BIT)
  5157. #define VM_BIT 17 /* Virtual Mode flag */
  5158. #define VM_MASK (1 << VM_BIT)
  5159. #define AC_BIT 18 /* Alignment check */
  5160. #define AC_MASK (1 << AC_BIT)
  5161. #define VIF_BIT 19 /* Virtual Interrupt flag */
  5162. #define VIF_MASK (1 << VIF_BIT)
  5163. #define VIP_BIT 20 /* Virtual Interrupt pending */
  5164. #define VIP_MASK (1 << VIP_BIT)
  5165. /* ASM
  5166. ;------------------------------------------------------------------------------
  5167. ;
  5168. ; Temporary MASM macros (to be removed when supported by MASM)
  5169. ;
  5170. ;------------------------------------------------------------------------------
  5171. IFDEF MASM6
  5172. loopde EQU <looped>
  5173. loopdne EQU <loopned>
  5174. loopdz EQU <loopzd>
  5175. loopdnz EQU <loopnzd>
  5176. ELSE
  5177. loopd EQU <loop>
  5178. loopde EQU <loope>
  5179. loopdne EQU <loopne>
  5180. loopdz EQU <loopz>
  5181. loopdnz EQU <loopnz>
  5182. ENDIF
  5183. */
  5184. /******************************************************************************
  5185. * PAGE TABLE EQUATES
  5186. *****************************************************************************/
  5187. #define P_SIZE 0x1000 /* page size */
  5188. /******************************************************************************
  5189. *
  5190. * PAGE TABLE ENTRY BITS
  5191. *
  5192. *****************************************************************************/
  5193. #define P_PRESBIT 0
  5194. #define P_PRES (1 << P_PRESBIT)
  5195. #define P_WRITEBIT 1
  5196. #define P_WRITE (1 << P_WRITEBIT)
  5197. #define P_USERBIT 2
  5198. #define P_USER (1 << P_USERBIT)
  5199. #define P_ACCBIT 5
  5200. #define P_ACC (1 << P_ACCBIT)
  5201. #define P_DIRTYBIT 6
  5202. #define P_DIRTY (1 << P_DIRTYBIT)
  5203. #define P_AVAIL (P_PRES+P_WRITE+P_USER) /* avail to user & present */
  5204. /****************************************************
  5205. *
  5206. * Page types for page allocator calls
  5207. *
  5208. ***************************************************/
  5209. #define PG_VM 0
  5210. #define PG_SYS 1
  5211. #define PG_RESERVED1 2
  5212. #define PG_PRIVATE 3
  5213. #define PG_RESERVED2 4
  5214. #define PG_RELOCK 5 /* PRIVATE to MMGR */
  5215. #define PG_INSTANCE 6
  5216. #define PG_HOOKED 7
  5217. #define PG_IGNORE 0xFFFFFFFF
  5218. /****************************************************
  5219. *
  5220. * Definitions for the access byte in a descriptor
  5221. *
  5222. ***************************************************/
  5223. /*
  5224. * Following fields are common to segment and control descriptors
  5225. */
  5226. #define D_PRES 0x080 /* present in memory */
  5227. #define D_NOTPRES 0 /* not present in memory */
  5228. #define D_DPL0 0 /* Ring 0 */
  5229. #define D_DPL1 0x020 /* Ring 1 */
  5230. #define D_DPL2 0x040 /* Ring 2 */
  5231. #define D_DPL3 0x060 /* Ring 3 */
  5232. #define D_SEG 0x010 /* Segment descriptor */
  5233. #define D_CTRL 0 /* Control descriptor */
  5234. #define D_GRAN_BYTE 0x000 /* Segment length is byte granular */
  5235. #define D_GRAN_PAGE 0x080 /* Segment length is page granular */
  5236. #define D_DEF16 0x000 /* Default operation size is 16 bits */
  5237. #define D_DEF32 0x040 /* Default operation size is 32 bits */
  5238. /*
  5239. * Following fields are specific to segment descriptors
  5240. */
  5241. #define D_CODE 0x08 /* code */
  5242. #define D_DATA 0 /* data */
  5243. #define D_X 0 /* if code, exec only */
  5244. #define D_RX 0x02 /* if code, readable */
  5245. #define D_C 0x04 /* if code, conforming */
  5246. #define D_R 0 /* if data, read only */
  5247. #define D_W 0x02 /* if data, writable */
  5248. #define D_ED 0x04 /* if data, expand down */
  5249. #define D_ACCESSED 1 /* segment accessed bit */
  5250. /*
  5251. * Useful combination access rights bytes
  5252. */
  5253. #define RW_DATA_TYPE (D_PRES+D_SEG+D_DATA+D_W)
  5254. #define R_DATA_TYPE (D_PRES+D_SEG+D_DATA+D_R)
  5255. #define CODE_TYPE (D_PRES+D_SEG+D_CODE+D_RX)
  5256. #define D_PAGE32 (D_GRAN_PAGE+D_DEF32) /* 32 bit Page granular */
  5257. /*
  5258. * Masks for selector fields
  5259. */
  5260. #define SELECTOR_MASK 0xFFF8 /* selector index */
  5261. #define SEL_LOW_MASK 0xF8 /* mask for low byte of sel indx */
  5262. #define TABLE_MASK 0x04 /* table bit */
  5263. #define RPL_MASK 0x03 /* privilige bits */
  5264. #define RPL_CLR (~RPL_MASK) /* clear ring bits */
  5265. #define IVT_ROM_DATA_SIZE 0x500
  5266. /*XLATOFF*/
  5267. #ifndef Not_VxD
  5268. #define ENABLE_INTERRUPTS() {__asm sti}
  5269. #define DISABLE_INTERRUPTS() {__asm cli}
  5270. #define SAVE_FLAGS(flags) {\
  5271. {__asm pushfd}; \
  5272. {__asm pop flags}}
  5273. #define RESTORE_FLAGS(flags) {\
  5274. {__asm push flags}; \
  5275. {__asm popfd}}
  5276. #define IO_Delay() {\
  5277. {__asm _emit 0xeb __asm _emit 0x00}; \
  5278. }
  5279. #define Touch_Register(Register) {_asm xor Register, Register}
  5280. typedef DWORD HEVENT;
  5281. #define VMM_GET_DDB_NAMED 0
  5282. #pragma warning (disable:4209) // turn off redefine warning (with basedef.h)
  5283. typedef ULONG HTIMEOUT; // timeout handle
  5284. typedef ULONG CMS; // count of milliseconds
  5285. #pragma warning (default:4209) // turn on redefine warning (with basedef.h)
  5286. typedef DWORD VMM_SEMAPHORE;
  5287. typedef struct _HEAP_ALLOCATE_INFO {
  5288. DWORD StructSize;
  5289. PVOID CallerAddress;
  5290. ULONG Tag;
  5291. } HEAP_ALLOCATE_INFO, *PHEAP_ALLOCATE_INFO;
  5292. PVOID
  5293. _stdcall
  5294. HeapAllocateEx(
  5295. ULONG cBytes,
  5296. PVOID Reserved,
  5297. PHEAP_ALLOCATE_INFO AllocateInfo,
  5298. ULONG Flags
  5299. );
  5300. VOID
  5301. _stdcall
  5302. HeapFreeEx(
  5303. PVOID MemBlk,
  5304. PVOID Reserved
  5305. );
  5306. #ifndef WANTVXDWRAPS
  5307. WORD VXDINLINE
  5308. Get_VMM_Version()
  5309. {
  5310. WORD w;
  5311. VMMCall(Get_VMM_Version);
  5312. _asm mov [w], ax
  5313. return(w);
  5314. }
  5315. PVOID VXDINLINE
  5316. _HeapAllocate(ULONG Bytes, ULONG Flags)
  5317. {
  5318. PVOID p;
  5319. Touch_Register(eax)
  5320. Touch_Register(ecx)
  5321. Touch_Register(edx)
  5322. _asm push [Flags]
  5323. _asm push [Bytes]
  5324. VMMCall(_HeapAllocate)
  5325. _asm add esp, 8
  5326. _asm mov [p], eax
  5327. return(p);
  5328. }
  5329. ULONG VXDINLINE
  5330. _HeapFree(PVOID Address, ULONG Flags)
  5331. {
  5332. ULONG ul;
  5333. Touch_Register(eax)
  5334. Touch_Register(ecx)
  5335. Touch_Register(edx)
  5336. _asm push [Flags]
  5337. _asm push [Address]
  5338. VMMCall(_HeapFree)
  5339. _asm add esp, 8
  5340. _asm mov [ul], eax
  5341. return(ul);
  5342. }
  5343. HEVENT VXDINLINE
  5344. Call_Global_Event(void (__cdecl *pfnEvent)(), ULONG ulRefData)
  5345. {
  5346. HEVENT hevent;
  5347. _asm mov edx, [ulRefData]
  5348. _asm mov esi, [pfnEvent]
  5349. VMMCall(Call_Global_Event)
  5350. _asm mov [hevent], esi
  5351. return(hevent);
  5352. }
  5353. HEVENT VXDINLINE
  5354. Schedule_Global_Event(void (__cdecl *pfnEvent)(), ULONG ulRefData)
  5355. {
  5356. HEVENT hevent;
  5357. _asm mov edx, [ulRefData]
  5358. _asm mov esi, [pfnEvent]
  5359. VMMCall(Schedule_Global_Event)
  5360. _asm mov [hevent], esi
  5361. return(hevent);
  5362. }
  5363. void VXDINLINE
  5364. Cancel_Global_Event( HEVENT hevent )
  5365. {
  5366. _asm mov esi, hevent
  5367. VMMCall( Cancel_Global_Event );
  5368. }
  5369. HVM VXDINLINE
  5370. Get_Sys_VM_Handle(VOID)
  5371. {
  5372. HVM hvm;
  5373. Touch_Register(ebx)
  5374. VxDCall(Get_Sys_VM_Handle);
  5375. _asm mov [hvm], ebx
  5376. return(hvm);
  5377. }
  5378. VOID VXDINLINE
  5379. Fatal_Error_Handler(PCHAR pszMessage, DWORD dwExitFlag)
  5380. {
  5381. _asm mov esi, [pszMessage]
  5382. _asm mov eax, [dwExitFlag]
  5383. VMMCall(Fatal_Error_Handler);
  5384. }
  5385. VMM_SEMAPHORE VXDINLINE
  5386. Create_Semaphore(LONG lTokenCount)
  5387. {
  5388. VMM_SEMAPHORE vmm_semaphore;
  5389. _asm mov ecx, [lTokenCount]
  5390. VMMCall(Create_Semaphore)
  5391. _asm cmc
  5392. _asm sbb ecx, ecx
  5393. _asm and eax, ecx
  5394. _asm mov [vmm_semaphore], eax
  5395. return(vmm_semaphore);
  5396. }
  5397. void VXDINLINE
  5398. Destroy_Semaphore(VMM_SEMAPHORE vsSemaphore)
  5399. {
  5400. _asm mov eax, [vsSemaphore]
  5401. VMMCall(Destroy_Semaphore)
  5402. }
  5403. void VXDINLINE
  5404. Signal_Semaphore(VMM_SEMAPHORE vsSemaphore)
  5405. {
  5406. _asm mov eax, [vsSemaphore]
  5407. VMMCall(Signal_Semaphore)
  5408. }
  5409. void VXDINLINE
  5410. Wait_Semaphore(VMM_SEMAPHORE vsSemaphore, DWORD dwFlags)
  5411. {
  5412. _asm mov eax, [vsSemaphore]
  5413. _asm mov ecx, [dwFlags]
  5414. VMMCall(Wait_Semaphore)
  5415. }
  5416. HVM VXDINLINE
  5417. Get_Execution_Focus(void)
  5418. {
  5419. HVM hvm;
  5420. Touch_Register(ebx)
  5421. VMMCall(Get_Execution_Focus)
  5422. _asm mov [hvm], ebx
  5423. return(hvm);
  5424. }
  5425. void VXDINLINE
  5426. Begin_Critical_Section(ULONG Flags)
  5427. {
  5428. _asm mov ecx, [Flags]
  5429. VMMCall(Begin_Critical_Section)
  5430. }
  5431. void VXDINLINE
  5432. End_Critical_Section(void)
  5433. {
  5434. VMMCall(End_Critical_Section)
  5435. }
  5436. void VXDINLINE
  5437. Fatal_Memory_Handler(void)
  5438. {
  5439. VMMCall(Fatal_Memory_Error);
  5440. }
  5441. void VXDINLINE
  5442. Begin_Nest_Exec(void)
  5443. {
  5444. VMMCall(Begin_Nest_Exec)
  5445. }
  5446. void VXDINLINE
  5447. End_Nest_Exec(void)
  5448. {
  5449. VMMCall(End_Nest_Exec)
  5450. }
  5451. void VXDINLINE
  5452. Resume_Exec(void)
  5453. {
  5454. VMMCall(Resume_Exec)
  5455. }
  5456. HTIMEOUT VXDINLINE
  5457. Set_VM_Time_Out(void (*pfnTimeout)(), CMS cms, ULONG ulRefData)
  5458. {
  5459. HTIMEOUT htimeout;
  5460. _asm mov eax, [cms]
  5461. _asm mov edx, [ulRefData]
  5462. _asm mov esi, [pfnTimeout]
  5463. VMMCall(Set_VM_Time_Out)
  5464. _asm mov [htimeout], esi
  5465. return(htimeout);
  5466. }
  5467. HTIMEOUT VXDINLINE
  5468. Set_Global_Time_Out(void (__cdecl *pfnTimeout)(), CMS cms, ULONG ulRefData)
  5469. {
  5470. HTIMEOUT htimeout;
  5471. _asm mov eax, [cms]
  5472. _asm mov edx, [ulRefData]
  5473. _asm mov esi, [pfnTimeout]
  5474. VMMCall(Set_Global_Time_Out)
  5475. _asm mov [htimeout], esi
  5476. return(htimeout);
  5477. }
  5478. void VXDINLINE
  5479. Cancel_Time_Out(HTIMEOUT htimeout)
  5480. {
  5481. _asm mov esi, htimeout
  5482. VMMCall(Cancel_Time_Out)
  5483. }
  5484. void VXDINLINE
  5485. Update_System_Clock(ULONG msElapsed)
  5486. {
  5487. __asm mov ecx,[msElapsed]
  5488. VMMCall(Update_System_Clock)
  5489. }
  5490. void VXDINLINE
  5491. Enable_Touch_1st_Meg(void)
  5492. {
  5493. VMMCall(Enable_Touch_1st_Meg)
  5494. }
  5495. void VXDINLINE
  5496. Disable_Touch_1st_Meg(void)
  5497. {
  5498. VMMCall(Disable_Touch_1st_Meg)
  5499. }
  5500. void VXDINLINE
  5501. Out_Debug_String(char *psz)
  5502. {
  5503. __asm pushad
  5504. __asm mov esi, [psz]
  5505. VMMCall(Out_Debug_String)
  5506. __asm popad
  5507. }
  5508. void VXDINLINE
  5509. Queue_Debug_String(char *psz, ULONG ulEAX, ULONG ulEBX)
  5510. {
  5511. _asm push esi
  5512. _asm push [ulEAX]
  5513. _asm push [ulEBX]
  5514. _asm mov esi, [psz]
  5515. VMMCall(Queue_Debug_String)
  5516. _asm pop esi
  5517. }
  5518. #ifdef WIN40SERVICES
  5519. HTIMEOUT VXDINLINE
  5520. Set_Async_Time_Out(void (*pfnTimeout)(), CMS cms, ULONG ulRefData)
  5521. {
  5522. HTIMEOUT htimeout;
  5523. _asm mov eax, [cms]
  5524. _asm mov edx, [ulRefData]
  5525. _asm mov esi, [pfnTimeout]
  5526. VMMCall(Set_Async_Time_Out)
  5527. _asm mov [htimeout], esi
  5528. return(htimeout);
  5529. }
  5530. VXDINLINE struct VxD_Desc_Block *
  5531. VMM_Get_DDB(WORD DeviceID, PCHAR Name)
  5532. {
  5533. struct VxD_Desc_Block *p;
  5534. _asm movzx eax, [DeviceID]
  5535. _asm mov edi, [Name]
  5536. VMMCall(Get_DDB);
  5537. _asm mov [p], ecx
  5538. return(p);
  5539. }
  5540. DWORD VXDINLINE
  5541. VMM_Directed_Sys_Control(struct VxD_Desc_Block *DDB, DWORD SysControl, DWORD rEBX, DWORD rEDX, DWORD rESI, DWORD rEDI)
  5542. {
  5543. DWORD dw;
  5544. _asm mov eax, [SysControl]
  5545. _asm mov ebx, [rEBX]
  5546. _asm mov ecx, [DDB]
  5547. _asm mov edx, [rEDX]
  5548. _asm mov esi, [rESI]
  5549. _asm mov edi, [rEDI]
  5550. VMMCall(Directed_Sys_Control);
  5551. _asm mov [dw], eax
  5552. return(dw);
  5553. }
  5554. void VXDINLINE
  5555. _Trace_Out_Service(char *psz)
  5556. {
  5557. __asm push psz
  5558. VMMCall(_Trace_Out_Service)
  5559. }
  5560. void VXDINLINE
  5561. _Debug_Out_Service(char *psz)
  5562. {
  5563. __asm push psz
  5564. VMMCall(_Debug_Out_Service)
  5565. }
  5566. void VXDINLINE
  5567. _Debug_Flags_Service(ULONG flags)
  5568. {
  5569. __asm push flags
  5570. VMMCall(_Debug_Flags_Service)
  5571. }
  5572. void VXDINLINE _cdecl
  5573. _Debug_Printf_Service(char *pszfmt, ...)
  5574. {
  5575. __asm lea eax,(pszfmt + 4)
  5576. __asm push eax
  5577. __asm push pszfmt
  5578. VMMCall(_Debug_Printf_Service)
  5579. __asm add esp, 2*4
  5580. }
  5581. #endif // WIN40SERVICES
  5582. #endif // WANTVXDWRAPS
  5583. #endif // Not_VxD
  5584. /*XLATON*/
  5585. #endif /* _VMM_ */