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.

139 lines
8.1 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: wow.h
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * This header file contains macros to be used in rtl\wow.c client\ and kernel\
  7. *
  8. * History:
  9. * 22-AUG-97 CLupu created
  10. \***************************************************************************/
  11. #if !defined(_WIN64)
  12. /*
  13. * WIN32 and WOW6432 version of StartValidateHandleMacro
  14. */
  15. #define StartValidateHandleMacro(h) \
  16. { \
  17. PHE phe; \
  18. DWORD dw; \
  19. WORD uniq; \
  20. \
  21. /* \
  22. * This is a macro that does an AND with HMINDEXBITS, \
  23. * so it is fast. \
  24. */ \
  25. dw = HMIndexFromHandle(h); \
  26. \
  27. /* \
  28. * Make sure it is part of our handle table. \
  29. */ \
  30. if (dw < gpsi->cHandleEntries) { \
  31. /* \
  32. * Make sure it is the handle \
  33. * the app thought it was, by \
  34. * checking the uniq bits in \
  35. * the handle against the uniq \
  36. * bits in the handle entry. \
  37. */ \
  38. phe = &gSharedInfo.aheList[dw]; \
  39. uniq = HMUniqFromHandle(h); \
  40. if ( uniq == phe->wUniq \
  41. || uniq == 0 \
  42. || uniq == HMUNIQBITS \
  43. ) { \
  44. #else /* _WIN64 */
  45. #if defined(_USERK_)
  46. /*
  47. * Allow 32bit process running on 64bit OS to mask the uniq bits (WOW64).
  48. */
  49. #define ALLOWZEROFORWOW64 ((uniq == 0) && (PsGetProcessWow64Process(PsGetCurrentProcess()) != NULL))
  50. #else
  51. #define ALLOWZEROFORWOW64 0
  52. #endif
  53. /*
  54. * WIN64 version of StartValidateHandleMacro
  55. */
  56. #define StartValidateHandleMacro(h) \
  57. { \
  58. PHE phe; \
  59. DWORD dw; \
  60. WORD uniq; \
  61. \
  62. /* \
  63. * This is a macro that does an AND with HMINDEXBITS, \
  64. * so it is fast. \
  65. */ \
  66. dw = HMIndexFromHandle(h); \
  67. \
  68. /* \
  69. * Make sure it is part of our handle table. \
  70. */ \
  71. if (dw < gpsi->cHandleEntries) { \
  72. /* \
  73. * Make sure it is the handle \
  74. * the app thought it was, by \
  75. * checking the uniq bits in \
  76. * the handle against the uniq \
  77. * bits in the handle entry. \
  78. * For Win64 uniq can't be zero! \
  79. */ \
  80. phe = &gSharedInfo.aheList[dw]; \
  81. uniq = HMUniqFromHandle(h); \
  82. if ( uniq == phe->wUniq \
  83. || uniq == HMUNIQBITS \
  84. || ALLOWZEROFORWOW64 \
  85. ) { \
  86. #endif /* _WIN64 */
  87. #define BeginAliveValidateHandleMacro() \
  88. /* \
  89. * Now make sure that the handle is not destroyed. On free \
  90. * builds the RIP disappears and the main line is straightthrough. \
  91. */ \
  92. if (!(phe->bFlags & HANDLEF_DESTROY)) { \
  93. #define EndAliveValidateHandleMacro() \
  94. } else { \
  95. RIPMSG2(RIP_WARNING, "ValidateAliveHandle: Object phe %#p is destroyed. Handle: %#p", \
  96. phe, h); \
  97. } \
  98. #define BeginTypeValidateHandleMacro(pobj, bTypeTest) \
  99. /* \
  100. * Now make sure the app is passing the right handle \
  101. * type for this api. If the handle is TYPE_FREE, this'll \
  102. * catch it. Also let Generic requests through. \
  103. */ \
  104. if ((phe->bType == bTypeTest) || \
  105. (bTypeTest == TYPE_GENERIC && phe->bType != TYPE_FREE)) { \
  106. \
  107. /* \
  108. * Instead of try/except we use the heap range check \
  109. * mechanism to verify that the given 'pwnd' belongs to \
  110. * the default desktop. We also have to do a Win 3.1 like \
  111. * check to make sure the window is not deleted \
  112. * See NT bug 12242 Kitchen app. Also 6479 \
  113. * \
  114. * TESTDESKOP returns the handle if the handle is valid \
  115. * in the current desktop \
  116. */ \
  117. pobj = phe->phead; \
  118. { \
  119. #define EndTypeValidateHandleMacro \
  120. } \
  121. } \
  122. #define EndValidateHandleMacro \
  123. } \
  124. } \
  125. }