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.

239 lines
6.5 KiB

  1. /*++
  2. Copyright (c) 1991-2000 Microsoft Corporation
  3. Module Name:
  4. midlesp.h
  5. Abstract:
  6. This module contains private definitions for the pickling support.
  7. Author:
  8. Ryszard K. Kott (ryszardk) May, 1994
  9. Revision History:
  10. --*/
  11. #ifndef __PICKLEP_HXX__
  12. #define __PICKLEP_HXX__
  13. #define MIDL_ES_VERSION 1 /* initial version */
  14. /* NT5 beta1, denial of attacks version
  15. is compatible on wire */
  16. #define MIDL_ES_SIGNATURE 0x5c5b5351 /* PCKL */
  17. #define MES_MINIMAL_BUFFER_SIZE 16
  18. #define MES_MINIMAL_NDR64_BUFFER_SIZE ( MES_NDR64_CTYPE_HEADER_SIZE + MES_HEADER_SIZE )
  19. #define MES_PROC_HEADER_SIZE 56
  20. #define MES_CTYPE_HEADER_SIZE 8
  21. #define MES_HEADER_SIZE 8
  22. #define MES_NDR64_HEADER_SIZE 16
  23. #define MES_HEADER_PAD(x) ((((unsigned long)x)&7) ? (8-(((unsigned long)x)&7)) : 0)
  24. #define MIDL_NDR64_ES_VERSION 2
  25. #define MIDL_NDR64_ES_SIGNATURE 0x5c5b5351
  26. #define MES_NDR64_CTYPE_HEADER_SIZE ( 24 + 2 * sizeof(RPC_SYNTAX_IDENTIFIER) )
  27. //
  28. // Constants for peeking the procedure header
  29. // and for manipulation of the common type header.
  30. //
  31. #define MES_HEADER_PEEKED 0x01
  32. #define MES_INFO_AVAILABLE 0x02
  33. #define MES_CTYPE_HEADER_IN 0x04
  34. #define MES_CTYPE_HEADER_SIZED 0x08
  35. #define GET_MES_HEADER_PEEKED(p) (p->HandleFlags & MES_HEADER_PEEKED)
  36. #define SET_MES_HEADER_PEEKED(p) p->HandleFlags = p->HandleFlags | MES_HEADER_PEEKED;
  37. #define CLEAR_MES_HEADER_PEEKED(p) p->HandleFlags = p->HandleFlags & ~MES_HEADER_PEEKED;
  38. #define GET_MES_INFO_AVAILABLE(p) (p->HandleFlags & MES_INFO_AVAILABLE)
  39. #define SET_MES_INFO_AVAILABLE(p) p->HandleFlags = p->HandleFlags | MES_INFO_AVAILABLE;
  40. #define GET_COMMON_TYPE_HEADER_IN(p) (p->HandleFlags & MES_CTYPE_HEADER_IN)
  41. #define SET_COMMON_TYPE_HEADER_IN(p) p->HandleFlags = p->HandleFlags | MES_CTYPE_HEADER_IN;
  42. #define GET_COMMON_TYPE_HEADER_SIZED(p) (p->HandleFlags & MES_CTYPE_HEADER_SIZED)
  43. #define SET_COMMON_TYPE_HEADER_SIZED(p) p->HandleFlags = p->HandleFlags | MES_CTYPE_HEADER_SIZED;
  44. #define NDR_LOCAL_ENDIAN_LOW (NDR_LOCAL_ENDIAN >> 4)
  45. #define MES_DECODE_NDR64 ( MES_ENCODE_NDR64 + 1 )
  46. //
  47. // Handly casts
  48. #define PCHAR_CAST (char *)
  49. #define PPCHAR_CAST (char * *)
  50. #define PSHORT_CAST (short *)
  51. #define PLONG_CAST (long *)
  52. #define PHYPER_CAST (hyper *)
  53. #define PCHAR_LV_CAST *(char * *)&
  54. #define PSHORT_LV_CAST *(short * *)&
  55. #define PLONG_LV_CAST *(long * *)&
  56. #define PHYPER_LV_CAST *(hyper * *)&
  57. // For denial of attacks rpcmsg must be simulated for the engine.
  58. typedef struct _MIDL_ES_MESSAGE
  59. {
  60. MIDL_STUB_MESSAGE StubMsg;
  61. MIDL_ES_CODE Operation;
  62. void * UserState;
  63. unsigned long MesVersion:8;
  64. unsigned long HandleStyle:8;
  65. unsigned long HandleFlags:8;
  66. unsigned long Reserve:8;
  67. MIDL_ES_ALLOC Alloc;
  68. MIDL_ES_WRITE Write;
  69. MIDL_ES_READ Read;
  70. unsigned char * Buffer;
  71. unsigned long BufferSize;
  72. unsigned char * * pDynBuffer;
  73. unsigned long * pEncodedSize;
  74. RPC_SYNTAX_IDENTIFIER InterfaceId;
  75. unsigned long ProcNumber;
  76. unsigned long AlienDataRep;
  77. unsigned long IncrDataSize;
  78. unsigned long ByteCount;
  79. } MIDL_ES_MESSAGE, * PMIDL_ES_MESSAGE;
  80. typedef struct _MIDL_ES_MESSAGE_EX
  81. {
  82. MIDL_ES_MESSAGE MesMsg;
  83. unsigned long Signature;
  84. RPC_MESSAGE RpcMsg;
  85. RPC_SYNTAX_IDENTIFIER TransferSyntax;
  86. } MIDL_ES_MESSAGE_EX, *PMIDL_ES_MESSAGE_EX;
  87. void
  88. NdrpProcHeaderUnmarshall(
  89. PMIDL_ES_MESSAGE pMesMsg
  90. );
  91. void
  92. NdrpDataBufferInit(
  93. PMIDL_ES_MESSAGE pMesMsg,
  94. PFORMAT_STRING pProcFormat
  95. );
  96. void
  97. NdrpAllocPicklingBuffer(
  98. PMIDL_ES_MESSAGE pMesMsg,
  99. unsigned int RequiredLen
  100. );
  101. void
  102. NdrpWritePicklingBuffer(
  103. PMIDL_ES_MESSAGE pMesMsg,
  104. uchar * pBuffer,
  105. size_t WriteLength
  106. );
  107. void
  108. NdrpReadPicklingBuffer(
  109. PMIDL_ES_MESSAGE pMesMsg,
  110. unsigned int RequiredLen
  111. );
  112. void
  113. NdrpProcHeaderMarshall(
  114. PMIDL_ES_MESSAGE pMesMsg
  115. );
  116. size_t
  117. NdrpCommonTypeHeaderMarshall(
  118. PMIDL_ES_MESSAGE pMesMsg
  119. );
  120. void
  121. NdrpCommonTypeHeaderSize(
  122. PMIDL_ES_MESSAGE pMesMsg
  123. );
  124. //
  125. // Var arg for pickling, based on ndrvargs.h.
  126. // This assumes that all the ... args to NdrMesProcEncodeDecode
  127. // are far pointers to the original stack args.
  128. //
  129. #define GET_FIRST_ARG(pArg, ArgL) pArg = (va_list *)ArgL
  130. #define GET_NEXT_ARG( pArg, ArgL) PCHAR_LV_CAST pArg += sizeof(void *);
  131. // Internal version of _MIDL_TYPE_PICKLING_INFO (defined in midles.h) with
  132. // flag definitions.
  133. //
  134. // !!IF YOU CHANGE EITHER ONE YOU MUST CHANGE THE OTHER!!
  135. typedef struct __MIDL_TYPE_PICKLING_INFOp
  136. {
  137. unsigned long Version;
  138. union
  139. {
  140. unsigned long ulFlags; // external version
  141. MIDL_TYPE_PICKLING_FLAGS Flags; // internal version
  142. };
  143. UINT_PTR Reserved[3];
  144. } MIDL_TYPE_PICKLING_INFOp, *PMIDL_TYPE_PICKLING_INFOp;
  145. void
  146. NdrpProcHeaderMarshallAll(
  147. PMIDL_ES_MESSAGE pMesMsg
  148. );
  149. void
  150. NdrpProcHeaderUnmarshallAll(
  151. PMIDL_ES_MESSAGE pMesMsg
  152. );
  153. typedef size_t ( RPC_ENTRY * PFNMESTYPEALIGNSIZE )(
  154. handle_t Handle,
  155. const MIDL_TYPE_PICKLING_INFO * pPicklingInfo,
  156. const MIDL_STUB_DESC * pStubDesc,
  157. PFORMAT_STRING pFormat,
  158. const void * pObject
  159. );
  160. typedef void ( RPC_ENTRY * PFNMESTYPEENCODE ) (
  161. handle_t Handle,
  162. const MIDL_TYPE_PICKLING_INFO * pxPicklingInfo,
  163. const MIDL_STUB_DESC * pStubDesc,
  164. PFORMAT_STRING pFormat,
  165. const void * pObject
  166. );
  167. typedef void ( RPC_ENTRY * PFNMESDECODE ) (
  168. handle_t Handle,
  169. const MIDL_TYPE_PICKLING_INFO * pxPicklingInfo,
  170. const MIDL_STUB_DESC * pStubDesc,
  171. PFORMAT_STRING pFormat,
  172. void * pObject
  173. );
  174. // REVIEW: Should pObject be const here?
  175. typedef void ( RPC_ENTRY * PFNMESFREE ) (
  176. handle_t Handle,
  177. const MIDL_TYPE_PICKLING_INFO * pxPicklingInfo,
  178. const MIDL_STUB_DESC * pStubDesc,
  179. PFORMAT_STRING pFormat,
  180. void * pObject
  181. );
  182. #endif __PICKLEP_HXX__