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.

197 lines
6.2 KiB

  1. ;-----------------------------------------------------------------------
  2. ;
  3. ; APC.INC - Asynchronous Procedure Call Interface File
  4. ;
  5. ;-----------------------------------------------------------------------
  6. ;
  7. ; Author: Mike Toutonghi
  8. ; Copyright: 1993 Microsoft
  9. ;
  10. ;-----------------------------------------------------------------------
  11. ; File Description:
  12. ; Provides an interface to both USER and KERNEL level APCs under
  13. ; Chicago. This file must be kept in sync with APC.H
  14. ;
  15. ;-----------------------------------------------------------------------
  16. ; Revision History:
  17. ; 2/23/93 - created (miketout)
  18. ;
  19. ;-----------------------------------------------------------------------
  20. AssertSignature macro x
  21. ifdef DEBUG
  22. x&_dwSignature dd ?
  23. endif
  24. endm
  25. AssertCreate macro x, p
  26. ifdef DEBUG
  27. mov [p].x&_dwSignature, x&_SIGNATURE
  28. endif
  29. endm
  30. AssertDestroy macro x, p
  31. ifdef DEBUG
  32. mov [p].x&_dwSignature, 44414544h
  33. endif
  34. endm
  35. AssertP macro x, p
  36. ifdef DEBUG
  37. cmp [p].x&_dwSignature, x&_SIGNATURE
  38. Debug_OutNE "Assertion failed"
  39. endif
  40. endm
  41. ;---------------------------------------------------------------------
  42. ; SUPPORT STRUCTURES
  43. ;---------------------------------------------------------------------
  44. APC_FUNC_PROTO TYPEDEF PROTO STDCALL dwParam:DWORD
  45. ; These pointer types are only correct when included in 32 bit code
  46. PAPCFUNC TYPEDEF PTR APC_FUNC_PROTO
  47. PUAPC TYPEDEF PTR USERAPCREC
  48. PKAPC TYPEDEF PTR XKERNELAPCREC
  49. SYNCAPCREC STRUC
  50. sar_nextapc dd 0 ; next APCREC in list
  51. sar_dwparam1 dd 0 ; first parameter
  52. sar_dwparam2 dd 0 ; second parameter
  53. sar_apcaddr dd 0 ; address of APC
  54. sar_dwparam3 dd 0 ; third parameter
  55. AssertSignature SYNCAPCREC
  56. SYNCAPCREC ENDS
  57. SYNCAPCREC_SIGNATURE equ 20524153h
  58. USERAPCREC STRUC
  59. uar_nextapc dd 0 ; next APCREC in list
  60. uar_apcstate dd 0 ; state of APC (APC_DELIVERED)
  61. uar_dwparam dd 0 ; APC parameter
  62. uar_apcaddr dd 0 ; address of APC
  63. uar_apcR0rundown dd 0 ; call if can't deliver APC,
  64. AssertSignature USERAPCREC
  65. USERAPCREC ENDS
  66. USERAPCREC_SIGNATURE equ 20524155h
  67. .errnz ((SIZE USERAPCREC)-(SIZE SYNCAPCREC))
  68. ; APC state flags
  69. APC_DELIVERED equ 0 ; bit set when an APC is delivered
  70. APC_DELIVERED_MASK equ (1 SHL APC_DELIVERED)
  71. APC_FLAG_LAST equ 0 ; last APC flag
  72. KERNELAPCREC STRUC
  73. kar_nextapc dd 0 ; next APCREC in list
  74. kar_dwparam dd 0 ; APC parameter
  75. kar_apcaddr dd 0 ; address of APC
  76. kar_apcevent dd 0 ; set if event queued for APC
  77. kar_savedeax dd 0 ; saved eax for parameter
  78. kar_savedeip dd 0 ; eip for same reason as above
  79. kar_savedcs dw 0 ; saved ring 3 cs to return w/o stk
  80. kar_apcstate dw 0 ; state of APC (KAR_FLAG...)
  81. AssertSignature KERNELAPCREC
  82. KERNELAPCREC ENDS
  83. KERNELAPCREC_SIGNATURE equ 2052414bh
  84. ; KERNEL APC specific flags
  85. KAR_FLAG_BUSY equ 0
  86. KAR_FLAG_BUSY_MASK equ (1 SHL KAR_FLAG_BUSY)
  87. KAR_FLAG_STATIC equ (KAR_FLAG_BUSY+1)
  88. KAR_FLAG_STATIC_MASK equ (1 SHL KAR_FLAG_STATIC)
  89. KAR_FLAG_CALLBACK equ (KAR_FLAG_STATIC+1)
  90. KAR_FLAG_CALLBACK_MASK equ (1 SHL KAR_FLAG_CALLBACK)
  91. IFNDEF STATUS_WAIT_0
  92. STATUS_WAIT_0 EQU 0 ; normal return code
  93. ENDIF
  94. IFNDEF STATUS_USER_APC
  95. STATUS_USER_APC EQU 0C0H ; return code for wake from APC
  96. ENDIF
  97. IFNDEF STATUS_KERNEL_APC
  98. STATUS_KERNEL_APC EQU 0100H ; return code for kernel APC wake
  99. ENDIF
  100. ;
  101. ; Terminate Process Info structure for local reboot init dialog
  102. ;
  103. TPI struc
  104. tpi_ptpiNext dd ?
  105. tpi_hwnd dd ?
  106. tpi_ppdb dd ?
  107. tpi_ptdb dd ?
  108. tpi_flags dd ?
  109. tpi_nIndex dd ?
  110. AssertSignature TPI
  111. TPI ends
  112. TPI_SIGNATURE equ 20495054h
  113. TPIF_HUNG equ 00000001h
  114. TPIF_PROCESSNAME equ 00000002h
  115. ;
  116. ; TerminateThread apc parameter packet. Allocated at ring 3, passed to
  117. ; VxDTerminateThread.
  118. ;
  119. TERMDATA struc
  120. term_ptdb dd ?
  121. term_ptcbAPC dd ?
  122. term_pfnAPC dd ?
  123. term_hAPC dd ?
  124. term_htimeout dd ?
  125. term_pfrinfo dd ?
  126. AssertSignature TERMDATA
  127. TERMDATA ends
  128. TERMDATA_SIGNATURE equ 4d524554h
  129. TPITERM union
  130. tpiterm_term TERMDATA <>
  131. tpiterm_tpi TPI <>
  132. TPITERM ends
  133. ;
  134. ; Parameter packet used to start a ring 0 thread
  135. ;
  136. KERNTHREADSTARTDATA STRUCT
  137. StartAddress dd ? ; start address in ring 3
  138. dwThreadParam dd ? ; parameter for ring 3 startup function
  139. dwKTStackSize dd ? ; ring 3 stack size
  140. dwCreationFlags dd ? ; thread creation flags
  141. pRing3Event dd ? ; set after thread is created
  142. dwThreadID dd ? ; handle for new thread or NULL
  143. dwErrorCode dd ? ; error code if error
  144. KERNTHREADSTARTDATA ENDS
  145. ;
  146. ; Parameter packet used to start a ring 0 win32 thread
  147. ;
  148. R0THREADSTARTDATA STRUCT
  149. R0StartAddress dd ? ; start address in ring 0
  150. dwR0ThreadParam dd ? ; parameter for ring 0 startup function
  151. dwR3StackSize dd ? ; ring 3 stack size
  152. pRing0Event dd ? ; set after thread is created
  153. R0FailCallBack dd ? ; or invoke this callback on failure
  154. dwRing3ThreadID dd ? ; ID for thread
  155. dwRing0ThreadID dd ? ; same for ring 0
  156. R0THREADSTARTDATA ENDS
  157. INCLUDE TDBX.INC
  158. externdef _VWIN32_QueueUserAPC:near
  159. externdef _VWIN32_QueueKernelAPC:near
  160. externdef _VW32_CleanAPCList:near
  161. externdef _DeliverPendingKernelAPCs:near
  162. QueueSyncAPC proto C
  163. DeliverSyncAPCs proto C
  164. CancelKernelAPC proto
  165. CancelSuspendAPC proto
  166. SuspendAPCHandler proto stdcall, Reserved:DWORD