Leaked source code of windows server 2003
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.

183 lines
6.5 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: w32wow64.h
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * This header file contains macros used to access kernel mode data
  7. * from user mode for wow64.
  8. *
  9. * History:
  10. * 08-18-98 PeterHal Created.
  11. \***************************************************************************/
  12. #ifndef _W32WOW64_
  13. #define _W32WOW64_
  14. #include "w32w64a.h"
  15. /*
  16. * Pointers in shared memory need to be 64-bit for user32 on 64-bit kernel
  17. */
  18. #ifdef BUILD_WOW6432
  19. #define BUILD_WOW64
  20. #include <wow64t.h>
  21. #ifndef BUILD_WOW6432_WRN
  22. // disable ptr truncation warnings on the 32/64 build
  23. // by default
  24. #pragma warning (disable:4244)
  25. // disable warnings for ((KERNEL_PVOID)p) == NULL
  26. #pragma warning (disable:4047)
  27. #endif
  28. /*
  29. * From windows\inc\windef.w
  30. */
  31. typedef KERNEL_UINT_PTR KERNEL_WPARAM;
  32. typedef KERNEL_LONG_PTR KERNEL_LPARAM;
  33. typedef KERNEL_LONG_PTR KERNEL_LRESULT;
  34. #define KERNEL_WPARAM_TO_WPARAM(w) ((WPARAM)(w))
  35. #define KERNEL_LPARAM_TO_LPARAM(l) ((LPARAM)(l))
  36. #define KERNEL_LRESULT_TO_LRESULT(r) ((LRESULT)(r))
  37. #define KERNEL_INT_PTR_TO_INT_PTR(i) ((INT)(i))
  38. #define KERNEL_ULONG_PTR_TO_ULONG_PTR(u) ((ULONG)(u))
  39. #define KPBYTE_TO_PBYTE(p) ((PBYTE)(KERNEL_ULONG_PTR)(p))
  40. #define KPRECT_TO_PRECT(p) ((PRECT)(KERNEL_ULONG_PTR)(p))
  41. #define KPSBDATA_TO_PSBDATA(p) ((PSBDATA)(KERNEL_ULONG_PTR)(p))
  42. #define KPVOID_TO_PVOID(p) ((PVOID)(KERNEL_ULONG_PTR)(p))
  43. #define KPWSTR_TO_PWSTR(p) ((PWSTR)(KERNEL_ULONG_PTR)(p))
  44. #define KHANDLE_TO_HANDLE(h) ((HANDLE)(KERNEL_ULONG_PTR)(h))
  45. #define KHBITMAP_TO_HBITMAP(h) ((HBITMAP)(KERNEL_ULONG_PTR)(h))
  46. #define KHBRUSH_TO_HBRUSH(h) ((HBRUSH)(KERNEL_ULONG_PTR)(h))
  47. #define KHFONT_TO_HFONT(h) ((HFONT)(KERNEL_ULONG_PTR)(h))
  48. #define KHICON_TO_HICON(h) ((HICON)(KERNEL_ULONG_PTR)(h))
  49. #define KHIMC_TO_HIMC(h) ((HIMC)(KERNEL_ULONG_PTR)(h))
  50. #define KHKL_TO_HKL(h) ((HKL)(KERNEL_ULONG_PTR)(h))
  51. #define KHRGN_TO_HRGN(h) ((HRGN)(KERNEL_ULONG_PTR)(h))
  52. #define KHWND_TO_HWND(h) ((HWND)(KERNEL_ULONG_PTR)(h))
  53. typedef KERNEL_PVOID KPROC;
  54. typedef PEB64 PEBSHARED, *PPEBSHARED;
  55. typedef TEB64 TEBSHARED, *PTEBSHARED;
  56. #define NtCurrentTeb64() ((PTEB64)((PTEB32)NtCurrentTeb())->GdiBatchCount)
  57. #define NtCurrentPeb64() ((PPEB64)NtCurrentTeb64()->ProcessEnvironmentBlock)
  58. #define NtCurrentPebShared() NtCurrentPeb64()
  59. #define NtCurrentTebShared() NtCurrentTeb64()
  60. #if defined(_AMD64_) || defined(_X86_) || defined(_IA64_)
  61. // use IA64 PAGE_SIZE
  62. #define KERNEL_PAGE_SIZE (0x2000)
  63. #else
  64. #error Unknown platform for KERNEL_PAGE_SIZE
  65. #endif
  66. #else // BUILD_WOW6432
  67. typedef WPARAM KERNEL_WPARAM;
  68. typedef LPARAM KERNEL_LPARAM;
  69. typedef LRESULT KERNEL_LRESULT;
  70. #define KERNEL_WPARAM_TO_WPARAM(w) (w)
  71. #define KERNEL_LPARAM_TO_LPARAM(l) (l)
  72. #define KERNEL_LRESULT_TO_LRESULT(r) (r)
  73. #define KERNEL_INT_PTR_TO_INT_PTR(i) (i)
  74. #define KERNEL_ULONG_PTR_TO_ULONG_PTR(u) (u)
  75. #define KPBYTE_TO_PBYTE(p) (p)
  76. #define KPRECT_TO_PRECT(p) (p)
  77. #define KPSBDATA_TO_PSBDATA(p) (p)
  78. #define KPVOID_TO_PVOID(p) (p)
  79. #define KPWSTR_TO_PWSTR(p) (p)
  80. #define KHANDLE_TO_HANDLE(h) (h)
  81. #define KHBITMAP_TO_HBITMAP(h) (h)
  82. #define KHBRUSH_TO_HBRUSH(h) (h)
  83. #define KHFONT_TO_HFONT(h) (h)
  84. #define KHICON_TO_HICON(h) (h)
  85. #define KHIMC_TO_HIMC(h) (h)
  86. #define KHKL_TO_HKL(h) (h)
  87. #define KHRGN_TO_HRGN(h) (h)
  88. #define KHWND_TO_HWND(h) (h)
  89. typedef PROC KPROC;
  90. typedef PEB PEBSHARED, *PPEBSHARED;
  91. typedef TEB TEBSHARED, *PTEBSHARED;
  92. #define NtCurrentPebShared() NtCurrentPeb()
  93. #define NtCurrentTebShared() NtCurrentTeb()
  94. #define KERNEL_PAGE_SIZE PAGE_SIZE
  95. #endif // BUILD_WOW64
  96. DECLARE_KHANDLE(HCOLORSPACE);
  97. DECLARE_KHANDLE(HDC);
  98. DECLARE_KHANDLE(HFONT);
  99. DECLARE_KHANDLE(HICON);
  100. typedef KHICON KHCURSOR; // HICON & HCURSOR are polymorphic
  101. DECLARE_KHANDLE(HKL);
  102. DECLARE_KHANDLE(HRGN);
  103. DECLARE_KHANDLE(HWND);
  104. typedef BYTE * KPTR_MODIFIER KPBYTE;
  105. typedef WORD * KPTR_MODIFIER KPWORD;
  106. typedef INT * KPTR_MODIFIER KPINT;
  107. typedef DWORD * KPTR_MODIFIER KPDWORD;
  108. typedef ULONG_PTR * KPTR_MODIFIER KPULONG_PTR;
  109. typedef KERNEL_ULONG_PTR * KPTR_MODIFIER KPKERNEL_ULONG_PTR;
  110. typedef WCHAR * KPTR_MODIFIER KLPWSTR;
  111. typedef WCHAR * KPTR_MODIFIER KPWSTR;
  112. typedef CHAR * KPTR_MODIFIER KLPSTR;
  113. typedef CHAR * KPTR_MODIFIER KPSTR;
  114. #ifdef BUILD_WOW6432
  115. /*
  116. * Message structure
  117. *
  118. * This is copied right out of windows\inc\winuser.w
  119. */
  120. typedef struct tagKERNEL_MSG {
  121. KHWND hwnd;
  122. UINT message;
  123. KERNEL_WPARAM wParam;
  124. KERNEL_LPARAM lParam;
  125. DWORD time;
  126. POINT pt;
  127. } KERNEL_MSG, *PKERNEL_MSG;
  128. __inline VOID
  129. COPY_KERNELMSG_TO_MSG(PMSG pmsg, PKERNEL_MSG pkmsg)
  130. {
  131. pmsg->hwnd = KHWND_TO_HWND(pkmsg->hwnd);
  132. pmsg->message = pkmsg->message;
  133. pmsg->wParam = KERNEL_WPARAM_TO_WPARAM(pkmsg->wParam);
  134. pmsg->lParam = KERNEL_LPARAM_TO_LPARAM(pkmsg->lParam);
  135. pmsg->time = pkmsg->time;
  136. pmsg->pt = pkmsg->pt;
  137. }
  138. __inline VOID
  139. COPY_MSG_TO_KERNELMSG(PKERNEL_MSG pkmsg, PMSG pmsg)
  140. {
  141. pkmsg->hwnd = pmsg->hwnd;
  142. pkmsg->message = pmsg->message;
  143. pkmsg->wParam = pmsg->wParam;
  144. pkmsg->lParam = pmsg->lParam;
  145. pkmsg->time = pmsg->time;
  146. pkmsg->pt = pmsg->pt;
  147. }
  148. #else // BUILD_WOW6432
  149. #define KERNEL_MSG MSG
  150. #define PKERNEL_MSG PMSG
  151. #define COPY_KERNELMSG_TO_MSG(pmsg, pkmsg) RtlCopyMemory(pmsg, pkmsg, sizeof(MSG))
  152. #define COPY_MSG_TO_KERNELMSG(pkmsg, pmsg) RtlCopyMemory(pkmsg, pmsg, sizeof(MSG))
  153. #endif
  154. #endif // _W32WOW64_