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.

1211 lines
23 KiB

  1. ;* KERNEL32.INC
  2. ;*
  3. ;* (C) Copyright Microsoft Corp., 1988-1994
  4. ;*
  5. ;* Main .ASM definitions
  6. ;*
  7. ;* Origin: Dos Extender
  8. ;*
  9. ;* Change history:
  10. ;*
  11. ;* Date Who Description
  12. ;* --------- --------- -------------------------------------------------
  13. ;* 16-Feb-94 JonT Code cleanup
  14. ;*
  15. IFNDEF _KERNEL32_
  16. _KERNEL32_ EQU 1
  17. ; Calling Convention for internal
  18. KERNENTRY TEXTEQU <stdcall>
  19. include k16thk.inc
  20. ;=====================================================================
  21. ; Debug macros
  22. WOWDEBUG EQU 1
  23. IFDEF WOWDEBUG
  24. DEB_FATAL equ 0
  25. DEB_ERR equ 1
  26. DEB_WARN equ 2
  27. DEB_TRACE equ 3
  28. ; VOID
  29. PrintFailedAssertion PROTO KERNENTRY,
  30. iln:SDWORD,
  31. szFile:PTR SBYTE
  32. ; VOID
  33. vDebugOut PROTO C,
  34. level:SDWORD,
  35. pfmt:VARARG
  36. Assert MACRO cond, disable:=<0>
  37. ;; Define file name if it's not already defined
  38. IFNDEF szSrcFile
  39. .DATA
  40. % szSrcFile BYTE "&@FileCur", 0
  41. .CODE
  42. ENDIF
  43. IF disable
  44. EXITM
  45. ENDIF
  46. ;; Conditionally invoke function to print data
  47. .IF !(cond)
  48. INVOKE PrintFailedAssertion, @Line, ADDR szSrcFile
  49. .ENDIF
  50. ENDM
  51. Break TEXTEQU <int 3>
  52. ELSE ;IFDEF DEBUG
  53. Assert MACRO cond
  54. ENDM
  55. Break TEXTEQU <>
  56. ENDIF
  57. MAJOR_VERSION EQU 1
  58. MINOR_VERSION EQU 0
  59. WIN_VERSION EQU 0
  60. VERSION EQU WIN_VERSION OR \
  61. (MAJOR_VERSION SHL 8) OR \
  62. (MINOR_VERSION SHL 12) OR \
  63. (OS SHL 15)
  64. ; Path name separators and other values that might be localized.
  65. wNetIni TEXTEQU <WORD PTR '\\'>
  66. chNetIni TEXTEQU <BYTE PTR '\'>
  67. chExtSep TEXTEQU <BYTE PTR '.'>
  68. chDirSep TEXTEQU <BYTE PTR '\'>
  69. chDirSep2 TEXTEQU <BYTE PTR '/'>
  70. chDrvSep TEXTEQU <BYTE PTR ':'>
  71. wRelDir TEXTEQU <WORD PTR '..'>
  72. chRelDir TEXTEQU <BYTE PTR '.'>
  73. chMinDrv TEXTEQU <BYTE PTR 'A'>
  74. chMaxDrv TEXTEQU <BYTE PTR 'Z'>
  75. chMinDrvLow TEXTEQU <BYTE PTR 'a'>
  76. chMaxDrvLow TEXTEQU <BYTE PTR 'z'>
  77. chEnvSep TEXTEQU <BYTE PTR ';'>
  78. chWldChr TEXTEQU <BYTE PTR '?'>
  79. chWldSeq TEXTEQU <BYTE PTR '*'>
  80. fbUpper EQU 11011111b ; Mask converts to uppercase
  81. Unused MACRO param
  82. unuseddummysymbol = SIZEOF param
  83. ENDM
  84. ;* Constants
  85. cbPage EQU 4096
  86. fTrue EQU 1
  87. fFalse EQU 0
  88. ;* DOS maximum for paths and directories. Add one to each for null.
  89. cbNull EQU 1
  90. cbDirMax EQU 260 ; \dir\subdir\..\file.ext
  91. cbDrvMax EQU 3 ; c:\
  92. cbNetMax EQU 36 ; \\machine\share
  93. cbCompMax EQU 255
  94. cbPathMax EQU 260
  95. cbCmdMax EQU 100h - 80h ; All the room in PSP for command line
  96. cbCopyBufMin EQU 8000h ; 32K default
  97. ; The following is a "magic value" that we use on a number of the NET
  98. ; int 21h calls. The reason for this has to do with the way the INT 21
  99. ; API mapper in DOSMGR.386 works. For INT 21s from protected mode that
  100. ; DOSMGR doesn't understand how to map, all of the segment registers in
  101. ; the client structure get set to 0 BY DESIGN. To keep the NET layers
  102. ; from getting confused, it needs to KNOW that the call is from WIN32
  103. ; and the seg registers should just be ignored (all pointers are FLAT).
  104. ; We flag this case by putting this special signature in a 32-bit
  105. ; register, usually EBP.
  106. ;
  107. MAGICWIN32NETINT21SIG EQU 41524A44h
  108. ;* Wait constants
  109. dwWaitForever EQU 0FFFFFFFFh
  110. dwWaitNone EQU 0
  111. PATH_INVALID EQU (-1)
  112. DRIVE_NO_ROOT EQU 1
  113. DRIVE_INVALID EQU (-2)
  114. PATH_NETWORK EQU 2
  115. PATH_ROOT_OR_REL_TO_CURDIR EQU 1
  116. PATH_RELATIVE EQU 0
  117. FILE_ATTRIBUTE_VALID_FLAGS EQU 67h
  118. ;* Type definitions
  119. SEL TYPEDEF WORD
  120. HM TYPEDEF DWORD
  121. ; Type for 16:16 and 16:32 far pointers. We only use these internally.
  122. FPVOID16 TYPEDEF FAR16 PTR
  123. FPVOID TYPEDEF FAR32 PTR
  124. ; Size of reserved memory region above and below stacks. Thunks always map
  125. ; a 64K stack selector, so we should have 64K reserved above the stack.
  126. STACK_BARRIER_SIZE EQU 10000h
  127. WIN16_TERMINATION_STACK_SIZE EQU 2000h
  128. ; Register State Context Structure.
  129. REGS STRUCT 4
  130. regSS DWORD 0
  131. regGS DWORD 0
  132. regFS DWORD 0
  133. regES DWORD 0
  134. regDS DWORD 0
  135. regEDI DWORD 0
  136. regESI DWORD 0
  137. regEBP DWORD 0
  138. regESP DWORD 0
  139. regEBX DWORD 0
  140. regEDX DWORD 0
  141. regECX DWORD 0
  142. regEAX DWORD 0
  143. regEIP DWORD 0
  144. regCS DWORD 0
  145. regEFL DWORD 0
  146. REGS ENDS
  147. PREGS typedef PTR REGS
  148. ; Pointers to structures defined first so they can be used in structures
  149. LPNOD TYPEDEF PTR NOD
  150. LPLST TYPEDEF PTR LST
  151. NOD STRUCT 4
  152. pnodNext LPNOD 0 ; pointer to the next node in the list
  153. pnodPrev LPNOD 0 ; pointer to the previous node in the list
  154. dwData DWORD 0 ; data element associated with this node
  155. NOD ENDS
  156. LST STRUCT 4
  157. pnodHead LPNOD 0 ; pointer to first node in list
  158. pnodEnd LPNOD 0 ; pointer to last node in list
  159. pnodCur LPNOD 0 ; pointer to current node in list
  160. LST ENDS
  161. ; 16-bit CreateThread 32->16 thunk data
  162. THREAD_STARTUP_THUNK_DATA STRUCT 4
  163. Param16 DWORD 0
  164. StartAddress16 DWORD 0
  165. THREAD_STARTUP_THUNK_DATA ENDS
  166. ;* ------------------------------------------------------------ *
  167. ;* If objects are not yet included, include them *
  168. ;* ------------------------------------------------------------ *
  169. IFNDEF typObjAny
  170. INCLUDE OBJECT.INC
  171. ENDIF
  172. cbKernelHeap EQU 262144
  173. ; The following bits define the per page status information stored
  174. ; in the page info table. This table is an array of DWORDS, where
  175. ; each entry contains info bits for 6 pages (with the high two bits
  176. ; not used.
  177. mskPageInfo EQU 3Fh
  178. mskPageProtect EQU 0Fh
  179. mskPageType EQU 30h
  180. mskPageRsv EQU 10h
  181. mskPageCommit EQU 20h
  182. ; This structure is used to keep track of information about each
  183. ; memory allocation that the user makes.
  184. VMHD STRUCT 4
  185. pvBase LPVOID 0 ; base address of the memory block
  186. cbSize DWORD 0 ; total size of the memory block
  187. hmDpmi DWORD 0 ; DPMI memory handle of the block
  188. pidOwner DWORD 0 ; process ID of memory block owner
  189. pbPageInfo LPSTR 0 ; pointer to page info table for object
  190. flStatus WORD 0 ; status flags for the memory block
  191. fGlobal WORD 0 ; flag for global or virtual APIs
  192. VMHD ENDS
  193. PVMHD TYPEDEF PTR VMHD
  194. LPVMHD TYPEDEF PTR VMHD
  195. ; *** Global variables ***
  196. ifdef WOW
  197. EXTERNDEF dwMEOWFlags:DWORD
  198. else ; WOW
  199. ifdef MEOW_LOGGING
  200. EXTERNDEF dwMEOWFlags:DWORD
  201. endif ; def MEOW_LOGGING
  202. endif ; def WOW
  203. EXTERNDEF selLDT:SEL
  204. EXTERNDEF pLDT:PTR DWORD
  205. EXTERNDEF dwDscAddrToRing3Sel:DWORD
  206. EXTERNDEF selK32Psp:SEL
  207. EXTERNDEF lmaUserBase:LPVOID
  208. EXTERNDEF szWinDir:LPSTR, szSysDir:LPSTR
  209. ifndef WOW
  210. EXTERNDEF pppdbCur:PTR LPPDB
  211. EXTERNDEF pptdbCur:PTR LPTDB
  212. EXTERNDEF ppTDBXCur:PTR PTR TDBX
  213. endif ; ndef WOW
  214. EXTERNDEF ppdbKernel:LPPDB
  215. EXTERNDEF ptdbWin16:LPTDB
  216. EXTERNDEF ptdbSvc:LPTDB
  217. EXTERNDEF bBeepControl:BYTE
  218. EXTERNDEF Win16Lock:PTR LCRST
  219. EXTERNDEF Krn32Lock:PTR LCRST
  220. EXTERNDEF selFlatCode:USHORT
  221. EXTERNDEF selFlatData:USHORT
  222. ;* Function Prototypes
  223. ;* THKINIT.ASM
  224. ; VOID
  225. ThkInit PROTO KERNENTRY
  226. ;* DXKRNL.C
  227. ; LPVOID
  228. PvKernelAlloc PROTO KERNENTRY,
  229. cbSize:DWORD
  230. ; VOID *
  231. PvKernelRealloc PROTO KERNENTRY,
  232. pvMem:LPVOID,
  233. cbSize:DWORD
  234. ; VOID
  235. FKernelFree PROTO KERNENTRY,
  236. pvMem:LPVOID
  237. ; LONG
  238. KernelInit PROTO KERNENTRY,
  239. pK32Data:DWORD
  240. ;VOID
  241. KernelUninit PROTO KERNENTRY
  242. ;* KRNLUTIL.ASM
  243. ; VOID
  244. FillBytes PROTO KERNENTRY,
  245. pbDst:LPSTR,
  246. cb:DWORD,
  247. bData:DWORD
  248. ; DWORD
  249. CbSizeSz PROTO KERNENTRY,
  250. szStr:LPSTR
  251. ; VOID
  252. CopySz PROTO KERNENTRY,
  253. szDst:LPSTR,
  254. szSrc:LPSTR
  255. ; VOID
  256. AppendSz PROTO KERNENTRY,
  257. szDst:LPSTR,
  258. szSrc:LPSTR
  259. ; VOID
  260. LCompareSz PROTO KERNENTRY,
  261. sz1:LPSTR,
  262. sz2:LPSTR
  263. ; VOID
  264. LCompareNSz PROTO KERNENTRY,
  265. sz1:LPSTR,
  266. sz2:LPSTR,
  267. n:DWORD
  268. ; VOID
  269. dputs PROTO KERNENTRY,
  270. sz:LPSTR
  271. ; VOID
  272. KInt21 PROTO KERNENTRY
  273. ; DWORD
  274. FGetSelBase PROTO KERNENTRY,
  275. selGet:WORD
  276. ;* HEAPMGR.C
  277. ; HANDLE
  278. HheapCreateHeap PROTO KERNENTRY,
  279. flOptions:DWORD,
  280. cbInitialSize:DWORD,
  281. cbMaxSize:DWORD
  282. ; VOID
  283. HeapInit PROTO KERNENTRY,
  284. pbHeap:LPVOID,
  285. flOptions:DWORD,
  286. cbInitialSize:DWORD,
  287. cbMaxSize:DWORD
  288. ; BOOL
  289. FHeapDestroy PROTO KERNENTRY,
  290. hheap:HANDLE
  291. ; LPVOID
  292. PvAllocHeapMem PROTO KERNENTRY,
  293. hheap:HANDLE,
  294. cbSize:DWORD
  295. ; LPVOID
  296. PvResizeHeapMem PROTO KERNENTRY,
  297. hheap:HANDLE,
  298. pvMem:LPVOID,
  299. cbNew:DWORD
  300. ; BOOL
  301. FFreeHeapMem PROTO KERNENTRY,
  302. hheap:HANDLE,
  303. pvMem:LPVOID
  304. ; DWORD
  305. CbSizeHeapMem PROTO KERNENTRY,
  306. hheap:HANDLE,
  307. pvMem:LPVOID
  308. ;* IOUTIL.ASM
  309. DFH_FILE_CREATE EQU 0010h
  310. DFH_FILE_OPEN EQU 0001h
  311. DFH_FILE_TRUNCATE EQU 0002h
  312. DFH_ACTION_OPENED EQU 0001h
  313. DFH_ACTION_CREATED_OPENED EQU 0002h
  314. DFH_ACTION_REPLACED_OPENED EQU 0003h
  315. DFH_MODE_READONLY EQU 0000h
  316. DFH_MODE_WRITEONLY EQU 0001h
  317. DFH_MODE_READWRITE EQU 0002h
  318. DFH_MODE_SHARE_COMPATIBILITY EQU 0000h
  319. DFH_MODE_SHARE_EXCLUSIVE EQU 0010h
  320. DFH_MODE_SHARE_DENYWRITE EQU 0020h
  321. DFH_MODE_SHARE_DENYREAD EQU 0030h
  322. DFH_MODE_SHARE_DENYNONE EQU 0040h
  323. DFH_MODE_NO_INHERIT EQU 0080h
  324. DFH_MODE_EXTENDED_SIZE EQU 1000h
  325. ; DfhOpenFile
  326. ; FCloseFile
  327. ; CbReadFile
  328. ; CbWriteFile
  329. ; CbWriteOutFile
  330. ; LfoSetFilePos
  331. ; DWORD
  332. GetDOSExtendedError PROTO KERNENTRY
  333. ;* PROCESS.C
  334. ;BOOL
  335. CreateProcessKernel PROTO KERNENTRY, :PTR, :PTR, :PTR, :WORD, :PTR, :PTR
  336. ;VOID
  337. TerminateProcessKernel PROTO KERNENTRY
  338. ;VOID
  339. ExitCurrentProcess PROTO KERNENTRY, :DWORD
  340. ;VOID
  341. TerminateProcessOutOfContext PROTO KERNENTRY, ppdb:PTR, dwStatus:DWORD
  342. ;VOID
  343. TerminateProcessFinal PROTO KERNENTRY, ppdb:PTR
  344. ;VOID
  345. DisposePDB PROTO KERNENTRY, ppdb:PTR
  346. ;PDB*
  347. NewPDB PROTO KERNENTRY, ppdbParent:PTR
  348. ;void*
  349. MemToHeap PROTO KERNENTRY, hheap:HANDLE, buf:PTR, len:DWORD
  350. ;char*
  351. StrToHeap PROTO KERNENTRY, hheap:HANDLE, pstr:PTR
  352. ;DWORD
  353. CbSizeEnv PROTO KERNENTRY, :PTR, :WORD
  354. ;BOOL
  355. FFindEnvVar PROTO KERNENTRY, :PTR, :PTR, :PTR
  356. ;DWORD
  357. SetPSP PROTO KERNENTRY, :DWORD
  358. ;DWORD
  359. GetPSP PROTO KERNENTRY
  360. ;VOID
  361. GlobalHandleSwitchToK32PSP PROTO KERNENTRY, :HANDLE, :LPDWORD
  362. ;VOID
  363. GlobalHandleRestorePSP PROTO KERNENTRY, :DWORD
  364. ;* thread.c
  365. ;void
  366. SetError PROTO KERNENTRY, dwError:DWORD
  367. ; BUGBUG [KevinR] 14-Apr-1993
  368. ; This control-handler stuff is console-specific and should be
  369. ; separately included with wincon.inc.
  370. ;* Interface Definitions for control handlers (BREAK.C)
  371. ; Control constants for CONTROL+C and CONTROL+BREAK
  372. ctrlC EQU 0
  373. ctrlBreak EQU 1
  374. ctrlNone EQU 10
  375. ctrlInactive EQU 20
  376. ctrlTerminate EQU 30
  377. ; Number of control handlers initially and for each new allocation
  378. cbCtrlInc EQU 8
  379. ; typedef VOID (KERNENTRY *PFN_CONTROL)(DWORD CtrlType);
  380. PFN_CONTROL TYPEDEF PTR
  381. CONTROL_HANDLER TYPEDEF PROTO STDCALL :DWORD
  382. PCONTROL_HANDLER TYPEDEF PTR CONTROL_HANDLER
  383. ; Function Prototypes
  384. ; VOID
  385. ControlHandlerThread PROTO KERNENTRY
  386. ; BOOL
  387. FInitControlHandlers PROTO KERNENTRY :LPPDB
  388. ; VOID
  389. DestroyControlHandlers PROTO KERNENTRY :LPPDB
  390. ; BOOL
  391. FUpdateControlList PROTO KERNENTRY :LPPDB, :PCONTROL_HANDLER, :BOOL
  392. ; VOID
  393. DoControlHandlers PROTO KERNENTRY :DWORD
  394. ; VOID
  395. SwitchToControlThread PROTO KERNENTRY pedb:LPPDB, idControl:WORD
  396. ;* Interface Definitions for LE Loader (LELDR.C) */
  397. ; BOOL
  398. FInitModuleMgr PROTO KERNENTRY
  399. ; BOOL
  400. FLoadKernelModule PROTO KERNENTRY,
  401. :LPPDB,
  402. :LPSTR
  403. ; BOOL
  404. FLoadProgram PROTO KERNENTRY,
  405. :LPPDB,
  406. :LPSTR,
  407. :LPWORD
  408. ; BOOL
  409. FLoadLibrary PROTO KERNENTRY,
  410. :LPPDB,
  411. :LPSTR,
  412. :LPWORD
  413. ; BOOL
  414. FFreeModule PROTO KERNENTRY,
  415. :LPPDB,
  416. :WORD
  417. ; BOOL
  418. RemoveProcessImte PROTO KERNENTRY,
  419. :LPPDB,
  420. :WORD
  421. ; char *
  422. SzFileFromImte PROTO KERNENTRY,
  423. :WORD
  424. ; char *
  425. SzFromImte PROTO KERNENTRY,
  426. :WORD
  427. ; VOID
  428. FreeUnusedModules PROTO KERNENTRY,
  429. :LPLST
  430. ; SHORT
  431. ImteFromSz PROTO KERNENTRY,
  432. :LPSTR
  433. ; SHORT
  434. ImteFromFileSz PROTO KERNENTRY,
  435. :LPSTR
  436. ; BOOL
  437. FGetProcAddr PROTO KERNENTRY,
  438. imte:SWORD,
  439. pvName:LPVOID,
  440. ppvProc:PTR LPVOID
  441. ;* DIRUTIL.C
  442. AO_IN equ 0
  443. AO_OUT equ 1
  444. AO_INOUT equ 2
  445. AO_CONV_ANSI equ 0
  446. AO_NO_CONV equ 1
  447. ;LPSTR
  448. EnterResolveOemToAnsi PROTO KERNENTRY,
  449. szName:LPSTR,
  450. fInOut:DWORD
  451. ;VOID
  452. LeaveResolveOemToAnsi PROTO KERNENTRY,
  453. szSrcDest:LPSTR,
  454. fInOut:DWORD
  455. ;VOID
  456. LeaveResolveOemToAnsiEx PROTO KERNENTRY,
  457. szSrc:LPSTR,
  458. szDest:LPSTR,
  459. nSize:DWORD,
  460. fInOut:DWORD
  461. ;BOOL
  462. MarkOemToAnsiDone PROTO KERNENTRY,
  463. fNoConversion:DWORD
  464. ;VOID
  465. UnMarkOemToAnsiDone PROTO KERNENTRY
  466. ;* PROCUTIL.ASM
  467. ; VOID
  468. ThreadTerminationHandler PROTO KERNENTRY
  469. ; BOOL
  470. FBuildEnvArgs PROTO KERNENTRY,
  471. selPsp:SEL,
  472. pszProgName:PTR LPSTR,
  473. pszCmdLine:PTR LPSTR,
  474. ppchEnv:PTR LPSTR
  475. ; DWORD
  476. CbSearchPath PROTO KERNENTRY,
  477. lpPath:LPSTR,
  478. lpFileName:LPSTR,
  479. lpExtension:LPSTR,
  480. nBufferLength:DWORD,
  481. lpBuffer:LPSTR,
  482. lpFilePart:PTR LPSTR
  483. ; BOOL
  484. FIsDir PROTO KERNENTRY,
  485. lpDirPath:LPSTR
  486. ; LONG
  487. LValidateSecurity PROTO KERNENTRY,
  488. lpSecurity:LPSECURITY_ATTRIBUTES
  489. ; LONG
  490. LStrCmpI PROTO KERNENTRY,
  491. sz1:LPSTR,
  492. sz2:LPSTR
  493. ; LPSTR
  494. SzGetNamePos PROTO KERNENTRY,
  495. lpPath:LPSTR
  496. ; BOOL
  497. FGetFileInfo PROTO KERNENTRY,
  498. szName:LPSTR,
  499. fsAttrib:DWORD,
  500. lpFindFileData:LPWIN32_FIND_DATA
  501. ; DWORD
  502. CbAppendExt PROTO KERNENTRY,
  503. szName:LPSTR,
  504. szExt:LPSTR,
  505. cbBuf:DWORD
  506. ; BOOL
  507. FFixPathChars PROTO KERNENTRY,
  508. szPath:LPSTR
  509. ; DWORD
  510. CbStrUpr PROTO KERNENTRY,
  511. lpString:LPSTR
  512. ; VOID
  513. BeepOff PROTO KERNENTRY,
  514. bControl:BYTE
  515. ; DWORD
  516. GetPathType PROTO KERNENTRY,
  517. szPath:LPSTR
  518. ; ULONG
  519. GetLongName PROTO KERNENTRY lpFileName:LPCSTR, lpBuffer:LPSTR, cbBuffer:ULONG
  520. ; ULONG
  521. GetShortName PROTO KERNENTRY lpFileName:LPCSTR, lpBuffer:LPSTR, cbBuffer:ULONG
  522. ;* PROCUTIL.ASM - Internal register based functions
  523. ; EDI (LPSTR)
  524. FindEnvVar PROTO KERNENTRY
  525. ; EDI (LPSTR)
  526. ; EAX (LPSTR) and CARRY
  527. StrToBuffer PROTO KERNENTRY
  528. ; ESI (LPSTR)
  529. ; EDI (LPSTR)
  530. ; ECX (DWORD)
  531. ; DWORD
  532. CheckDrive PROTO KERNENTRY
  533. ; EAX (DWORD)
  534. ; BOOL
  535. ValidateDrive PROTO KERNENTRY,
  536. Drive:DWORD
  537. ; BOOL
  538. IsDriveFixed PROTO KERNENTRY,
  539. Drive:DWORD
  540. ; DWORD
  541. GetEnvDir PROTO KERNENTRY
  542. ; EDI (LPSTR)
  543. ; ESI (LPSTR)
  544. ; ECX (DWORD)
  545. ; Carry
  546. FcExistFile PROTO KERNENTRY
  547. ; ESI
  548. ; VOID
  549. SzStrCpy PROTO KERNENTRY
  550. ; ESI (LPSTR)
  551. ; EDI (LPSTR)
  552. ; VOID
  553. SzStrCat PROTO KERNENTRY
  554. ; ESI (LPSTR)
  555. ; EDI (LPSTR)
  556. ; LPSTR
  557. StrScan PROTO KERNENTRY
  558. ; EDI (LPSTR)
  559. ; AL (BYTE)
  560. ; LPSTR
  561. StrRScan PROTO KERNENTRY
  562. ; EDI (LPSTR)
  563. ; ESI (LPSTR)
  564. ; AL (BYTE)
  565. ;* DIRUTIL.C
  566. ; DWORD
  567. CbGetCurDir PROTO KERNENTRY,
  568. :DWORD,
  569. :LPSTR
  570. ; BOOL
  571. FSetCurDir PROTO KERNENTRY,
  572. :LPSTR
  573. ; DWORD
  574. FMakeFullName PROTO KERNENTRY,
  575. :LPSTR,
  576. :LPSTR,
  577. :LPSTR
  578. ; DWORD
  579. DwMakeFullPath PROTO KERNENTRY,
  580. :LPSTR,
  581. :LPSTR,
  582. :LPDWORD,
  583. :PTR LPSTR
  584. ; DWORD
  585. FNextFromDirList PROTO KERNENTRY,
  586. :PTR LPSTR,
  587. :LPSTR,
  588. :LPSTR,
  589. :LPSTR
  590. ; LPSTR
  591. PchGetNetDir PROTO KERNENTRY,
  592. pch:LPSTR
  593. ; KRNINIT.ASM
  594. ; BOOL
  595. FGetMediaData PROTO KERNENTRY,
  596. bDrive:BYTE,
  597. pvMedia:LPVOID
  598. ; VOID
  599. SetCritErrAction PROTO KERNENTRY,
  600. fFail:WORD
  601. ; BOOL
  602. FGetCritErr PROTO KERNENTRY
  603. ; DWORD
  604. IdGetClearCritErr PROTO KERNENTRY
  605. ; VOID
  606. SetCritErrId PROTO KERNENTRY,
  607. id:WORD
  608. ; DWORD
  609. IdGetControl PROTO KERNENTRY
  610. ; VOID
  611. SetControlId PROTO KERNENTRY,
  612. id:SWORD
  613. ; WORD
  614. IdWindows PROTO KERNENTRY
  615. ;* FILEHOPS.ASM
  616. ; BYTE
  617. ReadChar PROTO KERNENTRY,
  618. fEcho:BOOL
  619. ; DWORD
  620. ReadLine PROTO KERNENTRY,
  621. lpBuffer:LPSTR,
  622. cbBuffer:DWORD
  623. ;* CTIME.C
  624. ; BOOL
  625. FileTimeToDosDateTimeEx PROTO KERNENTRY,
  626. :PTR,
  627. :LPWORD,
  628. :LPWORD,
  629. :LPWORD
  630. ; BOOL
  631. DosDateTimeToFileTimeEx PROTO KERNENTRY,
  632. :WORD,
  633. :WORD,
  634. :WORD,
  635. :PTR
  636. ; ** Utility Macros
  637. ; Performance tricks for loading and comparing zero
  638. ; Load a register with zero
  639. movz MACRO reg
  640. sub reg, reg
  641. ENDM
  642. ; Load a register with -1
  643. movn1 MACRO reg, kind
  644. IFIDNI <kind>,<small> ; Small
  645. sub reg, reg ; 2 bytes, 2 clocks
  646. dec reg ; 1 byte, 2 clocks
  647. ELSE ; Fast
  648. mov reg, -1 ; 5 (eax), 4 (ax), 2 (al) bytes, 2 clocks
  649. ENDIF
  650. ENDM
  651. ; Load a register with 1
  652. mov1 MACRO reg, kind
  653. IFIDNI <kind>,<small> ; Small
  654. sub reg, reg ; 2 bytes, 2 clocks
  655. inc reg ; 1 byte, 2 clocks
  656. ELSE ; Fast
  657. mov reg, 1 ; 5 (eax), 4 (ax), 2 (al) bytes, 2 clocks
  658. ENDIF
  659. ENDM
  660. ; Compare a register to zero
  661. cmpz MACRO reg
  662. or reg, reg
  663. ENDM
  664. ; Drive letter macros
  665. DriveNumToLet MACRO regmem
  666. IF ((OPATTR regmem) AND 010y) OR ((OPATTR regmem) AND 010000y)
  667. add regmem, 'A'
  668. ELSE
  669. .ERR <Must be register or memory>
  670. ENDIF
  671. ENDM
  672. DriveLetToNum MACRO regmem
  673. IF ((OPATTR regmem) AND 010y) OR ((OPATTR regmem) AND 010000y)
  674. sub regmem, 'A'
  675. ELSE
  676. .ERR <Must be register or memory>
  677. ENDIF
  678. ENDM
  679. ; Localized versions of these may be different.
  680. Upper MACRO regmem
  681. IF ((OPATTR regmem) AND 010y) OR ((OPATTR regmem) AND 010000y)
  682. and regmem, 11011111y ; Convert letter to upper case
  683. ELSE
  684. .ERR <Must be register or memory>
  685. ENDIF
  686. ENDM
  687. Lower MACRO regmem
  688. IF ((OPATTR regmem) AND 010y) OR ((OPATTR regmem) AND 010000y)
  689. or regmem, 00100000y ; Convert letter to lower case
  690. ELSE
  691. .ERR <Must be register or memory>
  692. ENDIF
  693. ENDM
  694. ErrSet MACRO ecode
  695. IFIDNI <ecode>, <ax>
  696. movzx eax, ax
  697. INVOKE SetError, eax
  698. ELSE
  699. INVOKE SetError, ecode
  700. ENDIF
  701. ENDM
  702. ; Macros to push and pop register lists
  703. pushes MACRO reglist:VARARG
  704. FOR reg, <reglist>
  705. push reg
  706. ENDM
  707. ENDM
  708. pops MACRO reglist:VARARG
  709. LOCAL regs
  710. regs TEXTEQU <>
  711. FOR reg, <reglist>
  712. regs CATSTR <reg>, regs
  713. regs CATSTR <,>, regs
  714. ENDM
  715. regs SUBSTR regs, 2
  716. regs CATSTR <!<>, regs, <!>>
  717. % FOR reg, regs
  718. pop reg
  719. ENDM
  720. ENDM
  721. ; Macros for start and end of each API call
  722. INCLUDE APITRACE.INC
  723. ifdef DEBUG
  724. ApiEnterTrace PROTO KERNENTRY, ApiNumber:DWORD
  725. api_entry MACRO ApiNumber:REQ
  726. invoke ApiEnterTrace, ApiNumber
  727. ENDM
  728. else
  729. api_entry MACRO ApiNumber:REQ
  730. ENDM
  731. endif
  732. api_exit MACRO ApiNumber:REQ
  733. ENDM
  734. ;* These are values that are passed to PnodGetLstElem to tell it
  735. ;* which element to return from the list.
  736. ;/
  737. idLstGetFirst = 0 ;* get first element of list */
  738. idLstGetNext = 1 ;* get next element of the list */
  739. idLstGetPrev = 2 ;* get the previous element of the list */
  740. idLstGetLast = 4 ;* get the last element of the list */
  741. ;* These are values that are passed to AddListElem to tell it where
  742. ;* to put an element being added to the list.
  743. ;/
  744. idLstAddFirst = 0 ;* add at the head of the list */
  745. idLstAddCur = 1 ;* add at the current position in the list */
  746. AddLstElem PROTO KERNENTRY , :PTR LST, :PTR NOD, :DWORD
  747. PnodGetLstElem PROTO KERNENTRY , :PTR LST, :DWORD
  748. PnodRemoveLstElem PROTO KERNENTRY , :PTR LST
  749. FIsLstEmpty PROTO KERNENTRY, :PTR LST
  750. ;** Macro to get current TDBX pointer
  751. GetCurrentTDBX MACRO reg
  752. ifdef WOW
  753. assume fs:nothing
  754. ifb <reg>
  755. mov eax, fs:[TIBSTRUCT.tib_pTDB]
  756. mov eax, [eax].TDB.ptdbx
  757. else
  758. mov reg, fs:[TIBSTRUCT.tib_pTDB]
  759. mov reg, [reg].TDB.ptdbx
  760. endif
  761. else ; WOW
  762. ifb <reg>
  763. mov eax, [ppTDBXCur]
  764. mov eax, [eax]
  765. else
  766. mov reg, [ppTDBXCur]
  767. mov reg, [reg]
  768. endif
  769. endif ; else WOW
  770. ENDM
  771. ;** Macros to get current TDB pointer and current PDB pointer
  772. GetCurrentTDB MACRO reg
  773. ifdef WOW
  774. assume fs:nothing
  775. ifb <reg>
  776. mov eax, fs:[TIBSTRUCT.tib_pTDB]
  777. else
  778. mov reg, fs:[TIBSTRUCT.tib_pTDB]
  779. endif
  780. else ; WOW
  781. ifb <reg>
  782. mov eax, [pptdbCur]
  783. mov eax, [eax]
  784. else
  785. mov reg, [pptdbCur]
  786. mov reg, [reg]
  787. endif
  788. endif ; else WOW
  789. ENDM
  790. GetCurrentPDB MACRO reg
  791. ifdef WOW
  792. assume fs:nothing
  793. ifb <reg>
  794. mov eax, fs:[TIBSTRUCT.tib_pTDB]
  795. mov eax, [eax].TDB.ptib
  796. mov eax, [eax].TIBSTRUCT.tib_ppdbProc
  797. else
  798. mov reg, fs:[TIBSTRUCT.tib_pTDB]
  799. mov reg, [reg].TDB.ptib
  800. mov reg, [reg].TIBSTRUCT.tib_ppdbProc
  801. endif
  802. else ; WOW
  803. ifb <reg>
  804. mov eax, [pppdbCur]
  805. mov eax, [eax]
  806. else
  807. mov reg, [pppdbCur]
  808. mov reg, [reg]
  809. endif
  810. endif ; else WOW
  811. ENDM
  812. ;=====================================================================
  813. ; Synchronization routines (SYNC.C)
  814. IFNDEF typObjAny
  815. INCLUDE OBJECT.INC
  816. ENDIF
  817. ; BOOL
  818. bDeliverPendingAPCs PROTO KERNENTRY ;:VOID
  819. ; DWORD
  820. BlockThreadEx PROTO KERNENTRY :DWORD, :BOOL
  821. ; DWORD
  822. dwWaitMultipleObjects PROTO KERNENTRY :DWORD, :LPOBJ, :DWORD, :DWORD, :BOOL
  823. ; DWORD
  824. dwWaitSingleObject PROTO KERNENTRY :LPOBJ, :DWORD, :BOOL
  825. ; VOID
  826. DisposeSyncObj PROTO KERNENTRY :LPSYNCO
  827. ; LPSEM
  828. NewPsem PROTO KERNENTRY :DWORD, :DWORD
  829. ; BOOL
  830. bReleasePsem PROTO KERNENTRY :LPSEM, :DWORD, :LPLONG
  831. ; LPEVT
  832. NewPevt PROTO KERNENTRY :DWORD, :DWORD
  833. ; BOOL
  834. bSetPevt PROTO KERNENTRY :LPEVT
  835. ; BOOL
  836. bPulsePevt PROTO KERNENTRY :LPEVT
  837. ; BOOL
  838. bResetPevt PROTO KERNENTRY :LPEVT
  839. ; LPMUTX
  840. NewPmutx PROTO KERNENTRY :DWORD
  841. ; BOOL
  842. bReleasePmutx PROTO KERNENTRY :LPMUTX
  843. ; VOID
  844. InitCrst PROTO KERNENTRY :LPCRST
  845. ; VOID
  846. DestroyCrst PROTO KERNENTRY :LPCRST
  847. ; LPNSOBJ
  848. NewNsObject PROTO KERNENTRY :DWORD, :BYTE
  849. ; VOID
  850. DisposeNsObject PROTO KERNENTRY :LPNSOBJ
  851. ; BOOL
  852. LockMustComplete PROTO KERNENTRY :LPTDB
  853. ; VOID
  854. UnlockMustComplete PROTO KERNENTRY :LPTDB
  855. ;=====================================================================
  856. ; Exception management (EXCEPTC.C, EXCEPTA.ASM)
  857. ExceptStruct struct 4
  858. SegGs dd ?
  859. SegFs dd ?
  860. SegEs dd ?
  861. SegDs dd ?
  862. rgEdi dd ?
  863. rgEsi dd ?
  864. rgEbp dd ?
  865. rgEspTmp dd ?
  866. rgEbx dd ?
  867. rgEdx dd ?
  868. rgEcx dd ?
  869. rgEax dd ?
  870. dwExceptNum dd ?
  871. rgRetEip dd ?
  872. SegRetCs dd ?
  873. dwErrorCode dd ?
  874. rgEip dd ?
  875. SegCs dd ?
  876. rgEflags dd ?
  877. rgEsp dd ?
  878. SegSs dd ?
  879. ExceptStruct ends
  880. IEE struct 4
  881. dwExceptionNum dd ?
  882. rgRegisters ExceptStruct <>
  883. IEE ends
  884. PIEE typedef PTR IEE
  885. PIeeNew PROTO C
  886. ExceptDispatch PROTO C
  887. NtRaiseException PROTO C,
  888. ExceptionRecord:LPEXCEPTION_RECORD,
  889. ContextRecord:LPCONTEXT,
  890. FirstChance:BOOL
  891. NtContinue PROTO C,
  892. ContextRecord:LPCONTEXT,
  893. TestAlert:BOOL
  894. ZwContinue PROTO C,
  895. ContextRecord:LPCONTEXT,
  896. TestAlert:BOOL
  897. ZwRaiseException PROTO C,
  898. ExceptionRecord:LPEXCEPTION_RECORD,
  899. ContextRecord:LPCONTEXT,
  900. FirstChance:BOOL
  901. FreePiee PROTO C,
  902. piee:DWORD
  903. ;=====================================================================
  904. ; Device object management (DEVICE.C)
  905. ; FDB *
  906. PfdbNew PROTO KERNENTRY
  907. ; PIPDB *
  908. PpipedbNew PROTO KERNENTRY,
  909. pipszbyts:DWORD,
  910. IsNmPipe:BOOL
  911. ; MSDB *
  912. PmsdbNew PROTO KERNENTRY
  913. ; SDB *
  914. PsdbNew PROTO KERNENTRY
  915. ; TLHPDB*
  916. PtlhpdbNew PROTO KERNENTRY
  917. ; VOID
  918. DisposePtlhpdb PROTO KERNENTRY,
  919. :PTR TLHPDB
  920. ; VOID
  921. DisposePfdb PROTO KERNENTRY,
  922. :PTR FDB
  923. ; VOID
  924. DisposePmsdb PROTO KERNENTRY,
  925. :PTR MSDB
  926. ; VOID
  927. DisposePsdb PROTO KERNENTRY,
  928. :PTR SDB
  929. ; VOID
  930. DisposePpipedb PROTO KERNENTRY,
  931. :PTR PIPDB
  932. ; HANDLE
  933. hSerialNew PROTO KERNENTRY,
  934. ppdb:PTR SDB,
  935. handle:DWORD,
  936. DevNode:DWORD
  937. ;; OFSTRUCTEX has a word cBytes instead of a BYTE in OFSTRUCT
  938. ;; OpenFileEx16And32 uses this structure for support of OpenFile with
  939. ;; LFN support. The Win32 OpenFile calls this and has a wrapper to
  940. ;; ensure that we still have a Win32 API that has OFS_MAXPATHNAME of 128.
  941. OFSTRUCTEX struct 1
  942. cBytes dw ?
  943. fFixedDisk db ?
  944. nErrCode dw ?
  945. Reserved1 dw ?
  946. Reserved2 dw ?
  947. szPathName db MAX_PATH DUP (?)
  948. OFSTRUCTEX ends
  949. ENDIF ; _KERNEL32_