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.

1093 lines
34 KiB

  1. // KERNEL32.H
  2. //
  3. // (C) Copyright Microsoft Corp., 1988-1994
  4. //
  5. // Main Kernel32 include file
  6. //
  7. // Origin: Dos Extender
  8. //
  9. // Change history:
  10. //
  11. // Date Who Description
  12. // --------- --------- -------------------------------------------------
  13. // Jan-91 - Mar-92 GeneA Original Languages Dos Extender work
  14. // 15-Feb-94 JonT Code cleanup and precompiled headers
  15. #ifndef __KERNEL32_H
  16. #define __KERNEL32_H
  17. // So that RTL functions don't have declspec import
  18. #ifdef _KERNEL32_
  19. #define _NTSYSTEM_
  20. #endif
  21. // If NT.H was included, we have to undefine some stuff to prevent
  22. // refinitions
  23. #undef MAJOR_VERSION
  24. #undef MINOR_VERSION
  25. #undef FILE_ATTRIBUTE_VALID_FLAGS
  26. #ifndef WOW32_EXTENSIONS
  27. // Include the Win32 windows.h to get all standard definitions
  28. #include <windows.h>
  29. #undef RtlMoveMemory
  30. #undef RtlCopyMemory
  31. // Following is defined in winnt.h only if nt.h is not included.
  32. #ifndef MAXDWORD
  33. #define MAXDWORD MAXULONG
  34. #endif
  35. // These APIs are doc'd to be exported from user32, but we implement them
  36. // in kernel32. Rename them so we don't get a prototype declaration type
  37. // conflict, due to the non-definition of _USER32_ making them be of type
  38. // import.
  39. #define wsprintfA k32wsprintfA
  40. int WINAPIV wsprintfA( LPSTR lpOut, LPCSTR lpFmt, ...);
  41. #define wvsprintfA k32wvsprintfA
  42. int WINAPI wvsprintfA( LPSTR, LPCSTR, va_list arglist);
  43. #define LoadStringA k32LoadStringA
  44. int WINAPI LoadStringA( HINSTANCE hInstance, UINT uID,
  45. LPSTR lpBuffer, int nBufferMax);
  46. #endif // ndef WOW32_EXTENSIONS
  47. //====================================================================
  48. // General definitions
  49. #define LOCAL
  50. #define GLOBAL
  51. #ifndef KERNENTRY
  52. #define KERNENTRY __stdcall
  53. #endif
  54. #define cbPage 4096
  55. #define fTrue 1L
  56. #define fFalse 0L
  57. typedef WORD SEL;
  58. #define IMTE short
  59. // Wait constants
  60. #define dwWaitForever 0xffffffff
  61. #define dwWaitNone 0
  62. #define dwAbort 0xffffffff
  63. #define dwInvalid 0xffffffff
  64. #include <k16thk.h>
  65. #ifndef WOW32_EXTENSIONS
  66. /*XLATOFF*/
  67. #ifdef WOW
  68. #include <wh.h>
  69. #endif // def WOW
  70. /*XLATON*/
  71. typedef DEBUG_EVENT* PDE;
  72. #ifdef MEOW_LOGGING
  73. VOID WDEBLogDebugString(char *, ...);
  74. #endif // def MEOW_LOGGING
  75. //====================================================================
  76. // Debug macros
  77. #define WOWDEBUG
  78. #ifdef WOWDEBUG
  79. VOID ApiEnterTrace(DWORD ApiNumber);
  80. #define api_entry(ApiNumber) ApiEnterTrace(ApiNumber);
  81. #else
  82. #define api_entry(ApiNumber)
  83. #endif
  84. #define api_exit(ApiNumber)
  85. #ifdef WOWDEBUG
  86. int __cdecl dprintf(const char *, ...);
  87. #define dprintf(s) dprintf##s
  88. #else
  89. #define dprintf(s)
  90. #endif
  91. GLOBAL VOID KERNENTRY PrintFailedAssertion(int, char *);
  92. GLOBAL VOID KERNENTRY vDebugOut(int level, const char *pfmt, ...);
  93. #ifdef WOWDEBUG
  94. #define Break() { _asm _emit 0xcc }
  95. #ifndef IS_VXD
  96. #define Trap() { _asm { _emit 0xcc } }
  97. #define TrapC(c) { if (c) { Trap() } }
  98. #endif
  99. #ifdef IS_VXD
  100. #define SetFile() \
  101. static char __szSrcFile[] = __FILE__; \
  102. static char __szAssert[] = "Assertion failed: Line %d File %s";
  103. #define Assert(cond) \
  104. if (!(cond)) {\
  105. Debug_Printf(__szAssert,__LINE__,__szSrcFile);\
  106. Trap(); \
  107. }
  108. #else
  109. #define SetFile() \
  110. static char __szSrcFile[] = __FILE__;
  111. #define Assert(cond) \
  112. if (!(cond)) {\
  113. PrintFailedAssertion(__LINE__,__szSrcFile);\
  114. }
  115. #endif
  116. // Used to assert the return code of a function
  117. #define AssertReturn Assert
  118. #define DebugMsg(sz) dputs(sz)
  119. #define DebugOut(args) vDebugOut args
  120. #define LogMsg(sz) dprintf(((sz "\n")))
  121. #define LogMsgI(sz,I) dprintf(((sz "%d\n",I)))
  122. #define LogMsgX(sz,i) dprintf(((sz "0x%lX\n",i)))
  123. #define LogMsgSz(sz,szData) dprintf(((sz "%s\n",szData)))
  124. #define LogMsgP(args) dprintf((args))
  125. #define LogFailure() LogMsgI("On " __FILE__ " Failure Path line ", __LINE__)
  126. #define HeapCheck() if (!hpWalk(hheapKernel)) _asm int 3
  127. #else
  128. #define Break()
  129. #ifndef IS_VXD
  130. #define Trap()
  131. #define TrapC(c)
  132. #endif
  133. #define Assert(cond)
  134. #define AssertReturn
  135. #define DebugMsg(sz)
  136. #define DebugOut(args)
  137. #define LogMsg(sz)
  138. #define LogMsgI(sz,i)
  139. #define LogMsgX(sz,i)
  140. #define LogMsgSz(sz,szData)
  141. #define LogMsgP(args)
  142. #define LogFailure()
  143. #define HeapCheck()
  144. #endif
  145. enum { DEB_FATAL, DEB_ERR, DEB_WARN, DEB_TRACE };
  146. #endif // ndef WOW32_EXTENSIONS
  147. //====================================================================
  148. // File and path definitions
  149. #define chExtSep '.'
  150. #define szExtSep "."
  151. #define chNetIni '\\'
  152. #define chDirSep '\\'
  153. #define szDirSep "\\"
  154. #define chDirSep2 '/'
  155. #define chDrvSep ':'
  156. #define chRelDir '.'
  157. #define chEnvSep ';'
  158. #define chWldChr '?'
  159. #define chWldSeq '*'
  160. #define chMinDrv 'A'
  161. #define chMaxDrv 'Z'
  162. #define chMinDrvLow 'a'
  163. #define chMaxDrvLow 'z'
  164. #define fbUpper 0xdf // Mask converts to uppercase
  165. #define cbNull 1
  166. #define cbDirMax 260 /* \dir\subdir\..\file.ext */
  167. #define cbDrvMax 3 /* c:\ */
  168. #define cbNetMax 36 /* \\machine\share */
  169. #define cbCompMax 255 /* should be same as namemax? */
  170. #define cbPathMax 260
  171. #define cbCmdMax (0x100 - 0x80) /* All the room in PSP for command line */
  172. // The following is a "magic value" that we use on a number of the NET
  173. // int 21h calls. The reason for this has to do with the way the INT 21
  174. // API mapper in DOSMGR.386 works. For INT 21s from protected mode that
  175. // DOSMGR doesn't understand how to map, all of the segment registers in
  176. // the client structure get set to 0 BY DESIGN. To keep the NET layers
  177. // from getting confused, it needs to KNOW that the call is from WIN32
  178. // and the seg registers should just be ignored (all pointers are FLAT).
  179. // We flag this case by putting this special signature in a 32-bit
  180. // register, usually EBP.
  181. //
  182. #define MAGICWIN32NETINT21SIG 0x41524A44
  183. // OFSTRUCTEX has a word cBytes instead of a BYTE in OFSTRUCT
  184. // OpenFileEx16And32 uses this structure for support of OpenFile with
  185. // LFN support. The Win32 OpenFile calls this and has a wrapper to
  186. // ensure that we still have a Win32 API that has OFS_MAXPATHNAME of 128.
  187. typedef struct tagOFSTRUCTEX {
  188. WORD cBytes;
  189. BYTE fFixedDisk;
  190. WORD nErrCode;
  191. WORD Reserved1;
  192. WORD Reserved2;
  193. BYTE szPathName[cbPathMax];
  194. } OFSTRUCTEX;
  195. typedef OFSTRUCTEX *LPOFSTRUCTEX;
  196. #define FA_VALID_FLAGS 0x67
  197. //====================================================================
  198. // Linked lists
  199. typedef struct _nod
  200. {
  201. struct _nod * pnodNext; /* pointer to the next node in the list */
  202. struct _nod * pnodPrev; /* pointer to the previous node in the list */
  203. DWORD dwData; /* data element associated with this node */
  204. } NOD;
  205. typedef struct _lst
  206. {
  207. NOD * pnodHead; /* pointer to first node in list */
  208. NOD * pnodEnd; /* pointer to last node in list */
  209. NOD * pnodCur; /* pointer to current node in list */
  210. } LST;
  211. // These are values that are passed to PnodGetLstElem to tell it
  212. // which element to return from the list.
  213. #define idLstGetFirst 0 /* get first element of list */
  214. #define idLstGetNext 1 /* get next element of the list */
  215. #define idLstGetPrev 2 /* get the previous element of the list */
  216. #define idLstGetLast 4 /* get the last element of the list */
  217. #define idLstGetCur 5 /* return the current element of the list */
  218. // These are values that are passed to AddListElem to tell it where
  219. // to put an element being added to the list.
  220. #define idLstAddFirst 0 /* add at the head of the list */
  221. #define idLstAddCur 1 /* add at the current position in the list */
  222. #define idLstAddLast 2 /* add at the end of the list */
  223. // These are the values that are passed to PnodFindLstElem to tell it
  224. // how to search for the requested list element.
  225. #define idLstFindFirst 0
  226. #define idLstFindNext 1
  227. #define idLstFindPrev 2
  228. #define idLstFindLast 3
  229. #ifndef WOW32_EXTENSIONS
  230. LST* KERNENTRY PlstNew(LST *);
  231. VOID KERNENTRY FreePlst(LST *);
  232. VOID KERNENTRY DestroyPlst(LST *);
  233. NOD* KERNENTRY PnodNew(VOID);
  234. VOID KERNENTRY FreePnod(NOD *);
  235. BOOL KERNENTRY FIsLstEmpty(LST *);
  236. NOD* KERNENTRY PnodGetLstElem(LST *, int);
  237. VOID KERNENTRY SetLstCurElem (LST *, NOD *);
  238. NOD* KERNENTRY PnodFindLstElem(LST *, DWORD, int);
  239. NOD* KERNENTRY PnodCreateLstElem(LST *, DWORD, int);
  240. VOID KERNENTRY AddLstElem(LST *, NOD *, int);
  241. NOD* KERNENTRY PnodRemoveLstElem(LST *);
  242. VOID KERNENTRY RemoveLstPnod(LST *, NOD *);
  243. VOID KERNENTRY DestroyAllLstElem(LST *);
  244. VOID KERNENTRY DestroyLstElem(LST *);
  245. VOID KERNENTRY AddLst (LST *, LST *, DWORD);
  246. BOOL KERNENTRY FCopyLst (LST *, LST *);
  247. #endif // ndef WOW32_EXTENSIONS
  248. //====================================================================
  249. // Object definitions
  250. //
  251. // We are out of tls with Picture Publisher which need 66.
  252. // This is a quick fix to bump up to 80. If more conditions
  253. // call for more tls slots, should cosider dynamic expansion .
  254. //
  255. #undef TLS_MINIMUM_AVAILABLE
  256. #define TLS_MINIMUM_AVAILABLE 80
  257. #include <object.h>
  258. #ifndef WOW32_EXTENSIONS
  259. // Ansi/Oem parameter defines for SetFileApisToOem
  260. #define AO_IN 0
  261. #define AO_OUT 1
  262. #define AO_INOUT 2
  263. // the below flags passed to MarkOemToAnsiDone specify if
  264. // teh caller can handle ANSI only or ANSI/OEM
  265. #define AO_CONV_ANSI 0
  266. #define AO_NO_CONV 1
  267. // fOKToSetThreadOem is set by true OEM support APIs
  268. // the vwin32 int21 dispatcher sets the TCB_OEM bit if this is set
  269. #define IamOEM() ((GetCurrentTdb())->flFlags & fOKToSetThreadOem)
  270. // Macro version of UnMarkOemToAnsi for C code
  271. #define UnMarkOToA() \
  272. { GetCurrentTdb()->flFlags &= ~(fWasOemNowAnsi | fOKToSetThreadOem); }
  273. // File handle cache strucs/definitions
  274. #include "fhcache.h"
  275. //====================================================================
  276. // Kernel file handle cache routines (FHCACHE.C)
  277. WORD KERNENTRY GetCachedFileHandle(CFH_ID *,USHORT dfh, BOOL fRing0);
  278. USHORT KERNENTRY GetDosFileHandle(CFH_ID *,USHORT * pcfh);
  279. void KERNENTRY UnlockCachedFileHandle(CFH_ID *,USHORT cfh);
  280. LONG KERNENTRY CloseCachedFileHandle(CFH_ID *,USHORT cfh);
  281. void KERNENTRY RemoveFromFileHandleCache(CFH_ID *,USHORT cfh);
  282. //====================================================================
  283. // Kernel initialization and heap wrappers (DXKRNL.C)
  284. VOID* KERNENTRY PvKernelAlloc(DWORD);
  285. VOID* KERNENTRY PvKernelAlloc0(DWORD);
  286. VOID* KERNENTRY PvKernelRealloc(VOID*, DWORD);
  287. BOOL KERNENTRY FKernelFree(VOID*);
  288. #define malloc(cb) PvKernelAlloc(cb)
  289. #define malloc0(cb) PvKernelAlloc0(cb)
  290. #define free(p) FKernelFree(p)
  291. typedef BOOL (KERNENTRY * PFNDEBCB)(PDE, PDB*);
  292. #define cmdIdle 0L
  293. #define cmdExec 1L
  294. #define cmdQuit 2L
  295. #define cmdTermPpdb 3L
  296. #define cmdTermPtdb 4L
  297. #define cmdExecApp 5L
  298. #define cmdCloseHandle 6L
  299. #define cmdInitComplete 7L
  300. #define cmdLoaderError 8L
  301. VOID KERNENTRY SetKrnlCmd(DWORD, PDB *, TDB *, DWORD);
  302. //====================================================================
  303. // Kernel entrypoint and .ASM helper routines (KRNINIT.ASM)
  304. VOID KERNENTRY K16WaitEvent(WORD);
  305. VOID KERNENTRY K16PostEvent(WORD);
  306. VOID KERNENTRY K16Yield(VOID);
  307. WORD KERNENTRY K16CreateTask(struct _tdb* ptdb);
  308. WORD KERNENTRY K16FixTask(WORD ptdb, WORD hModule);
  309. WORD KERNENTRY K16DeleteTask(DWORD hTask);
  310. WORD KERNENTRY K16CreateMod(char* pModName, WORD wExpWinVer);
  311. VOID KERNENTRY K16DeleteMod(WORD hModule);
  312. //====================================================================
  313. // Misc .ASM support routines (KRNLUTIL.ASM)
  314. VOID KERNENTRY FillBytes (VOID *, DWORD, BYTE);
  315. DWORD KERNENTRY CbSizeSz (const char *);
  316. char* KERNENTRY CopySz (char *, const char *);
  317. char* KERNENTRY AppendSz (char *, const char *);
  318. BOOL KERNENTRY BFileNameTooLong(const char *);
  319. LONG KERNENTRY LCompareSz (const char *, const char *);
  320. LONG KERNENTRY LCompareNSz(const char *, const char *, DWORD);
  321. LONG KERNENTRY LStrCmpI( LPCSTR lpsz1, LPCSTR lpsz2);
  322. VOID KERNENTRY RtlCopyMemory( PVOID Destination, CONST VOID *Source, DWORD Length);
  323. #undef CopyMemory
  324. #define CopyMemory( a, b, c) RtlCopyMemory( a, b, c)
  325. // BUGBUG
  326. // We used to have memcpy accidentally mapped to RtlMoveMemory,
  327. // which is wrong. However, memcpy is used in many places and it is
  328. // not obvious that all occurrences have non-overlapping
  329. // arguments. Therefore, we make explicit the old map.
  330. // On a case-by-case basis, we should replace occurrences of
  331. // memcpy by RtlCopyMemory where we are certain the arguments
  332. // do not overlap. In the other cases, we should explicitly use
  333. // RtlMoveMemory.
  334. #define memcpy(dest, src, len) RtlMoveMemory(dest, src, len) // BUGBUG
  335. #undef MoveMemory
  336. #define MoveMemory( a, b, c) RtlMoveMemory( a, b, c)
  337. #define memmov(dest, src, len) RtlMoveMemory(dest, src, len)
  338. #define strlen(s) CbSizeSz(s)
  339. #define strcpy(dest, src) CopySz(dest, src)
  340. #define strcat(dest, src) AppendSz(dest, src)
  341. #define strcmp(s1, s2) LCompareSz(s1, s2)
  342. // #define memset(dest, val, len) FillBytes(dest, len, val)
  343. // note different parameter order - also, compiler would inline memset()
  344. VOID KERNENTRY dputs (const char *);
  345. SEL KERNENTRY SelGetEnviron (SEL);
  346. VOID KERNENTRY SetPspEnviron (SEL, SEL);
  347. int KERNENTRY CbOfDosFileTable(WORD);
  348. VOID KERNENTRY GetDosFileTable(WORD, DWORD, BYTE *);
  349. void KERNENTRY KInt21(void);
  350. // Intel descriptor structure.
  351. typedef struct _dscr
  352. {
  353. USHORT dbLimLow;
  354. USHORT lmaBaseLow;
  355. BYTE lmaBaseMid;
  356. BYTE arbAccess;
  357. BYTE mbLimHi;
  358. BYTE lmaBaseHi;
  359. } DSCR;
  360. VOID KERNENTRY InitDscr (DSCR* pdscr, ULONG lmaBase, ULONG dwLimit,
  361. ULONG arbAccess, ULONG arbExtra);
  362. BOOL KERNENTRY FAllocDscr (ULONG cselAlloc, SEL* pselBase);
  363. BOOL KERNENTRY FFreeDscr (SEL selFree);
  364. BOOL KERNENTRY FSetDscr (SEL selSet, DSCR* pdscrSet);
  365. BOOL KERNENTRY FGetDscr (SEL selGet, DSCR* pdscrGet);
  366. //====================================================================
  367. // Virtual memory management (MMAPI.C)
  368. // Undocumented flags for the flAllocationType field in VirtualAlloc
  369. #define MEM_SHARED 0x08000000 // make memory globally visible
  370. //====================================================================
  371. // Heap management (HEAP.C)
  372. // Undocumented flags to HeapCreate
  373. #define HEAP_SHARED 0x04000000 // put heap in shared memory
  374. #define HEAP_LOCKED 0x00000080 // put heap in locked memory
  375. //====================================================================
  376. // File I/O primitives (IOUTIL.ASM)
  377. #endif // ndef WOW32_EXTENSIONS
  378. typedef DWORD DFH; // Dos File Handle
  379. #define DFH_FILE_CREATE 0x0010
  380. #define DFH_FILE_OPEN 0x0001
  381. #define DFH_FILE_TRUNCATE 0x0002
  382. #define DFH_ACTION_OPENED 0x0001
  383. #define DFH_ACTION_CREATED_OPENED 0x0002
  384. #define DFH_ACTION_REPLACED_OPENED 0x0003
  385. #define DFH_MODE_READONLY 0x0000
  386. #define DFH_MODE_WRITEONLY 0x0001
  387. #define DFH_MODE_READWRITE 0x0002
  388. #define DFH_MODE_SHARE_COMPATIBILITY 0x0000
  389. #define DFH_MODE_SHARE_EXCLUSIVE 0x0010
  390. #define DFH_MODE_SHARE_DENYWRITE 0x0020
  391. #define DFH_MODE_SHARE_DENYREAD 0x0030
  392. #define DFH_MODE_SHARE_DENYNONE 0x0040
  393. #define DFH_MODE_NO_INHERIT 0x0080
  394. #define DFH_MODE_EXTENDED_SIZE 0x1000
  395. #define DFH_MODE_RAND_ACCESS_HINT 0x0008
  396. #define DFH_MODE_SEQ_ACCESS_HINT 0x8000
  397. #ifndef WOW32_EXTENSIONS
  398. DFH KERNENTRY DfhOpenFile (char *, DWORD);
  399. DFH KERNENTRY DfhCreateFile (char *, DWORD, DWORD, DWORD, LPDWORD);
  400. BOOL KERNENTRY FCloseFile (DFH);
  401. DWORD KERNENTRY CbReadFile (DFH, DWORD, VOID *);
  402. DWORD KERNENTRY CbWriteFile (DFH, DWORD, VOID *);
  403. DWORD KERNENTRY CbWriteOutFile (DFH, DWORD, VOID *);
  404. DWORD KERNENTRY LfoSetFilePos (DFH, DWORD, DWORD, DWORD *);
  405. DFH KERNENTRY DfhDupDfh (DFH);
  406. BOOL KERNENTRY FGetDevInfo(DFH, DWORD *);
  407. BOOL KERNENTRY FForceDupDfh (DFH, DFH);
  408. DWORD KERNENTRY GetDOSDateTime (DWORD);
  409. BOOL KERNENTRY FileTimeToDosDateTimeEx (CONST FILETIME *,
  410. LPWORD, LPWORD, LPWORD);
  411. BOOL KERNENTRY DosDateTimeToFileTimeEx (WORD, WORD, WORD, LPFILETIME);
  412. DWORD KERNENTRY SetPSP (DWORD);
  413. DWORD KERNENTRY GetPSP (VOID);
  414. VOID KERNENTRY GlobalHandleSwitchToK32PSP ( HANDLE, LPDWORD );
  415. VOID KERNENTRY GlobalHandleRestorePSP ( DWORD );
  416. //====================================================================
  417. // Process creation/deletion (PROCESS.C)
  418. #define cbStartupInfo31 offsetof(STARTUPINFO, dwHotKey)
  419. #endif // ndef WOW32_EXTENSIONS
  420. // 16-bit CreateThread 32->16 thunk data
  421. typedef struct _thread_startup_thunk_data {
  422. DWORD Param16;
  423. DWORD StartAddress16;
  424. } THREAD_STARTUP_THUNK_DATA;
  425. #ifndef WOW32_EXTENSIONS
  426. BOOL KERNENTRY CreateProcessKernel(char *, char *, char *, WORD, WORD *, PVOID);
  427. VOID KERNENTRY TerminateProcessKernel(VOID);
  428. VOID KERNENTRY ExitCurrentProcess(DWORD);
  429. VOID KERNENTRY TerminateProcessOutOfContext(PDB*, DWORD);
  430. VOID KERNENTRY TerminateProcessFinal(PDB* ppdb);
  431. PDB* KERNENTRY NewPDB(PDB* ppdbParent);
  432. VOID KERNENTRY DisposePDB(PDB* ppdb);
  433. DWORD KERNENTRY CbSizeEnv(LPCSTR, DWORD);
  434. BOOL KERNENTRY FFindEnvVar(char **, char **, char *);
  435. void* KERNENTRY MemToHeap(HANDLE hheap, const void *buf, int len);
  436. char* KERNENTRY StrToHeap(HANDLE hheap, const char *str);
  437. //====================================================================
  438. // Thread creation/deletion (THREAD.C)
  439. // PtdbNew flags values
  440. #define TDBN_NOEXCEPTIONHANDLER 0x00000001
  441. #define TDBN_NPX_WIN32_EXPT 0x00000002
  442. #define TDBN_NPX_EMULATE 0x00000004
  443. #define TDBN_WIN32 0x00000008
  444. #define TDBN_INITIAL_WIN32_THREAD 0x00000010
  445. #define TDBN_KERNEL_THREAD 0x00000020
  446. #define TDBN_SUSPENDED 0x00000040
  447. #define TDBN_FIBER 0x00000080
  448. HANDLE KERNENTRY ICreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes,
  449. DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress,
  450. LPVOID lpParameter, DWORD dwCreationFlags,
  451. LPDWORD lpThreadId, DWORD flFlags);
  452. TDB * KERNENTRY PtdbCreate (PPDB ppdb, int cbStack, DWORD pfnEntry, DWORD dwParam, DWORD flFlags);
  453. TDB * KERNENTRY PtdbNew (PDB *, int, DWORD, DWORD, DWORD);
  454. VOID KERNENTRY ExitCurrentThread(DWORD);
  455. VOID KERNENTRY TerminateCurrentThread(DWORD);
  456. VOID KERNENTRY TerminatePtdb(TDB *, DWORD, BOOL);
  457. DWORD KERNENTRY IdWaitOnPtdb (TDB *, DWORD);
  458. BOOL KERNENTRY FSuspendPtdb (TDB *);
  459. BOOL KERNENTRY FResumePtdb (TDB *);
  460. VOID KERNENTRY DisposePtdb (TDB *);
  461. VOID KERNENTRY BlockAllThreads (VOID);
  462. BOOL KERNENTRY SuspendProcessThreads (PDB * ppdb);
  463. BOOL KERNENTRY ResumeProcessThreads (PDB * ppdb);
  464. PVOID KERNENTRY AllocateStack(PVOID *, PVOID *, DWORD, DWORD, DWORD);
  465. VOID KERNENTRY FreeStack(PVOID);
  466. VOID KERNENTRY SetError(DWORD);
  467. DWORD KERNENTRY SuspendPtdb(TDB *);
  468. DWORD KERNENTRY ResumePtdb(TDB *);
  469. DWORD KERNENTRY ErcGetError(VOID);
  470. #endif // ndef WOW32_EXTENSIONS
  471. // AllocateStack flags
  472. #define AS_NORMAL 0x0000
  473. #define AS_TEMPORARY 0x0001
  474. typedef VOID (KERNENTRY *PFN_THREADSTARTUP)(
  475. PTHREAD_START_ROUTINE pfnEntryPoint,
  476. LPVOID dwParam,
  477. DWORD flFlags
  478. );
  479. #ifndef WOW32_EXTENSIONS
  480. #ifdef WOW
  481. PTDB KERNENTRY IGetCurrentTdb(VOID);
  482. #define GetCurrentTdb() IGetCurrentTdb()
  483. #define GetCurrentTdbx() (GetCurrentTdb()->ptdbx)
  484. #define GetCurrentPdb() (GetCurrentTdb()->ptib->ppdbProc)
  485. #else // WOW
  486. #define GetCurrentPdb() (*pppdbCur)
  487. #define GetCurrentTdb() (*pptdbCur)
  488. #define GetCurrentTdbx() (*ppTDBXCur)
  489. #endif // else WOW
  490. //====================================================================
  491. // Control handlers (BREAK.C)
  492. // Control constants for CONTROL+C and CONTROL+BREAK
  493. #define ctrlC 0
  494. #define ctrlBreak 1
  495. #define ctrlNone 10
  496. #define ctrlInactive 20
  497. #define ctrlTerminate 30
  498. #define cbCtrlInc 8 // Number of control handlers initially and for each new allocation
  499. VOID KERNENTRY ControlHandlerThread(VOID);
  500. BOOL KERNENTRY FInitControlHandlers(PDB *);
  501. VOID KERNENTRY DestroyControlHandlers(PDB *);
  502. BOOL KERNENTRY FUpdateControlList(PDB *, PFN_CONTROL, BOOL);
  503. BOOL KERNENTRY DoControlHandlers(DWORD);
  504. VOID KERNENTRY SwitchToControlThread(PDB *, WORD);
  505. VOID KERNENTRY FieldConsoleCtrlEvent(DWORD, PVOID);
  506. //====================================================================
  507. // Exception management (EXCEPTI.ASM, EXCEPTC.C, EXCEPTA.ASM)
  508. #define LO16_TRAP_INTERCEPT
  509. #define HI16_TRAP_INTERCEPT
  510. #define TRAP_DIVIDE_BY_ZERO 0
  511. #define TRAP_NONMASKABLE_INT 2
  512. #define TRAP_OVERFLOW 4
  513. #define TRAP_INVALID_OPCODE 6
  514. #define TRAP_DEVICE_NOT_AVAILABLE 7
  515. #define TRAP_3E 0x3e
  516. #define TRAP_75 0x75
  517. #define EXC_STACK_OVERFLOW 0x10E
  518. // Definition for Npx status word error mask
  519. #define FSW_INVALID_OPERATION 1
  520. #define FSW_DENORMAL 2
  521. #define FSW_ZERO_DIVIDE 4
  522. #define FSW_OVERFLOW 8
  523. #define FSW_UNDERFLOW 16
  524. #define FSW_PRECISION 32
  525. #define FSW_STACK_FAULT 64
  526. #define FSW_CONDITION_CODE_0 0x100
  527. #define FSW_CONDITION_CODE_1 0x200
  528. #define FSW_CONDITION_CODE_2 0x400
  529. #define FSW_CONDITION_CODE_3 0x4000
  530. #define FSW_EXCEPTION_MASK (FSW_INVALID_OPERATION + \
  531. FSW_DENORMAL + \
  532. FSW_ZERO_DIVIDE + \
  533. FSW_OVERFLOW + \
  534. FSW_UNDERFLOW + \
  535. FSW_PRECISION)
  536. typedef struct ExceptStruct
  537. {
  538. DWORD SegGs;
  539. DWORD SegFs;
  540. DWORD SegEs;
  541. DWORD SegDs;
  542. DWORD rgEdi;
  543. DWORD rgEsi;
  544. DWORD rgEbp;
  545. DWORD rgEspTmp;
  546. DWORD rgEbx;
  547. DWORD rgEdx;
  548. DWORD rgEcx;
  549. DWORD rgEax;
  550. DWORD dwExceptNum;
  551. DWORD rgRetEip;
  552. DWORD SegRetCs;
  553. DWORD dwErrorCode;
  554. DWORD rgEip;
  555. DWORD SegCs;
  556. DWORD rgEflags;
  557. DWORD rgEsp;
  558. DWORD SegSs;
  559. } ExceptStruct;
  560. typedef struct _IEE
  561. {
  562. DWORD dwExceptNum;
  563. ExceptStruct esExcept;
  564. } IEE;
  565. typedef IEE * PIEE;
  566. typedef struct _regs
  567. {
  568. DWORD regSS;
  569. DWORD regGS;
  570. DWORD regFS;
  571. DWORD regES;
  572. DWORD regDS;
  573. DWORD regEDI;
  574. DWORD regESI;
  575. DWORD regEBP;
  576. DWORD regESP;
  577. DWORD regEBX;
  578. DWORD regEDX;
  579. DWORD regECX;
  580. DWORD regEAX;
  581. DWORD regEIP;
  582. DWORD regCS;
  583. DWORD regEFL;
  584. } REGS;
  585. typedef REGS * PREGS;
  586. BOOL KERNENTRY Except7(void);
  587. BOOL KERNENTRY Load80x87Trap1(void);
  588. BOOL KERNENTRY Load80x87Trap2(void);
  589. VOID KERNENTRY PageFaultHandler(void);
  590. VOID KERNENTRY StackFaultHandler(void);
  591. VOID KERNENTRY RtlRaiseException(PEXCEPTION_RECORD ExceptionRecord);
  592. BOOL KERNENTRY FInitExceptions(void);
  593. void KERNENTRY TerminateExceptions(void);
  594. BOOL _cdecl RetInstruction(VOID);
  595. //====================================================================
  596. // Floating point support (FLOAT.ASM)
  597. BOOL KERNENTRY FVmcpdInit(long * pl, short * pver);
  598. BOOL KERNENTRY FCoprocRestore(VOID);
  599. BOOL KERNENTRY FInstallInt7Handler(VOID);
  600. BOOL KERNENTRY FUninstallInt7Handler(VOID);
  601. PVOID KERNENTRY GetEmulatorDataOffset(VOID);
  602. //====================================================================
  603. // PE Loader (PELDR.C)
  604. BOOL KERNENTRY FLoadKernelModule (PDB *, char *);
  605. BOOL KERNENTRY FLoadProgram (PDB *, char *);
  606. char* KERNENTRY SzNameFromMR(MODREF *pRef);
  607. MODREF* KERNENTRY MRFromHLib(HANDLE hLib);
  608. //====================================================================
  609. // Misc. process and kernel utilities (PROCUTIL.ASM)
  610. // Size of reserved memory region above and below stacks. Thunks always map
  611. // a 64K stack selector, so we should have 64K reserved above the stack.
  612. #define STACK_BARRIER_SIZE (64*1024)
  613. #define WIN16_TERMINATION_STACK_SIZE 0x2000
  614. VOID KERNENTRY ThreadTerminationHandler(VOID);
  615. BOOL KERNENTRY FBuildEnvArgs (SEL, char **, char **, void **);
  616. DWORD KERNENTRY CbSearchPath(char *, char *, char *, DWORD, char *, char **);
  617. DWORD KERNENTRY CbGetCurDir(DWORD, char *);
  618. DWORD KERNENTRY CbGetDosCurDir(DWORD, char *);
  619. BOOL KERNENTRY FIsDir(LPCSTR);
  620. LONG KERNENTRY LStrCmpI(LPCSTR, LPCSTR);
  621. char* KERNENTRY SzGetNamePos(char *);
  622. DWORD KERNENTRY FGetFileInfo(char *, DWORD, LPWIN32_FIND_DATA);
  623. DWORD KERNENTRY CbStrUpr(char *);
  624. char* KERNENTRY PchGetNetDir(char *);
  625. BOOL KERNENTRY ValidateDrive(DWORD);
  626. BOOL KERNENTRY IsDriveFixed(DWORD);
  627. PPDB KERNENTRY PidToPDB(DWORD pid);
  628. DWORD KERNENTRY PDBToPid(PPDB ppdb);
  629. PTDB KERNENTRY TidToTDB(DWORD tid);
  630. DWORD KERNENTRY TDBToTid(PTDB ptdb);
  631. PPDB KERNENTRY ValidateProcessID(DWORD);
  632. ULONG KERNENTRY GetLongName(LPCSTR, LPSTR, ULONG);
  633. ULONG KERNENTRY GetShortName(LPCSTR, LPSTR, ULONG);
  634. //====================================================================
  635. // Find Change utilities (FCNAPI.C)
  636. GLOBAL VOID KERNENTRY DisposePfcndb(FCNDB *pfcndb);
  637. //====================================================================
  638. // Directory utilites (DIRUTIL.C)
  639. DWORD KERNENTRY CbGetCurDir(DWORD, char *);
  640. BOOL KERNENTRY FSetCurDir(char *);
  641. DWORD KERNENTRY FMakeFullName(char *, char *, char *);
  642. DWORD KERNENTRY DwMakeFullPath(char *, char *, DWORD *, char **);
  643. DWORD KERNENTRY FNextFromDirList(char **, char *, char *, char *);
  644. DWORD KERNENTRY CbAppendExt (char *, char *, DWORD);
  645. BOOL KERNENTRY FFixPathChars (char * szPath);
  646. VOID KERNENTRY BeepOff(BYTE bControl);
  647. DWORD KERNENTRY GetPathType(LPSTR szPath);
  648. // helpers for zombie psp management [ SBS inter-psp dup related]
  649. // mmfile.c
  650. VOID KERNENTRY IncRefZombiePSP(WORD psp);
  651. VOID KERNENTRY UnuseZombiePSP(WORD psp);
  652. // Ansi/Oem helper routines for conversion if reqd from Oem-Ansi for
  653. // implemeneting SetFileApisToOem
  654. LPSTR KERNENTRY EnterResolveOemToAnsi(LPSTR szName, int fInOut);
  655. VOID KERNENTRY LeaveResolveOemToAnsi(LPSTR szSrcDest, int fInOut);
  656. BOOL KERNENTRY MarkOemToAnsiDone(BOOL fNoConversion);
  657. VOID KERNENTRY UnMarkOemToAnsiDone();
  658. //====================================================================
  659. // USER Signal routines (SIGNAL.C)
  660. BOOL KERNENTRY SignalBroadcast(DWORD dwSignalID, DWORD dwID, WORD hTaskMod16);
  661. //====================================================================
  662. // Sync APIs (SYNC.C)
  663. // delivery of APCs
  664. BOOL KERNENTRY bDeliverPendingAPCs( VOID );
  665. DWORD KERNENTRY BlockThreadEx( DWORD Timeout, BOOL Alertable );
  666. // thread block/unblock primitives
  667. VOID KERNENTRY Wait(void); // wait for/enter a critical section
  668. VOID KERNENTRY Signal(void); // leave a critical section
  669. DWORD KERNENTRY BlockThread(DWORD);
  670. VOID KERNENTRY WakeThread(TDB *, DWORD);
  671. // general wait multiple and wait single
  672. DWORD KERNENTRY dwWaitMultipleObjects(DWORD, OBJ *[], DWORD, DWORD,BOOL);
  673. DWORD KERNENTRY dwWaitSingleObject(OBJ *, DWORD, BOOL);
  674. // used for all synchronization objects
  675. VOID KERNENTRY DisposeSyncObj(SYNCO *);
  676. // semaphore specific functions
  677. SEM * KERNENTRY NewPsem (LONG, LONG);
  678. BOOL KERNENTRY bReleasePsem(SEM *, LONG, LPLONG);
  679. // event specific functions
  680. EVT * KERNENTRY NewPevt(BOOL, BOOL);
  681. BOOL KERNENTRY bSetPevt(EVT *);
  682. BOOL KERNENTRY bPulsePevt(EVT *);
  683. BOOL KERNENTRY bResetPevt(EVT *);
  684. // mutex specific functions
  685. MUTX * KERNENTRY NewPmutx(BOOL);
  686. BOOL KERNENTRY bReleasePmutx(MUTX *);
  687. VOID KERNENTRY CheckOwnedMutexes( TDB *ptdb );
  688. // critical section specific functions
  689. VOID KERNENTRY InitCrst(CRST *);
  690. VOID KERNENTRY DestroyCrst(CRST *);
  691. CRST * KERNENTRY NewCrst();
  692. VOID KERNENTRY DisposeCrst(CRST *);
  693. VOID KERNENTRY EnterCrst(CRST *);
  694. VOID KERNENTRY LeaveCrst(CRST *);
  695. VOID KERNENTRY CheckOwnedCrsts( TDB *ptdb );
  696. VOID KERNENTRY DeallocOrphanedCrsts( PDB *ppdb );
  697. // creation and deletion of non-synchronization, waitable objects
  698. NSOBJ * KERNENTRY NewNsObject( DWORD dwSize, BYTE typObj);
  699. VOID KERNENTRY DisposeNsObject( NSOBJ *pnsobj );
  700. // must complete sections for threads
  701. BOOL KERNENTRY LockMustComplete( TDB * );
  702. VOID KERNENTRY UnlockMustComplete( TDB * );
  703. //====================================================================
  704. // Named object primitives (NAMEDOBJ.C)
  705. OBJNAME* KERNENTRY NameObject(OBJ * pobj, LPCSTR ObjName);
  706. OBJ* KERNENTRY FindObjectName( LPCSTR Name );
  707. BOOL KERNENTRY FreeObjHashName(OBJNAME *ObjName);
  708. HANDLE KERNENTRY NewHandleForName( LPCSTR lpName, DWORD typOfObj, DWORD fFlags );
  709. //====================================================================
  710. // System error box defines
  711. int WINAPI SysErrorBox(LPSTR, LPSTR, DWORD, DWORD, DWORD);
  712. #define SEB_OK 1 // Button with "OK".
  713. #define SEB_CANCEL 2 // Button with "Cancel"
  714. #define SEB_YES 3 // Button with "&Yes"
  715. #define SEB_NO 4 // Button with "&No"
  716. #define SEB_RETRY 5 // Button with "&Retry"
  717. #define SEB_ABORT 6 // Button with "&Abort"
  718. #define SEB_IGNORE 7 // Button with "&Ignore"
  719. #define SEB_CLOSE 8 // Button with "Close"
  720. #define SEB_DEFBUTTON 0x8000 // Mask to make this button default
  721. #define SEB_BTN1 1 // Button 1 was selected
  722. #define SEB_BTN2 2 // Button 1 was selected
  723. #define SEB_BTN3 3 // Button 1 was selected
  724. //====================================================================
  725. // Low-level device objects (DEVICE.C)
  726. FDB* KERNENTRY PfdbNew (VOID);
  727. PIPDB* KERNENTRY PpipedbNew (DWORD pipszbyts, BOOL IsNmPipe);
  728. SDB* KERNENTRY PsdbNew (VOID);
  729. DIODB* KERNENTRY PdiodbNew (VOID);
  730. VOID KERNENTRY DisposePfdb (FDB *);
  731. VOID KERNENTRY DisposePfdbObjCleanUp (FDB *);
  732. VOID KERNENTRY DisposePfdbDOSClose (FDB *);
  733. VOID KERNENTRY DisposePsdb (SDB *);
  734. VOID KERNENTRY DisposePpipedb (PIPDB *);
  735. VOID KERNENTRY DisposePdiodb (DIODB *);
  736. HANDLE KERNENTRY hSerialNew (PDB *ppdb, DWORD handle, DWORD DevNode);
  737. OBJ* KERNENTRY PobjCheckDevPhnd (HANDLE *, DWORD, DWORD);
  738. DWORD KERNENTRY PfdbDupPfdb (FDB *);
  739. VOID KERNENTRY DisposePmsdb (MSDB *);
  740. MSDB* KERNENTRY PmsdbNew (VOID);
  741. VOID KERNENTRY DisposePtlhpdb (TLHPDB *);
  742. TLHPDB* KERNENTRY PtlhpdbNew (VOID);
  743. PMSGINDICATORDB KERNENTRY PMsgIndicatorDBNew(VOID);
  744. VOID KERNENTRY DisposeMsgIndicatorDB( PMSGINDICATORDB);
  745. //====================================================================
  746. // Miscellaneous functions (MISCAPI.C)
  747. void KERNENTRY ReleaseSystem(PTDB ptdb);
  748. void KERNENTRY ReleaseDisplay(PTDB ptdb);
  749. //====================================================================
  750. // ACCESS RIGHTS BIT DEFINITIONS
  751. // These fields are common to all descriptors
  752. #define AB_PRESENT 0x80 // segment present bit
  753. #define AB_DPL 0x60 // mask for DPL field
  754. #define AB_DPL0 0x00 // ring 0 DPL
  755. #define AB_DPL1 0x20 // ring 1 DPL
  756. #define AB_DPL2 0x40 // ring 2 DPL
  757. #define AB_DPL3 0x60 // ring 3 DPL
  758. #define AB_SEGMENT 0x10 // user (i.e. non-system) segment
  759. #define AB_SYSTEM 0x00 // system descriptor
  760. #define EB_GRAN 0x80 // granularity bit (segment limit is page granularity)
  761. #define EB_DEFAULT 0x40 // default operand size (USE32 code)
  762. #define EB_BIG 0x40 // big bit (for data segments)
  763. #define EB_LIMIT 0x0f // mask for upper bits of segment limit field
  764. // These fields are relevant to code and data segment descriptors
  765. // (non-system descriptors)
  766. #define AB_DATA 0x10 // data segment
  767. #define AB_STACK 0x14 // expand down data (i.e. stack segment)
  768. #define AB_WRITE 0x02 // writable data
  769. #define AB_CODE 0x18 // code segment
  770. #define AB_CONFORM 0x04 // conforming code
  771. #define AB_READ 0x02 // readable code
  772. #define AB_ACCESSED 0x01 // segment has been accessed
  773. // These are the descriptor types for system descriptors
  774. #define DT_INVAL1 0x00 // invalid descriptor
  775. #define DT_TSS286 0x01 // available 286 task state segment
  776. #define DT_LDT 0x02 // Local Descriptor Table descriptor
  777. #define DT_TSS286B 0x03 // busy 286 task state segment
  778. #define DT_CALL286 0x04 // 286 style call gate
  779. #define DT_TASK 0x05 // task gate
  780. #define DT_INTR286 0x06 // 286 style interrupt gate
  781. #define DT_TRAP286 0x07 // 286 style trap gate
  782. #define DT_INVAL2 0x08 // invalid descriptor
  783. #define DT_TSS386 0x09 // available 386 task state segment
  784. #define DT_RSVD1 0x0A // reserved type
  785. #define DT_TSS386B 0x0B // busy 386 task state segment
  786. #define DT_CALL386 0x0C // 386 style call gate
  787. #define DT_RSVD2 0x0D // reserved type
  788. #define DT_INTR386 0x0E // 386 style interrupt gate
  789. #define DT_TRAP386 0x0F // 386 style trap gate
  790. // These are some common combinations of the above fields making up
  791. // useful access rights bytes.
  792. #define ARB_CODE0 AB_PRESENT+AB_DPL0+AB_CODE+AB_READ // ring 0 code
  793. #define ARB_CODE3 AB_PRESENT+AB_DPL3+AB_CODE+AB_READ // ring 3 code
  794. #define ARB_DATA0NP AB_DPL0+AB_DATA+AB_WRITE // illegal segment
  795. #define ARB_DATA0 AB_PRESENT+AB_DPL0+AB_DATA+AB_WRITE // ring 0 r/w data
  796. #define ARB_DATA3 AB_PRESENT+AB_DPL3+AB_DATA+AB_WRITE // ring 3 r/w data
  797. #define LIM_NONE 0xffffffff
  798. #define SELECTOR_MASK 0xFFF8 /* selector index */
  799. #define TABLE_MASK 0x04 /* table bit */
  800. #define RPL_MASK 0x03 /* privilige bits */
  801. // FROM IFS.H
  802. /** Values for fReturnFlags in Duphandle: */
  803. #define WDUP_RMM_DRIVE 0x01 // file mapped on a RMM drive
  804. #define WDUP_NETWARE_HANDLE 0x02 // handle belongs to Netware
  805. //====================================================================
  806. // System include files
  807. #endif // ndef WOW32_EXTENSIONS
  808. #include <ldrdefs.h>
  809. #include <w32base.h>
  810. #define _WINNT_
  811. #include <vmm.h>
  812. #include <deb.h>
  813. #include <coresig.inc> // dual mode .INC/.H file
  814. #ifndef IS_VXD
  815. #define Not_VxD
  816. #endif
  817. #include <w32sys.h>
  818. #include <vwin32.h>
  819. #include <krnlcmn.h>
  820. #include <vmda.h>
  821. #include <console.h>
  822. #include <syslevel.h>
  823. #include <tdb16.h>
  824. #include <k32rc.h>
  825. #include <heap.h>
  826. #include <dxkrnl.h>
  827. #include <leldr.h>
  828. #ifndef IS_VXD
  829. #include <ring0.h>
  830. #endif
  831. #include <handle.h>
  832. #include <cdis.h>
  833. #include <dbgdot.h>
  834. #include <apitrace.h>
  835. #ifndef WOW32_EXTENSIONS
  836. //====================================================================
  837. // Global variables
  838. #ifdef WOW
  839. extern DWORD dwMEOWFlags;
  840. #else // WOW
  841. #ifdef MEOW_LOGGING
  842. extern DWORD dwMEOWFlags;
  843. #endif // def MEOW_LOGGING
  844. #endif // def WOW
  845. extern SEL selLDT;
  846. extern DWORD* pLDT;
  847. extern WORD* pK16HeadTDB;
  848. #ifndef WOW
  849. extern PDB** pppdbCur;
  850. extern TDB** pptdbCur;
  851. #endif // def WOW
  852. extern TDB* ptdbSvc;
  853. extern DWORD lmaUserBase;
  854. extern char* szWinDir;
  855. extern char* szSysDir;
  856. extern WORD cbWinDir;
  857. extern WORD cbSysDir;
  858. extern LCRST* Win16Lock;
  859. extern LCRST* Krn32Lock;
  860. extern LCRST* pcrstDriveState;
  861. extern BOOL F80x87Present;
  862. extern DWORD CbEmulData;
  863. extern IMTE ImteEmulator;
  864. extern WORD selK32Psp; // Selector to PSP of kernel process
  865. extern PDB * ppdbKernel; // pointer to the PDB of the kernel process
  866. extern TDB * ptdbWin16; // pointer to kernel win16 thread
  867. extern LST * plstTdb; // pointer to active thread list
  868. extern LST * plstPdb; // pointer to process list
  869. extern HANDLE hheapKernel; // Kernel's shared heap
  870. extern WORD Dos386PSPSeg;
  871. extern WORD Dos386PSPSel;
  872. extern VOID * lpSysVMHighLinear; // high linear mapping of low mem
  873. extern char WhineLevel; // debug level indicator
  874. extern USHORT selFlatCode;
  875. extern USHORT selFlatData;
  876. extern LEH* plehKernel; // Kernel's PE header
  877. extern BYTE fIsWDebThere; // Flags if kernel debugger is around
  878. extern DWORD ercNoThread; // Err code until first thread
  879. extern PTDB ptdbFault;
  880. extern HINSTANCE hinstKernel32;
  881. #ifndef WOW
  882. extern TDBX** ppTDBXCur;
  883. #endif // ndef WOW
  884. extern BYTE bBeepControl;
  885. extern int K32PSP;
  886. extern MTE **pmteModTable;
  887. extern IFSMGR_CTP_STRUCT *lpFlatIfsMgrConvertTable;
  888. // Types
  889. typedef enum _FILE_TYPE
  890. { FT_ERROR, FT_WIN16, FT_DOS, FT_BAT, FT_COM, FT_PIF, FT_WIN32CONSOLE,
  891. FT_WIN32GUI, FT_WIN32DLL } FILE_TYPE;
  892. #ifdef WOW
  893. #define GetTIB(ptdb) (*((ptdb)->ptib))
  894. #else // WOW
  895. #define GetTIB(ptdb) ((ptdb)->tib)
  896. #endif // else WOW
  897. #endif // ndef WOW32_EXTENSIONS
  898. #endif // #ifndef __KERNEL32_H