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.

255 lines
7.6 KiB

  1. /******************************************************************************
  2. *
  3. * (C) Copyright MICROSOFT Corp. All Rights Reserved, 1989-1995
  4. *
  5. * Title: vwin32.h -
  6. *
  7. * Version: 4.00
  8. *
  9. * Date: 24-May-1993
  10. *
  11. ******************************************************************************/
  12. /*INT32*/
  13. #ifndef _VWIN32_H_
  14. #define _VWIN32_H_
  15. #define THREAD_TYPE_WIN32 VWIN32_DEVICE_ID
  16. #ifndef Not_VxD
  17. /*XLATOFF*/
  18. #define VWIN32_Service Declare_Service
  19. #define VWIN32_StdCall_Service Declare_SCService
  20. #pragma warning (disable:4003) // turn off not enough params warning
  21. /*XLATON*/
  22. /*MACROS*/
  23. Begin_Service_Table(VWIN32)
  24. VWIN32_Service (VWIN32_Get_Version, LOCAL)
  25. VWIN32_Service (VWIN32_DIOCCompletionRoutine, LOCAL)
  26. VWIN32_Service (_VWIN32_QueueUserApc)
  27. VWIN32_Service (_VWIN32_Get_Thread_Context)
  28. VWIN32_Service (_VWIN32_Set_Thread_Context)
  29. VWIN32_Service (_VWIN32_CopyMem, LOCAL)
  30. VWIN32_Service (_VWIN32_Npx_Exception)
  31. VWIN32_Service (_VWIN32_Emulate_Npx)
  32. VWIN32_Service (_VWIN32_CheckDelayedNpxTrap)
  33. VWIN32_Service (VWIN32_EnterCrstR0)
  34. VWIN32_Service (VWIN32_LeaveCrstR0)
  35. VWIN32_Service (_VWIN32_FaultPopup)
  36. VWIN32_Service (VWIN32_GetContextHandle)
  37. VWIN32_Service (VWIN32_GetCurrentProcessHandle, LOCAL)
  38. VWIN32_Service (_VWIN32_SetWin32Event)
  39. VWIN32_Service (_VWIN32_PulseWin32Event)
  40. VWIN32_Service (_VWIN32_ResetWin32Event)
  41. VWIN32_Service (_VWIN32_WaitSingleObject)
  42. VWIN32_Service (_VWIN32_WaitMultipleObjects)
  43. VWIN32_Service (_VWIN32_CreateRing0Thread)
  44. VWIN32_Service (_VWIN32_CloseVxDHandle)
  45. VWIN32_Service (VWIN32_ActiveTimeBiasSet, LOCAL)
  46. VWIN32_Service (VWIN32_GetCurrentDirectory, LOCAL)
  47. VWIN32_Service (VWIN32_BlueScreenPopup)
  48. VWIN32_Service (VWIN32_TerminateApp)
  49. VWIN32_Service (_VWIN32_QueueKernelAPC)
  50. VWIN32_Service (VWIN32_SysErrorBox)
  51. VWIN32_Service (_VWIN32_IsClientWin32)
  52. VWIN32_Service (VWIN32_IFSRIPWhenLev2Taken, LOCAL)
  53. VWIN32_Service (_VWIN32_InitWin32Event)
  54. VWIN32_Service (_VWIN32_InitWin32Mutex)
  55. VWIN32_Service (_VWIN32_ReleaseWin32Mutex)
  56. VWIN32_Service (_VWIN32_BlockThreadEx)
  57. VWIN32_Service (VWIN32_GetProcessHandle, LOCAL)
  58. VWIN32_Service (_VWIN32_InitWin32Semaphore)
  59. VWIN32_Service (_VWIN32_SignalWin32Sem)
  60. VWIN32_Service (_VWIN32_QueueUserApcEx)
  61. VWIN32_Service (_VWIN32_OpenVxDHandle)
  62. VWIN32_Service (_VWIN32_CloseWin32Handle)
  63. VWIN32_Service (_VWIN32_AllocExternalHandle)
  64. VWIN32_Service (_VWIN32_UseExternalHandle)
  65. VWIN32_Service (_VWIN32_UnuseExternalHandle)
  66. VWIN32_StdCall_Service (KeInitializeTimer, 1)
  67. VWIN32_StdCall_Service (KeSetTimer, 4)
  68. VWIN32_StdCall_Service (KeCancelTimer, 1)
  69. VWIN32_StdCall_Service (KeReadStateTimer, 1)
  70. VWIN32_Service (_VWIN32_ReferenceObject)
  71. VWIN32_Service (_VWIN32_GetExternalHandle)
  72. VWIN32_StdCall_Service (VWIN32_ConvertNtTimeout, 1)
  73. VWIN32_Service (_VWIN32_SetWin32EventBoostPriority)
  74. VWIN32_Service (_VWIN32_GetRing3Flat32Selectors)
  75. VWIN32_Service (_VWIN32_GetCurThreadCondition)
  76. VWIN32_Service (VWIN32_Init_FP)
  77. VWIN32_StdCall_Service (R0SetWaitableTimer, 5)
  78. End_Service_Table(VWIN32)
  79. /*ENDMACROS*/
  80. /*XLATOFF*/
  81. #pragma warning (default:4003) // turn on not enough params warning
  82. PVOID VXDINLINE
  83. VWIN32OpenVxDHandle(ULONG Handle,ULONG dwType)
  84. {
  85. PVOID ul;
  86. _asm push [dwType]
  87. _asm push [Handle]
  88. VxDCall(_VWIN32_OpenVxDHandle)
  89. _asm add esp, 8
  90. _asm mov [ul], eax
  91. return(ul);
  92. }
  93. WORD VXDINLINE
  94. VWIN32_Get_Version(VOID)
  95. {
  96. WORD w;
  97. VxDCall(VWIN32_Get_Version);
  98. _asm mov [w], ax
  99. return(w);
  100. }
  101. /*XLATON*/
  102. #endif // Not_VxD
  103. //
  104. // For _VWIN32_GetCurThreadCondition
  105. //
  106. #define THREAD_CONDITION_DOS_BOX 0x00000000l
  107. #define THREAD_CONDITION_V86_NEST 0x00000001l
  108. #define THREAD_CONDITION_WDM 0x00000002l
  109. #define THREAD_CONDITION_INDETERMINATE 0x00000003l
  110. #define THREAD_CONDITION_LOCKED_STACK 0x00000004l
  111. #define THREAD_CONDITION_PURE_WIN16 0x00000005l
  112. #define THREAD_CONDITION_THUNKED_WIN16 0x00000006l
  113. #define THREAD_CONDITION_THUNKED_WIN32 0x00000007l
  114. #define THREAD_CONDITION_PURE_WIN32 0x00000008l
  115. #define THREAD_CONDITION_APPY_TIME 0x00000009l
  116. #define THREAD_CONDITION_RING0_APPY_TIME 0x0000000Al
  117. #define THREAD_CONDITION_EXIT 0x0000000Bl
  118. #define THREAD_CONDITION_INVALID_FLAGS 0xFFFFFFFFl
  119. #define THREAD_CONDITION_NORMAL_FLAGS 0x00000000l
  120. //
  121. // structure for VWIN32_SysErrorBox
  122. //
  123. typedef struct vseb_s {
  124. DWORD vseb_resp;
  125. WORD vseb_b3;
  126. WORD vseb_b2;
  127. WORD vseb_b1;
  128. DWORD vseb_pszCaption;
  129. DWORD vseb_pszText;
  130. } VSEB;
  131. typedef VSEB *PVSEB;
  132. #define SEB_ANSI 0x4000 // ANSI strings if set on vseb_b1
  133. #define SEB_TERMINATE 0x2000 // forces termination if button pressed
  134. // VWIN32_QueueKernelAPC flags
  135. #define KERNEL_APC_IGNORE_MC 0x00000001
  136. #define KERNEL_APC_STATIC 0x00000002
  137. #define KERNEL_APC_WAKE 0x00000004
  138. // for DeviceIOControl support
  139. // On a DeviceIOControl call vWin32 will pass following parameters to
  140. // the Vxd that is specified by hDevice. hDevice is obtained thru an
  141. // earlier call to hDevice = CreateFile("\\.\vxdname", ...);
  142. // ESI = DIOCParams STRUCT (defined below)
  143. typedef struct DIOCParams {
  144. DWORD Internal1; // ptr to client regs
  145. DWORD VMHandle; // VM handle
  146. DWORD Internal2; // DDB
  147. DWORD dwIoControlCode;
  148. DWORD lpvInBuffer;
  149. DWORD cbInBuffer;
  150. DWORD lpvOutBuffer;
  151. DWORD cbOutBuffer;
  152. DWORD lpcbBytesReturned;
  153. DWORD lpoOverlapped;
  154. DWORD hDevice;
  155. DWORD tagProcess;
  156. } DIOCPARAMETERS;
  157. typedef DIOCPARAMETERS *PDIOCPARAMETERS;
  158. // dwIoControlCode values for vwin32's DeviceIOControl Interface
  159. // all VWIN32_DIOC_DOS_ calls require lpvInBuffer abd lpvOutBuffer to be
  160. // struct * DIOCRegs
  161. #define VWIN32_DIOC_GETVERSION DIOC_GETVERSION
  162. #define VWIN32_DIOC_DOS_IOCTL 1
  163. #define VWIN32_DIOC_DOS_INT25 2
  164. #define VWIN32_DIOC_DOS_INT26 3
  165. #define VWIN32_DIOC_DOS_INT13 4
  166. #define VWIN32_DIOC_SIMCTRLC 5
  167. #define VWIN32_DIOC_DOS_DRIVEINFO 6
  168. #define VWIN32_DIOC_CLOSEHANDLE DIOC_CLOSEHANDLE
  169. // DIOCRegs
  170. // Structure with i386 registers for making DOS_IOCTLS
  171. // vwin32 DIOC handler interprets lpvInBuffer , lpvOutBuffer to be this struc.
  172. // and does the int 21
  173. // reg_flags is valid only for lpvOutBuffer->reg_Flags
  174. typedef struct DIOCRegs {
  175. DWORD reg_EBX;
  176. DWORD reg_EDX;
  177. DWORD reg_ECX;
  178. DWORD reg_EAX;
  179. DWORD reg_EDI;
  180. DWORD reg_ESI;
  181. DWORD reg_Flags;
  182. } DIOC_REGISTERS;
  183. // if we are not included along with winbase.h
  184. #ifndef FILE_FLAG_OVERLAPPED
  185. // OVERLAPPED structure for DeviceIOCtl VxDs
  186. typedef struct _OVERLAPPED {
  187. DWORD O_Internal;
  188. DWORD O_InternalHigh;
  189. DWORD O_Offset;
  190. DWORD O_OffsetHigh;
  191. HANDLE O_hEvent;
  192. } OVERLAPPED;
  193. #endif
  194. // Parameters for _VWIN32_OpenVxDHandle to validate the Win32 handle type.
  195. #define OPENVXD_TYPE_SEMAPHORE 0
  196. #define OPENVXD_TYPE_EVENT 1
  197. #define OPENVXD_TYPE_MUTEX 2
  198. #define OPENVXD_TYPE_ANY 3
  199. //
  200. // Object type table declaration for _VWIN32_AllocExternalHandle
  201. //
  202. /*XLATOFF*/
  203. #define R0OBJCALLBACK __stdcall
  204. typedef VOID (R0OBJCALLBACK *R0OBJFREE)(PVOID pR0ObjBody);
  205. typedef PVOID (R0OBJCALLBACK *R0OBJDUP)(PVOID pR0ObjBody, DWORD hDestProc);
  206. /*XLATON*/
  207. /* ASM
  208. R0OBJFREE TYPEDEF DWORD
  209. R0OBJDUP TYPEDEF DWORD
  210. */
  211. typedef struct _R0OBJTYPETABLE {
  212. DWORD ott_dwSize; // sizeof(R0OBJTYPETABLE)
  213. R0OBJFREE ott_pfnFree; // called by Win32 CloseHandle
  214. R0OBJDUP ott_pfnDup; // called by Win32 DuplicateHandle
  215. } R0OBJTYPETABLE, *PR0OBJTYPETABLE;
  216. /* ASM
  217. R0OBJTYPETABLE typedef _R0OBJTYPETABLE;
  218. */
  219. #define R0EHF_INHERIT 0x00000001 // Handle is inheritable
  220. #define R0EHF_GLOBAL 0x00000002 // Handle is valid in all contexts
  221. #endif // _VWIN32_H_