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.

269 lines
9.2 KiB

  1. /*****************************************************************************
  2. * K32SHARE.H
  3. *
  4. * Shared interfaces/information between Kernel16 and Kernel32.
  5. *
  6. * This file must be kept in sync with K32SHARE.INC!
  7. *
  8. * Created: 8-Sep-92 [JonT]
  9. *
  10. ****************************************************************************/
  11. /* XLATOFF */
  12. typedef struct tagK16SYSVAR {
  13. DWORD dwSize;
  14. /* LCRST Win16Lock; */
  15. DWORD VerboseSysLevel;
  16. DWORD dwDebugErrorLevel;
  17. WORD winVer;
  18. WORD Win_PDB;
  19. } K16SYSVAR;
  20. typedef struct _tempstackinfo { /**/
  21. DWORD si_base; // base of stack
  22. DWORD si_top; // top of stack
  23. union {
  24. struct {
  25. WORD so_offset;
  26. WORD so_segment;
  27. } si_so;
  28. DWORD si_segoff; // use with 'lss sp, si_segoff'
  29. };
  30. } TEMPSTACKINFO;
  31. /* XLATON */
  32. /*ASM
  33. _TEMPSTACKINFO STRUCT
  34. si_base dd ? ; base of stack
  35. si_top dd ? ; top of stack
  36. si_segoff dd ? ; use with 'lss sp, si_segoff'
  37. _TEMPSTACKINFO ENDS
  38. TEMPSTACKINFO TYPEDEF _TEMPSTACKINFO
  39. */
  40. #define STACK_GUARD_QUANTUM 8 // 8 guard pages on growable stacks
  41. #define STACK_THUNK_SIZE (STACK_GUARD_QUANTUM * 0x1000)
  42. // IFSMgr table of conversion pointers for Unicode/Ansi/OEM conversion
  43. typedef struct _IFSMGR_CTP_STRUCT { /**/
  44. DWORD cbCTPCount; // count of pointers in table
  45. DWORD pUniToWinAnsiTable;
  46. DWORD pUniToOEMTable;
  47. DWORD pWinAnsiToUniTable;
  48. DWORD pOEMToUniTable;
  49. DWORD pUniToUpperDelta;
  50. DWORD pUniToUpperTable;
  51. } IFSMGR_CTP_STRUCT;
  52. // Kernel16->Kernel32 structure passed at init time
  53. typedef struct tagK32STARTDATA { /* sd */
  54. DWORD dwSize; // DWORD, structure size
  55. DWORD hCurTDB; // DWORD, 16 bit hTask of current task
  56. DWORD selPSP; // DWORD, selector of current kernel's PSP
  57. DWORD lpfnVxDCall; // 16:16 pointer to DOS386 BP
  58. DWORD selLDT; // R/W Selector to LDT
  59. DWORD pLDT; // Lin address of LDT (assumes not moveable)
  60. DWORD dwWinVer; // Windows version
  61. DWORD pK16CurTask; // Points to Kernel16's current task var
  62. DWORD pWinDir; // Points to the Windows directory
  63. DWORD pSysDir; // Points to the Windows system directory
  64. WORD wcbWinDir; // Length of windir (not zero terminated)
  65. WORD wcbSysDir; // Length of sysdir (not zero terminated)
  66. #ifndef WOW
  67. struct _tdb **pptdbCur; // pointer to current thread pointer
  68. #endif // ndef WOW
  69. DWORD Win16Lock; // ptr to Win16 hierarchical critical section
  70. DWORD pVerboseSysLevel; // ptr to Enter/LeaveSysLevel verbosity control
  71. #ifdef WOW
  72. DWORD Krn32BaseLoadAddr; // Base address KERNEL32 loaded at
  73. #else
  74. DWORD ppCurTDBX; // ptr to current 32 bit TDBX
  75. #endif // ifdef WOW
  76. DWORD pThkData; // ptr to shared thunk data
  77. K16SYSVAR *pK16SysVar; // ptr to K16 system variables
  78. DWORD pHGGlobs; // ptr to K16 HGGlobs structure
  79. DWORD pK16CurDosDrive; // ptr to kernel16's curdosdrive variable
  80. DWORD pK16CurDriveOwner; // ptr to kernel16's cur_drive_owner variable
  81. WORD wSelBurgerMaster; // BurgerMaster segment
  82. WORD wHeadK16FreeList; // Head of the k16 global free list
  83. DWORD lpSelTableStart; // Ptr to K16 SelTableStart variable
  84. DWORD lpSelTableLen; // Ptr to K16 SelTableStart variable
  85. DWORD pK16HeadTDB; // ptr to head of the 16-bit TDB list
  86. DWORD fIsSymDebThere; // Same as KF_SYMDEB flag in K16.
  87. struct _tempstackinfo *pTermStack; // ptr to win16 termination stack info
  88. DWORD pIFSMgrCTPStruct; // pointer to unicode/ansi conversion table
  89. DWORD pK16ResHandler; // 16:16 PELoadResourceHandler
  90. DWORD pK32LangID; // flat addr of k32's ulLanguageID
  91. PULONG pulRITEventPending; // pointer to RITEventPending variable
  92. WORD K32HeapSize; // max size of kernel32's heap
  93. #ifdef WOW
  94. WORD Unused;
  95. #else // WOW
  96. WORD SystemTickCountDS; // selector of tick count variable
  97. #endif // else WOW
  98. DWORD pcrstGHeap16; // ptr to k16 global heap critical section
  99. PVOID pcscr16; // pointer to 16 bit crst code ranges
  100. DWORD pwHeadSelman16; // pointer to head of 16-bit selman list
  101. DWORD dwIdObsfucator; // XOR mask for obfuscating pids & tids
  102. DWORD pDiagFlag; // ptr to diagnostic logging enabled boolean
  103. DWORD fNovell; // ver info of Real Netx (ea00 call)
  104. DWORD pcrstDriveState; // drive state for DOS calls
  105. #ifndef WOW
  106. PVOID lpSysVMHighLinear; // high linear mapping for low mem
  107. #endif // ndef WOW
  108. #ifdef WOW
  109. PVOID AdrK16WantSetSelector;
  110. DWORD pK16CurDOSPsp; // ptr to k16 cur_dos_pdb variable
  111. DWORD pDOSCurPsp; // ptr to curr pdb variable in DOS
  112. #endif
  113. } K32STARTDATA;
  114. // Thread Info Block
  115. // Note that this structure is always contained in the TDB
  116. // This is the only part of the TDB that is known to apps and to Kernel16
  117. //
  118. // This is the NT form. We must match the marked fields:
  119. // typedef struct _NT_TIB {
  120. // struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList; **** match!!!
  121. // PVOID StackBase; **** match!!!
  122. // PVOID StackLimit; **** match!!!
  123. // PVOID SubSystemTib;
  124. // union {
  125. // PVOID FiberData; **** match!!!
  126. // ULONG Version;
  127. // };
  128. // PVOID ArbitraryUserPointer; ?????
  129. // struct _NT_TIB *Self; **** match!!!
  130. // } NT_TIB;
  131. //
  132. // typedef struct _TEB {
  133. // NT_TIB NtTib;
  134. // PVOID EnvironmentPointer;
  135. // CLIENT_ID ClientId;
  136. // PVOID ActiveRpcHandle;
  137. // PVOID ThreadLocalStoragePointer; **** match!!!
  138. // PPEB ProcessEnvironmentBlock; **** match!!!
  139. // ULONG LastErrorValue;
  140. // UCHAR LastErrorString[NT_LAST_ERROR_STRING_LENGTH];
  141. // ULONG CountOfOwnedCriticalSections;
  142. // PVOID Sparea;
  143. // PVOID Spareb;
  144. // LCID CurrentLocale;
  145. // ULONG FpSoftwareStatusRegister;
  146. // PVOID SystemReserved1[55];
  147. // PVOID Win32ThreadInfo;
  148. // PVOID SystemReserved2[337];
  149. // PVOID CsrQlpcStack;
  150. // ULONG GdiClientPID;
  151. // ULONG GdiClientTID;
  152. // PVOID GdiThreadLocalInfo;
  153. // PVOID User32Reserved0;
  154. // PVOID User32Reserved1;
  155. // PVOID UserReserved[315];
  156. // ULONG LastStatusValue;
  157. // UNICODE_STRING StaticUnicodeString;
  158. // WCHAR StaticUnicodeBuffer[STATIC_UNICODE_BUFFER_LENGTH];
  159. // PVOID DeallocationStack;
  160. // PVOID TlsSlots[TLS_MINIMUM_AVAILABLE];
  161. // LIST_ENTRY TlsLinks;
  162. // PVOID Vdm;
  163. // PVOID ReservedForNtRpc;
  164. // } TEB;
  165. typedef struct _TIBSTRUCT { /* tib */
  166. DWORD pvExcept; // Head of exception record list
  167. VOID* pvStackUserLimit; // Top of user stack
  168. VOID* pvStackUser; // Base of user stack
  169. #ifdef WOW
  170. VOID* pvSubSystemTib;
  171. #else // WOW
  172. // Replace SubSystemTib with the following 2 WORDs
  173. WORD hTaskK16; // Kernel16 hTask associated with this thread
  174. WORD ss16; // 16-bit stack selector, for 32=>16 thunks
  175. #endif // else WOW
  176. PVOID pvFiberData; // Fiber support macros reference this field
  177. PVOID pvArbitraryUserPointer;
  178. struct _TIBSTRUCT *ptibSelf; // Linear address of TIB structure
  179. #ifdef WOW
  180. BYTE bFiller[4096-7*4-2*2-4-7*4];
  181. WORD hTaskK16; // Kernel16 hTask associated with this thread
  182. WORD ss16; // 16-bit stack selector, for 32=>16 thunks
  183. PVOID pTDB;
  184. #endif // def WOW
  185. WORD flags; // TIB flags
  186. WORD Win16LockVCount; // Count of thunk virtual locks
  187. struct _DEBDLLCONTEXT *pcontextDeb; // pointer to debug DLL context record
  188. DWORD *pCurPri; // ptr to current priority of this thread
  189. DWORD dwMsgQueue; // User's per thread queue dword value
  190. PVOID *ThreadLocalStoragePointer; // pointer to thread local storage array
  191. struct _pdb* ppdbProc; // Used as PID for M3 NT compatibility
  192. VOID *pvFirstDscr; // Per-thread selman list.
  193. } TIBSTRUCT;
  194. /* XLATOFF */
  195. typedef TIBSTRUCT TIB;
  196. /* XLATON */
  197. // TIB.flags values
  198. #define TIBF_WIN32_BIT 0 // this is a Win32 thread
  199. #define TIBF_TRAP_BIT 1 // single step trap in DIT has occured
  200. #define TIBF_WIN32 (1 << TIBF_WIN32_BIT)
  201. #define TIBF_TRAP (1 << TIBF_TRAP_BIT)
  202. //
  203. // Critical section code range structure. Contains the start and end
  204. // linear addresses of the EnterCrst/LeaveCrst code that can't be
  205. // interrupted by ring 0 code.
  206. //
  207. typedef struct _CSCR { /**/
  208. PVOID cscr_pStart; // starting linear address of crst code
  209. PVOID cscr_pEnd; // ending linear address of crst code
  210. PVOID cscr_pOK; // this addr in the above range is ok to be at
  211. PVOID cscr_pNOP; // linear address of nop to replace with int 3
  212. } CSCR;
  213. typedef CSCR *PCSCR;
  214. #define NUM_CSCR_16 6
  215. #define NUM_CSCR_32 4
  216. #define NUM_CSCR (NUM_CSCR_16 + NUM_CSCR_32)
  217. /* ASM
  218. ;
  219. ; Macro to convert bit flag to bit number
  220. ;
  221. BITNUM MACRO bitflag:REQ
  222. LOCAL bit, bitn, val
  223. bitn = 0
  224. bit = 1
  225. %val = bitflag
  226. .errnz val AND (val - 1) ; multiple bits invalid
  227. REPEAT 32
  228. IF (val AND bit) NE 0
  229. EXITM
  230. ENDIF
  231. bitn = bitn + 1
  232. bit = bit SHL 1
  233. ENDM
  234. ifndef WOW
  235. .erre bitn - 32 ; no bit defined
  236. endif
  237. EXITM %bitn
  238. ENDM
  239. */