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.

404 lines
13 KiB

  1. /*
  2. * This is the internal ole2 header, which means it contains those
  3. * interfaces which might eventually be exposed to the outside
  4. * and which will be exposed to our implementations. We don't want
  5. * to expose these now, so I have put them in a separate file.
  6. */
  7. #if !defined( _OLE2INT_H_ )
  8. #define _OLE2INT_H_
  9. #ifndef RC_INVOKED
  10. #pragma message ("INCLUDING OLE2INT.H from " __FILE__)
  11. #endif /* RC_INVOKED */
  12. // ------------------------------------
  13. // system includes
  14. #include <string.h>
  15. #include <StdLib.h>
  16. #include <windows.h>
  17. #include <shellapi.h>
  18. #define GetCurrentThread() GetCurrentTask()
  19. #define GetCurrentProcess() GetCurrentTask()
  20. #define GetWindowThread(h) GetWindowTask(h)
  21. #define LocalHandle(p) LocalHandle((UINT)(p))
  22. #define SETPVTBL(Name)
  23. // ------------------------------------
  24. // public includes
  25. #include <ole2anac.h>
  26. #include <ole2.h>
  27. #include <ole2sp.h>
  28. // ------------------------------------
  29. // internal includes
  30. #include <utils.h>
  31. #include <olecoll.h>
  32. #include <valid.h>
  33. #include <map_kv.h>
  34. #include <privguid.h>
  35. #ifndef _SIZE_T_DEFINED
  36. typedef unsigned int size_t;
  37. #define _SIZE_T_DEFINED
  38. #endif
  39. #if defined(_M_I86SM) || defined(_M_I86MM)
  40. #define _NEARDATA
  41. #endif
  42. #include <utstream.h>
  43. /*
  44. * Warning disables:
  45. *
  46. * We compile with warning level 4, with the following warnings
  47. * disabled:
  48. *
  49. * 4355: 'this' used in base member initializer list
  50. *
  51. * We don't see the point of this message and we do this all
  52. * the time.
  53. *
  54. * 4505: Unreferenced local function has been removed -- the given
  55. * function is local and not referenced in the body of the module.
  56. *
  57. * Unfortunately, this is generated for every inline function
  58. * seen in the header files that is not used in the module.
  59. * Since we use a number of inlines, this is a nuisance
  60. * warning. It would be nice if the compiler distinguished
  61. * between inlines and regular functions.
  62. *
  63. * 4706: Assignment within conditional expression.
  64. *
  65. * We use this style of programming extensively, so this
  66. * warning is disabled.
  67. */
  68. #pragma warning(disable:4355)
  69. #pragma warning(disable:4068)
  70. /*
  71. * MACROS for Mac/PC core code
  72. *
  73. * The following macros reduce the proliferation of #ifdefs. They
  74. * allow tagging a fragment of code as Mac only, PC only, or with
  75. * variants which differ on the PC and the Mac.
  76. *
  77. * Usage:
  78. *
  79. *
  80. * h = GetHandle();
  81. * Mac(DisposeHandle(h));
  82. *
  83. *
  84. * h = GetHandle();
  85. * MacWin(h2 = h, CopyHandle(h, h2));
  86. *
  87. */
  88. #define Mac(x)
  89. #define Win(x) x
  90. #define MacWin(x,y) y
  91. // Macros for Double-Byte Character Support
  92. // Beware of double evaluation
  93. #define IncLpch(sz) ((sz)=CharNext ((sz)))
  94. #define DecLpch(szStart, sz) ((sz)=CharPrev ((szStart),(sz)))
  95. /* dlls instance and module handles */
  96. extern HMODULE hmodOLE2;
  97. /* Variables for registered clipboard formats */
  98. extern CLIPFORMAT cfObjectLink;
  99. extern CLIPFORMAT cfOwnerLink;
  100. extern CLIPFORMAT cfNative;
  101. extern CLIPFORMAT cfLink;
  102. extern CLIPFORMAT cfBinary;
  103. extern CLIPFORMAT cfFileName;
  104. extern CLIPFORMAT cfNetworkName;
  105. extern CLIPFORMAT cfDataObject;
  106. extern CLIPFORMAT cfEmbeddedObject;
  107. extern CLIPFORMAT cfEmbedSource;
  108. extern CLIPFORMAT cfLinkSource;
  109. extern CLIPFORMAT cfOleDraw;
  110. extern CLIPFORMAT cfLinkSrcDescriptor;
  111. extern CLIPFORMAT cfObjectDescriptor;
  112. extern CLIPFORMAT cfCustomLinkSource;
  113. extern CLIPFORMAT cfPBrush;
  114. extern CLIPFORMAT cfMSDraw;
  115. /* Number of logical pixels per inch for current driver */
  116. extern int giPpliX;
  117. extern int giPpliY;
  118. /* Exported CLSIDs.. */
  119. #define CLSID_StaticMetafile CLSID_Picture_Metafile
  120. #define CLSID_StaticDib CLSID_Picture_Dib
  121. // special Assert for asserts below (since the expression is so large)
  122. #ifdef _DEBUG
  123. #define AssertOut(a, b) { if (!(a)) FnAssert(szCheckOutParam, b, _szAssertFile, __LINE__); }
  124. #else
  125. #define AssertOut(a, b) ((void)0)
  126. #endif
  127. #define AssertOutPtrParam(hr, p) \
  128. AssertOut(SUCCEEDED(hr) && IsValidPtrIn(p, sizeof(char)) || \
  129. FAILED(hr) && (p) == NULL, \
  130. szBadOutParam)
  131. #define AssertOutPtrIface(hr, p) \
  132. AssertOut(SUCCEEDED(hr) && IsValidInterface(p) || \
  133. FAILED(hr) && (p) == NULL, \
  134. szBadOutIface)
  135. #define AssertOutPtrFailed(p) \
  136. AssertOut((p) == NULL, \
  137. szNonNULLOutPtr)
  138. #define AssertOutStgmedium(hr, pstgm) \
  139. AssertOut(SUCCEEDED(hr) && (pstgm)->tymed != TYMED_NULL || \
  140. FAILED(hr) && (pstgm)->tymed == TYMED_NULL, \
  141. szBadOutStgm)
  142. // assert data for above assert out macros; once per dll
  143. #define ASSERTOUTDATA \
  144. char szCheckOutParam[] = "check out param"; \
  145. char szBadOutParam[] = "Out pointer param conventions not followed"; \
  146. char szBadOutIface[] = "Out pointer interface conventions not followed"; \
  147. char szNonNULLOutPtr[] = "Out pointer not NULL on error"; \
  148. char szBadOutStgm[] = "Out stgmed param conventions not followed";
  149. extern char szCheckOutParam[];
  150. extern char szBadOutParam[];
  151. extern char szBadOutIface[];
  152. extern char szNonNULLOutPtr[];
  153. extern char szBadOutStgm[];
  154. /***********************************************************************/
  155. /**** C++ memory management ****/
  156. /***********************************************************************/
  157. // these should never be called (and assert if they are)
  158. void * operator new(size_t size);
  159. void operator delete(void * ptr);
  160. void FAR* operator new(size_t size); // same as new (MEMCTX_TASK)
  161. void FAR* operator new(size_t size, DWORD memctx, void FAR* lpvSame=NULL);
  162. void operator delete(void FAR* ptr);
  163. // example usage:
  164. // lp = new(MEMCTX_TASK) CClass;
  165. // lp = new(MEMCTX_SHARED) CClass;
  166. // lp = new(MEMCTX_SAME, lpv) CClass;
  167. // MEMCTX for compobj internal memory (only used by compobj code)
  168. // NOTE: this value is not represented in the MEMCTX enum in compobj.h
  169. #define MEMCTX_COPRIVATE 5
  170. // exports from compobj.dll:
  171. // returns MEMCTX of existing pointer
  172. STDAPI_(DWORD) CoMemctxOf(void const FAR* lpv);
  173. STDAPI_(void FAR*) CoMemAlloc(ULONG cb ,DWORD memctx, void FAR* lpvSame);
  174. STDAPI_(void) CoMemFree(void FAR* lpv, DWORD memctx);
  175. // old names
  176. #define MemoryPlacement DWORD
  177. #define PlacementOf CoMemctxOf
  178. #define TASK MEMCTX_TASK, NULL
  179. #define SHARED MEMCTX_SHARED, NULL
  180. #define SAME MEMCTX_SAME, NULL
  181. /***********************************************************************/
  182. /**** FILE FORMAT RELATED INFO ****/
  183. /***********************************************************************/
  184. // Coponent object stream information
  185. #define COMPOBJ_STREAM "\1CompObj"
  186. #define BYTE_ORDER_INDICATOR 0xfffe // for MAC it could be different
  187. #define COMPOBJ_STREAM_VERSION 0x0001
  188. // OLE defines values for different OSs
  189. #define OS_WIN 0x0000
  190. #define OS_MAC 0x0001
  191. #define OS_NT 0x0002
  192. // HIGH WORD is OS indicator, LOW WORD is OS version number
  193. extern DWORD gdwOrgOSVersion;
  194. extern DWORD gdwOleVersion;
  195. // Ole streams information
  196. #define OLE_STREAM "\1Ole"
  197. #define OLE_PRODUCT_VERSION 0x0200 // (HIGH BYTE major version)
  198. #define OLE_STREAM_VERSION 0x0001
  199. #define OLE10_NATIVE_STREAM "\1Ole10Native"
  200. #define OLE10_ITEMNAME_STREAM "\1Ole10ItemName"
  201. #define OLE_PRESENTATION_STREAM "\2OlePres000"
  202. #define CONTENTS_STREAM "CONTENTS"
  203. /***********************************************************************
  204. Storage APIs internally used
  205. *************************************************************************/
  206. OLEAPI ReadClipformatStm(LPSTREAM lpstream, DWORD FAR* lpdwCf);
  207. OLEAPI WriteClipformatStm(LPSTREAM lpstream, CLIPFORMAT cf);
  208. OLEAPI WriteMonikerStm (LPSTREAM pstm, LPMONIKER pmk);
  209. OLEAPI ReadMonikerStm (LPSTREAM pstm, LPMONIKER FAR* pmk);
  210. OLEAPI_(LPSTREAM) CreateMemStm(DWORD cb, LPHANDLE phMem);
  211. OLEAPI_(LPSTREAM) CloneMemStm(HANDLE hMem);
  212. OLEAPI_(void) ReleaseMemStm (LPHANDLE hMem, BOOL fInternalOnly = FALSE);
  213. /*************************************************************************
  214. Initialization code for individual modules
  215. *************************************************************************/
  216. INTERNAL_(void) DDEWEP (
  217. BOOL fSystemExit
  218. );
  219. INTERNAL_(BOOL) DDELibMain (
  220. HANDLE hInst,
  221. WORD wDataSeg,
  222. WORD cbHeapSize,
  223. LPSTR lpszCmdLine
  224. );
  225. BOOL InitializeRunningObjectTable(void);
  226. void DestroyRunningObjectTable(void);
  227. #define BITMAP_TO_DIB(foretc) \
  228. if (foretc.cfFormat == CF_BITMAP) {\
  229. foretc.cfFormat = CF_DIB;\
  230. foretc.tymed = TYMED_HGLOBAL;\
  231. }
  232. #define VERIFY_ASPECT_SINGLE(dwAsp) {\
  233. if (!(dwAsp && !(dwAsp & (dwAsp-1)) && (dwAsp <= DVASPECT_DOCPRINT))) {\
  234. AssertSz(FALSE, "More than 1 aspect is specified");\
  235. return ResultFromScode(DV_E_DVASPECT);\
  236. }\
  237. }
  238. #define VERIFY_TYMED_SINGLE(tymed) {\
  239. if (!(tymed && !(tymed & (tymed-1)) && (tymed <= TYMED_MFPICT))) \
  240. return ResultFromScode(DV_E_TYMED); \
  241. }
  242. #define VERIFY_TYMED_SINGLE_VALID_FOR_CLIPFORMAT(pfetc) {\
  243. if ((pfetc->cfFormat==CF_METAFILEPICT && pfetc->tymed!=TYMED_MFPICT)\
  244. || (pfetc->cfFormat==CF_BITMAP && pfetc->tymed!=TYMED_GDI)\
  245. || (pfetc->cfFormat!=CF_METAFILEPICT && \
  246. pfetc->cfFormat!=CF_BITMAP && \
  247. pfetc->tymed!=TYMED_HGLOBAL))\
  248. return ResultFromScode(DV_E_TYMED); \
  249. }
  250. // REVIEW ...
  251. // Only DDE layer will test for these values. And only for advises on cached
  252. // formats do we use these values
  253. #define ADVFDDE_ONSAVE 0x40000000
  254. #define ADVFDDE_ONCLOSE 0x80000000
  255. // Used in Ole Private Stream
  256. typedef enum tagOBJFLAGS
  257. {
  258. OBJFLAGS_LINK=1L,
  259. OBJFLAGS_DOCUMENT=2L, // this bit is owned by container and is
  260. // propogated through saves
  261. OBJFLAGS_CONVERT=4L,
  262. } OBJFLAGS;
  263. /*****************************************
  264. Prototypes for dde\client\ddemnker.cpp
  265. ******************************************/
  266. INTERNAL DdeBindToObject
  267. (LPCSTR szFile,
  268. REFCLSID clsid,
  269. BOOL fPackageLink,
  270. LPBC pbc, // not used
  271. LPMONIKER pmkToLeft, // not used
  272. REFIID iid,
  273. LPLPVOID ppv);
  274. INTERNAL DdeIsRunning
  275. (CLSID clsid,
  276. LPCSTR szFile,
  277. LPBC pbc,
  278. LPMONIKER pmkToLeft,
  279. LPMONIKER pmkNewlyRunning);
  280. /**************************************
  281. Prototypes for moniker\mkparse.cpp
  282. ***************************************/
  283. INTERNAL Ole10_ParseMoniker
  284. (LPMONIKER pmk,
  285. LPSTR FAR* pszFile,
  286. LPSTR FAR* pszItem);
  287. /****************************************************************************/
  288. /* Utility APIs, might get exposed later */
  289. /****************************************************************************/
  290. OLEAPI OleGetData(LPDATAOBJECT lpDataObj, LPFORMATETC pformatetcIn,
  291. LPSTGMEDIUM pmedium, BOOL fGetOwnership);
  292. OLEAPI OleSetData(LPDATAOBJECT lpDataObj, LPFORMATETC pformatetc,
  293. STGMEDIUM FAR * pmedium, BOOL fRelease);
  294. STDAPI OleDuplicateMedium(LPSTGMEDIUM lpMediumSrc, LPSTGMEDIUM lpMediumDest);
  295. OLEAPI_(BOOL) OleIsDcMeta (HDC hdc);
  296. INTERNAL SzFixNet( LPBINDCTX pbc, LPSTR szUNCName, LPSTR FAR * lplpszReturn,
  297. UINT FAR * pEndServer, BOOL fForceConnection = TRUE);
  298. FARINTERNAL ReadFmtUserTypeProgIdStg
  299. (IStorage FAR * pstg,
  300. CLIPFORMAT FAR* pcf,
  301. LPSTR FAR* pszUserType,
  302. LPSTR szProgID);
  303. /****************************************************************************/
  304. /* Internal StubManager APIs, might get exposed later */
  305. /****************************************************************************/
  306. OLEAPI CoDisconnectWeakExternal(IUnknown FAR* pUnk, DWORD dwReserved);
  307. #pragma warning(disable: 4073) // disable warning about using init_seg
  308. #pragma init_seg(lib)
  309. #endif // _OLE2INT_H_