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.

881 lines
29 KiB

  1. ;************************************************************************
  2. ;* *
  3. ;* OBJECT.INC -- General Object Manager Definitions *
  4. ;* *
  5. ;************************************************************************
  6. ;* Author: Gene Apperson *
  7. ;* Copyright: 1991 Microsoft *
  8. ;************************************************************************
  9. ;* File Description: *
  10. ;* *
  11. ;* *
  12. ;************************************************************************
  13. ;* Revision History: *
  14. ;* 12/15/92 (miketout) added object definitions from KERNEL32.INC *
  15. ;* *
  16. ;* NOTE!!!: 2/12/93 (miketout) created WIN\CORE\INC\OBJECT16.INC *
  17. ;* to provide 16 bit code access to 32 bit object types *
  18. ;* (yes, it's not encapsulated as well, but it prevents *
  19. ;* thunking on some critical ops. *
  20. ;* OBJECT16.INC MUST REMAIN IN SYNC WITH THIS FILE *
  21. ;* *
  22. ;************************************************************************
  23. ;* We may be included implicitly by KERNEL32.INC. If we've already been
  24. ;* included, skip our declaration and definition. We match this IFNDEF at
  25. ;* the bottom of the file.
  26. IFNDEF typObjAny
  27. ;* ------------------------------------------------------------ *
  28. ;* Object Type Codes *
  29. ;* ------------------------------------------------------------ *
  30. typObjSemaphore EQU 1
  31. typObjEvent EQU 2
  32. typObjMutex EQU 3
  33. typObjCrst EQU 4
  34. typObjTimer EQU 5
  35. typObjProcess EQU 6
  36. typObjThread EQU 7
  37. typObjFile EQU 8
  38. typObjChange EQU 9
  39. typObjConsole EQU 10
  40. typObjIO EQU 11
  41. typObjConScreenbuf EQU 12
  42. typObjMapFile EQU 13
  43. typObjSerial EQU 14
  44. typObjDevIOCtl EQU 15
  45. typObjPipe EQU 16
  46. typObjMailslot EQU 17
  47. typObjToolhelp EQU 18
  48. typObjSocket EQU 19
  49. typObjR0ObjExt EQU 20
  50. typObjMsgIndicator EQU 21
  51. typObjAny EQU 0FFFFFFFFh
  52. typObjNone EQU 0
  53. ; to let us determine what type of object were dealing with in a
  54. ; wait condition
  55. typObjFirstSync EQU typObjSemaphore
  56. typObjLastSync EQU typObjTimer
  57. typObjFirstWait EQU typObjProcess
  58. typObjLastWait EQU typObjIO
  59. typObjMaxValid EQU typObjMsgIndicator
  60. typObjShiftAdjust EQU (-1)
  61. ;* ------------------------------------------------------------ *
  62. ;* Definitions of Object Type Ptrs *
  63. ;* ------------------------------------------------------------ *
  64. LPPDB TYPEDEF PTR PDB
  65. LPTDB TYPEDEF PTR TDB
  66. LPFCNDB TYPEDEF PTR FCNDB
  67. LPSEM TYPEDEF PTR SEM
  68. LPEVT TYPEDEF PTR EVT
  69. LPMUTX TYPEDEF PTR MUTX
  70. LPCRST TYPEDEF PTR CRST
  71. LPLCRST TYPEDEF PTR LCRST
  72. LPOBJ TYPEDEF PTR OBJ
  73. LPSYNCO TYPEDEF PTR SYNCO
  74. LPNSOBJ TYPEDEF PTR NSOBJ
  75. LPWNOD TYPEDEF PTR WNOD
  76. IFNDEF LPTDBX
  77. LPTDBX TYPEDEF PTR
  78. ENDIF
  79. ; THIS IS TO ALLOW INCLUSION OF THIS FILE IN RING 0 FILES
  80. ; WHERE THESE ITEMS ARE NOT DEFINED
  81. IFNDEF LPVOID
  82. LPVOID TYPEDEF PTR
  83. ENDIF
  84. IFNDEF LPSTR
  85. LPSTR TYPEDEF PTR
  86. ENDIF
  87. IFNDEF LPLST
  88. LPLST TYPEDEF PTR
  89. ENDIF
  90. IFNDEF PREGS
  91. PREGS TYPEDEF DWORD
  92. ENDIF
  93. IFNDEF HANDLE
  94. HANDLE TYPEDEF DWORD
  95. ENDIF
  96. IFNDEF BOOL
  97. BOOL TYPEDEF DWORD
  98. ENDIF
  99. IFNDEF TLS_MINIMUM_AVAILABLE
  100. TLS_MINIMUM_AVAILABLE EQU 80
  101. ENDIF
  102. IFNDEF TLS_MINIMUM_AVAILABLE_GLOBAL
  103. TLS_MINIMUM_AVAILABLE_GLOBAL EQU 8
  104. ENDIF
  105. IFNDEF KERNENTRY
  106. KERNENTRY EQU C
  107. ENDIF
  108. ;* ------------------------------------------------------------ *
  109. ;* Generic Object Structure *
  110. ;* ------------------------------------------------------------ *
  111. ;* This structure defines a generic object. There is an instance
  112. ;* of this structure at the head of all objects in the system. The
  113. ;* generic object manipulation functions operate on fields in this
  114. ;* structure and call on the object specific manipulation functions
  115. ;* based on the object type when necessary.
  116. OBJ STRUCT
  117. typObj BYTE 0 ;* object type
  118. objFlags BYTE 0 ;* object flags
  119. cntUses WORD 0 ;* count of references to this object
  120. OBJ ENDS
  121. fObjTypeSpecific EQU 80h ;* meaning depends on object type
  122. fObjTypeSpecific2 EQU 40h
  123. fObjTypeSpecific3 EQU 20h
  124. ; Various object-specific type flags.
  125. fEvtManualReset EQU fObjTypeSpecific ; set for manual reset
  126. fNewCrstBlock EQU fObjTypeSpecific ; high bit for thread blkd while crst owned (in typObj)
  127. fTimerIsRing3 EQU fObjTypeSpecific2 ;
  128. ; Common object macro
  129. ; To be included in object structure definitions.
  130. ; This structure should always be a multiple of 4 bytes in length
  131. COMMON_OBJECT MACRO
  132. typObj BYTE 0 ;* object type
  133. objFlags BYTE 0 ;* object flags
  134. cntUses WORD 0 ;* count of references to this object
  135. ENDM
  136. ; Common non-synchronization object macro
  137. ; This macro defines data which comprises the base of all
  138. ; waitable objects which are not synchronization objects
  139. COMMON_NSOBJECT MACRO
  140. typObj BYTE 0 ;* object type
  141. objFlags BYTE 0 ;* object flags
  142. cntUses WORD 0 ;* count of references to this object
  143. psyncEvt LPEVT 0 ;* synchronization event for this obj
  144. ENDM
  145. ; Wait node structure
  146. ; This structure is the link which allows threads to wait on multiple
  147. ; synchronization types at once
  148. WNOD STRUC
  149. pwnNext LPWNOD 0 ; pointer to next in this circular list
  150. pwnCirc LPWNOD 0 ; next circular list of wait nodes
  151. ptdbxWait LPTDBX 0 ; waiting thread for this wait node
  152. pobjWait LPOBJ 0 ; object being waited on
  153. WNOD ENDS
  154. ; Every object name is stored in a structure like this one. Each hash table entry
  155. ; for object names points to a forward linked list of these structures.
  156. OBJNAME STRUC
  157. NextOName DWORD 0 ; next in hash list
  158. ObjPtr LPOBJ 0 ; named object this refers to
  159. NameStr BYTE 0 ; name string (one byte)
  160. OBJNAME ENDS
  161. ; This structure contains all of the generic fields for synchronization objects
  162. SYNCO STRUC
  163. COMMON_OBJECT
  164. pwnWait LPWNOD 0 ; pointer to first wait node for this object
  165. cntCur DWORD 0 ; current signaled count
  166. NameStruct DWORD 0 ; pointer to name
  167. SYNCO ENDS
  168. ; This structure is common to NSOBJ type objects
  169. NSOBJ STRUC
  170. COMMON_NSOBJECT
  171. NSOBJ ENDS
  172. ; This defines and structure make up an event object.
  173. ; event structure
  174. EVT STRUC
  175. COMMON_OBJECT
  176. pwnWait LPWNOD 0 ; pointer to first wait node
  177. cntCur DWORD 0 ; current count
  178. NameStruct DWORD 0 ; name pointer
  179. EVT ENDS
  180. ; semaphore structure
  181. SEM STRUC
  182. COMMON_OBJECT
  183. pwnWait LPWNOD 0 ; pointer to first wait node
  184. cntCur DWORD 0 ; current count
  185. NameStruct DWORD 0 ; name pointer
  186. cntMax DWORD 0 ; maximum allowed count
  187. SEM ENDS
  188. ; A Mutex
  189. MUTX STRUC
  190. COMMON_OBJECT
  191. pwnWait LPWNOD 0 ; pointer to first wait node
  192. cntCur DWORD 0 ; own count
  193. NameStruct DWORD 0 ; pointer to object name
  194. ptdbxOwner LPTDBX 0 ; thread which owns this mutex
  195. SysMutexLst DWORD 0 ; link for system mutex list
  196. MUTX ENDS
  197. ; This is the critical section structure
  198. CRST STRUC
  199. typObj BYTE 0 ; typObj already defined
  200. objFlags BYTE 0 ; object flags
  201. objPadding WORD 0 ; OBJ.cntUses not needed
  202. cntRecur DWORD 0 ; recursion count
  203. ptdbxOwner LPTDBX 0 ; owning tdbx
  204. ptdbxWait LPTDBX 0 ; waiting tdbxs
  205. cntCur DWORD 0 ; current count
  206. SysCrstLst DWORD 0 ; system list of critical sections
  207. pdbLst DWORD 0 ; list of owning processes
  208. pextcrst DWORD 0 ; pointer to external critical section
  209. CRST ENDS
  210. ; This is the exported critical section structure which is used to
  211. ; indirectly access the internal critical section structure and handle
  212. ; cleanup.
  213. CRST_EXPORT STRUC
  214. COMMON_OBJECT ; it is an object
  215. crstInternal DWORD 0 ; ptr to internal critical section
  216. CRST_EXPORT ENDS
  217. ;-------------------------------------------------------------
  218. ; GET DEFINES FOR HEIRARCHICAL CRITICAL SECTIONS
  219. ;-------------------------------------------------------------
  220. LCRST_DEFINED EQU ; disable duplicate def in syslevel.inc
  221. INCLUDE SYSLEVEL.INC
  222. ; Heirachical critical section structure
  223. LCRST STRUC
  224. cstSync CRST <> ; sync object
  225. IFDEF SYSLEVELCHECK
  226. slLevel dd 0 ; level defined if sys level checking
  227. ENDIF
  228. LCRST ENDS
  229. ;-------------------------------------------------------------
  230. CREATEDATA16 STRUC
  231. pProcessInfo LPVOID 0 ; LPPROCESS_INFORMATION
  232. pStartupInfo LPVOID 0 ; LPSTARTUPINFO
  233. CREATEDATA16 ENDS
  234. ;-------------------------------------------------------------
  235. ; INCLUDE TIB DEFINITION
  236. ;-------------------------------------------------------------
  237. INCLUDE K32SHARE.INC
  238. INCLUDE APC.INC
  239. ; Thread Data Block structure.
  240. ;
  241. ; !!!! BUGBUG !!!!
  242. ; This definition is duplicated in object.h and core\inc\object16.inc
  243. ;
  244. TDB STRUC
  245. COMMON_NSOBJECT
  246. ifdef WOW
  247. ptib DWORD 0
  248. else ; WOW
  249. tib TIBSTRUCT <> ; Thread Info Block--see above
  250. endif ; else WOW
  251. cntHandles DWORD 0 ; count of handles to this thread
  252. selEmul WORD 0 ; selector for emulator data
  253. selTib WORD 0 ; selector for this TDB
  254. dwStatus DWORD 0 ; thread status/termination code
  255. flFlags DWORD 0
  256. dwPad1 DWORD 0 ; See comments in .\object.h
  257. R0ThreadHandle DWORD 0 ; ring 0 thread handle
  258. wMacroThunkSelStack16 WORD 0 ; Used to be TIBSTRUCT.selStack16
  259. wPad WORD 0
  260. pvMapSSTable LPVOID 0 ; Table of 16-bit ss's for flat thunks
  261. dwCurSS DWORD 0 ; Current default 16-bit ss for flat thunks
  262. dwCurNegBase DWORD 0 ; negative base of current default ss
  263. pvThunkConnectList LPVOID 0 ; head of list of in-progress thunk handshakes
  264. pvExcept16 LPVOID 0 ; head of 16-bit thread exception handler chain
  265. tdb_pcontext LPVOID 0 ; pointer to context. if 0, goto ring 0
  266. tdb_ihteDebugger DWORD 0 ; thread handle for debugger
  267. tdb_pderDebugger LPVOID 0 ; pointer to debugger control block
  268. ercError DWORD 0 ; extended error code for last thread error
  269. pvEmulData LPVOID 0 ; Pointer to emulator data area
  270. pStackBase LPVOID 0 ; stack object base address
  271. ptdbx LPTDBX 0 ; pointer to the per thread TDBX
  272. dwPad2 DWORD 0 ; see comments in .\object.h
  273. TlsArray DWORD TLS_MINIMUM_AVAILABLE+TLS_MINIMUM_AVAILABLE_GLOBAL dup (0) ; thread local storage array
  274. tpDeltaPri DWORD 0 ; delta from base priority class
  275. tdb_tpiterm TPITERM <> ; tpi/termination data union
  276. pCreateData16 LPVOID 0 ; ptr to CREATEDATA16 stuct
  277. dwAPISuspendCount DWORD 0 ; suspend/resume api count
  278. lpLoadLibExDir LPVOID 0 ; LoadLibraryEx() dir (if any)
  279. wSSBig WORD 0 ; selector of optional Big Stack
  280. wPad2 WORD 0
  281. lp16SwitchRec DWORD 0
  282. tdb_htoEndTask DWORD 0
  283. tdb_cMustCompletely DWORD 0
  284. ifdef DEBUG
  285. apiTraceReenterCount DWORD 0 ; api trace reenter count
  286. pSavedRip LPVOID 0 ; saved rip string from 16bit krnl
  287. TlsSetCallerArray DWORD TLS_MINIMUM_AVAILABLE+TLS_MINIMUM_AVAILABLE_GLOBAL dup (0) ; caller's of TlsSetValue
  288. endif
  289. ifdef WOW
  290. hTerminate DWORD 0
  291. endif
  292. TDB ENDS
  293. _TDB TYPEDEF TDB
  294. TDBSTUBSIZE EQU SIZEOF _TDB
  295. ; Flags for TDB.wflFlags
  296. fWaitDefault EQU 0 ; default flags
  297. fWaitAllFlag EQU 1 ; set for wait all, clear for wait any
  298. fWaitCrst EQU 2 ; special critical section wait
  299. ; Flags for TDB.flFlags
  300. fCreateThreadEvent EQU 00000001h
  301. fCancelExceptionAbort EQU 00000002h
  302. fOnTempStack EQU 00000004h
  303. fGrowableStack EQU 00000008h
  304. fDelaySingleStep EQU 00000010h
  305. fOpenExeAsImmovableFile EQU 00000020h
  306. fCreateSuspended EQU 00000040h
  307. fStackOverflow EQU 00000080h
  308. fNestedCleanAPCs EQU 00000100h
  309. fWasOemNowAnsi EQU 00000200h
  310. fOKToSetThreadOem EQU 00000400h
  311. fTermCleanupStack EQU 00000800h
  312. fInCreateProcess EQU 00001000h
  313. fHoldDisplay EQU 00002000h
  314. fHoldSystem EQU 00004000h
  315. ; Flags for fields of PDB.flFlags
  316. fDebugSingle EQU 00000001h
  317. fCreateProcessEvent EQU 00000002h
  318. fExitProcessEvent EQU 00000004h
  319. fWin16Process EQU 00000008h
  320. fDosProcess EQU 00000010h
  321. fConsoleProcess EQU 00000020h
  322. ; fFreeBit
  323. ; fFileApisAreOem EQU 00000040h
  324. fNukeProcess EQU 00000080h
  325. fServiceProcess EQU 00000100h
  326. fProcessCreated EQU 00000200h
  327. fDllRedirection EQU 00000400h
  328. fLoginScripthack EQU 00000800h ;DOS app loaded into existing console and TSR'd
  329. ; These bits can be in either the TDB or the PDB
  330. fSignaled EQU 80000000h
  331. fInitError EQU 40000000h
  332. fTerminated EQU 20000000h
  333. fTerminating EQU 10000000h
  334. fFaulted EQU 08000000h
  335. fTHISSLOTISFREE EQU 04000000h
  336. fNearlyTerminating EQU 00800000h
  337. fDebugEventPending EQU 00400000h
  338. fSendDLLNotifications EQU 00200000h
  339. ; Environment data block for various per-process data including arguments,
  340. ; current directories, handles, and environment strings. This data block
  341. ; resides in the scratch heap.
  342. EDB STRUCT 4
  343. pchEnv LPSTR 0 ; environment block (preceeded by PchEnvHdr)
  344. unused DWORD 0 ; was cbEnvMax
  345. szCmdA LPSTR 0 ; command line (ANSI copy)
  346. szDir LPSTR 0 ; current directory of process
  347. ; hTaskWin16 DWORD 0 ; associated Win16 task handle
  348. pvStartup LPVOID 0 ; pointer to startup information
  349. hStdIn HANDLE 0 ; handle of standard in
  350. hStdOut HANDLE 0 ; handle of standard out
  351. hStdErr HANDLE 0 ; handle of standard error
  352. hProc HANDLE 0 ; handle of the owning process
  353. pInheritedConsole LPVOID 0 ; inherited console
  354. ctrlType DWORD 0 ; ctrlNone, ctrlC, ctrlBreak
  355. psemCtrl LPSEM 0 ; Protects access to control data
  356. pevtCtrl LPEVT 0 ; Control C or Break event
  357. ptdbCtrl LPTDB 0 ; Control handler thread
  358. rgpfnCtrl LPVOID 0 ; Array of Control handlers
  359. cpfnCtrlMac SDWORD 0 ; Last item in array
  360. cpfnCtrlMax SDWORD 0 ; Size of array
  361. rgszDirs LPSTR 26 DUP (0) ; array of drive directories
  362. szCmdW LPSTR 0 ; command line (Unicode copy)
  363. szDirO LPSTR 0 ; current directory OEM copy
  364. EDB ENDS
  365. LPEDB TYPEDEF PTR EDB
  366. ;PCHENVHDR: This header structure must precede the environment strings
  367. ;block pointed to by _edb->pchEnv. It contains the info about the
  368. ;block allocation.
  369. PCHENVHDR STRUCT 4
  370. dwSig DWORD 0 ;Signature: must be PCHENVHDR_SIG
  371. cbReserved DWORD 0 ;# of bytes reserved (must be page-size divisible)
  372. cbCommitted DWORD 0 ;# of bytes committed (must be page-size divisible)
  373. PCHENVHDR ENDS
  374. LPPCHENVHDR TYPEDEF PTR PCHENVHDR
  375. PCHENVHDR_SIG equ 045484350h ;'PCHE'
  376. ; Entrypoints into WSOCK32.DLL
  377. SOCKET_EPTS STRUCT 4
  378. recv DWORD ?
  379. arecv DWORD ?
  380. send DWORD ?
  381. asend DWORD ?
  382. close DWORD ?
  383. SOCKET_EPTS ENDS
  384. MAX_PROCESS_DWORD EQU 1
  385. ; Process Data Block Structure.
  386. PDB STRUCT 4
  387. COMMON_NSOBJECT
  388. dwReserved1 DWORD 0 ; so that other offsets don't change
  389. dwReserved2 DWORD 0 ; so that other offsets don't change
  390. dwStatus DWORD 0 ;Process termination status code
  391. wasDwImageBase DWORD 0 ;Points to PE header for process
  392. hheapLocal HANDLE 0 ;Handle to default local heap for process
  393. hContext DWORD 0 ;Handle to process' private mem. context
  394. flFlags DWORD 0 ;Debugging and inheritance flags
  395. pPsp LPVOID 0 ;Linear address of PSP
  396. selPsp WORD 0 ;Selector for PSP of the process
  397. imte SWORD 0 ;Index to module table entry for this process
  398. cntThreads SWORD 0 ;number of threads in this process
  399. cntThreadsNotTerminated SWORD 0 ;threads not past termination code
  400. UnusedWord1 SWORD 0 ;padding
  401. R0ThreadCount SWORD 0 ;ring 0 version of same
  402. hheapShared HANDLE 0 ;Handle to heap in shared memory
  403. hTaskWin16 DWORD 0 ;Associated Win16 task handle
  404. pFvd DWORD 0 ;Ptr to memory mapped file view descriptors
  405. pedb LPEDB 0 ;Pointer to environment data block
  406. phtbHandles LPVOID 0 ;Handle table
  407. ppdbParent LPPDB 0 ;Pointer to PDB of parent process
  408. plstMod LPLST 0 ;Pointer to process module table list
  409. plstTdb LPLST 0 ;Pointer to list of threads
  410. pdb_pdeeDebuggee LPVOID 0 ;Pointer to debuggee control block
  411. plhFree LPVOID 0 ;Local heap free handle list head ptr
  412. pid DWORD 0 ;ID, same as initial thread id
  413. crstLoadLock LCRST <> ;loader synchronization (hierarchical)
  414. pConsole LPVOID 0 ;Console
  415. TlsIdxMask DWORD ((TLS_MINIMUM_AVAILABLE+31)/32) dup(0) ; mask of used TLS idxs
  416. adw DWORD MAX_PROCESS_DWORD dup(0) ;free-form storage
  417. ppdbPGroup LPPDB 0 ;process group this process belongs to
  418. pModExe LPVOID 0 ;pointer to ModRef of EXE
  419. pExceptionFilter DWORD 0 ;set by SetUnhandledExceptionFilter
  420. pcPriClassBase DWORD 0 ;priority value of this processes' pri class
  421. hhi_procfirst HANDLE 0 ;linked list of heaps for this process
  422. plhBlock DWORD 0 ;local heap lhandle blocks
  423. psock_epts DWORD 0 ;socket entrypoints
  424. pconsoleProvider DWORD 0 ;pconsole that winoldapp is providing.
  425. wEnvSel WORD 0 ;selman-alloced DOS environment selector
  426. wErrorMode WORD 0 ;handling of critical errors
  427. pevtLoadFinished LPEVT 0 ;waiting for load to be finished
  428. hUTState WORD 0 ;UT info
  429. pad3 WORD 0
  430. lpCmdLineNoQuote DWORD 0 ;Optional unquoted command line (apphack)
  431. PDB ENDS
  432. _PDB TYPEDEF PDB
  433. PDBSTUBSIZE EQU SIZEOF _PDB
  434. cppdbProcTableInit EQU 32 ; maximum number of processes
  435. ;* File Data Block Structure.
  436. FDB STRUCT 4
  437. COMMON_NSOBJECT
  438. hdevDos WORD 0 ; DOS device handle
  439. wDupSrcPSPSel WORD 0 ; NETX: if inter-PSP dup'ed = src pspseg
  440. cfhid DWORD 0 ; (CFH_ID) look in object.h
  441. FDB ENDS
  442. ;* Find Change Notify Structure.
  443. FCNDB STRUCT 4
  444. COMMON_NSOBJECT
  445. hChangeInt DWORD 0 ; internal change handle
  446. FCNDB ENDS
  447. ;* Pipe Data Block Structure.
  448. PIPDB STRUCT 4
  449. COMMON_OBJECT
  450. hMem DWORD 0 ; Mem handle of pipe
  451. hNmPipe DWORD 0 ; Named pipe handle (hInvalid if anon)
  452. rdRef DWORD 0 ; Ref count on read handle
  453. wrRef DWORD 0 ; Ref count on write handle
  454. pszByt DWORD 0 ; Size of hMem (pipe) in bytes
  455. wPtr DWORD 0 ; write pointer (offset in hMem)
  456. ; Pointer to last byte written
  457. rPtr DWORD 0 ; read pointer (offset in hMem)
  458. ; Pointer to next byte to read
  459. wBlkEvnt DWORD 0 ; write event handle (waiting for room to write)
  460. rBlkEvnt DWORD 0 ; read event handle (waiting for data to read)
  461. PIPDB ENDS
  462. ;* Mailslot Data Block Structure.
  463. MSDB STRUCT 4
  464. COMMON_OBJECT
  465. lpMSName DWORD 0 ; Pnt to name of mailslot (== 0 for
  466. ; read (CreateMailslot) handle)
  467. hMSDos DWORD 0 ; INT 21 mailslot handle (== 0FFFFFFFFh
  468. ; for write (CreateFile) handle)
  469. MSDB ENDS
  470. ;* ToolHelp Data Block Structure.
  471. TLHPDB STRUCT 4
  472. COMMON_OBJECT
  473. ClassEntryCnt DWORD 0
  474. ClassEntryList DWORD 0
  475. HeapListCnt DWORD 0
  476. HeapList DWORD 0
  477. ProcessEntryCnt DWORD 0
  478. ProcessEntryList DWORD 0
  479. ThreadEntryCnt DWORD 0
  480. ThreadEntryList DWORD 0
  481. ModuleEntryCnt DWORD 0
  482. ModuleEntryList DWORD 0
  483. TLHPDB ENDS
  484. ;;
  485. ;; A dynamic extension to the timerdb that's used whenever a ring-3 timer
  486. ;; is armed with a completion function. This structure must live in locked
  487. ;; memory.
  488. ;;
  489. ;; Access to this structure is serialized by being in a no-preempt section.
  490. ;; There are no semaphores guarding it.
  491. ;;
  492. ;; This structure is allocated whenever SetWaitableTimer() is called on a
  493. ;; timer with a non-null completion function. It's stored in the Completion
  494. ;; field and the fTimerIsRing3 bit is set to indicate that this a TIMERR3APC
  495. ;; (opposed to a ring-0 DPC.)
  496. ;;
  497. ;; This structure is detached from the timerdb on the next call to
  498. ;; CancelWaitableTimer(). It's also usually freed at this time except
  499. ;; if a cancel occurs after the last apc has been delivered but TimerApcHandler
  500. ;; hasn't yet set fHandlerDone to indicate that's it finished using the
  501. ;; structure. In this case, we can't free it so we instead link it onto
  502. ;; the TimerDisposalWaitingList. When fHandlerDone does become TRUE,
  503. ;; it will be available for pickup the next time we need one of these
  504. ;; structures.
  505. ;;
  506. ;; The automatic rearming of a periodic timer reuses the existing
  507. ;; TIMERR3APC. It checks the fHandleDone: if the handler hasn't
  508. ;; finished (or begun) on the previous apc, we don't schedule a new
  509. ;; one (as per specs).
  510. ;;
  511. ;; Fields:
  512. ;; cRef - reference count
  513. ;; pfnCompletion - Ptr to ring-3 completion (never NULL)
  514. ;; lpCompletionArg - uninterpreted argument to pfnCompletion
  515. ;; R0ThreadHandle - thread that called SetWaitableTimer()
  516. ;; DueTime - trigger time to pass to pfnCompletion. This
  517. ;; field isn't set until the timer goes off.
  518. ;; dwApcHandle - if apc has been queued, contains the underlying
  519. ;; apc handle. This apc handle gets recycled at the
  520. ;; same time we free the TIMERR3APC (or in the case
  521. ;; of a periodic timer, when we reuse the structure
  522. ;; for the next arming.)
  523. ;; lpNext - Used for linking in TimerDisposalWaitingList,
  524. ;; undefined otherwise.
  525. ;;
  526. ;;
  527. ;;
  528. TIMERR3APC STRUCT 4
  529. t3a_cRef DWORD 0
  530. t3a_pfnCompletion DWORD 0
  531. t3a_lpCompletionArg DWORD 0
  532. t3a_ApcTdbx DWORD 0
  533. t3a_DueTime QWORD 0
  534. t3a_dwApcHandle DWORD 0
  535. t3a_lpNext DWORD 0
  536. t3a_lpTimerDB DWORD 0
  537. TIMERR3APC ENDS
  538. LPTIMERR3APC TYPEDEF PTR TIMERR3APC
  539. ;; Timer object.
  540. ;;
  541. ;; Notes:
  542. ;; The timerdb must ALWAYS be pagelocked. This is consistent
  543. ;; with the requirement that the structure passed to KeSetTimer
  544. ;; be pagelocked. Furthermore, we use the non-preemptibility of
  545. ;; of ring-0 code to serialize access to many parts of the structure
  546. ;; (due to the fact that much of this code has to run at event time.)
  547. ;; This non-preemptibility is guaranteed only if the structure is
  548. ;; locked.
  549. ;;
  550. ;; Timers can be created at ring-0 or ring-3. If a timer is created at
  551. ;; ring-3, the memory is always allocated and deallocated by kernel32.
  552. ;; Kernel32 also makes sure that an explicit canceltimer is always done
  553. ;; on the timer before it is finally freed - we depend on this fact
  554. ;; to do the proper cleanup for timerr3apc's.
  555. ;;
  556. ;; Timers created at ring-3 can be passed to Ke* routines.
  557. ;;
  558. ;; Timers created at ring-0 cannot be passed to SetWaitableTimer() at
  559. ;; ring-3. (There are some nasty cleanup problems associated with this
  560. ;; due to the fact that ring-0 timers are freed by the device driver
  561. ;; with no notification given to the system.)
  562. ;;
  563. ;; We use the cntUses field to determine whether a timer was created
  564. ;; at ring 3.
  565. ;;
  566. ;; Synchronization:
  567. ;;
  568. ;; typObj Static, none needed
  569. ;; objFlags
  570. ;; fTimerIsRing3 by being in a no-preempt section
  571. ;; cntUses Used by handle manager
  572. ;; pwnWait WaitR0
  573. ;; cntCur WaitR0 [w/ one exception: see [1])
  574. ;; NameStruct Krn32Lock - used only at ring3
  575. ;; lpNextTimerDb by being in a no-preempt section
  576. ;; hTimeout by being in a no-preempt section
  577. ;; DueTime by being in a no-preempt section
  578. ;; Completion by being in a no-preempt section
  579. ;; lPeriod by being in a no-preempt section
  580. ;;
  581. ;; [1] Because KeSetTimer has to unsignal the timer, and be
  582. ;; able to do it at event time, it pokes a zero directly
  583. ;; into cntCur. But this is ok because the only code
  584. ;; that signals timers is TimerDoTimeout which is
  585. ;; non-preemptive.
  586. ;;
  587. ;; Flag descriptions:
  588. ;;
  589. ;; fTimerIsRing3
  590. ;; If the COMPLETION is non-null, this bit indicates whether the
  591. ;; COMPLETION points to a TIMERR3APC (ring-3 completion) or a KDPC
  592. ;; (ring-0 completion.) The value of this bit is undefined at any
  593. ;; other time.
  594. ;;
  595. ;;
  596. ;;
  597. ;; Field descriptions:
  598. ;;
  599. ;; <common-obj and common-sync stuff omitted>
  600. ;;
  601. ;; lpNextTimerDb:
  602. ;; All active timers that were set with fResume TRUE are linked into
  603. ;; TimerSysLst (for the purpose of knowing how to program the power
  604. ;; timer.) This field is NULL when the timer is inactive or active
  605. ;; without fResume. It is undefined while the timer is in the INPROGRESS
  606. ;; state.
  607. ;;
  608. ;; hTimeout
  609. ;; If the timer is active, this field contains the handle to the
  610. ;; underlying VMM hTimeout. If the timer is inactive, this
  611. ;; field is NULL. If the timer is in the in-progress state,
  612. ;; this field is undefined (actually points to a stale VMM timeout
  613. ;; handle!)
  614. ;;
  615. ;;
  616. ;; DueTime:
  617. ;; If the timer is active, contains the absolute time that the
  618. ;; timer is due to go off. Expressed as a FILETIME converted from
  619. ;; GetSystemTime. Undefined if the timer isn't active.
  620. ;;
  621. ;; Completion:
  622. ;; Then contains either:
  623. ;; NULL - no completion was set
  624. ;; LPTIMERR3APC - if fTimerIsRing3 is set
  625. ;; PKDPC - if fTimerIsRing3 is not set.
  626. ;;
  627. ;; Note that it is normal for a timer to be inactive and contain
  628. ;; a pointer to a TIMERR3APC structure. This case occurs when
  629. ;; a timer set with a ring-3 completion fires normally. The
  630. ;; TIMERR3APC structure is kept around so that a subsequent
  631. ;; CancelWaitableTimer() can retrieve the underlying apc handle
  632. ;; embedded in it.
  633. ;;
  634. ;; lPeriod:
  635. ;; Contains either 0 for a one-shot timer or a positive value
  636. ;; (the firing period in milliseconds.)
  637. TIMERDB STRUCT 4
  638. COMMON_OBJECT ; standard waitable non-synchronization object
  639. ;; These fields have to appear in this form because a timer is a sync object.
  640. tmr_pwnWait DWORD 0 ;pointer to the wait node for this object
  641. tmr_cntCur DWORD 0 ;signaled state
  642. tmr_NameStruct DWORD 0 ;name structure for this object
  643. ;; These fields are timer-specific.
  644. tmr_lpNextTimerDb DWORD 0 ;link in TimerSysLst (can be NULL)
  645. tmr_hTimeout DWORD 0
  646. tmr_DueTime QWORD 0
  647. tmr_Completion DWORD 0 ;completion routine (or NULL)
  648. tmr_lPeriod DWORD 0
  649. ;; Try not to add new fields. This structure cannot exceed 40 bytes
  650. ;; or we break compatibility with NT's Ke api. If you try to hang
  651. ;; another structure off it, remember that the Ke*Timer apis can't
  652. ;; allocate memory from the heap (system meltdown if these apis
  653. ;; are called at event time on a system that's paging thru DOS.)
  654. TIMERDB ENDS
  655. ;; Must be no larger than the NT KTIMER structure (which is 40 bytes.)
  656. ;; Checking for our exact size so that anyone who changes the size
  657. ;; will have to stop and consider.
  658. .errnz SIZEOF TIMERDB - 40
  659. LPTIMERDB TYPEDEF PTR TIMERDB
  660. ;* Console Input Data Block Structure.
  661. CIDB STRUCT 4
  662. COMMON_OBJECT
  663. hdevDos WORD 0 ; DOS device handle
  664. WORD 0
  665. flMode DWORD 0 ; Object mode
  666. CIDB ENDS
  667. ;* Console Output Data Block Structure.
  668. CODB STRUCT 4
  669. COMMON_OBJECT
  670. hdevDos WORD 0 ; DOS device handle
  671. WORD 0
  672. flMode DWORD 0 ; Object mode
  673. ; Next fields are the same as CONSOLE_SCREEN_BUFFER
  674. ; dwSize
  675. xMax WORD 0 ; Maximum column in buffer
  676. yMax WORD 0 ; Maximum row in buffer
  677. ; dwCursorPosition
  678. xCurPos WORD 0 ; Current cursor column
  679. yCurPos WORD 0 ; Current cursor row
  680. ; dwScrollPosition
  681. xScrollPos WORD 0 ; Column of buffer in window
  682. yScrollPos WORD 0 ; Row of buffer in window
  683. wAttrib WORD 0 ; Current color
  684. ; dwCurrentWindowSize
  685. xCurWin WORD 0 ; Columns of current window
  686. yCurWin WORD 0 ; Rows of current window
  687. ; dwMaximumWindowSize
  688. xMaxWin WORD 0 ; Maximum window width
  689. yMaxWin WORD 0 ; Maximum window height
  690. ; Next two fields are the same as CONSOLE_CURSOR_INFO
  691. dwSize DWORD 0 ; Percent of cursor fill
  692. fVisible BOOL 0 ; Visibility of cursor
  693. ; Remaining fields are private
  694. wIniAttrib WORD 0 ; Startup color
  695. wText WORD 0
  696. xpChar WORD 0 ; Pixel width of character (not used)
  697. ypChar WORD 0 ; Pixel height of character
  698. pvWin LPVOID 0 ; Address of current text window
  699. pvWinMax LPVOID 0 ; Last valid window address
  700. cbLine DWORD 0 ; Bytes per row
  701. CODB ENDS
  702. LPCODB TYPEDEF PTR CODB
  703. ; WARNING!!!
  704. ; This must remain consistent with CORE\WIN32\INC\CONSOLE.H and VMDOSAPP\GRABEMU.ASM
  705. ;MAXTITLESIZE EQU 128 ; Same as in Winoldap (tty.inc)
  706. ;CONSOLE STRUCT
  707. ; COMMON_NSOBJECT
  708. ; psbActiveScreenBuffer DWORD 0 ; Pointer to active screen buffer (if any)
  709. ; cMaxSize DWORD 0 ; Max size of this console (maintained by WinOldAp)
  710. ; flags DWORD 0 ; Various console flags
  711. ; cOriginalSize DWORD 0 ; Size inherited from DOS
  712. ; csCRST CRST <> ; critical section for synching access to lists, etc.
  713. ; plstOwners DWORD 0 ; pointer to list of owners (processes)
  714. ; plstBuffers DWORD 0 ; pointer to list of screen buffers
  715. ; dwLastExitCode DWORD 0 ; Most recent exit code by a process in this console group
  716. ; szTitle BYTE MAXTITLESIZE DUP(0) ; Title (displayed by WinOldAp)
  717. ; VID DWORD 0 ; ID used by VCOND
  718. ; hVM DWORD 0 ; Process handle of VM which supports this console for i/o
  719. ; hDisplay DWORD 0 ; hwnd of display port (used by WinOldAp)
  720. ; ppdbControlFocus LPPDB 0 ; Process which holds current control focus for this console
  721. ; ; rest is not currently interesting
  722. ;CONSOLE ENDS
  723. SDB STRUC
  724. COMMON_OBJECT
  725. SerialHandle DWORD 0
  726. Flags DWORD 0
  727. SDB ENDS
  728. LPSDB TYPEDEF PTR SDB
  729. ;* ------------------------------------------------------------ *
  730. ;* Function Prototypes
  731. ;* ------------------------------------------------------------ *
  732. ; LPOBJ
  733. NewObject PROTO KERNENTRY, :DWORD, :BYTE
  734. ; VOID
  735. DisposeObj PROTO KERNENTRY, :LPVOID
  736. ; VOID
  737. UseObject PROTO KERNENTRY, :LPVOID
  738. ; BOOL
  739. FUnuseObject PROTO KERNENTRY, :LPVOID
  740. ; LPOBJ
  741. PobjDupObject PROTO KERNENTRY, :LPOBJ
  742. ; VOID
  743. LockObject PROTO KERNENTRY, :LPOBJ
  744. ; VOID
  745. UnlockObject PROTO KERNENTRY, :LPOBJ
  746. ;* Matching IFNDEF at top of file
  747. ENDIF
  748. ;* ------------------------------------------------------------ *
  749. ;* ------------------------------------------------------------ *
  750. ;* ------------------------------------------------------------ *
  751. ;* ------------------------------------------------------------ *
  752. ;* ------------------------------------------------------------ *
  753. ;****************************************************************