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.

2034 lines
60 KiB

  1. /************************************************************************
  2. Copyright (c) 1993 - 1999 Microsoft Corporation
  3. Module Name :
  4. mrshl.c
  5. Abstract :
  6. This file contains the marshalling routines called by MIDL generated
  7. stubs and the interpreter.
  8. Author :
  9. David Kays dkays September 1993.
  10. Revision History :
  11. ***********************************************************************/
  12. #include "precomp.hxx"
  13. #include "..\..\ndr20\ndrole.h"
  14. // make this extern as this will be call from ClientMarshal & ServerMarshal also.
  15. extern const PSIMPLETYPE_MARSHAL_ROUTINE Ndr64SimpleTypeMarshallRoutinesTable[] =
  16. {
  17. NdrpSimpleTypeInvalidMarshall,
  18. NdrpSimpleTypeCharMarshall,
  19. NdrpSimpleTypeCharMarshall,
  20. NdrpSimpleTypeShortMarshall,
  21. NdrpSimpleTypeShortMarshall,
  22. NdrpSimpleTypeLongMarshall,
  23. NdrpSimpleTypeLongMarshall,
  24. NdrpSimpleTypeHyperMarshall,
  25. NdrpSimpleTypeHyperMarshall, // FC64_UINT64
  26. NdrpSimpleTypeInvalidMarshall,
  27. NdrpSimpleTypeInvalidMarshall, // FC64_INT128
  28. NdrpSimpleTypeLongMarshall, // FC64_FLOAT32
  29. NdrpSimpleTypeHyperMarshall,
  30. NdrpSimpleTypeInvalidMarshall,
  31. NdrpSimpleTypeInvalidMarshall,
  32. NdrpSimpleTypeInvalidMarshall, // 0xF
  33. NdrpSimpleTypeCharMarshall, // FC64_CHAR
  34. NdrpSimpleTypeShortMarshall, // FC64_WCHAR
  35. NdrpSimpleTypeIgnoreMarshall,
  36. NdrpSimpleTypeLongMarshall,
  37. NdrpSimpleTypeInvalidMarshall,
  38. NdrpSimpleTypeInvalidMarshall,
  39. NdrpSimpleTypeInvalidMarshall,
  40. NdrpSimpleTypeInvalidMarshall,
  41. NdrpSimpleTypeInvalidMarshall,
  42. NdrpSimpleTypeInvalidMarshall,
  43. NdrpSimpleTypeInvalidMarshall,
  44. NdrpSimpleTypeInvalidMarshall,
  45. NdrpSimpleTypeInvalidMarshall,
  46. NdrpSimpleTypeInvalidMarshall,
  47. NdrpSimpleTypeInvalidMarshall,
  48. NdrpSimpleTypeInvalidMarshall // make it 32 entries.
  49. };
  50. void
  51. Ndr64SimpleTypeMarshall(
  52. PMIDL_STUB_MESSAGE pStubMsg,
  53. uchar * pMemory,
  54. uchar FormatChar )
  55. /*++
  56. Routine Description :
  57. Marshalls a simple type.
  58. Arguments :
  59. pStubMsg - Pointer to the stub message.
  60. pMemory - Pointer to the data to be marshalled.
  61. FormatChar - Simple type format character.
  62. Return :
  63. None.
  64. --*/
  65. {
  66. /*
  67. switch ( FormatChar )
  68. {
  69. case FC64_CHAR :
  70. case FC64_UINT8:
  71. case FC64_INT8:
  72. *(pStubMsg->Buffer)++ = *pMemory;
  73. break;
  74. case FC64_WCHAR :
  75. case FC64_UINT16:
  76. case FC64_INT16:
  77. ALIGN(pStubMsg->Buffer,1);
  78. *((NDR64_UINT16 *)pStubMsg->Buffer) = *((NDR64_UINT16 *)pMemory);
  79. pStubMsg->Buffer += sizeof(NDR64_UINT16);
  80. break;
  81. case FC64_UINT32:
  82. case FC64_INT32:
  83. case FC64_ERROR_STATUS_T:
  84. case FC64_FLOAT32:
  85. ALIGN(pStubMsg->Buffer,3);
  86. *((NDR64_UINT32 *)pStubMsg->Buffer) = *((NDR64_UINT32 *)pMemory);
  87. pStubMsg->Buffer += sizeof(NDR64_UINT32);
  88. break;
  89. case FC64_UINT64:
  90. case FC64_INT64:
  91. case FC64_FLOAT64:
  92. ALIGN(pStubMsg->Buffer,7);
  93. *((NDR64_UINT64 *)pStubMsg->Buffer) = *((NDR64_UINT64 *)pMemory);
  94. pStubMsg->Buffer += sizeof(NDR64_UINT64);
  95. break;
  96. case FC64_IGNORE:
  97. break;
  98. default :
  99. NDR_ASSERT(0,"Ndr64SimpleTypeMarshall : bad format char");
  100. RpcRaiseException( RPC_S_INTERNAL_ERROR );
  101. return;
  102. }
  103. */
  104. NDR_ASSERT( FormatChar <= FC64_ERROR_STATUS_T, "bad format char");
  105. Ndr64SimpleTypeMarshallRoutinesTable[FormatChar](pStubMsg, pMemory );
  106. }
  107. void
  108. Ndr64UDTSimpleTypeMarshall1(
  109. PMIDL_STUB_MESSAGE pStubMsg,
  110. uchar * pMemory,
  111. PNDR64_FORMAT FormatString )
  112. {
  113. Ndr64SimpleTypeMarshall(pStubMsg,pMemory,*(PFORMAT_STRING)FormatString);
  114. }
  115. void
  116. Ndr64pRangeMarshall(
  117. PMIDL_STUB_MESSAGE pStubMsg,
  118. uchar * pMemory,
  119. PNDR64_FORMAT pFormat )
  120. /*++
  121. --*/
  122. {
  123. const NDR64_RANGE_FORMAT * pRangeFormat =
  124. (const NDR64_RANGE_FORMAT*)pFormat;
  125. Ndr64SimpleTypeMarshall( pStubMsg, pMemory, pRangeFormat->RangeType );
  126. }
  127. void
  128. Ndr64pInterfacePointerMarshall (
  129. PMIDL_STUB_MESSAGE pStubMsg,
  130. uchar * pMemory,
  131. PNDR64_FORMAT pFormat )
  132. /*++
  133. Routine Description :
  134. Marshalls an interface pointer.
  135. Arguments :
  136. pStubMsg - Pointer to the stub message.
  137. pMemory - Pointer to the interface pointer being marshalled.
  138. pFormat - Interface pointer's format string description.
  139. Return :
  140. None.
  141. Notes : There is now one representation of a marshalled interface pointer.
  142. // wire representation of a marshalled interface pointer
  143. typedef struct tagMInterfacePointer
  144. {
  145. ULONG ulCntData; // size of data
  146. [size_is(ulCntData)] BYTE abData[]; // data (OBJREF)
  147. } MInterfacePointer;
  148. --*/
  149. {
  150. const NDR64_CONSTANT_IID_FORMAT *pConstInterfaceFormat =
  151. (NDR64_CONSTANT_IID_FORMAT*)pFormat;
  152. const NDR64_IID_FORMAT *pInterfaceFormat =
  153. (NDR64_IID_FORMAT*)pFormat;
  154. //
  155. // Get an IID pointer.
  156. //
  157. IID *piid;
  158. if ( ((NDR64_IID_FLAGS*)&pInterfaceFormat->Flags)->ConstantIID )
  159. {
  160. piid = (IID*)&pConstInterfaceFormat->Guid;
  161. }
  162. else
  163. {
  164. piid = (IID *) Ndr64EvaluateExpr( pStubMsg,
  165. pInterfaceFormat->IIDDescriptor,
  166. EXPR_IID );
  167. if(piid == 0)
  168. {
  169. RpcRaiseException( RPC_S_INVALID_ARG );
  170. return;
  171. }
  172. }
  173. // Leave space in the buffer for the conformant size.
  174. ZeroOutGapAndAlign( pStubMsg, NDR64_WIRE_COUNT_ALIGN );
  175. NDR64_WIRE_COUNT_TYPE * pMaxCount = (NDR64_WIRE_COUNT_TYPE *) pStubMsg->Buffer;
  176. pStubMsg->Buffer += sizeof(NDR64_WIRE_COUNT_TYPE);
  177. ulong *pulCntData = (ulong *) pStubMsg->Buffer;
  178. pStubMsg->Buffer += sizeof(ulong);
  179. //Calculate the maximum size of the stream.
  180. ulong position = (ulong)( pStubMsg->Buffer - (uchar *)pStubMsg->RpcMsg->Buffer);
  181. ulong cbMax = pStubMsg->RpcMsg->BufferLength - position;
  182. //Create a stream on memory.
  183. IStream *pStream = NdrpCreateStreamOnMemory(pStubMsg->Buffer, cbMax);
  184. if(pStream == 0)
  185. {
  186. RpcRaiseException(RPC_S_OUT_OF_MEMORY);
  187. return;
  188. }
  189. RpcTryFinally
  190. {
  191. HRESULT hr = (*pfnCoMarshalInterface)(pStream, *piid, (IUnknown *)pMemory,
  192. pStubMsg->dwDestContext, pStubMsg->pvDestContext, 0);
  193. if(FAILED(hr))
  194. {
  195. RpcRaiseException(hr);
  196. return;
  197. }
  198. ULARGE_INTEGER libPosition;
  199. LARGE_INTEGER libMove;
  200. libMove.QuadPart = 0;
  201. pStream->Seek(libMove, STREAM_SEEK_CUR, &libPosition);
  202. //Update the array bounds.
  203. *pMaxCount = libPosition.QuadPart;
  204. //Advance the stub message buffer pointer.
  205. pStubMsg->Buffer += (*pulCntData = Ndr64pConvertTo2GB(libPosition.QuadPart));
  206. }
  207. RpcFinally
  208. {
  209. pStream->Release();
  210. }
  211. RpcEndFinally
  212. }
  213. __forceinline void
  214. Ndr64pPointerMarshallInternal(
  215. PMIDL_STUB_MESSAGE pStubMsg,
  216. NDR64_PTR_WIRE_TYPE *pBufferMark,
  217. uchar * pMemory,
  218. PNDR64_FORMAT pFormat )
  219. /*++
  220. Routine Description :
  221. Private routine for marshalling a pointer and its pointee. This is the
  222. entry point for pointers embedded in structures, arrays, and unions.
  223. Used for FC64_RP, FC64_UP, FC64_FP, FC64_OP.
  224. Arguments :
  225. pStubMsg - Pointer to the stub message.
  226. pBufferMark - Pointer to the pointer in the wire buffer.
  227. pMemory - Pointer to the data to be marshalled.
  228. pFormat - Pointer format string description.
  229. pStubMsg->Buffer - the place for the pointee.
  230. Return :
  231. None.
  232. --*/
  233. {
  234. const NDR64_POINTER_FORMAT *pPointerFormat = (NDR64_POINTER_FORMAT*) pFormat;
  235. //
  236. // Check the pointer type.
  237. //
  238. switch ( pPointerFormat->FormatCode )
  239. {
  240. case FC64_RP :
  241. if ( pBufferMark )
  242. {
  243. // Put the pointer in the buffer.
  244. *((NDR64_PTR_WIRE_TYPE*)pBufferMark) = PTR_WIRE_REP(pMemory);
  245. }
  246. if ( !pMemory )
  247. {
  248. RpcRaiseException( RPC_X_NULL_REF_POINTER );
  249. }
  250. break;
  251. case FC64_UP :
  252. case FC64_OP :
  253. // Put the pointer in the buffer.
  254. *((NDR64_PTR_WIRE_TYPE*)pBufferMark) = PTR_WIRE_REP(pMemory);
  255. if ( ! pMemory )
  256. {
  257. return;
  258. }
  259. break;
  260. case FC64_IP :
  261. // Put the pointer in the buffer
  262. *((NDR64_PTR_WIRE_TYPE*)pBufferMark) = PTR_WIRE_REP(pMemory);
  263. if ( ! pMemory )
  264. {
  265. return;
  266. }
  267. Ndr64pInterfacePointerMarshall (pStubMsg,
  268. pMemory,
  269. pPointerFormat->Pointee
  270. );
  271. return;
  272. case FC64_FP :
  273. //
  274. // Marshall the pointer's ref id and see if we've already
  275. // marshalled the pointer's data.
  276. //
  277. {
  278. ulong RefId;
  279. BOOL Result =
  280. Ndr64pFullPointerQueryPointer( pStubMsg,
  281. pMemory,
  282. FULL_POINTER_MARSHALLED,
  283. &RefId );
  284. *(NDR64_PTR_WIRE_TYPE*)pBufferMark = Ndr64pRefIdToWirePtr( RefId );
  285. if ( Result )
  286. return;
  287. }
  288. break;
  289. default :
  290. NDR_ASSERT(0,"Ndr64pPointerMarshall : bad pointer type");
  291. RpcRaiseException( RPC_S_INTERNAL_ERROR );
  292. return;
  293. }
  294. if ( NDR64_SIMPLE_POINTER( pPointerFormat->Flags ) )
  295. {
  296. Ndr64SimpleTypeMarshall( pStubMsg,
  297. pMemory,
  298. *(PFORMAT_STRING)pPointerFormat->Pointee );
  299. return;
  300. }
  301. if ( NDR64_POINTER_DEREF( pPointerFormat->Flags ) )
  302. pMemory = *((uchar **)pMemory);
  303. SAVE_CONTEXT<uchar> uFlagsSave( pStubMsg->uFlags );
  304. NDR64_RESET_EMBEDDED_FLAGS_TO_STANDALONE(pStubMsg->uFlags);
  305. Ndr64TopLevelTypeMarshall(
  306. pStubMsg,
  307. pMemory,
  308. pPointerFormat->Pointee );
  309. }
  310. NDR64_MRSHL_POINTER_QUEUE_ELEMENT::NDR64_MRSHL_POINTER_QUEUE_ELEMENT(
  311. MIDL_STUB_MESSAGE *pStubMsg,
  312. NDR64_PTR_WIRE_TYPE * pBufferMarkNew,
  313. uchar * const pMemoryNew,
  314. const PFORMAT_STRING pFormatNew) :
  315. pBufferMark(pBufferMarkNew),
  316. pMemory(pMemoryNew),
  317. pFormat(pFormatNew),
  318. uFlags(pStubMsg->uFlags),
  319. pCorrMemory(pStubMsg->pCorrMemory)
  320. {
  321. }
  322. void
  323. NDR64_MRSHL_POINTER_QUEUE_ELEMENT::Dispatch(
  324. MIDL_STUB_MESSAGE *pStubMsg)
  325. {
  326. SAVE_CONTEXT<uchar> uFlagsSave(pStubMsg->uFlags, uFlags );
  327. CORRELATION_CONTEXT CorrCtxt( pStubMsg, pCorrMemory );
  328. Ndr64pPointerMarshallInternal( pStubMsg,
  329. pBufferMark,
  330. pMemory,
  331. (PNDR64_FORMAT)pFormat );
  332. }
  333. #if defined(DBG)
  334. void
  335. NDR64_MRSHL_POINTER_QUEUE_ELEMENT::Print()
  336. {
  337. DbgPrint("NDR_MRSHL_POINTER_QUEUE_ELEMENT\n");
  338. DbgPrint("pNext: %p\n", pNext );
  339. DbgPrint("pBufferMark: %p\n", pBufferMark );
  340. DbgPrint("pMemory: %p\n", pMemory );
  341. DbgPrint("pFormat: %p\n", pFormat );
  342. DbgPrint("pCorrMemory: %p\n", pCorrMemory );
  343. DbgPrint("uFlags: %x\n", uFlags );
  344. }
  345. #endif
  346. void
  347. Ndr64pEnquePointerMarshall(
  348. PMIDL_STUB_MESSAGE pStubMsg,
  349. NDR64_PTR_WIRE_TYPE *pBufferMark,
  350. uchar * pMemory,
  351. PNDR64_FORMAT pFormat )
  352. {
  353. NDR64_POINTER_CONTEXT PointerContext( pStubMsg );
  354. RpcTryFinally
  355. {
  356. NDR64_MRSHL_POINTER_QUEUE_ELEMENT*pElement =
  357. new(PointerContext.GetActiveState())
  358. NDR64_MRSHL_POINTER_QUEUE_ELEMENT(pStubMsg,
  359. pBufferMark,
  360. pMemory,
  361. (PFORMAT_STRING)pFormat);
  362. PointerContext.Enque( pElement );
  363. PointerContext.DispatchIfRequired();
  364. }
  365. RpcFinally
  366. {
  367. PointerContext.EndContext();
  368. }
  369. RpcEndFinally
  370. }
  371. void
  372. Ndr64pPointerMarshall(
  373. PMIDL_STUB_MESSAGE pStubMsg,
  374. NDR64_PTR_WIRE_TYPE *pBufferMark,
  375. uchar * pMemory,
  376. PNDR64_FORMAT pFormat )
  377. {
  378. SAVE_CONTEXT<uchar> uFlagsSave(pStubMsg->uFlags);
  379. if ( !NdrIsLowStack(pStubMsg) )
  380. {
  381. Ndr64pPointerMarshallInternal( pStubMsg,
  382. pBufferMark,
  383. pMemory,
  384. pFormat );
  385. return;
  386. }
  387. Ndr64pEnquePointerMarshall(
  388. pStubMsg,
  389. pBufferMark,
  390. pMemory,
  391. pFormat );
  392. }
  393. __forceinline void
  394. Ndr64TopLevelPointerMarshall(
  395. PMIDL_STUB_MESSAGE pStubMsg,
  396. uchar * pMemory,
  397. PNDR64_FORMAT pFormat )
  398. {
  399. NDR64_PTR_WIRE_TYPE *pBufferMark = NULL;
  400. // Non embedded ref pointers do not have a wire representation
  401. if ( *(PFORMAT_STRING)pFormat != FC64_RP )
  402. {
  403. ZeroOutGapAndAlign( pStubMsg, NDR64_PTR_WIRE_ALIGN );
  404. pBufferMark = (NDR64_PTR_WIRE_TYPE*)pStubMsg->Buffer;
  405. pStubMsg->Buffer += sizeof(NDR64_PTR_WIRE_TYPE);
  406. }
  407. Ndr64pPointerMarshall( pStubMsg,
  408. pBufferMark,
  409. pMemory,
  410. pFormat );
  411. }
  412. __forceinline void
  413. Ndr64EmbeddedPointerMarshall(
  414. PMIDL_STUB_MESSAGE pStubMsg,
  415. uchar * pMemory,
  416. PNDR64_FORMAT pFormat )
  417. {
  418. ZeroOutGapAndAlign( pStubMsg, NDR64_PTR_WIRE_ALIGN );
  419. NDR64_PTR_WIRE_TYPE* pBufferMark = (NDR64_PTR_WIRE_TYPE*)pStubMsg->Buffer;
  420. pStubMsg->Buffer += sizeof(NDR64_PTR_WIRE_TYPE);
  421. POINTER_BUFFER_SWAP_CONTEXT SwapContext(pStubMsg);
  422. Ndr64pPointerMarshall( pStubMsg,
  423. pBufferMark,
  424. *(uchar**)pMemory,
  425. pFormat );
  426. }
  427. void
  428. Ndr64SimpleStructMarshall(
  429. PMIDL_STUB_MESSAGE pStubMsg,
  430. uchar * pMemory,
  431. PNDR64_FORMAT pFormat )
  432. /*++
  433. Routine description :
  434. Marshalls a simple structure.
  435. Used for FC64_STRUCT and FC64_PSTRUCT.
  436. Arguments :
  437. pStubMsg - Pointer to the stub message.
  438. pMemory - Pointer to the structure to be marshalled.
  439. pFormat - Structure's format string description.
  440. Return :
  441. None.
  442. --*/
  443. {
  444. const NDR64_STRUCTURE_HEADER_FORMAT * const pStructFormat =
  445. (NDR64_STRUCTURE_HEADER_FORMAT*) pFormat;
  446. const NDR64_UINT32 StructSize = pStructFormat->MemorySize;
  447. ZeroOutGapAndAlign(pStubMsg, pStructFormat->Alignment);
  448. uchar *pBufferSave = pStubMsg->Buffer;
  449. RpcpMarshalMemoryCopy( pBufferSave,
  450. pMemory,
  451. pStructFormat->MemorySize );
  452. pStubMsg->Buffer += pStructFormat->MemorySize;
  453. // Marshall embedded pointers.
  454. if ( pStructFormat->Flags.HasPointerInfo )
  455. {
  456. CORRELATION_CONTEXT CorrCtxt( pStubMsg, pMemory);
  457. Ndr64pPointerLayoutMarshall( pStubMsg,
  458. pStructFormat + 1,
  459. 0,
  460. pMemory,
  461. pBufferSave );
  462. }
  463. }
  464. void
  465. Ndr64ConformantStructMarshall(
  466. PMIDL_STUB_MESSAGE pStubMsg,
  467. uchar * pMemory,
  468. PNDR64_FORMAT pFormat )
  469. /*++
  470. Routine description :
  471. Marshalls a conformant structure.
  472. Arguments :
  473. pStubMsg - Pointer to the stub message.
  474. pMemory - Pointer to the structure to be marshalled.
  475. pFormat - Structure's format string description.
  476. Return :
  477. None.
  478. Note
  479. --*/
  480. {
  481. const NDR64_CONF_STRUCTURE_HEADER_FORMAT * const pStructFormat =
  482. (NDR64_CONF_STRUCTURE_HEADER_FORMAT*) pFormat;
  483. const NDR64_CONF_ARRAY_HEADER_FORMAT * const pArrayFormat =
  484. (NDR64_CONF_ARRAY_HEADER_FORMAT *) pStructFormat->ArrayDescription;
  485. CORRELATION_CONTEXT CorrCtxt( pStubMsg, pMemory );
  486. NDR64_WIRE_COUNT_TYPE MaxCount =
  487. Ndr64EvaluateExpr( pStubMsg,
  488. pArrayFormat->ConfDescriptor,
  489. EXPR_MAXCOUNT );
  490. if ( NDR64_IS_CONF_MARK_VALID( pStubMsg->uFlags ) )
  491. *(NDR64_WIRE_COUNT_TYPE *)pStubMsg->ConformanceMark = MaxCount;
  492. else
  493. {
  494. ZeroOutGapAndAlign( pStubMsg, NDR64_WIRE_COUNT_ALIGN );
  495. *((NDR64_WIRE_COUNT_TYPE *)pStubMsg->Buffer) = MaxCount;
  496. pStubMsg->Buffer += sizeof(NDR64_WIRE_COUNT_TYPE);
  497. }
  498. ZeroOutGapAndAlign(pStubMsg, pStructFormat->Alignment);
  499. uchar *pBufferStart = pStubMsg->Buffer;
  500. NDR64_UINT32 StructSize = Ndr64pConvertTo2GB( (NDR64_UINT64)pStructFormat->MemorySize +
  501. ( MaxCount * (NDR64_UINT64)pArrayFormat->ElementSize ) );
  502. RpcpMarshalMemoryCopy( pBufferStart,
  503. pMemory,
  504. StructSize );
  505. pStubMsg->Buffer += StructSize;
  506. if ( pStructFormat->Flags.HasPointerInfo )
  507. {
  508. Ndr64pPointerLayoutMarshall( pStubMsg,
  509. pStructFormat + 1,
  510. (NDR64_UINT32)MaxCount,
  511. pMemory,
  512. pBufferStart );
  513. }
  514. }
  515. void
  516. Ndr64ComplexStructMarshall(
  517. PMIDL_STUB_MESSAGE pStubMsg,
  518. uchar * pMemory,
  519. PNDR64_FORMAT pFormat )
  520. /*++
  521. Routine description :
  522. Marshalls a complex structure.
  523. Used for FC64_BOGUS_STRUCT.
  524. Arguments :
  525. pStubMsg - Pointer to the stub message.
  526. pMemory - Pointer to the structure being marshalled.
  527. pFormat - Structure's format string description.
  528. Return :
  529. None.
  530. Notes :
  531. --*/
  532. {
  533. const NDR64_BOGUS_STRUCTURE_HEADER_FORMAT * pStructFormat =
  534. (NDR64_BOGUS_STRUCTURE_HEADER_FORMAT*) pFormat;
  535. const NDR64_CONF_BOGUS_STRUCTURE_HEADER_FORMAT * pConfStructFormat =
  536. (NDR64_CONF_BOGUS_STRUCTURE_HEADER_FORMAT*) pFormat;
  537. uchar * pBufferSave = pStubMsg->Buffer;
  538. bool fSetPointerBufferMark = ! pStubMsg->PointerBufferMark;
  539. // Compute where the pointees should be unmarshalled to.
  540. if ( fSetPointerBufferMark )
  541. {
  542. BOOL fOldIgnore = pStubMsg->IgnoreEmbeddedPointers;
  543. pStubMsg->IgnoreEmbeddedPointers = TRUE;
  544. //
  545. // Set BufferLength equal to the current buffer pointer, and then
  546. // when we return from NdrComplexStructBufferSize it will pointer to
  547. // the location in the buffer where the pointees should be marshalled.
  548. // pStubMsg->BufferLength = pBufferSave;
  549. // Instead of pointer, we now calculate pointer increment explicitly.
  550. // Set the pointer alignment as a base.
  551. // We use pBufferSave as the sizing routine accounts for the conf sizes.
  552. //
  553. ulong BufferLenOffset = 0xf & PtrToUlong( pBufferSave );
  554. ulong BufferLengthSave = pStubMsg->BufferLength;
  555. pStubMsg->BufferLength = BufferLenOffset;
  556. Ndr64ComplexStructBufferSize(
  557. pStubMsg,
  558. pMemory,
  559. pFormat );
  560. // Pointer increment including alignments.
  561. BufferLenOffset = pStubMsg->BufferLength - BufferLenOffset;
  562. // Set the location in the buffer where pointees will be marshalled.
  563. pStubMsg->PointerBufferMark = pStubMsg->Buffer + BufferLenOffset;
  564. pStubMsg->BufferLength = BufferLengthSave;
  565. pStubMsg->IgnoreEmbeddedPointers = fOldIgnore;
  566. }
  567. PFORMAT_STRING pFormatPointers = (PFORMAT_STRING)pStructFormat->PointerLayout;
  568. PFORMAT_STRING pFormatArray = NULL;
  569. BOOL fIsFullBogus = ( *(PFORMAT_STRING)pFormat == FC64_BOGUS_STRUCT ||
  570. *(PFORMAT_STRING)pFormat == FC64_CONF_BOGUS_STRUCT );
  571. PFORMAT_STRING pMemberLayout = ( *(PFORMAT_STRING)pFormat == FC64_CONF_BOGUS_STRUCT ||
  572. *(PFORMAT_STRING)pFormat == FC64_FORCED_CONF_BOGUS_STRUCT ) ?
  573. (PFORMAT_STRING)( pConfStructFormat + 1) :
  574. (PFORMAT_STRING)( pStructFormat + 1);
  575. SAVE_CONTEXT<uchar*> ConformanceMarkSave(pStubMsg->ConformanceMark);
  576. SAVE_CONTEXT<uchar> uFlagsSave( pStubMsg->uFlags );
  577. CORRELATION_CONTEXT CorrCtxt( pStubMsg, pMemory );
  578. // Get conformant array description.
  579. if ( pStructFormat->Flags.HasConfArray )
  580. {
  581. pFormatArray = (PFORMAT_STRING)pConfStructFormat->ConfArrayDescription;
  582. if ( !NDR64_IS_CONF_MARK_VALID( pStubMsg->uFlags ) )
  583. {
  584. // Align for conformance marshalling.
  585. ZeroOutGapAndAlign(pStubMsg, NDR64_WIRE_COUNT_ALIGN);
  586. // Remember where the conformance count(s) will be marshalled.
  587. pStubMsg->ConformanceMark = pStubMsg->Buffer;
  588. // Increment the buffer pointer for every array dimension.
  589. pStubMsg->Buffer += pConfStructFormat->Dimensions * sizeof(NDR64_WIRE_COUNT_TYPE);
  590. NDR64_SET_CONF_MARK_VALID( pStubMsg->uFlags );
  591. }
  592. }
  593. else
  594. pFormatArray = 0;
  595. // Align buffer on struct's alignment.
  596. ZeroOutGapAndAlign(pStubMsg, pStructFormat->Alignment);
  597. //
  598. // Marshall the structure member by member.
  599. //
  600. for ( ; ; )
  601. {
  602. switch ( *pMemberLayout )
  603. {
  604. case FC64_STRUCT:
  605. {
  606. const NDR64_SIMPLE_REGION_FORMAT *pRegion =
  607. (NDR64_SIMPLE_REGION_FORMAT*) pMemberLayout;
  608. ZeroOutGapAndAlign( pStubMsg, pRegion->Alignment );
  609. RpcpMarshalMemoryCopy( pStubMsg->Buffer,
  610. pMemory,
  611. pRegion->RegionSize );
  612. pStubMsg->Buffer += pRegion->RegionSize;
  613. pMemory += pRegion->RegionSize;
  614. pMemberLayout += sizeof( *pRegion );
  615. break;
  616. }
  617. case FC64_STRUCTPADN :
  618. {
  619. const NDR64_MEMPAD_FORMAT *pMemPad = (NDR64_MEMPAD_FORMAT*)pMemberLayout;
  620. pMemory += pMemPad->MemPad;
  621. pMemberLayout += sizeof(*pMemPad);
  622. break;
  623. }
  624. case FC64_POINTER :
  625. {
  626. NDR_ASSERT(pFormatPointers, "Ndr64ComplexStructMarshall: pointer field but no pointer layout");
  627. Ndr64EmbeddedPointerMarshall(
  628. pStubMsg,
  629. pMemory,
  630. pFormatPointers );
  631. pMemory += PTR_MEM_SIZE;
  632. pFormatPointers += sizeof(NDR64_POINTER_FORMAT);
  633. pMemberLayout += sizeof(NDR64_SIMPLE_MEMBER_FORMAT);
  634. break;
  635. }
  636. case FC64_EMBEDDED_COMPLEX :
  637. {
  638. const NDR64_EMBEDDED_COMPLEX_FORMAT * pEmbeddedFormat =
  639. (NDR64_EMBEDDED_COMPLEX_FORMAT*) pMemberLayout;
  640. Ndr64EmbeddedTypeMarshall( pStubMsg,
  641. pMemory,
  642. pEmbeddedFormat->Type );
  643. pMemory = Ndr64pMemoryIncrement( pStubMsg,
  644. pMemory,
  645. pEmbeddedFormat->Type,
  646. FALSE );
  647. pMemberLayout += sizeof(*pEmbeddedFormat);
  648. break;
  649. }
  650. case FC64_BUFFER_ALIGN:
  651. {
  652. const NDR64_BUFFER_ALIGN_FORMAT *pBufAlign =
  653. (NDR64_BUFFER_ALIGN_FORMAT*) pMemberLayout;
  654. ZeroOutGapAndAlign(pStubMsg, pBufAlign->Alignment);
  655. pMemberLayout += sizeof( *pBufAlign );
  656. break;
  657. }
  658. case FC64_CHAR :
  659. case FC64_WCHAR :
  660. case FC64_INT8:
  661. case FC64_UINT8:
  662. case FC64_INT16:
  663. case FC64_UINT16:
  664. case FC64_INT32:
  665. case FC64_UINT32:
  666. case FC64_INT64:
  667. case FC64_UINT64:
  668. case FC64_FLOAT32 :
  669. case FC64_FLOAT64 :
  670. case FC64_ERROR_STATUS_T:
  671. Ndr64SimpleTypeMarshall( pStubMsg,
  672. pMemory,
  673. *pMemberLayout );
  674. pMemory += NDR64_SIMPLE_TYPE_MEMSIZE(*pMemberLayout);
  675. pMemberLayout += sizeof(NDR64_SIMPLE_MEMBER_FORMAT);
  676. break;
  677. case FC64_IGNORE :
  678. ZeroOutGapAndAlign(pStubMsg, NDR64_PTR_WIRE_ALIGN );
  679. pMemory += PTR_MEM_SIZE;
  680. *(NDR64_PTR_WIRE_TYPE*)pStubMsg->Buffer = 0;
  681. pStubMsg->Buffer += sizeof(NDR64_PTR_WIRE_TYPE);
  682. pMemberLayout += sizeof(NDR64_SIMPLE_MEMBER_FORMAT);
  683. break;
  684. case FC64_END :
  685. goto ComplexMarshallEnd;
  686. default :
  687. NDR_ASSERT(0,"Ndr64ComplexStructMarshall : bad format char");
  688. RpcRaiseException( RPC_S_INTERNAL_ERROR );
  689. return;
  690. } // switch
  691. } // for
  692. ComplexMarshallEnd:
  693. //
  694. // Marshall conformant array if we have one.
  695. if ( pFormatArray )
  696. {
  697. Ndr64EmbeddedTypeMarshall( pStubMsg,
  698. pMemory,
  699. pFormatArray );
  700. }
  701. else
  702. {
  703. // If the structure doesn't have a conformant array, align it again
  704. ZeroOutGapAndAlign( pStubMsg, pStructFormat->Alignment );
  705. }
  706. if ( fSetPointerBufferMark )
  707. {
  708. pStubMsg->Buffer = pStubMsg->PointerBufferMark;
  709. pStubMsg->PointerBufferMark = 0;
  710. }
  711. }
  712. void
  713. Ndr64NonConformantStringMarshall(
  714. PMIDL_STUB_MESSAGE pStubMsg,
  715. uchar * pMemory,
  716. PNDR64_FORMAT pFormat )
  717. /*++
  718. Routine description :
  719. Marshalls a non conformant string.
  720. Arguments :
  721. pStubMsg - Pointer to the stub message.
  722. pMemory - Pointer to the string to be marshalled.
  723. pFormat - String's format string description.
  724. Return :
  725. None.
  726. --*/
  727. {
  728. const NDR64_NON_CONFORMANT_STRING_FORMAT * pStringFormat =
  729. (NDR64_NON_CONFORMANT_STRING_FORMAT*) pFormat;
  730. NDR64_UINT32 CopySize =
  731. Ndr64pCommonStringSize( pStubMsg,
  732. pMemory,
  733. &pStringFormat->Header );
  734. if ( CopySize > pStringFormat->TotalSize )
  735. RpcRaiseException(RPC_X_INVALID_BOUND);
  736. ZeroOutGapAndAlign( pStubMsg, NDR64_WIRE_COUNT_ALIGN );
  737. ((NDR64_WIRE_COUNT_TYPE*)pStubMsg->Buffer)[0] = pStubMsg->Offset;
  738. ((NDR64_WIRE_COUNT_TYPE*)pStubMsg->Buffer)[1] = pStubMsg->ActualCount;
  739. pStubMsg->Buffer += sizeof(NDR64_WIRE_COUNT_TYPE) * 2;
  740. // Copy the string.
  741. RpcpMarshalMemoryCopy( pStubMsg->Buffer,
  742. pMemory,
  743. CopySize );
  744. pStubMsg->Buffer += CopySize;
  745. }
  746. void
  747. Ndr64ConformantStringMarshall(
  748. PMIDL_STUB_MESSAGE pStubMsg,
  749. uchar * pMemory,
  750. PNDR64_FORMAT pFormat )
  751. /*++
  752. Routine description :
  753. Marshalls a conformant string.
  754. Arguments :
  755. pStubMsg - Pointer to the stub message.
  756. pMemory - Pointer to the string to be marshalled.
  757. pFormat - String's format string description.
  758. Return :
  759. None.
  760. --*/
  761. {
  762. const NDR64_CONFORMANT_STRING_FORMAT * pStringFormat =
  763. (const NDR64_CONFORMANT_STRING_FORMAT*) pFormat;
  764. const NDR64_SIZED_CONFORMANT_STRING_FORMAT * pSizedStringFormat =
  765. (const NDR64_SIZED_CONFORMANT_STRING_FORMAT*) pFormat;
  766. NDR64_WIRE_COUNT_TYPE *pMaxCountMark;
  767. if ( !NDR64_IS_CONF_MARK_VALID( pStubMsg->uFlags ) )
  768. {
  769. ZeroOutGapAndAlign( pStubMsg, NDR64_WIRE_COUNT_ALIGN );
  770. pMaxCountMark = (NDR64_WIRE_COUNT_TYPE*)pStubMsg->Buffer;
  771. pStubMsg->Buffer += sizeof(NDR64_WIRE_COUNT_TYPE);
  772. }
  773. else
  774. {
  775. pMaxCountMark = (NDR64_WIRE_COUNT_TYPE*)pStubMsg->ConformanceMark;
  776. }
  777. NDR64_UINT32 CopySize =
  778. Ndr64pCommonStringSize( pStubMsg,
  779. pMemory,
  780. &pStringFormat->Header );
  781. //
  782. // If the string is sized then compute the max count, otherwise the
  783. // max count is equal to the actual count.
  784. //
  785. NDR64_WIRE_COUNT_TYPE MaxCount = pStubMsg->ActualCount;
  786. if ( pStringFormat->Header.Flags.IsSized )
  787. {
  788. MaxCount =
  789. Ndr64EvaluateExpr( pStubMsg,
  790. pSizedStringFormat->SizeDescription,
  791. EXPR_MAXCOUNT );
  792. if ( pStubMsg->ActualCount > MaxCount )
  793. RpcRaiseException(RPC_X_INVALID_BOUND);
  794. }
  795. // Marshall the max count.
  796. *pMaxCountMark = MaxCount;
  797. ZeroOutGapAndAlign( pStubMsg, NDR64_WIRE_COUNT_ALIGN);
  798. ((NDR64_WIRE_COUNT_TYPE*)pStubMsg->Buffer)[0] = pStubMsg->Offset;
  799. ((NDR64_WIRE_COUNT_TYPE*)pStubMsg->Buffer)[1] = pStubMsg->ActualCount;
  800. pStubMsg->Buffer += sizeof(NDR64_WIRE_COUNT_TYPE) * 2;
  801. RpcpMarshalMemoryCopy( pStubMsg->Buffer,
  802. pMemory,
  803. CopySize );
  804. // Update the Buffer pointer.
  805. pStubMsg->Buffer += CopySize;
  806. }
  807. void
  808. Ndr64FixedArrayMarshall(
  809. PMIDL_STUB_MESSAGE pStubMsg,
  810. uchar * pMemory,
  811. PNDR64_FORMAT pFormat )
  812. /*++
  813. Routine Description :
  814. Marshalls a fixed array of any number of dimensions.
  815. Arguments :
  816. pStubMsg - Pointer to the stub message.
  817. pMemory - Pointer to the array to be marshalled.
  818. pFormat - Array's format string description.
  819. Return :
  820. None.
  821. --*/
  822. {
  823. const NDR64_FIX_ARRAY_HEADER_FORMAT * pArrayFormat =
  824. (NDR64_FIX_ARRAY_HEADER_FORMAT*) pFormat;
  825. // Align the buffer.
  826. ZeroOutGapAndAlign( pStubMsg, pArrayFormat->Alignment );
  827. uchar *pBufferStart = pStubMsg->Buffer;
  828. // Copy the array.
  829. RpcpMarshalMemoryCopy( pBufferStart,
  830. pMemory,
  831. pArrayFormat->TotalSize );
  832. // Increment stub message buffer pointer.
  833. pStubMsg->Buffer += pArrayFormat->TotalSize;
  834. // Marshall embedded pointers.
  835. if ( pArrayFormat->Flags.HasPointerInfo )
  836. {
  837. Ndr64pPointerLayoutMarshall( pStubMsg,
  838. pArrayFormat + 1,
  839. 0,
  840. pMemory,
  841. pBufferStart );
  842. }
  843. }
  844. void
  845. Ndr64ConformantArrayMarshall(
  846. PMIDL_STUB_MESSAGE pStubMsg,
  847. uchar * pMemory,
  848. PNDR64_FORMAT pFormat )
  849. /*++
  850. Routine Description :
  851. Marshalls a top level one dimensional conformant array.
  852. Arguments :
  853. pStubMsg - Pointer to the stub message.
  854. pMemory - Pointer to the array being marshalled.
  855. pFormat - Array's format string description.
  856. Return :
  857. None.
  858. --*/
  859. {
  860. const NDR64_CONF_ARRAY_HEADER_FORMAT *pArrayFormat =
  861. (NDR64_CONF_ARRAY_HEADER_FORMAT*) pFormat;
  862. uchar *pConformanceMark;
  863. if ( !NDR64_IS_CONF_MARK_VALID( pStubMsg->uFlags ) )
  864. {
  865. // Align the buffer for conformance marshalling.
  866. ZeroOutGapAndAlign(pStubMsg,NDR64_WIRE_COUNT_ALIGN);
  867. pConformanceMark = pStubMsg->Buffer;
  868. pStubMsg->Buffer += sizeof(NDR64_WIRE_COUNT_TYPE);
  869. }
  870. else
  871. {
  872. pConformanceMark = pStubMsg->ConformanceMark;
  873. }
  874. NDR64_WIRE_COUNT_TYPE MaxCount =
  875. Ndr64EvaluateExpr( pStubMsg,
  876. pArrayFormat->ConfDescriptor,
  877. EXPR_MAXCOUNT );
  878. *(NDR64_WIRE_COUNT_TYPE*)pConformanceMark = MaxCount;
  879. // Compute the total array size in bytes.
  880. NDR64_UINT32 CopySize =
  881. Ndr64pConvertTo2GB(MaxCount * (NDR64_UINT64)pArrayFormat->ElementSize);
  882. ZeroOutGapAndAlign( pStubMsg, pArrayFormat->Alignment );
  883. // doesn't need further processing here.
  884. if ( CopySize == 0 )
  885. return;
  886. RpcpMarshalMemoryCopy( pStubMsg->Buffer,
  887. pMemory,
  888. CopySize );
  889. // Update buffer pointer.
  890. uchar *pBufferStart = pStubMsg->Buffer;
  891. pStubMsg->Buffer += CopySize;
  892. // Marshall embedded pointers.
  893. if ( pArrayFormat->Flags.HasPointerInfo )
  894. {
  895. Ndr64pPointerLayoutMarshall( pStubMsg,
  896. pArrayFormat + 1,
  897. (NDR64_UINT32)MaxCount,
  898. pMemory,
  899. pBufferStart );
  900. }
  901. }
  902. void
  903. Ndr64ConformantVaryingArrayMarshall(
  904. PMIDL_STUB_MESSAGE pStubMsg,
  905. uchar * pMemory,
  906. PNDR64_FORMAT pFormat )
  907. /*++
  908. Routine Description :
  909. Marshalls a top level one dimensional conformant varying array.
  910. Used for FC64_CVARRAY.
  911. Arguments :
  912. pStubMsg - Pointer to the stub message.
  913. pMemory - Pointer to the array being marshalled.
  914. pFormat - Array's format string description.
  915. Return :
  916. None.
  917. --*/
  918. {
  919. const NDR64_CONF_VAR_ARRAY_HEADER_FORMAT * pArrayFormat =
  920. (NDR64_CONF_VAR_ARRAY_HEADER_FORMAT*) pFormat;
  921. uchar *pConformanceMark;
  922. if ( ! NDR64_IS_CONF_MARK_VALID( pStubMsg->uFlags ) )
  923. {
  924. ZeroOutGapAndAlign( pStubMsg, NDR64_WIRE_COUNT_ALIGN);
  925. pConformanceMark = pStubMsg->Buffer;
  926. pStubMsg->Buffer += sizeof(NDR64_WIRE_COUNT_TYPE);
  927. }
  928. else
  929. {
  930. pConformanceMark = pStubMsg->ConformanceMark;
  931. }
  932. NDR64_WIRE_COUNT_TYPE MaxCount =
  933. Ndr64EvaluateExpr( pStubMsg,
  934. pArrayFormat->ConfDescriptor,
  935. EXPR_MAXCOUNT );
  936. NDR64_WIRE_COUNT_TYPE ActualCount =
  937. Ndr64EvaluateExpr( pStubMsg,
  938. pArrayFormat->VarDescriptor,
  939. EXPR_ACTUALCOUNT );
  940. if ( ActualCount > MaxCount )
  941. RpcRaiseException( RPC_X_INVALID_BOUND );
  942. *(NDR64_WIRE_COUNT_TYPE*)pConformanceMark = MaxCount;
  943. // Align the buffer for variance marshalling.
  944. ZeroOutGapAndAlign(pStubMsg, NDR64_WIRE_COUNT_ALIGN);
  945. // Marshall variance.
  946. ((NDR64_WIRE_COUNT_TYPE *)pStubMsg->Buffer)[0] = 0;
  947. ((NDR64_WIRE_COUNT_TYPE *)pStubMsg->Buffer)[1] = ActualCount;
  948. pStubMsg->Buffer += sizeof(NDR64_WIRE_COUNT_TYPE) * 2;
  949. NDR64_UINT32 CopySize =
  950. Ndr64pConvertTo2GB( ActualCount *
  951. (NDR64_UINT64)pArrayFormat->ElementSize );
  952. ZeroOutGapAndAlign( pStubMsg, pArrayFormat->Alignment );
  953. if ( CopySize == 0 )
  954. return;
  955. // Copy the array.
  956. RpcpMarshalMemoryCopy( pStubMsg->Buffer,
  957. pMemory,
  958. CopySize );
  959. uchar *pBufferStart = pStubMsg->Buffer;
  960. pStubMsg->Buffer += CopySize;
  961. // Marshall embedded pointers.
  962. if ( pArrayFormat->Flags.HasPointerInfo )
  963. {
  964. Ndr64pPointerLayoutMarshall( pStubMsg,
  965. pArrayFormat + 1,
  966. (NDR64_UINT32)ActualCount,
  967. pMemory,
  968. pBufferStart );
  969. }
  970. }
  971. void
  972. Ndr64VaryingArrayMarshall(
  973. PMIDL_STUB_MESSAGE pStubMsg,
  974. uchar * pMemory,
  975. PNDR64_FORMAT pFormat )
  976. /*++
  977. Routine Description :
  978. Marshalls a top level or embedded one dimensional varying array.
  979. Arguments :
  980. pStubMsg - Pointer to the stub message.
  981. pMemory - Pointer to the array being marshalled.
  982. pFormat - Array's format string description.
  983. Return :
  984. None.
  985. --*/
  986. {
  987. const NDR64_VAR_ARRAY_HEADER_FORMAT * pArrayFormat =
  988. (NDR64_VAR_ARRAY_HEADER_FORMAT*) pFormat;
  989. // Compute the variance offset and count.
  990. NDR64_WIRE_COUNT_TYPE ActualCount =
  991. Ndr64EvaluateExpr( pStubMsg,
  992. pArrayFormat->VarDescriptor,
  993. EXPR_ACTUALCOUNT );
  994. NDR64_UINT32 CopySize =
  995. Ndr64pConvertTo2GB( ActualCount * (NDR64_UINT64)pArrayFormat->ElementSize );
  996. // Align the buffer for variance marshalling.
  997. ZeroOutGapAndAlign(pStubMsg, NDR64_WIRE_COUNT_ALIGN );
  998. // Marshall variance.
  999. ((NDR64_WIRE_COUNT_TYPE *)pStubMsg->Buffer)[0] = 0;
  1000. ((NDR64_WIRE_COUNT_TYPE *)pStubMsg->Buffer)[1] = ActualCount;
  1001. pStubMsg->Buffer += sizeof(NDR64_WIRE_COUNT_TYPE) * 2;
  1002. ZeroOutGapAndAlign(pStubMsg, pArrayFormat->Alignment);
  1003. if ( CopySize == 0 )
  1004. return;
  1005. // Copy the array.
  1006. RpcpMarshalMemoryCopy( pStubMsg->Buffer,
  1007. pMemory,
  1008. CopySize );
  1009. // Update buffer pointer.
  1010. uchar *pBufferStart = pStubMsg->Buffer;
  1011. pStubMsg->Buffer += CopySize;
  1012. // Marshall embedded pointers.
  1013. if ( pArrayFormat->Flags.HasPointerInfo )
  1014. {
  1015. Ndr64pPointerLayoutMarshall( pStubMsg,
  1016. pArrayFormat + 1,
  1017. (NDR64_UINT32)ActualCount,
  1018. pMemory,
  1019. pBufferStart );
  1020. }
  1021. }
  1022. void
  1023. Ndr64ComplexArrayMarshall(
  1024. PMIDL_STUB_MESSAGE pStubMsg,
  1025. uchar * pMemory,
  1026. PNDR64_FORMAT pFormat )
  1027. /*++
  1028. Routine Description :
  1029. Marshalls a top level complex array.
  1030. Arguments :
  1031. pStubMsg - Pointer to the stub message.
  1032. pMemory - Pointer to the array being marshalled.
  1033. pFormat - Array's format string description.
  1034. Return :
  1035. None.
  1036. --*/
  1037. {
  1038. const NDR64_BOGUS_ARRAY_HEADER_FORMAT *pArrayFormat =
  1039. (NDR64_BOGUS_ARRAY_HEADER_FORMAT *) pFormat;
  1040. bool fSetPointerBufferMark = ! pStubMsg->PointerBufferMark;
  1041. if ( fSetPointerBufferMark )
  1042. {
  1043. BOOL fOldIgnore = pStubMsg->IgnoreEmbeddedPointers;
  1044. pStubMsg->IgnoreEmbeddedPointers = TRUE;
  1045. ulong BufferLenOffset = 0xf & PtrToUlong( pStubMsg->Buffer );
  1046. ulong BufferLengthSave = pStubMsg->BufferLength;
  1047. pStubMsg->BufferLength = BufferLenOffset;
  1048. Ndr64ComplexArrayBufferSize( pStubMsg,
  1049. pMemory,
  1050. pFormat );
  1051. // Pointer increment including alignments.
  1052. BufferLenOffset = pStubMsg->BufferLength - BufferLenOffset;
  1053. //
  1054. // This is the buffer pointer to the position where embedded pointers
  1055. // will be marshalled.
  1056. //
  1057. pStubMsg->PointerBufferMark = pStubMsg->Buffer + BufferLenOffset;
  1058. pStubMsg->BufferLength = BufferLengthSave;
  1059. pStubMsg->IgnoreEmbeddedPointers = fOldIgnore;
  1060. }
  1061. BOOL IsFixed = ( pArrayFormat->FormatCode == FC64_FIX_BOGUS_ARRAY ) ||
  1062. ( pArrayFormat->FormatCode == FC64_FIX_FORCED_BOGUS_ARRAY );
  1063. PFORMAT_STRING pElementFormat = (PFORMAT_STRING)pArrayFormat->Element;
  1064. NDR64_WIRE_COUNT_TYPE Elements = pArrayFormat->NumberElements;
  1065. NDR64_WIRE_COUNT_TYPE Count = Elements;
  1066. NDR64_WIRE_COUNT_TYPE Offset = 0;
  1067. SAVE_CONTEXT<uchar*> ConformanceMarkSave( pStubMsg->ConformanceMark );
  1068. SAVE_CONTEXT<uchar*> VarianceMarkSave( pStubMsg->VarianceMark );
  1069. SAVE_CONTEXT<uchar> uFlagsSave( pStubMsg->uFlags );
  1070. if ( !IsFixed )
  1071. {
  1072. const NDR64_CONF_VAR_BOGUS_ARRAY_HEADER_FORMAT* pConfVarFormat=
  1073. (NDR64_CONF_VAR_BOGUS_ARRAY_HEADER_FORMAT*)pFormat;
  1074. if ( pConfVarFormat->ConfDescription != 0 )
  1075. {
  1076. if ( ! NDR64_IS_CONF_MARK_VALID( pStubMsg->uFlags ) )
  1077. {
  1078. //
  1079. // Outer most dimension sets the conformance marker.
  1080. //
  1081. // Align the buffer for conformance marshalling.
  1082. ZeroOutGapAndAlign(pStubMsg, NDR64_WIRE_COUNT_ALIGN);
  1083. // Mark where the conformance count(s) will be marshalled.
  1084. pStubMsg->ConformanceMark = pStubMsg->Buffer;
  1085. // Increment past where the conformance will go.
  1086. pStubMsg->Buffer += pArrayFormat->NumberDims * sizeof(NDR64_WIRE_COUNT_TYPE);
  1087. NDR64_SET_CONF_MARK_VALID( pStubMsg->uFlags );
  1088. }
  1089. Elements = Ndr64EvaluateExpr( pStubMsg,
  1090. pConfVarFormat->ConfDescription,
  1091. EXPR_MAXCOUNT );
  1092. *(NDR64_WIRE_COUNT_TYPE*) pStubMsg->ConformanceMark = Elements;
  1093. pStubMsg->ConformanceMark += sizeof(NDR64_WIRE_COUNT_TYPE);
  1094. Offset = 0;
  1095. Count = Elements;
  1096. }
  1097. //
  1098. // Check for variance description.
  1099. //
  1100. if ( pConfVarFormat->VarDescription != 0 )
  1101. {
  1102. if ( ! NDR64_IS_VAR_MARK_VALID( pStubMsg->uFlags ) )
  1103. {
  1104. NDR64_UINT32 Dimensions;
  1105. //
  1106. // Set the variance marker.
  1107. //
  1108. ZeroOutGapAndAlign(pStubMsg, NDR64_WIRE_COUNT_ALIGN );
  1109. Dimensions = ( pArrayFormat->Flags.IsArrayofStrings ) ? ( pArrayFormat->NumberDims - 1) :
  1110. ( pArrayFormat->NumberDims );
  1111. // Increment past where the variance will go.
  1112. pStubMsg->VarianceMark = pStubMsg->Buffer;
  1113. pStubMsg->Buffer += Dimensions * sizeof(NDR64_WIRE_COUNT_TYPE) * 2;
  1114. if ( NDR64_IS_ARRAY_OR_STRING( *pElementFormat ) )
  1115. NDR64_SET_VAR_MARK_VALID( pStubMsg->uFlags );
  1116. }
  1117. else if ( !NDR64_IS_ARRAY_OR_STRING( *pElementFormat ) )
  1118. NDR64_RESET_VAR_MARK_VALID( pStubMsg->uFlags );
  1119. Count =
  1120. Ndr64EvaluateExpr( pStubMsg,
  1121. pConfVarFormat->VarDescription,
  1122. EXPR_ACTUALCOUNT );
  1123. Offset =
  1124. Ndr64EvaluateExpr( pStubMsg,
  1125. pConfVarFormat->OffsetDescription,
  1126. EXPR_OFFSET );
  1127. if ( Count + Offset > Elements )
  1128. RpcRaiseException( RPC_X_INVALID_BOUND );
  1129. ((NDR64_WIRE_COUNT_TYPE*)pStubMsg->VarianceMark)[0] = Offset;
  1130. ((NDR64_WIRE_COUNT_TYPE*)pStubMsg->VarianceMark)[1] = Count;
  1131. pStubMsg->VarianceMark += sizeof(NDR64_WIRE_COUNT_TYPE) * 2;
  1132. }
  1133. }
  1134. NDR64_UINT32 ElementMemorySize =
  1135. Ndr64pMemorySize( pStubMsg,
  1136. pElementFormat,
  1137. FALSE );
  1138. pMemory += Ndr64pConvertTo2GB( Offset *
  1139. (NDR64_UINT64)ElementMemorySize);
  1140. Ndr64pConvertTo2GB( Elements *
  1141. (NDR64_UINT64)ElementMemorySize );
  1142. Ndr64pConvertTo2GB( Count *
  1143. (NDR64_UINT64)ElementMemorySize );
  1144. ZeroOutGapAndAlign(pStubMsg, pArrayFormat->Alignment);
  1145. for ( ; Count--; )
  1146. {
  1147. Ndr64EmbeddedTypeMarshall( pStubMsg,
  1148. pMemory,
  1149. pElementFormat );
  1150. pMemory += ElementMemorySize;
  1151. }
  1152. if ( fSetPointerBufferMark )
  1153. {
  1154. pStubMsg->Buffer = pStubMsg->PointerBufferMark;
  1155. pStubMsg->PointerBufferMark = 0;
  1156. }
  1157. }
  1158. void
  1159. Ndr64UnionMarshall (
  1160. PMIDL_STUB_MESSAGE pStubMsg,
  1161. uchar * pMemory,
  1162. PNDR64_FORMAT pFormat )
  1163. /*++
  1164. Routine Description :
  1165. Marshalls an encapsulated union.
  1166. Used for FC64_ENCAPSULATED_UNION.
  1167. Arguments :
  1168. pStubMsg - Pointer to the stub message.
  1169. pMemory - Pointer to the union being marshalled.
  1170. pFormat - Union's format string description.
  1171. Return :
  1172. None.
  1173. --*/
  1174. {
  1175. const NDR64_UNION_ARM_SELECTOR* pArmSelector;
  1176. EXPR_VALUE SwitchIs;
  1177. NDR64_FORMAT_CHAR SwitchType;
  1178. uchar *pArmMemory;
  1179. switch(*(PFORMAT_STRING)pFormat)
  1180. {
  1181. case FC64_NON_ENCAPSULATED_UNION:
  1182. {
  1183. const NDR64_NON_ENCAPSULATED_UNION* pNonEncapUnionFormat =
  1184. (const NDR64_NON_ENCAPSULATED_UNION*) pFormat;
  1185. ZeroOutGapAndAlign(pStubMsg, pNonEncapUnionFormat->Alignment);
  1186. SwitchType = pNonEncapUnionFormat->SwitchType;
  1187. pArmSelector = (NDR64_UNION_ARM_SELECTOR*)(pNonEncapUnionFormat + 1);
  1188. SwitchIs = Ndr64EvaluateExpr( pStubMsg,
  1189. pNonEncapUnionFormat->Switch,
  1190. EXPR_SWITCHIS );
  1191. pArmMemory = pMemory;
  1192. break;
  1193. }
  1194. case FC64_ENCAPSULATED_UNION:
  1195. {
  1196. const NDR64_ENCAPSULATED_UNION* pEncapUnionFormat =
  1197. (const NDR64_ENCAPSULATED_UNION*)pFormat;
  1198. ZeroOutGapAndAlign(pStubMsg, pEncapUnionFormat->Alignment);
  1199. SwitchType = pEncapUnionFormat->SwitchType;
  1200. pArmSelector = (NDR64_UNION_ARM_SELECTOR*)(pEncapUnionFormat + 1);
  1201. SwitchIs = Ndr64pSimpleTypeToExprValue(SwitchType,
  1202. pMemory);
  1203. pArmMemory = pMemory + pEncapUnionFormat->MemoryOffset;
  1204. break;
  1205. }
  1206. default:
  1207. NDR_ASSERT(0, "Bad union format\n");
  1208. }
  1209. Ndr64SimpleTypeMarshall( pStubMsg,
  1210. (uchar *)&SwitchIs,
  1211. SwitchType );
  1212. ZeroOutGapAndAlign(pStubMsg, pArmSelector->Alignment);
  1213. PNDR64_FORMAT pArmFormat =
  1214. Ndr64pFindUnionArm( pStubMsg,
  1215. pArmSelector,
  1216. SwitchIs );
  1217. if ( !pArmFormat )
  1218. return;
  1219. Ndr64EmbeddedTypeMarshall( pStubMsg,
  1220. pArmMemory,
  1221. pArmFormat );
  1222. }
  1223. void
  1224. Ndr64XmitOrRepAsMarshall (
  1225. PMIDL_STUB_MESSAGE pStubMsg,
  1226. uchar * pMemory,
  1227. PNDR64_FORMAT pFormat,
  1228. bool bIsEmbedded )
  1229. /*++
  1230. Routine Description :
  1231. Marshalls a transmit as or represent as argument:
  1232. - translate the presented object into a transmitted object
  1233. - marshall the transmitted object
  1234. - free the transmitted object
  1235. Format string layout:
  1236. check out ndr64types.h
  1237. Arguments :
  1238. pStubMsg - a pointer to the stub message
  1239. pMemory - presented type translated into transmitted type
  1240. and than to be marshalled
  1241. pFormat - format string description
  1242. --*/
  1243. {
  1244. // Skip the token itself and Oi flag. Fetch the QuintupleIndex.
  1245. NDR64_TRANSMIT_AS_FORMAT * pTransFormat =
  1246. ( NDR64_TRANSMIT_AS_FORMAT *) pFormat;
  1247. NDR_ASSERT( pTransFormat->FormatCode == FC64_TRANSMIT_AS || pTransFormat->FormatCode , "invalid format string for user marshal" );
  1248. unsigned short QIndex = pTransFormat->RoutineIndex;
  1249. // First translate the presented type into the transmitted type.
  1250. // This includes an allocation of a transmitted type object.
  1251. pStubMsg->pPresentedType = pMemory;
  1252. pStubMsg->pTransmitType = NULL;
  1253. const XMIT_ROUTINE_QUINTUPLE * pQuintuple =
  1254. pStubMsg->StubDesc->aXmitQuintuple;
  1255. pQuintuple[ QIndex ].pfnTranslateToXmit( pStubMsg );
  1256. unsigned char * pTransmittedType = pStubMsg->pTransmitType;
  1257. // In NDR64, Xmit/Rep cannot be a pointer or contain a pointer.
  1258. // So we don't need to worry about the pointer queue here.
  1259. if ( bIsEmbedded )
  1260. {
  1261. Ndr64EmbeddedTypeMarshall( pStubMsg,
  1262. pTransmittedType,
  1263. pTransFormat->TransmittedType );
  1264. }
  1265. else
  1266. {
  1267. Ndr64TopLevelTypeMarshall( pStubMsg,
  1268. pTransmittedType,
  1269. pTransFormat->TransmittedType );
  1270. }
  1271. pStubMsg->pTransmitType = pTransmittedType;
  1272. // Free the temporary transmitted object (it was allocated by the user).
  1273. pQuintuple[ QIndex ].pfnFreeXmit( pStubMsg );
  1274. }
  1275. void
  1276. Ndr64TopLevelXmitOrRepAsMarshall (
  1277. PMIDL_STUB_MESSAGE pStubMsg,
  1278. uchar * pMemory,
  1279. PNDR64_FORMAT pFormat )
  1280. {
  1281. Ndr64XmitOrRepAsMarshall( pStubMsg,
  1282. pMemory,
  1283. pFormat,
  1284. false );
  1285. }
  1286. void
  1287. Ndr64EmbeddedXmitOrRepAsMarshall (
  1288. PMIDL_STUB_MESSAGE pStubMsg,
  1289. uchar * pMemory,
  1290. PNDR64_FORMAT pFormat )
  1291. {
  1292. Ndr64XmitOrRepAsMarshall( pStubMsg,
  1293. pMemory,
  1294. pFormat,
  1295. true );
  1296. }
  1297. void
  1298. Ndr64UserMarshallMarshallInternal(
  1299. PMIDL_STUB_MESSAGE pStubMsg,
  1300. uchar * pMemory,
  1301. PNDR64_FORMAT pFormat,
  1302. NDR64_PTR_WIRE_TYPE *pWirePtr )
  1303. {
  1304. NDR64_USER_MARSHAL_FORMAT * pUserFormat =
  1305. ( NDR64_USER_MARSHAL_FORMAT *) pFormat;
  1306. unsigned char * pUserBuffer = pStubMsg->Buffer;
  1307. unsigned char * pUserBufferSaved = pUserBuffer;
  1308. // We always call user's routine to marshall.
  1309. USER_MARSHAL_CB UserMarshalCB;
  1310. Ndr64pInitUserMarshalCB( pStubMsg,
  1311. pUserFormat,
  1312. USER_MARSHAL_CB_MARSHALL,
  1313. & UserMarshalCB );
  1314. unsigned short QIndex = pUserFormat->RoutineIndex;
  1315. const USER_MARSHAL_ROUTINE_QUADRUPLE * pQuadruple =
  1316. (const USER_MARSHAL_ROUTINE_QUADRUPLE *)( ( NDR_PROC_CONTEXT *)pStubMsg->pContext )->pSyntaxInfo->aUserMarshalQuadruple;
  1317. if ((pUserBufferSaved < (uchar *) pStubMsg->RpcMsg->Buffer) ||
  1318. ((unsigned long) (pUserBufferSaved - (uchar *) pStubMsg->RpcMsg->Buffer)
  1319. > pStubMsg->RpcMsg->BufferLength))
  1320. {
  1321. RpcRaiseException( RPC_X_INVALID_BUFFER );
  1322. }
  1323. pUserBuffer = pQuadruple[ QIndex ].pfnMarshall( (ulong*) &UserMarshalCB,
  1324. pUserBuffer,
  1325. pMemory );
  1326. if ((pUserBufferSaved > pUserBuffer) ||
  1327. ((unsigned long) (pUserBuffer - (uchar *) pStubMsg->RpcMsg->Buffer)
  1328. > pStubMsg->RpcMsg->BufferLength ))
  1329. {
  1330. RpcRaiseException( RPC_X_INVALID_BUFFER );
  1331. }
  1332. if ( pUserBuffer == pUserBufferSaved )
  1333. {
  1334. // This is valid only if the wire type was a unique type.
  1335. if ( ( pUserFormat->Flags & USER_MARSHAL_UNIQUE) )
  1336. {
  1337. *pWirePtr = 0;
  1338. return;
  1339. }
  1340. else
  1341. RpcRaiseException( RPC_X_NULL_REF_POINTER );
  1342. }
  1343. pStubMsg->Buffer = pUserBuffer;
  1344. }
  1345. void
  1346. NDR64_USR_MRSHL_MRSHL_POINTER_QUEUE_ELEMENT::Dispatch(MIDL_STUB_MESSAGE *pStubMsg)
  1347. {
  1348. Ndr64UserMarshallMarshallInternal( pStubMsg,
  1349. pMemory,
  1350. pFormat,
  1351. pWireMarkerPtr );
  1352. }
  1353. #if defined(DBG)
  1354. void
  1355. NDR64_USR_MRSHL_MRSHL_POINTER_QUEUE_ELEMENT::Print()
  1356. {
  1357. DbgPrint("NDR_USR_MRSHL_MRSHL_POINTER_QUEUE_ELEMENT\n");
  1358. DbgPrint("pMemory: %p\n", pMemory );
  1359. DbgPrint("pFormat: %p\n", pFormat );
  1360. DbgPrint("pWireMarkerPtr: %p\n", pWireMarkerPtr );
  1361. }
  1362. #endif
  1363. void
  1364. Ndr64UserMarshallPointeeMarshall(
  1365. PMIDL_STUB_MESSAGE pStubMsg,
  1366. uchar * pMemory,
  1367. PNDR64_FORMAT pFormat,
  1368. NDR64_PTR_WIRE_TYPE *pWirePtr )
  1369. {
  1370. if ( !pStubMsg->pPointerQueueState ||
  1371. !pStubMsg->pPointerQueueState->GetActiveQueue() )
  1372. {
  1373. POINTER_BUFFER_SWAP_CONTEXT SwapContext( pStubMsg );
  1374. Ndr64UserMarshallMarshallInternal(
  1375. pStubMsg,
  1376. pMemory,
  1377. pFormat,
  1378. pWirePtr );
  1379. return;
  1380. }
  1381. NDR64_USR_MRSHL_MRSHL_POINTER_QUEUE_ELEMENT*pElement =
  1382. new(pStubMsg->pPointerQueueState)
  1383. NDR64_USR_MRSHL_MRSHL_POINTER_QUEUE_ELEMENT(pMemory,
  1384. (PFORMAT_STRING)pFormat,
  1385. pWirePtr);
  1386. pStubMsg->pPointerQueueState->GetActiveQueue()->Enque( pElement );
  1387. }
  1388. void
  1389. Ndr64UserMarshalMarshall(
  1390. PMIDL_STUB_MESSAGE pStubMsg,
  1391. uchar * pMemory,
  1392. PNDR64_FORMAT pFormat,
  1393. bool bIsEmbedded )
  1394. /*++
  1395. Routine Description :
  1396. Marshals a usr_marshall object.
  1397. Arguments :
  1398. pStubMsg - Pointer to the stub message.
  1399. pMemory - Pointer to the usr_marshall object to marshall.
  1400. pFormat - Object's format string description.
  1401. Return :
  1402. None.
  1403. --*/
  1404. {
  1405. NDR64_USER_MARSHAL_FORMAT * pUserFormat =
  1406. ( NDR64_USER_MARSHAL_FORMAT *) pFormat;
  1407. NDR_ASSERT( pUserFormat->FormatCode == FC64_USER_MARSHAL, "invalid format string for user marshal" );
  1408. ZeroOutGapAndAlign( pStubMsg, pUserFormat->TransmittedTypeWireAlignment );
  1409. if ( pUserFormat->Flags & USER_MARSHAL_POINTER )
  1410. {
  1411. NDR64_PTR_WIRE_TYPE *pWireMarkerPtr = NULL;
  1412. if ( ( pUserFormat->Flags & USER_MARSHAL_UNIQUE ) ||
  1413. (( pUserFormat->Flags & USER_MARSHAL_REF ) && bIsEmbedded) )
  1414. {
  1415. pWireMarkerPtr = (NDR64_PTR_WIRE_TYPE *) pStubMsg->Buffer;
  1416. *((NDR64_PTR_WIRE_TYPE *)pStubMsg->Buffer) = NDR64_USER_MARSHAL_MARKER;
  1417. pStubMsg->Buffer += sizeof(NDR64_PTR_WIRE_TYPE);
  1418. }
  1419. Ndr64UserMarshallPointeeMarshall( pStubMsg,
  1420. pMemory,
  1421. pFormat,
  1422. pWireMarkerPtr );
  1423. return;
  1424. }
  1425. Ndr64UserMarshallMarshallInternal(
  1426. pStubMsg,
  1427. pMemory,
  1428. pFormat,
  1429. NULL );
  1430. }
  1431. void
  1432. Ndr64TopLevelUserMarshalMarshall(
  1433. PMIDL_STUB_MESSAGE pStubMsg,
  1434. uchar * pMemory,
  1435. PNDR64_FORMAT pFormat )
  1436. {
  1437. Ndr64UserMarshalMarshall( pStubMsg,
  1438. pMemory,
  1439. pFormat,
  1440. false );
  1441. }
  1442. void
  1443. Ndr64EmbeddedUserMarshalMarshall(
  1444. PMIDL_STUB_MESSAGE pStubMsg,
  1445. uchar * pMemory,
  1446. PNDR64_FORMAT pFormat )
  1447. {
  1448. Ndr64UserMarshalMarshall( pStubMsg,
  1449. pMemory,
  1450. pFormat,
  1451. true );
  1452. }
  1453. void
  1454. Ndr64ServerContextNewMarshall(
  1455. PMIDL_STUB_MESSAGE pStubMsg,
  1456. NDR_SCONTEXT ContextHandle,
  1457. NDR_RUNDOWN RundownRoutine,
  1458. PFORMAT_STRING pFormat )
  1459. /*
  1460. This is a non-optimized NDR engine entry for context handle marshaling.
  1461. In particular it is able to handle all the new NT5 context handle flavors.
  1462. The optimized routine follows below.
  1463. ContextHandle - note, this is not the user's handle but a
  1464. NDR_SCONTEXT pointer from the stub local stack.
  1465. User's handle is a field in that object.
  1466. Note that intepreter calls Ndr64MarshallHandle. However, we can't use it
  1467. as it assumes a helper array of saved context handles that we don't need.
  1468. */
  1469. {
  1470. void * pGuard = RPC_CONTEXT_HANDLE_DEFAULT_GUARD;
  1471. DWORD Flags = RPC_CONTEXT_HANDLE_DEFAULT_FLAGS;
  1472. NDR64_CONTEXT_HANDLE_FORMAT * pContextFormat;
  1473. pContextFormat = ( NDR64_CONTEXT_HANDLE_FORMAT * )pFormat;
  1474. NDR_ASSERT( pContextFormat->FormatCode == FC64_BIND_CONTEXT, "invalid format char " );
  1475. // NT5 beta2 features: strict context handle, serialize and noserialize.
  1476. if ( pContextFormat->ContextFlags & NDR_STRICT_CONTEXT_HANDLE )
  1477. {
  1478. pGuard = pStubMsg->StubDesc->RpcInterfaceInformation;
  1479. pGuard = & ((PRPC_SERVER_INTERFACE)pGuard)->InterfaceId;
  1480. }
  1481. if ( pContextFormat->ContextFlags & NDR_CONTEXT_HANDLE_NOSERIALIZE )
  1482. {
  1483. Flags = RPC_CONTEXT_HANDLE_DONT_SERIALIZE;
  1484. }
  1485. else if ( pContextFormat->ContextFlags & NDR_CONTEXT_HANDLE_SERIALIZE )
  1486. {
  1487. Flags = RPC_CONTEXT_HANDLE_SERIALIZE;
  1488. }
  1489. ALIGN( pStubMsg->Buffer, 0x3 );
  1490. NDRSContextMarshall2(
  1491. pStubMsg->RpcMsg->Handle,
  1492. ContextHandle,
  1493. pStubMsg->Buffer,
  1494. RundownRoutine,
  1495. pGuard,
  1496. Flags );
  1497. pStubMsg->Buffer += CONTEXT_HANDLE_WIRE_SIZE;
  1498. }
  1499. // define the jump table
  1500. #define NDR64_BEGIN_TABLE \
  1501. PNDR64_MARSHALL_ROUTINE extern const Ndr64MarshallRoutinesTable[] = \
  1502. {
  1503. #define NDR64_TABLE_END \
  1504. };
  1505. #define NDR64_ZERO_ENTRY NULL
  1506. #define NDR64_UNUSED_TABLE_ENTRY( number, tokenname ) ,NULL
  1507. #define NDR64_UNUSED_TABLE_ENTRY_NOSYM( number ) ,NULL
  1508. #define NDR64_TABLE_ENTRY( number, tokenname, marshall, embeddedmarshall, unmarshall, embeddedunmarshall, buffersize, embeddedbuffersize, memsize, embeddedmemsize, free, embeddedfree, typeflags ) \
  1509. ,marshall
  1510. #define NDR64_SIMPLE_TYPE_TABLE_ENTRY( number, tokenname, typebuffersize, memorysize) \
  1511. ,Ndr64UDTSimpleTypeMarshall1
  1512. #include "tokntbl.h"
  1513. C_ASSERT( sizeof(Ndr64MarshallRoutinesTable)/sizeof(PNDR64_MARSHALL_ROUTINE) == 256 );
  1514. #undef NDR64_BEGIN_TABLE
  1515. #undef NDR64_TABLE_ENTRY
  1516. #define NDR64_TABLE_ENTRY( number, tokenname, marshall, embeddedmarshall, unmarshall, embeddedunmarshall, buffersize, embeddedbuffersize, memsize, embeddedmemsize, free, embeddedfree, typeflags ) \
  1517. ,embeddedmarshall
  1518. #define NDR64_BEGIN_TABLE \
  1519. PNDR64_MARSHALL_ROUTINE extern const Ndr64EmbeddedMarshallRoutinesTable[] = \
  1520. {
  1521. #include "tokntbl.h"
  1522. C_ASSERT( sizeof(Ndr64EmbeddedMarshallRoutinesTable) / sizeof(PNDR64_MARSHALL_ROUTINE) == 256 );