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.

198 lines
6.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994.
  5. //
  6. // File: transmit.h
  7. //
  8. // Contents: Function prototypes for STGMEDIUM marshalling.
  9. //
  10. // Functions: STGMEDIUM_to_xmit
  11. // STGMEDIUM_from_xmit
  12. // STGMEDIUM_free_inst
  13. //
  14. // History: May-10-94 ShannonC Created
  15. // History: May-10-95 Ryszardk wire_marshal changes
  16. //
  17. //--------------------------------------------------------------------------
  18. #pragma once
  19. #ifndef __TRANSMIT_H__
  20. #define __TRANSMIT_H__
  21. #include <debnot.h>
  22. #if (DBG==1)
  23. DECLARE_DEBUG(UserNdr)
  24. //
  25. #define UserNdrDebugOut(x) UserNdrInlineDebugOut x
  26. #define UserNdrAssert(x) Win4Assert(x)
  27. #define UserNdrVerify(x) Win4Assert(x)
  28. //#define UNDR_FORCE DEB_FORCE
  29. #define UNDR_FORCE 0
  30. #define UNDR_OUT1 0
  31. #define UNDR_OUT4 0
  32. EXTERN_C char *
  33. WdtpGetStgmedName( STGMEDIUM * );
  34. #else
  35. #define UserNdrDebugOut(x)
  36. #define UserNdrAssert(x)
  37. #define UserNdrVerify(x)
  38. #define UNDR_FORCE 0
  39. #define UNDR_OUT1 0
  40. #define UNDR_OUT4 0
  41. #endif
  42. // Shortcut typedefs.
  43. typedef unsigned char uchar;
  44. typedef unsigned short ushort;
  45. typedef unsigned long ulong;
  46. typedef unsigned int uint;
  47. #ifndef TRUE
  48. #define TRUE (1)
  49. #define FALSE (0)
  50. typedef unsigned short BOOL;
  51. #endif
  52. //
  53. // Alignment and access macros.
  54. //
  55. #define ALIGN( pStuff, cAlign ) \
  56. pStuff = (unsigned char *)((ULONG_PTR)((pStuff) + (cAlign)) & ~ (cAlign))
  57. #define LENGTH_ALIGN( Length, cAlign ) \
  58. Length = (((Length) + (cAlign)) & ~ (cAlign))
  59. #define PCHAR_LV_CAST *(char __RPC_FAR * __RPC_FAR *)&
  60. #define PSHORT_LV_CAST *(short __RPC_FAR * __RPC_FAR *)&
  61. #define PLONG_LV_CAST *(long __RPC_FAR * __RPC_FAR *)&
  62. #define PHYPER_LV_CAST *(hyper __RPC_FAR * __RPC_FAR *)&
  63. #define PUSHORT_LV_CAST *(unsigned short __RPC_FAR * __RPC_FAR *)&
  64. #define PULONG_LV_CAST *(unsigned long __RPC_FAR * __RPC_FAR *)&
  65. // Just a pointer sized random thing we can identify in the stream.
  66. // For error checking purposes only.
  67. #define USER_MARSHAL_MARKER 0x72657355
  68. //
  69. // These are based on flags defined in wtypes.idl comming from the channel.
  70. // They indicate where we are marshalling.
  71. //
  72. #define INPROC_CALL( Flags) (USER_CALL_CTXT_MASK(Flags) == MSHCTX_INPROC)
  73. #define REMOTE_CALL( Flags) ((USER_CALL_CTXT_MASK(Flags) == MSHCTX_DIFFERENTMACHINE) \
  74. || (USER_CALL_CTXT_MASK(Flags) == MSHCTX_NOSHAREDMEM))
  75. #define DIFFERENT_MACHINE_CALL( Flags) \
  76. (USER_CALL_CTXT_MASK(Flags) == MSHCTX_DIFFERENTMACHINE)
  77. // There is a difference in the scope of handles, Daytona vs. Chicago.
  78. // The following is an illustration of the notions of
  79. // HGLOBAL handle vs. data passing and GDI handle vs. data passing.
  80. // The type of an rpc call is defined by the flags above.
  81. //
  82. // This is included only for historical interest, as this code no longer
  83. // has anything to do with chicago, win9x, or any of that goo.
  84. //
  85. // Daytona rules: GDI same as HGLOBAL
  86. //I------------I----------------I-----------------------------------I
  87. //I inproc I same machine I diff. machine (a.k.a "remote" ) I
  88. //I------------I----------------------------------------------------I
  89. //| HGLOBL h.p.| HGLOBAL data passing |
  90. //|------------|----------------------------------------------------|
  91. //| GDI h.p. | GDI data passing |
  92. //|------------|----------------------------------------------------|
  93. //
  94. // Chicago rules: HGLOBAL stricter than GDI.
  95. //I------------I----------------I-----------------------------------I
  96. //I inproc I same machine I diff. machine (a.k.a "remote" ) I
  97. //I------------I----------------------------------------------------I
  98. //| HGLOBL h.p.| HGLOBAL data passing |
  99. //|-----------------------------------------------------------------|
  100. //| GDI handle passing | GDI data passing |
  101. //|-----------------------------|-----------------------------------|
  102. #define HGLOBAL_HANDLE_PASSING( Flags ) INPROC_CALL( Flags)
  103. #define HGLOBAL_DATA_PASSING( Flags ) (!INPROC_CALL( Flags))
  104. // On Chicago, some handles are valid between processes.
  105. // #if defined(_CHICAGO_)
  106. // #define GDI_HANDLE_PASSING( Flags ) (! REMOTE_CALL( Flags ))
  107. // #define GDI_DATA_PASSING( Flags ) REMOTE_CALL( Flags )
  108. // #else
  109. // #endif
  110. #define GDI_HANDLE_PASSING( Flags ) HGLOBAL_HANDLE_PASSING( Flags )
  111. #define GDI_DATA_PASSING( Flags ) HGLOBAL_DATA_PASSING( Flags )
  112. #define WDT_DATA_MARKER WDT_REMOTE_CALL
  113. #define WDT_HANDLE_MARKER WDT_INPROC_CALL
  114. #define WDT_HANDLE64_MARKER WDT_INPROC64_CALL
  115. #define IS_DATA_MARKER( dw ) (WDT_REMOTE_CALL == dw)
  116. #define IS_HANDLE_MARKER( dw ) (WDT_INPROC_CALL == dw)
  117. #define IS_HANDLE64_MARKER( dw ) (WDT_INPROC64_CALL == dw)
  118. //
  119. // CLIPFORMAT remoting
  120. //
  121. #define CLIPFORMAT_BUFFER_MAX 248
  122. #define NON_STANDARD_CLIPFORMAT(pcf)((0xC000<= *pcf) && (*pcf <=0xFFFF))
  123. #define REMOTE_CLIPFORMAT(pFlags) ((USER_CALL_CTXT_MASK(*pFlags) == MSHCTX_DIFFERENTMACHINE) )
  124. //
  125. // Useful memory macros, for consistency.
  126. //
  127. #define WdtpMemoryCopy(Destination, Source, Length) \
  128. RtlCopyMemory(Destination, Source, Length)
  129. #define WdtpZeroMemory(Destination, Length) \
  130. RtlZeroMemory(Destination, Length)
  131. #define WdtpAllocate(p,size) \
  132. ((USER_MARSHAL_CB *)p)->pStubMsg->pfnAllocate( size )
  133. #define WdtpFree(pf,ptr) \
  134. ((USER_MARSHAL_CB *)pf)->pStubMsg->pfnFree( ptr )
  135. //
  136. // Used in call_as.c
  137. //
  138. EXTERN_C
  139. void NukeHandleAndReleasePunk(
  140. STGMEDIUM * pStgmed );
  141. //
  142. // Useful checking/exception routines.
  143. //
  144. #if DBG==1
  145. #define RAISE_RPC_EXCEPTION( e ) \
  146. { \
  147. Win4Assert( !"Wire marshaling problem!" ); \
  148. RpcRaiseException( (e) ); \
  149. }
  150. #else
  151. #define RAISE_RPC_EXCEPTION( e ) \
  152. { \
  153. RpcRaiseException( (e) ); \
  154. }
  155. #endif
  156. #define CHECK_BUFFER_SIZE( b, s ) \
  157. if ( (b) < (s) ) \
  158. { \
  159. RAISE_RPC_EXCEPTION( RPC_X_BAD_STUB_DATA ); \
  160. }
  161. #endif // __TRANSMIT_H__