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.

260 lines
7.1 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. wow64t.h
  5. Abstract:
  6. 32-bit structure definitions for 64-bit NT.
  7. Author:
  8. Barry Bond (barrybo) 20-Jun-1998
  9. Revision History:
  10. --*/
  11. #ifndef _WOW64T_
  12. #define _WOW64T_
  13. //
  14. // Page size on x86 NT
  15. //
  16. #define PAGE_SIZE_X86NT 0x1000
  17. #define PAGE_SHIFT_X86NT 12L
  18. //
  19. // Conver the number of native pages to sub x86-pages
  20. //
  21. #define Wow64GetNumberOfX86Pages(NativePages) \
  22. (NativePages * (PAGE_SIZE >> PAGE_SHIFT_X86NT))
  23. // The name of the 32-bit system directory, which is a child of %SystemRoot%
  24. #define WOW64_SYSTEM_DIRECTORY "syswow64"
  25. #define WOW64_SYSTEM_DIRECTORY_U L"syswow64"
  26. // Length in bytes of the new system directory, not counting a
  27. // null terminator
  28. //
  29. #define WOW64_SYSTEM_DIRECTORY_SIZE (sizeof(WOW64_SYSTEM_DIRECTORY)-sizeof(CHAR))
  30. #define WOW64_SYSTEM_DIRECTORY_U_SIZE (sizeof(WOW64_SYSTEM_DIRECTORY_U)-sizeof(WCHAR))
  31. #define WOW64_X86_TAG " (x86)"
  32. #define WOW64_X86_TAG_U L" (x86)"
  33. #define TYPE32(x) ULONG
  34. #define TYPE64(x) ULONGLONG
  35. //
  36. // Wow64Info structure is shared between 32-bit and 64-bit modules inside a Wow64 process.
  37. // NOTE : This structure shouldn't contain any pointer-dependent data, as
  38. // it is viewed from 32-bit and 64-bit code.
  39. //
  40. typedef struct _WOW64INFO {
  41. ULONG NativeSystemPageSize; // Page size of the native system the emulator is running on.
  42. ULONG CpuFlags;
  43. } WOW64INFO, *PWOW64INFO;
  44. typedef struct _PEB_LDR_DATA32 {
  45. ULONG Length;
  46. BOOLEAN Initialized;
  47. TYPE32(HANDLE) SsHandle;
  48. LIST_ENTRY32 InLoadOrderModuleList;
  49. LIST_ENTRY32 InMemoryOrderModuleList;
  50. LIST_ENTRY32 InInitializationOrderModuleList;
  51. TYPE32(PVOID) EntryInProgress;
  52. } PEB_LDR_DATA32, *PPEB_LDR_DATA32;
  53. typedef struct _GDI_TEB_BATCH32 {
  54. ULONG Offset;
  55. TYPE32(ULONG_PTR) HDC;
  56. ULONG Buffer[GDI_BATCH_BUFFER_SIZE];
  57. } GDI_TEB_BATCH32,*PGDI_TEB_BATCH32;
  58. typedef struct _GDI_TEB_BATCH64 {
  59. ULONG Offset;
  60. TYPE64(ULONG_PTR) HDC;
  61. ULONG Buffer[GDI_BATCH_BUFFER_SIZE];
  62. } GDI_TEB_BATCH64,*PGDI_TEB_BATCH64;
  63. typedef struct _Wx86ThreadState32 {
  64. TYPE32(PULONG) CallBx86Eip;
  65. TYPE32(PVOID) DeallocationCpu;
  66. BOOLEAN UseKnownWx86Dll;
  67. char OleStubInvoked;
  68. } WX86THREAD32, *PWX86THREAD32;
  69. typedef struct _Wx86ThreadState64 {
  70. TYPE64(PULONG) CallBx86Eip;
  71. TYPE64(PVOID) DeallocationCpu;
  72. BOOLEAN UseKnownWx86Dll;
  73. char OleStubInvoked;
  74. } WX86THREAD64, *PWX86THREAD64;
  75. typedef struct _CLIENT_ID32 {
  76. TYPE32(HANDLE) UniqueProcess;
  77. TYPE32(HANDLE) UniqueThread;
  78. } CLIENT_ID32;
  79. typedef CLIENT_ID32 *PCLIENT_ID32;
  80. #if !defined(CLIENT_ID64_DEFINED)
  81. typedef struct _CLIENT_ID64 {
  82. TYPE64(HANDLE) UniqueProcess;
  83. TYPE64(HANDLE) UniqueThread;
  84. } CLIENT_ID64;
  85. typedef CLIENT_ID64 *PCLIENT_ID64;
  86. #define CLIENT_ID64_DEFINED
  87. #endif
  88. typedef ULONG GDI_HANDLE_BUFFER32[GDI_HANDLE_BUFFER_SIZE32];
  89. typedef ULONG GDI_HANDLE_BUFFER64[GDI_HANDLE_BUFFER_SIZE64];
  90. #define PEBTEB_BITS 32
  91. #include "pebteb.h"
  92. #undef PEBTEB_BITS
  93. #define PEBTEB_BITS 64
  94. #include "pebteb.h"
  95. #undef PEBTEB_BITS
  96. typedef struct _RTL_DRIVE_LETTER_CURDIR32 {
  97. USHORT Flags;
  98. USHORT Length;
  99. ULONG TimeStamp;
  100. STRING32 DosPath;
  101. } RTL_DRIVE_LETTER_CURDIR32, *PRTL_DRIVE_LETTER_CURDIR32;
  102. typedef struct _CURDIR32 {
  103. UNICODE_STRING32 DosPath;
  104. TYPE32(HANDLE) Handle;
  105. } CURDIR32, *PCURDIR32;
  106. typedef struct _RTL_USER_PROCESS_PARAMETERS32 {
  107. ULONG MaximumLength;
  108. ULONG Length;
  109. ULONG Flags;
  110. ULONG DebugFlags;
  111. TYPE32(HANDLE) ConsoleHandle;
  112. ULONG ConsoleFlags;
  113. TYPE32(HANDLE) StandardInput;
  114. TYPE32(HANDLE) StandardOutput;
  115. TYPE32(HANDLE) StandardError;
  116. CURDIR32 CurrentDirectory; // ProcessParameters
  117. UNICODE_STRING32 DllPath; // ProcessParameters
  118. UNICODE_STRING32 ImagePathName; // ProcessParameters
  119. UNICODE_STRING32 CommandLine; // ProcessParameters
  120. TYPE32(PVOID) Environment; // NtAllocateVirtualMemory
  121. ULONG StartingX;
  122. ULONG StartingY;
  123. ULONG CountX;
  124. ULONG CountY;
  125. ULONG CountCharsX;
  126. ULONG CountCharsY;
  127. ULONG FillAttribute;
  128. ULONG WindowFlags;
  129. ULONG ShowWindowFlags;
  130. UNICODE_STRING32 WindowTitle; // ProcessParameters
  131. UNICODE_STRING32 DesktopInfo; // ProcessParameters
  132. UNICODE_STRING32 ShellInfo; // ProcessParameters
  133. UNICODE_STRING32 RuntimeData; // ProcessParameters
  134. RTL_DRIVE_LETTER_CURDIR32 CurrentDirectores[ RTL_MAX_DRIVE_LETTERS ];
  135. } RTL_USER_PROCESS_PARAMETERS32, *PRTL_USER_PROCESS_PARAMETERS32;
  136. #if !defined(BUILD_WOW6432)
  137. //
  138. // Macros to encapsulate fields that are used to store the TEB.
  139. // They are kernel safe since the 64BIT TEB is locked down in memory
  140. // and cann't be moved or decommited until the thread dies.
  141. #define WOW64_GET_TEB32(teb64) \
  142. ((PTEB32)((teb64)->NtTib.ExceptionList))
  143. //
  144. // Update the first qword in the 64-bit TEB. The 32-bit rdteb instruction
  145. // reads the TEB32 pointer value directly from this field.
  146. //
  147. #define WOW64_SET_TEB32(teb64, teb32) \
  148. (teb64)->NtTib.ExceptionList = (struct _EXCEPTION_REGISTRATION_RECORD *)(teb32);
  149. #define WOW64_TEB32_POINTER_ADDRESS(teb64) \
  150. (PVOID)&((teb64)->NtTib.ExceptionList)
  151. #endif
  152. //
  153. // Thunk macros
  154. #define UStr32ToUStr(dst, src) { (dst)->Length = (src)->Length; \
  155. (dst)->MaximumLength = (src)->MaximumLength; \
  156. (dst)->Buffer = (PWSTR) ((src)->Buffer); }
  157. #define UStrToUStr32(dst, src) { (dst)->Length = (src)->Length; \
  158. (dst)->MaximumLength = (src)->MaximumLength; \
  159. (dst)->Buffer = (ULONG) ((src)->Buffer); }
  160. #define NtCurrentTeb32() ((PTEB32) (NtCurrentTeb()->NtTib.ExceptionList) )
  161. #define NtCurrentPeb32() ((PPEB32) (NtCurrentTeb32()->ProcessEnvironmentBlock) )
  162. // This is currently defined in windows\core\w32inc\w32wow64.h:
  163. #define NtCurrentTeb64() ((PTEB64)((PTEB32)NtCurrentTeb())->GdiBatchCount)
  164. // This is currently defined in base\wow64\inc\wow64.h:
  165. #define WOW64_TLS_FILESYSREDIR 8 // Used to enable/disable the filesystem
  166. #define WOW64_TLS_WOW64INFO 10 // Used to access native system information for wow64 processes.
  167. // These should only be called from Win32 code known to be running on Win64.
  168. #if !_WIN64
  169. #define Wow64EnableFilesystemRedirector() \
  170. NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = 0;
  171. #define Wow64DisableFilesystemRedirector(filename) \
  172. NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = (ULONGLONG)(ULONG)filename;
  173. //
  174. // Wow64Info is accessed only from compiled code for x86 on win64.
  175. // NOTE: Only Wow64 processes are allowed to call these macros.
  176. //
  177. #define Wow64GetSharedInfo() ((PWOW64INFO)NtCurrentTeb64()->TlsSlots[WOW64_TLS_WOW64INFO])
  178. #define Wow64GetSystemNativePageSize() \
  179. ((PWOW64INFO)(NtCurrentTeb64()->TlsSlots[WOW64_TLS_WOW64INFO]))->NativeSystemPageSize
  180. #else
  181. #define Wow64GetSharedInfo() ((PWOW64INFO)NtCurrentTeb()->TlsSlots[WOW64_TLS_WOW64INFO])
  182. #endif
  183. #endif // _WOW64T_