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.

547 lines
16 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. #ifndef _MAC
  17. #ifdef WIN32
  18. #define _INC_OLE // Don't include ole.h (ole2.h included below)
  19. #define __RPC_H__ // Don't include rpc.h (compobj.h included below)
  20. #endif
  21. #include <windows.h>
  22. #include <malloc.h>
  23. #include <shellapi.h>
  24. #else
  25. #include <mac.h>
  26. #endif
  27. #ifdef WIN32
  28. #define __loadds // Not used
  29. #define UnlockData(ds) // Not used
  30. #define GlobalLock(h) ((LPSTR) GlobalLock(h)) // Retunred type has changed
  31. #define _fmalloc malloc
  32. #define _frealloc realloc
  33. #define _ffree free
  34. #define _fmemset memset
  35. #define _fmemcpy memcpy
  36. #define _fmemcmp memcmp
  37. #define _fmemmove memmove
  38. #define _fstrcpy strcpy // - you should use strcpy
  39. #define _fstrcat strcat // - you should use strcat
  40. #define _fstrlen strlen // - you should use strlen
  41. #define _fstrchr strchr // - you should use strchr
  42. #define _fstrcmp strcmp // - you should use strcmp
  43. #define _fstrncmp strncmp // - you should use strncmp
  44. #define _fstricmp stricmp // - you should use stricmp
  45. #define _fstrnicmp strnicmp // - you should use strnicmp
  46. #define _fstrtok strtok // - you should use strtok
  47. #endif
  48. #ifdef WIN32
  49. #define HTASK DWORD // Use Proccess id / Thread id
  50. #define GetCurrentThread() GetCurrentThreadId()
  51. #define GetCurrentProcess() GetCurrentProcessId()
  52. #define GetWindowThread(h) ((HTASK)GetWindowTask(h))
  53. #else
  54. #define GetCurrentThread() GetCurrentTask()
  55. #define GetCurrentProcess() GetCurrentTask()
  56. #define GetWindowThread(h) GetWindowTask(h)
  57. #endif
  58. #ifdef WIN32
  59. #define LocalHandle(p) LocalHandle((void*)(p))
  60. #else
  61. #define LocalHandle(p) LocalHandle((UINT)(p))
  62. #endif
  63. #ifdef WIN32
  64. #define SetWindowOrg(h,x,y) SetWindowOrgEx((h),(x),(y),NULL)
  65. #define SetWindowExt(h,x,y) SetWindowExtEx((h),(x),(y),NULL)
  66. #define SetViewportOrg(h,x,y) SetViewportOrgEx((h),(x),(y),NULL)
  67. #define SetViewportExt(h,x,y) SetViewportExtEx((h),(x),(y),NULL)
  68. #define SetBitmapDimension(h,x,y) SetBitmapDimensionEx((h),(x),(y),NULL)
  69. #endif
  70. #ifdef WIN32
  71. #define WEP_FREE_DLL 0
  72. #define WEP_SYSTEM_EXIT 1
  73. #endif
  74. #ifdef WIN32
  75. // "BarryM needs to look at this
  76. // Probably reverse the logic (that is do path to drive index translation
  77. // within a GetDriveTypeEx(char FAR* pszRoot))
  78. // This also is used by dde code"
  79. //
  80. // 15-Feb-2000 At this point changing anything would break more than it
  81. // helped.
  82. //
  83. inline UINT GetDriveType16(int i)
  84. {
  85. char s[4];
  86. if (i < 0 || i > 26)
  87. return 0;
  88. s[0] = i + 'A'; s[1] = ':'; s[2] = '\\'; s[3] = '\0';
  89. return GetDriveTypeA(s); // GetDriveType already mapped to GetDriveType16
  90. }
  91. #undef GetDriveType // Remove mapping to GetDriveTypeA
  92. #define GetDriveType(i) GetDriveType16(i)
  93. #endif
  94. #ifdef WIN32
  95. #undef RegQueryValue // Remove mapping to RegQueryValueA
  96. #define RegQueryValue(hkey,lpszKey,lpszVal,lpcb) \
  97. RegQueryValueA((hkey),(lpszKey),(lpszVal),((DWORD*) (lpcb)))
  98. #undef RegOpenKey // Remove mapping to RegOpenKeyA
  99. #define RegOpenKey(hkey,lpszSubKey,phkey) \
  100. RegOpenKeyA((hkey),((LPSTR)(lpszSubKey)),(phkey))
  101. #endif
  102. #ifdef WIN32
  103. extern void *pvtblIDebug;
  104. extern void *pvtblCBaseMoniker;
  105. extern void *pvtblCFileMoniker;
  106. extern void *pvtblCItemMoniker;
  107. extern void *pvtblCCompositeMoniker;
  108. extern void *pvtblCAntiMoniker;
  109. extern void *pvtblCPointerMoniker;
  110. extern void *pvtblCRunningObjectTable;
  111. extern void *pvtblCROTEnumMoniker;
  112. extern void SetpVtbl(void *pvtbl);
  113. #define SETPVTBL(Name) if (PlacementOf(this) == SHARED) SetpVtbl(pvtbl##Name)
  114. #else
  115. #define SETPVTBL(Name)
  116. #endif
  117. // ------------------------------------
  118. // public includes
  119. #include <ole2anac.h>
  120. #include <ole2.h>
  121. #include <cobjps.h>
  122. #include <ole2sp.h>
  123. // ------------------------------------
  124. // internal includes
  125. #include <olemem.h>
  126. #include <cmacs.h>
  127. #include <utils.h>
  128. #include <olecoll.h>
  129. #include <valid.h>
  130. #include <array_fv.h>
  131. #include <map_kv.h>
  132. #include <privguid.h>
  133. #ifndef _SIZE_T_DEFINED
  134. typedef unsigned int size_t;
  135. #define _SIZE_T_DEFINED
  136. #endif
  137. #if defined(_M_I86SM) || defined(_M_I86MM)
  138. #define _NEARDATA
  139. #endif
  140. #include <utstream.h>
  141. /*
  142. * Warning disables:
  143. *
  144. * We compile with warning level 4, with the following warnings
  145. * disabled:
  146. *
  147. * 4355: 'this' used in base member initializer list
  148. *
  149. * We don't see the point of this message and we do this all
  150. * the time.
  151. *
  152. * 4505: Unreferenced local function has been removed -- the given
  153. * function is local and not referenced in the body of the module.
  154. *
  155. * Unfortunately, this is generated for every inline function
  156. * seen in the header files that is not used in the module.
  157. * Since we use a number of inlines, this is a nuisance
  158. * warning. It would be nice if the compiler distinguished
  159. * between inlines and regular functions.
  160. *
  161. * 4706: Assignment within conditional expression.
  162. *
  163. * We use this style of programming extensively, so this
  164. * warning is disabled.
  165. */
  166. #pragma warning(disable:4355)
  167. #pragma warning(disable:4068)
  168. /*
  169. * MACROS for Mac/PC core code
  170. *
  171. * The following macros reduce the proliferation of #ifdefs. They
  172. * allow tagging a fragment of code as Mac only, PC only, or with
  173. * variants which differ on the PC and the Mac.
  174. *
  175. * Usage:
  176. *
  177. *
  178. * h = GetHandle();
  179. * Mac(DisposeHandle(h));
  180. *
  181. *
  182. * h = GetHandle();
  183. * MacWin(h2 = h, CopyHandle(h, h2));
  184. *
  185. */
  186. #ifdef _MAC
  187. #define Mac(x) x
  188. #define Win(x)
  189. #define MacWin(x,y) x
  190. #else
  191. #define Mac(x)
  192. #define Win(x) x
  193. #define MacWin(x,y) y
  194. #endif
  195. // Macros for Double-Byte Character Support
  196. #ifdef _MAC
  197. #define IncLpch IncLpch
  198. #define DecLpch DecLpch
  199. #else
  200. // Beware of double evaluation
  201. #define IncLpch(sz) ((sz)=CharNext ((sz)))
  202. #define DecLpch(szStart, sz) ((sz)=CharPrev ((szStart),(sz)))
  203. #endif
  204. #ifndef _MAC
  205. /* dlls instance and module handles */
  206. extern HMODULE hmodOLE2;
  207. /* Variables for registered clipboard formats */
  208. extern CLIPFORMAT cfObjectLink;
  209. extern CLIPFORMAT cfOwnerLink;
  210. extern CLIPFORMAT cfNative;
  211. extern CLIPFORMAT cfLink;
  212. extern CLIPFORMAT cfBinary;
  213. extern CLIPFORMAT cfFileName;
  214. extern CLIPFORMAT cfNetworkName;
  215. extern CLIPFORMAT cfDataObject;
  216. extern CLIPFORMAT cfEmbeddedObject;
  217. extern CLIPFORMAT cfEmbedSource;
  218. extern CLIPFORMAT cfLinkSource;
  219. extern CLIPFORMAT cfOleDraw;
  220. extern CLIPFORMAT cfLinkSrcDescriptor;
  221. extern CLIPFORMAT cfObjectDescriptor;
  222. extern CLIPFORMAT cfCustomLinkSource;
  223. extern CLIPFORMAT cfPBrush;
  224. extern CLIPFORMAT cfMSDraw;
  225. #endif
  226. /* Number of logical pixels per inch for current driver */
  227. extern int giPpliX;
  228. extern int giPpliY;
  229. /* Exported CLSIDs.. */
  230. #define CLSID_StaticMetafile CLSID_Picture_Metafile
  231. #define CLSID_StaticDib CLSID_Picture_Dib
  232. // special Assert for asserts below (since the expression is so large)
  233. #ifdef _DEBUG
  234. #define AssertOut(a, b) { if (!(a)) FnAssert(szCheckOutParam, b, _szAssertFile, __LINE__); }
  235. #else
  236. #define AssertOut(a, b) ((void)0)
  237. #endif
  238. #define AssertOutPtrParam(hr, p) \
  239. AssertOut(SUCCEEDED(hr) && IsValidPtrIn(p, sizeof(char)) || \
  240. FAILED(hr) && (p) == NULL, \
  241. szBadOutParam)
  242. #define AssertOutPtrIface(hr, p) \
  243. AssertOut(SUCCEEDED(hr) && IsValidInterface(p) || \
  244. FAILED(hr) && (p) == NULL, \
  245. szBadOutIface)
  246. #define AssertOutPtrFailed(p) \
  247. AssertOut((p) == NULL, \
  248. szNonNULLOutPtr)
  249. #define AssertOutStgmedium(hr, pstgm) \
  250. AssertOut(SUCCEEDED(hr) && (pstgm)->tymed != TYMED_NULL || \
  251. FAILED(hr) && (pstgm)->tymed == TYMED_NULL, \
  252. szBadOutStgm)
  253. // assert data for above assert out macros; once per dll
  254. #define ASSERTOUTDATA \
  255. char szCheckOutParam[] = "check out param"; \
  256. char szBadOutParam[] = "Out pointer param conventions not followed"; \
  257. char szBadOutIface[] = "Out pointer interface conventions not followed"; \
  258. char szNonNULLOutPtr[] = "Out pointer not NULL on error"; \
  259. char szBadOutStgm[] = "Out stgmed param conventions not followed";
  260. extern char szCheckOutParam[];
  261. extern char szBadOutParam[];
  262. extern char szBadOutIface[];
  263. extern char szNonNULLOutPtr[];
  264. extern char szBadOutStgm[];
  265. /***********************************************************************/
  266. /**** C++ memory management ****/
  267. /***********************************************************************/
  268. // these should never be called (and assert if they are)
  269. void * operator new(size_t size);
  270. void operator delete(void * ptr);
  271. void FAR* operator new(size_t size); // same as new (MEMCTX_TASK)
  272. void FAR* operator new(size_t size, DWORD memctx, void FAR* lpvSame=NULL);
  273. void operator delete(void FAR* ptr);
  274. // example usage:
  275. // lp = new(MEMCTX_TASK) CClass;
  276. // lp = new(MEMCTX_SHARED) CClass;
  277. // lp = new(MEMCTX_SAME, lpv) CClass;
  278. // MEMCTX for compobj internal memory (only used by compobj code)
  279. // NOTE: this value is not represented in the MEMCTX enum in compobj.h
  280. #define MEMCTX_COPRIVATE 5
  281. // exports from compobj.dll:
  282. // returns MEMCTX of existing pointer
  283. STDAPI_(DWORD) CoMemctxOf(void const FAR* lpv);
  284. STDAPI_(void FAR*) CoMemAlloc(ULONG cb ,DWORD memctx, void FAR* lpvSame);
  285. STDAPI_(void) CoMemFree(void FAR* lpv, DWORD memctx);
  286. // old names
  287. #define MemoryPlacement DWORD
  288. #define PlacementOf CoMemctxOf
  289. #define TASK MEMCTX_TASK, NULL
  290. #define SHARED MEMCTX_SHARED, NULL
  291. #define SAME MEMCTX_SAME, NULL
  292. /***********************************************************************/
  293. /**** FILE FORMAT RELATED INFO ****/
  294. /***********************************************************************/
  295. // Coponent object stream information
  296. #define COMPOBJ_STREAM "\1CompObj"
  297. #define BYTE_ORDER_INDICATOR 0xfffe // for MAC it could be different
  298. #define COMPOBJ_STREAM_VERSION 0x0001
  299. // OLE defines values for different OSs
  300. #define OS_WIN 0x0000
  301. #define OS_MAC 0x0001
  302. #define OS_NT 0x0002
  303. // HIGH WORD is OS indicator, LOW WORD is OS version number
  304. extern DWORD gdwOrgOSVersion;
  305. extern DWORD gdwOleVersion;
  306. // Ole streams information
  307. #define OLE_STREAM "\1Ole"
  308. #define OLE_PRODUCT_VERSION 0x0200 // (HIGH BYTE major version)
  309. #define OLE_STREAM_VERSION 0x0001
  310. #define OLE10_NATIVE_STREAM "\1Ole10Native"
  311. #define OLE10_ITEMNAME_STREAM "\1Ole10ItemName"
  312. #define OLE_PRESENTATION_STREAM "\2OlePres000"
  313. #define CONTENTS_STREAM "CONTENTS"
  314. /***********************************************************************
  315. Storage APIs internally used
  316. *************************************************************************/
  317. OLEAPI ReadClipformatStm(LPSTREAM lpstream, DWORD FAR* lpdwCf);
  318. OLEAPI WriteClipformatStm(LPSTREAM lpstream, CLIPFORMAT cf);
  319. OLEAPI WriteMonikerStm (LPSTREAM pstm, LPMONIKER pmk);
  320. OLEAPI ReadMonikerStm (LPSTREAM pstm, LPMONIKER FAR* pmk);
  321. OLEAPI_(LPSTREAM) CreateMemStm(DWORD cb, LPHANDLE phMem);
  322. OLEAPI_(LPSTREAM) CloneMemStm(HANDLE hMem);
  323. OLEAPI_(void) ReleaseMemStm (LPHANDLE hMem, BOOL fInternalOnly = FALSE);
  324. /*************************************************************************
  325. Initialization code for individual modules
  326. *************************************************************************/
  327. INTERNAL_(void) DDEWEP (
  328. BOOL fSystemExit
  329. );
  330. INTERNAL_(BOOL) DDELibMain (
  331. HANDLE hInst,
  332. WORD wDataSeg,
  333. WORD cbHeapSize,
  334. LPSTR lpszCmdLine
  335. );
  336. BOOL InitializeRunningObjectTable(void);
  337. void DestroyRunningObjectTable(void);
  338. #ifdef _MAC
  339. #define BITMAP_TO_DIB(foretc)
  340. #else
  341. #define BITMAP_TO_DIB(foretc) \
  342. if (foretc.cfFormat == CF_BITMAP) {\
  343. foretc.cfFormat = CF_DIB;\
  344. foretc.tymed = TYMED_HGLOBAL;\
  345. }
  346. #endif
  347. #define VERIFY_ASPECT_SINGLE(dwAsp) {\
  348. if (!(dwAsp && !(dwAsp & (dwAsp-1)) && (dwAsp <= DVASPECT_DOCPRINT))) {\
  349. AssertSz(FALSE, "More than 1 aspect is specified");\
  350. return ResultFromScode(DV_E_DVASPECT);\
  351. }\
  352. }
  353. #define VERIFY_TYMED_SINGLE(tymed) {\
  354. if (!(tymed && !(tymed & (tymed-1)) && (tymed <= TYMED_MFPICT))) \
  355. return ResultFromScode(DV_E_TYMED); \
  356. }
  357. #define VERIFY_TYMED_SINGLE_VALID_FOR_CLIPFORMAT(pfetc) {\
  358. if ((pfetc->cfFormat==CF_METAFILEPICT && pfetc->tymed!=TYMED_MFPICT)\
  359. || (pfetc->cfFormat==CF_BITMAP && pfetc->tymed!=TYMED_GDI)\
  360. || (pfetc->cfFormat!=CF_METAFILEPICT && \
  361. pfetc->cfFormat!=CF_BITMAP && \
  362. pfetc->tymed!=TYMED_HGLOBAL))\
  363. return ResultFromScode(DV_E_TYMED); \
  364. }
  365. // REVIEW ...
  366. // Only DDE layer will test for these values. And only for advises on cached
  367. // formats do we use these values
  368. #define ADVFDDE_ONSAVE 0x40000000
  369. #define ADVFDDE_ONCLOSE 0x80000000
  370. // Used in Ole Private Stream
  371. typedef enum tagOBJFLAGS
  372. {
  373. OBJFLAGS_LINK=1L,
  374. OBJFLAGS_DOCUMENT=2L, // this bit is owned by container and is
  375. // propogated through saves
  376. OBJFLAGS_CONVERT=4L,
  377. } OBJFLAGS;
  378. /*****************************************
  379. Prototypes for dde\client\ddemnker.cpp
  380. ******************************************/
  381. INTERNAL DdeBindToObject
  382. (LPCSTR szFile,
  383. REFCLSID clsid,
  384. BOOL fPackageLink,
  385. LPBC pbc, // not used
  386. LPMONIKER pmkToLeft, // not used
  387. REFIID iid,
  388. LPLPVOID ppv);
  389. INTERNAL DdeIsRunning
  390. (CLSID clsid,
  391. LPCSTR szFile,
  392. LPBC pbc,
  393. LPMONIKER pmkToLeft,
  394. LPMONIKER pmkNewlyRunning);
  395. /**************************************
  396. Prototypes for moniker\mkparse.cpp
  397. ***************************************/
  398. INTERNAL Ole10_ParseMoniker
  399. (LPMONIKER pmk,
  400. LPSTR FAR* pszFile,
  401. LPSTR FAR* pszItem);
  402. /****************************************************************************/
  403. /* Utility APIs, might get exposed later */
  404. /****************************************************************************/
  405. OLEAPI OleGetData(LPDATAOBJECT lpDataObj, LPFORMATETC pformatetcIn,
  406. LPSTGMEDIUM pmedium, BOOL fGetOwnership);
  407. OLEAPI OleSetData(LPDATAOBJECT lpDataObj, LPFORMATETC pformatetc,
  408. STGMEDIUM FAR * pmedium, BOOL fRelease);
  409. STDAPI OleDuplicateMedium(LPSTGMEDIUM lpMediumSrc, LPSTGMEDIUM lpMediumDest);
  410. OLEAPI_(BOOL) OleIsDcMeta (HDC hdc);
  411. INTERNAL SzFixNet( LPBINDCTX pbc, LPSTR szUNCName, LPSTR FAR * lplpszReturn,
  412. UINT FAR * pEndServer, BOOL fForceConnection = TRUE);
  413. FARINTERNAL ReadFmtUserTypeProgIdStg
  414. (IStorage FAR * pstg,
  415. CLIPFORMAT FAR* pcf,
  416. LPSTR FAR* pszUserType,
  417. LPSTR szProgID);
  418. /****************************************************************************/
  419. /* Internal StubManager APIs, might get exposed later */
  420. /****************************************************************************/
  421. OLEAPI CoDisconnectWeakExternal(IUnknown FAR* pUnk, DWORD dwReserved);
  422. #pragma warning(disable: 4073) // disable warning about using init_seg
  423. #pragma init_seg(lib)
  424. #include "ole2segs.h"
  425. #include "cosegs.h"
  426. #include "prxsegs.h"
  427. #endif // _OLE2INT_H_