Leaked source code of windows server 2003
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.

270 lines
6.2 KiB

  1. ; DCAPVxD.ASM
  2. ;
  3. ; A VxD whose purpose is to be able to set a Win32 event at
  4. ; interrupt time
  5. ;
  6. ; Created 13-Aug-96 [JonT]
  7. ; DeviceIO support 29-May-97 [MikeG]
  8. PAGE 58,132
  9. .386p
  10. WIN40COMPAT EQU 1
  11. .xlist
  12. include vmm.inc
  13. include debug.inc
  14. include vwin32.inc
  15. .list
  16. ; The following equate makes the VXD dynamically loadable.
  17. DCAPVXD_DYNAMIC equ 1
  18. ; Our version
  19. DCAPVXD_MAJOR equ 1
  20. DCAPVXD_MINOR equ 0
  21. DCAPVXD_VERSION equ ((DCAPVXD_MAJOR shl 8) + DCAPVXD_MINOR)
  22. ; Magic Function code values for DeviceIOControl code.
  23. DCAPVXD_THREADTIMESERVICE equ 101h
  24. DCAPVXD_R0THREADIDSERVICE equ 102h
  25. ;============================================================================
  26. ; V I R T U A L D E V I C E D E C L A R A T I O N
  27. ;============================================================================
  28. DECLARE_VIRTUAL_DEVICE DCAPVXD, 1, 0, DCAPVXD_Control, UNDEFINED_DEVICE_ID, \
  29. UNDEFINED_INIT_ORDER,,DCAPVXD_PMAPI_Handler
  30. VxD_LOCKED_CODE_SEG
  31. ;===========================================================================
  32. ;
  33. ; PROCEDURE: DCAPVXD_Control
  34. ;
  35. ; DESCRIPTION:
  36. ; Device control procedure for the DCAPVXD VxD
  37. ;
  38. ; ENTRY:
  39. ; EAX = Control call ID
  40. ;
  41. ; EXIT:
  42. ; If carry clear then
  43. ; Successful
  44. ; else
  45. ; Control call failed
  46. ;
  47. ; USES:
  48. ; EAX, EBX, ECX, EDX, ESI, EDI, Flags
  49. ;
  50. ;============================================================================
  51. BeginProc DCAPVXD_Control
  52. ; Control_Dispatch SYS_DYNAMIC_DEVICE_INIT, DCAPVXD_Dynamic_Init
  53. ; Control_Dispatch SYS_DYNAMIC_DEVICE_EXIT, DCAPVXD_Dynamic_Exit
  54. Control_Dispatch W32_DEVICEIOCONTROL, DCAPVXD_DeviceIOControl
  55. clc
  56. ret
  57. EndProc DCAPVXD_Control
  58. VxD_LOCKED_CODE_ENDS
  59. VxD_PAGEABLE_CODE_SEG
  60. ;===========================================================================
  61. ;
  62. ; PROCEDURE: DCAPVXD_PMAPI_Handler
  63. ;
  64. ; DESCRIPTION:
  65. ; Win16 API handler
  66. ;
  67. ; ENTRY:
  68. ; EBX = VM handle
  69. ; EBP = ptr to client register set
  70. ;
  71. ; EXIT:
  72. ; Carry set if failed
  73. ; else carry clear
  74. ;
  75. ; USES:
  76. ; EAX, EBX, ECX, EDX, ESI, EDI, Flags
  77. ;
  78. ;============================================================================
  79. BeginProc DCAPVXD_PMAPI_Handler
  80. movzx eax, [ebp.Client_AX]
  81. or ah, ah ;AH = 0 is Get Version
  82. jz DCAPVXD_Get_Version
  83. dec ah ;AH = 1 is Set Event
  84. jz DCAPVXD_Set_Event
  85. dec ah ;AH = 2 is Close VxD Handle
  86. jz DCAPVXD_Close_VxD_Handle
  87. public DCAPVXD_PMAPI_FAIL
  88. DCAPVXD_PMAPI_FAIL:
  89. or [ebp.Client_EFlags], CF_MASK
  90. ret
  91. public DCAPVXD_PMAPI_OK
  92. DCAPVXD_PMAPI_OK:
  93. and [ebp.Client_EFlags], NOT CF_MASK
  94. ret
  95. EndProc DCAPVXD_PMAPI_Handler
  96. ; DCAPVXD_Get_Version
  97. ; Returns the version of the device
  98. BeginProc DCAPVXD_Get_Version
  99. mov WORD PTR [ebp.Client_AX], DCAPVXD_VERSION
  100. jmp DCAPVXD_PMAPI_OK
  101. EndProc DCAPVXD_Get_Version
  102. ; DCAPVXD_Set_Event
  103. ; Sets a Win32 event.
  104. ; Entry:
  105. ; ECX points to a Win32 event (NOT a handle!)
  106. ; Returns:
  107. ; EAX 0:Event pointer invalid
  108. ; -1:Event queued to be set later
  109. ; 1:Event set now
  110. BeginProc DCAPVXD_Set_Event
  111. ; Set the event
  112. mov eax, [ebp.Client_ECX]
  113. VxDcall _VWIN32_SetWin32Event
  114. ; If the return is NC, EAX is 1, so return
  115. mov [ebp.Client_EAX], eax
  116. jnc DCAPVXD_PMAPI_OK
  117. ; If the return is CY and EAX is 0, bad parameter, return 0
  118. or eax, eax
  119. jc DCAPVXD_PMAPI_Fail
  120. ; If the return is CY and EAX is 1, SetEvent was queued. Return -1
  121. neg eax
  122. mov [ebp.Client_EAX], eax
  123. jmp DCAPVXD_PMAPI_OK
  124. EndProc DCAPVXD_Set_Event
  125. ; DCAPVXD_Close_VxD_Handle
  126. ; Frees a locked Win32 object for which we had a pointer. We can only
  127. ; call this from a VxD, unfortunately, even though it's just going to
  128. ; turn around and run it at ring 0.
  129. BeginProc DCAPVXD_Close_VxD_Handle
  130. mov eax, [ebp.Client_ECX]
  131. VxDcall _VWIN32_CloseVxDHandle
  132. jmp DCAPVXD_PMAPI_OK
  133. EndProc DCAPVXD_Close_VxD_Handle
  134. ;******************************************************************************
  135. ;
  136. ; DCAPVXD_DeviceIOControl
  137. ;
  138. ; Handle the 32bit api calls from 32bit applications. The 32 bit apps cannot
  139. ; use int 2f for api calls, so this interface has been provided.
  140. ;
  141. ; We'll just swizzle the parameters into what our int 2F interface expects and
  142. ; call its subroutines.
  143. ;
  144. ; Entry:
  145. ; EAX = W32_DEVICEIOCONTROL
  146. ; EBX = DDB
  147. ; ECX = dwIoControlCode (DIOC_GETVERSION or DIOC_OPEN)
  148. ; EDX = hDevice (Handle)
  149. ; ESI = Pointer to DIOCParams
  150. ;
  151. ; ECX = DIOC_GetVersion = 0
  152. ; DIOC_Open = 0
  153. ; Define our own flags starting at 100h
  154. ;
  155. ;
  156. ;
  157. ;
  158. ; EXIT:
  159. ; EAX = 0 = success
  160. ; ECX = Version number if version call
  161. ;
  162. ;==============================================================================
  163. ;;If we keep adding codes, fixup the jumps below to be a table
  164. ;;If you do this be VERY careful. We are using a magic IOCtl base for
  165. ;;functions. Also, define a common header file, or come see me [mikeg] or
  166. ;;richp.
  167. Public DCAPVXD_DeviceIOControl
  168. BeginProc DCAPVXD_DeviceIOControl
  169. push edi
  170. push esi
  171. mov eax, [esi.lpvInBuffer] ;;If functions added, verify input buffer
  172. mov edi, [esi.lpcbBytesReturned] ;;size
  173. mov edx, [esi.lpvOutBuffer] ;;EDX is HOT! Don't smash
  174. cmp ecx,DIOC_OPEN
  175. jne short @F
  176. mov ecx, 0400h ;;Win95 and later
  177. mov dword ptr [edx],ecx
  178. mov dword ptr [edi], 4
  179. xor eax,eax
  180. jmp short DIOC_Exit
  181. @@:
  182. cmp ecx,DCAPVXD_THREADTIMESERVICE
  183. je short DIOC_ThreadTime
  184. cmp ecx,DCAPVXD_R0THREADIDSERVICE
  185. je short DIOC_GetThreadID
  186. jmp short DIOC_NotImp
  187. DIOC_ThreadTime:
  188. mov eax,dword ptr [eax] ;;eax points to the handle value...
  189. VMMCall _GetThreadExecTime, <eax> ;;C convention...
  190. mov dword ptr [edx],eax
  191. mov dword ptr [edi], 4
  192. xor eax,eax ;;EAX==0 success
  193. jmp short DIOC_Exit
  194. DIOC_GetThreadID:
  195. mov ecx,edi ;;Keep the ptr to the cbBytes....
  196. VMMCall Get_Cur_Thread_Handle
  197. mov dword ptr [edx],edi
  198. mov dword ptr [ecx ], 4
  199. xor eax,eax
  200. jmp short DIOC_Exit
  201. DIOC_NotImp:
  202. mov eax,-1 ;; Failure. No other calls supported
  203. DIOC_Exit:
  204. pop esi
  205. pop edi
  206. clc
  207. ret
  208. EndProc DCAPVXD_DeviceIOControl
  209. VxD_PAGEABLE_CODE_ENDS
  210. END