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.

232 lines
5.5 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright <c> 2000 Microsoft Corporation
  3. Module Name :
  4. ndrpall.h
  5. Abtract :
  6. Contains private definitions which are common to both
  7. ndr20 and ndr64
  8. Author :
  9. mzoran May 31, 2000
  10. Revision History :
  11. --------------------------------------------------------------------*/
  12. #if !defined(__NDRPALL_H__)
  13. #define __NDRPALL_H__
  14. //
  15. // The MIDL version is contained in the stub descriptor starting with
  16. // MIDL version 2.00.96 (pre NT 3.51 Beta 2, 2/95) and can be used for a finer
  17. // granularity of compatability checking. The MIDL version was zero before
  18. // MIDL version 2.00.96. The MIDL version number is converted into
  19. // an integer long using the following expression :
  20. // ((Major << 24) | (Minor << 16) | Revision)
  21. //
  22. #define MIDL_NT_3_51 ((2UL << 24) | (0UL << 16) | 102UL)
  23. #define MIDL_VERSION_3_0_39 ((3UL << 24) | (0UL << 16) | 39UL)
  24. #define MIDL_VERSION_3_2_88 ((3UL << 24) | (2UL << 16) | 88UL)
  25. #define MIDL_VERSION_5_0_136 ((5UL << 24) | (0UL << 16) | 136UL)
  26. #define MIDL_VERSION_5_2_202 ((5UL << 24) | (2UL << 16) | 202UL)
  27. // Shortcut typedefs.
  28. typedef unsigned char uchar;
  29. typedef unsigned short ushort;
  30. typedef unsigned long ulong;
  31. typedef unsigned int uint;
  32. typedef unsigned __int64 uint64;
  33. #if defined(NDRFREE_DEBUGPRINT)
  34. // force a debug print and a breakpoint on a free build
  35. #define NDR_ASSERT( exp, S ) \
  36. if (!(exp)) { DbgPrint( "%s(%s)\n", __FILE__, __LINE__ );DbgPrint( S## - Ryszard's private rpcrt4.dll\n", NULL );DebugBreak(); }
  37. #else
  38. // Just use the RPC runtime assert
  39. #define NDR_ASSERT( exp, S ) \
  40. { ASSERT( ( S, (exp) ) ); }
  41. #endif
  42. #define NDR_MEMORY_LIST_SIGNATURE 'MEML'
  43. typedef struct _NDR_MEMORY_LIST_TAIL_NODE {
  44. ULONG Signature;
  45. void *pMemoryHead;
  46. struct _NDR_MEMORY_LIST_TAIL_NODE *pNextNode;
  47. } NDR_MEMORY_LIST_TAIL_NODE, *PNDR_MEMORY_LIST_TAIL_NODE;
  48. struct NDR_ALLOC_ALL_NODES_CONTEXT {
  49. unsigned char * AllocAllNodesMemory;
  50. unsigned char * AllocAllNodesMemoryBegin;
  51. unsigned char * AllocAllNodesMemoryEnd;
  52. };
  53. void
  54. NdrpFreeMemoryList(
  55. PMIDL_STUB_MESSAGE pStubMsg
  56. );
  57. void
  58. NdrpGetIIDFromBuffer(
  59. PMIDL_STUB_MESSAGE pStubMsg,
  60. IID ** ppIID
  61. );
  62. void
  63. NDRSContextEmergencyCleanup (
  64. IN RPC_BINDING_HANDLE BindingHandle,
  65. IN OUT NDR_SCONTEXT hContext,
  66. IN NDR_RUNDOWN userRunDownIn,
  67. IN PVOID NewUserContext,
  68. IN BOOL fManagerRoutineException
  69. );
  70. void
  71. NdrpEmergencyContextCleanup(
  72. MIDL_STUB_MESSAGE * pStubMsg,
  73. PNDR_CONTEXT_HANDLE_ARG_DESC pCtxtDesc,
  74. void * pArg,
  75. BOOL fManagerRoutineException );
  76. //
  77. // Alignment macros.
  78. //
  79. #define ALIGN( pStuff, cAlign ) \
  80. pStuff = (uchar *)((LONG_PTR)((pStuff) + (cAlign)) \
  81. & ~ ((LONG_PTR)(cAlign)))
  82. #define LENGTH_ALIGN( Length, cAlign ) \
  83. Length = (((Length) + (cAlign)) & ~ (cAlign))
  84. #if defined(_IA64_)
  85. #include "ia64reg.h"
  86. #ifdef __cplusplus
  87. extern "C" {
  88. #endif
  89. unsigned __int64 __getReg (int);
  90. #pragma intrinsic (__getReg)
  91. #ifdef __cplusplus
  92. } // extern "C"
  93. #endif
  94. #endif
  95. #if defined(_X86_)
  96. __forceinline
  97. void*
  98. NdrGetCurrentStackPointer(void)
  99. {
  100. _asm{ mov eax, esp }
  101. }
  102. __forceinline
  103. void
  104. NdrSetupLowStackMark( PMIDL_STUB_MESSAGE pStubMsg )
  105. {
  106. pStubMsg->LowStackMark = (uchar*)NdrGetCurrentStackPointer() - 0x1000; //4KB
  107. }
  108. __forceinline
  109. BOOL
  110. NdrIsLowStack(MIDL_STUB_MESSAGE *pStubMsg ) {
  111. return (SIZE_T)NdrGetCurrentStackPointer() < (SIZE_T)pStubMsg->LowStackMark;
  112. //return false;
  113. }
  114. #elif defined(_AMD64_)
  115. __forceinline
  116. void*
  117. NdrGetCurrentStackPointer(void)
  118. {
  119. PVOID TopOfStack;
  120. return (&TopOfStack + 1);
  121. }
  122. __forceinline
  123. void
  124. NdrSetupLowStackMark( PMIDL_STUB_MESSAGE pStubMsg )
  125. {
  126. pStubMsg->LowStackMark = (uchar*)NdrGetCurrentStackPointer() - 0x1000; //4KB
  127. }
  128. __forceinline
  129. BOOL
  130. NdrIsLowStack(MIDL_STUB_MESSAGE *pStubMsg ) {
  131. return (SIZE_T)NdrGetCurrentStackPointer() < (SIZE_T)pStubMsg->LowStackMark;
  132. //return false;
  133. }
  134. #elif defined(_IA64_)
  135. __forceinline
  136. void*
  137. NdrGetCurrentStackPointer(void)
  138. {
  139. return (void*)__getReg(CV_IA64_IntSp);
  140. }
  141. __forceinline
  142. void*
  143. NdrGetCurrentBackingStorePointer(void)
  144. {
  145. return (void*)__getReg(CV_IA64_RsBSP);
  146. }
  147. __forceinline
  148. void
  149. NdrSetupLowStackMark( PMIDL_STUB_MESSAGE pStubMsg )
  150. {
  151. // a backing store pointer which is used to store the stack based registers.
  152. // The normal stack grows downward and the backing store pointer grows upward.
  153. pStubMsg->LowStackMark = (uchar*)NdrGetCurrentStackPointer() - 0x4000; //16KB
  154. pStubMsg->BackingStoreLowMark =
  155. (uchar*)NdrGetCurrentBackingStorePointer() + 0x4000; //16KB // IA64 really has 2 stack pointers. The normal stack pointer and
  156. }
  157. __forceinline
  158. BOOL
  159. NdrIsLowStack(MIDL_STUB_MESSAGE *pStubMsg ) {
  160. return ((SIZE_T)NdrGetCurrentBackingStorePointer() > (SIZE_T)pStubMsg->BackingStoreLowMark) ||
  161. ((SIZE_T)NdrGetCurrentStackPointer() < (SIZE_T)pStubMsg->LowStackMark);
  162. //return false;
  163. }
  164. #else
  165. #error Unsupported Architecture
  166. #endif
  167. __forceinline
  168. void
  169. NdrRpcSetNDRSlot( void * pStubMsg )
  170. {
  171. RPC_STATUS rc = I_RpcSetNDRSlot( pStubMsg ) ;
  172. if ( rc!= RPC_S_OK )
  173. RpcRaiseException(rc );
  174. }
  175. BOOL
  176. IsWriteAV (
  177. IN struct _EXCEPTION_POINTERS *ExceptionPointers
  178. );
  179. int RPC_ENTRY
  180. NdrServerUnmarshallExceptionFlag(
  181. IN struct _EXCEPTION_POINTERS *ExceptionPointers
  182. );
  183. #endif // __NDRPALL_H__