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.

873 lines
28 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: ole2com.h
  7. //
  8. // Contents: Common definitions shared by com and ole232
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 4-26-94 kevinro Created
  15. // 06-16-94 AlexT Add FnAssert prototype
  16. // 07-26-94 AlexGo Added CStabilize and CSafeRefCount
  17. // 21-Dec-94 BruceMa Wrap mbstowcs and wcstombs
  18. // 23-Jan-95 t-ScottH added Dump method to CSafeRefCount
  19. // 08-Sep-95 murthys Added declarations for compapi worker
  20. // used by com, stg, scm etc
  21. //
  22. // Notes:
  23. // There are two versions of ole2int.h in the project. This is
  24. // unfortunate, but would be a major pain in the butt to fix.
  25. // What I have done is to extract the share parts of the two files,
  26. // and put them in this file. ole2int.h then includes this file.
  27. //
  28. // Someday, somebody should reconcile all of the differences between the
  29. // two ole2int.h files, and rename them. Don't have time for that now,
  30. // so I have gone for the path of least resistance.
  31. // KevinRo
  32. //----------------------------------------------------------------------------
  33. #ifndef _OLE2COM_H_
  34. #define _OLE2COM_H_
  35. #include <memapi.hxx>
  36. //
  37. // common compobj API worker functions used by com, stg, scm etc
  38. //
  39. // These definitions are shared between all of the components of OLE that
  40. // use the common directory, such as SCM and COMPOBJ
  41. //
  42. // format for string form of GUID is (leading identifier ????)
  43. // ????{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}
  44. #define GUIDSTR_MAX (1+ 8 + 1 + 4 + 1 + 4 + 1 + 4 + 1 + 12 + 1 + 1)
  45. #define CLSIDSTR_MAX (GUIDSTR_MAX)
  46. #define IIDSTR_MAX (GUIDSTR_MAX)
  47. //
  48. // Internal values used between OLE32 and SCM
  49. //
  50. #define APT_THREADED 0
  51. #define FREE_THREADED 1
  52. #define SINGLE_THREADED 2
  53. #define BOTH_THREADED 3
  54. #define NEUTRAL_THREADED 4
  55. #define GOT_FROM_ROT 0x80000000
  56. //
  57. // Internal CLSCTX used for loading Proxy/Stub DLLs
  58. //
  59. #define CLSCTX_PS_DLL 0x80000000
  60. //
  61. // The following flags are used to support loading INPROC items into 16-bit DLL's
  62. //
  63. #define CLSCTX_INPROC_HANDLERS (CLSCTX_INPROC_HANDLER16 | CLSCTX_INPROC_HANDLER)
  64. #define CLSCTX_INPROC_SERVERS (CLSCTX_INPROC_SERVER16 | CLSCTX_INPROC_SERVER | CLSCTX_PS_DLL)
  65. // "common" compapi worker functions
  66. INTERNAL_(int) wStringFromGUID2(REFGUID rguid, LPWSTR lpsz, int cbMax);
  67. INTERNAL wStringFromUUID(REFGUID rguid, LPWSTR lpsz);
  68. void FormatHexNumW( unsigned long ulValue, unsigned long chChars, WCHAR *pwcStr);
  69. void FormatHexNumA( unsigned long ulValue, unsigned long chChars, char *pchStr);
  70. #define wStringFromGUID2T wStringFromGUID2
  71. BOOL wThreadModelMatch(DWORD dwCallerThreadModel,DWORD dwDllThreadModel,DWORD dwContext);
  72. LONG wQueryStripRegValue(HKEY hkey,LPCWSTR pwszSubKey,LPTSTR pwszValue, PLONG pcbValue);
  73. LONG wGetDllInfo(HKEY hClsRegEntry,LPCWSTR pwszKey,LPTSTR pwszDllName,LONG *pclDllName,ULONG *pulDllThreadType);
  74. BOOL wCompareDllName(LPCWSTR pwszPath, LPCWSTR pwszDllName, DWORD dwDllNameLen);
  75. // compapi worker functions
  76. INTERNAL wIsInternalProxyStubIID(REFIID riid, LPCLSID lpclsid);
  77. INTERNAL wCoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew);
  78. INTERNAL wCLSIDFromOle1Class(LPCWSTR lpsz, LPCLSID lpclsid, BOOL fForceAssign=FALSE);
  79. INTERNAL wCLSIDFromString(LPWSTR lpsz, LPCLSID lpclsid);
  80. #define wCLSIDFromProgID wCLSIDFromOle1Class
  81. INTERNAL_(int) wOle1ClassFromCLSID2(REFCLSID rclsid, LPWSTR lpsz, int cbMax);
  82. INTERNAL wCoGetTreatAsClass(REFCLSID clsidOld, LPCLSID lpClsidNew);
  83. INTERNAL wRegQueryPSClsid(REFIID riid, LPCLSID lpclsid);
  84. INTERNAL wRegQuerySyncIIDFromAsyncIID(REFIID riid, LPCLSID lpiidSync);
  85. INTERNAL wRegQueryAsyncIIDFromSyncIID(REFIID riid, LPCLSID lpiidAsync);
  86. INTERNAL wCoGetPSClsid(REFIID riid, LPCLSID lpclsid);
  87. INTERNAL wCoGetClassExt(LPCWSTR pwszExt, LPCLSID pclsid);
  88. INTERNAL wRegGetClassExt(LPCWSTR lpszExt, LPCLSID pclsid);
  89. INTERNAL wCoGetClassPattern(HANDLE hfile, CLSID *pclsid);
  90. INTERNAL wCoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwContext, REFIID riid, LPVOID FAR* ppv);
  91. INTERNAL_(HRESULT) wCoMarshalInterThreadInterfaceInStream(REFIID riid, LPUNKNOWN pUnk, LPSTREAM *ppStm);
  92. INTERNAL_(HRESULT) wCoGetInterfaceAndReleaseStream(LPSTREAM pstm, REFIID riid, LPVOID *ppv);
  93. INTERNAL_(BOOL) wGUIDFromString(LPCWSTR lpsz, LPGUID pguid);
  94. INTERNAL_(BOOL) wUUIDFromString(LPCWSTR lpsz, LPGUID pguid);
  95. INTERNAL wStringFromCLSID(REFCLSID rclsid, LPWSTR FAR* lplpsz);
  96. INTERNAL wStringFromIID(REFIID rclsid, LPWSTR FAR* lplpsz);
  97. INTERNAL wIIDFromString(LPWSTR lpsz, LPIID lpiid);
  98. INTERNAL_(BOOL) wCoIsOle1Class(REFCLSID rclsid);
  99. INTERNAL wkProgIDFromCLSID(REFCLSID rclsid, LPWSTR FAR* ppszProgID);
  100. INTERNAL wRegOpenClassKey(REFCLSID clsid, REGSAM samDesired, HKEY FAR* lphkeyClsid);
  101. INTERNAL wRegOpenClassSubkey(REFCLSID rclsid, LPCWSTR lpszSubkey, HKEY *phkeySubkey);
  102. INTERNAL wRegOpenFileExtensionKey(LPCWSTR pszFileExt, HKEY FAR* lphkeyClsid);
  103. INTERNAL wRegOpenInterfaceKey(REFIID riid, HKEY * lphkeyIID);
  104. INTERNAL wRegOpenProgIDKey(LPCWSTR pszProgID, HKEY FAR* lphkeyClsid);
  105. INTERNAL wRegQueryClassValue(REFCLSID rclsid, LPCWSTR lpszSubKey,
  106. LPWSTR lpszValue, int cbMax);
  107. INTERNAL_(LONG) wRegOpenKeyEx(
  108. HKEY hKey,
  109. LPCWSTR lpSubKey,
  110. DWORD ulOptions,
  111. REGSAM samDesired,
  112. PHKEY phkResult);
  113. //
  114. // There are two sets of possible keys. There are the 32 bit, as well as
  115. // the 16 bit
  116. //
  117. const WCHAR wszCLSID[] = L"CLSID";
  118. const WCHAR wszInprocServer[] = L"InprocServer32";
  119. const WCHAR wszInprocHandler[] = L"InprocHandler32";
  120. const WCHAR wszLocalServer[] = L"LocalServer32";
  121. const WCHAR wszActivateAtBits[] = L"ActivateAtBits";
  122. const WCHAR wszActivateRemote[] = L"Remote";
  123. const WCHAR wszDebug[] = L"Debug";
  124. const WCHAR wszLocalServer16[] = L"LocalServer";
  125. const WCHAR wszInprocServer16[] = L"InprocServer";
  126. const WCHAR wszInprocHandler16[] = L"InprocHandler";
  127. const WCHAR wszOle2Dll[] = L"OLE2.DLL";
  128. #define OLE2_DLL wszOle2Dll
  129. #define OLE2_BYTE_LEN sizeof(OLE2_DLL)
  130. #define OLE2_CHAR_LEN (sizeof(OLE2_DLL) / sizeof(WCHAR) - 1)
  131. const WCHAR wszCLSIDBACK[] = L"CLSID\\";
  132. #define CLSIDBACK wszCLSIDBACK
  133. #define CLSIDBACK_BYTE_LEN sizeof(CLSIDBACK)
  134. #define CLSIDBACK_CHAR_LEN (sizeof(CLSIDBACK) / sizeof(WCHAR) - 1)
  135. #define KEY_LEN 256 // max size of registry key
  136. #define VALUE_LEN 256 // max size of registry value
  137. #ifdef _CAIRO_
  138. #define _DCOM_ // enable definition of Cairo OLE COM extensions
  139. #include <oleext.h>
  140. #else
  141. // These API's are exposed for Cairo but not for Daytona, so we declare
  142. // them here for internal users
  143. WINOLEAPI OleInitializeEx(LPVOID pvReserved, DWORD);
  144. WINOLEAPI CoGetPersistentInstance(
  145. REFIID riid,
  146. DWORD dwCtrl,
  147. DWORD grfMode,
  148. OLECHAR *pwszName,
  149. struct IStorage *pstg,
  150. REFCLSID rclsidOle1,
  151. BOOL * pfOle1Loaded,
  152. void **ppvUnk);
  153. #endif
  154. //
  155. // No longer in the Cairo DEF file. We want to remove this as soon as
  156. // oleutest can be changed to not use it.
  157. //
  158. WINOLEAPI CoNewPersistentInstance(
  159. REFCLSID rclsid,
  160. REFIID riid,
  161. DWORD dwCtrl,
  162. DWORD grfMode,
  163. OLECHAR *pwszCreateFrom,
  164. struct IStorage *pstgCreateFrom,
  165. OLECHAR *pwszNewName,
  166. void **ppunk);
  167. #if DBG==1
  168. STDAPI FnAssert(LPSTR lpstrExpr, LPSTR lpstrMsg, LPSTR lpstrFileName, UINT iLine);
  169. ULONG GetInfoLevel(CHAR *pszKey, ULONG *pulValue, CHAR *pszdefval);
  170. void StgDebugInit(void);
  171. #endif
  172. //
  173. // The Storage entry points that are called from OLE entry points.
  174. //
  175. HRESULT Storage32DllGetClassObject(REFCLSID clsid, REFIID riid, void **ppv);
  176. STDAPI Storage32DllRegisterServer(void);
  177. #if defined(_M_I86SM) || defined(_M_I86MM)
  178. #define _NEARDATA
  179. #endif
  180. #ifdef WIN32
  181. #define HTASK DWORD // Use Proccess id / Thread id
  182. #endif
  183. #ifdef WIN32
  184. // we have to define these because they have been deleted from
  185. // win32s, where only the ...Ex versions exist anymore.
  186. // Now, that's backward compatibility!
  187. # define SetWindowOrg(h,x,y) SetWindowOrgEx((h),(x),(y),NULL)
  188. # define SetWindowExt(h,x,y) SetWindowExtEx((h),(x),(y),NULL)
  189. # define SetViewportOrg(h,x,y) SetViewportOrgEx((h),(x),(y),NULL)
  190. # define SetViewportExt(h,x,y) SetViewportExtEx((h),(x),(y),NULL)
  191. # define SetBitmapDimension(h,x,y) SetBitmapDimensionEx((h),(x),(y),NULL)
  192. #endif
  193. #ifdef WIN32
  194. # define _xstrcpy lstrcpyW
  195. # define _xstrcat lstrcatW
  196. # define _xstrlen lstrlenW
  197. # define _xstrchr wcschr
  198. # define _xstrcmp lstrcmpW
  199. # define _xstricmp lstrcmpiW
  200. # define _xstrtok wcstok
  201. # define _xisdigit(c) (IsCharAlphaNumericW(c) && !IsCharAlphaW(c))
  202. #else // !WIN32
  203. # define _xstrcpy _fstrcpy
  204. # define _xstrcat _fstrcat
  205. # define _xstrlen _fstrlen
  206. # define _xstrchr _fstrchr
  207. # define _xstrcmp _fstrcmp
  208. # define _xstricmp _fstricmp
  209. # define _xstrtok _fstrtok
  210. # define _xisdigit(c) isdigit(c)
  211. #endif // WIN32
  212. //+----------------------------------------------------------------------------
  213. //
  214. // Macro:
  215. // GETPPARENT
  216. //
  217. // Synopsis:
  218. // Given a pointer to something contained by a struct (or
  219. // class,) the type name of the containing struct (or class),
  220. // and the name of the member being pointed to, return a pointer
  221. // to the container.
  222. //
  223. // Arguments:
  224. // [pmemb] -- pointer to member of struct (or class.)
  225. // [struc] -- type name of containing struct (or class.)
  226. // [membname] - name of member within the struct (or class.)
  227. //
  228. // Returns:
  229. // pointer to containing struct (or class)
  230. //
  231. // Notes:
  232. // Assumes all pointers are FAR.
  233. //
  234. // History:
  235. // 11/10/93 - ChrisWe - created
  236. //
  237. //-----------------------------------------------------------------------------
  238. #define GETPPARENT(pmemb, struc, membname) (\
  239. (struc FAR *)(((char FAR *)(pmemb))-offsetof(struc, membname)))
  240. //STDSTATIC is intended to be used for static class methods
  241. //only!!
  242. #define STDSTATIC_(type) static type EXPORT
  243. #define STDSTATICIMP_(type) type EXPORT
  244. #ifdef WIN32
  245. # define WEP_FREE_DLL 0
  246. # define WEP_SYSTEM_EXIT 1
  247. #endif
  248. #ifndef _MAC
  249. /* dll's instance and module handles */
  250. extern HMODULE g_hmodOLE2;
  251. extern HINSTANCE g_hinst;
  252. /* Variables for registered clipboard formats */
  253. extern CLIPFORMAT g_cfObjectLink;
  254. extern CLIPFORMAT g_cfOwnerLink;
  255. extern CLIPFORMAT g_cfNative;
  256. extern CLIPFORMAT g_cfLink;
  257. extern CLIPFORMAT g_cfBinary;
  258. extern CLIPFORMAT g_cfFileName;
  259. extern CLIPFORMAT g_cfFileNameW;
  260. extern CLIPFORMAT g_cfNetworkName;
  261. extern CLIPFORMAT g_cfDataObject;
  262. extern CLIPFORMAT g_cfEmbeddedObject;
  263. extern CLIPFORMAT g_cfEmbedSource;
  264. extern CLIPFORMAT g_cfLinkSource;
  265. extern CLIPFORMAT g_cfOleDraw;
  266. extern CLIPFORMAT g_cfLinkSrcDescriptor;
  267. extern CLIPFORMAT g_cfObjectDescriptor;
  268. extern CLIPFORMAT g_cfCustomLinkSource;
  269. extern CLIPFORMAT g_cfPBrush;
  270. extern CLIPFORMAT g_cfMSDraw;
  271. extern CLIPFORMAT g_cfOlePrivateData;
  272. extern CLIPFORMAT g_cfScreenPicture; // used for XL and Word hack
  273. // see clipapi.cpp
  274. extern CLIPFORMAT g_cfOleClipboardPersistOnFlush;
  275. extern CLIPFORMAT g_cfMoreOlePrivateData;
  276. #endif // _MAC
  277. #include <utstream.h>
  278. /*
  279. * Warning disables:
  280. *
  281. * We compile with warning level 4, with the following warnings
  282. * disabled:
  283. *
  284. * 4355: 'this' used in base member initializer list
  285. *
  286. * We don't see the point of this message and we do this all
  287. * the time.
  288. *
  289. * 4505: Unreferenced local function has been removed -- the given
  290. * function is local and not referenced in the body of the module.
  291. *
  292. * Unfortunately, this is generated for every inline function
  293. * seen in the header files that is not used in the module.
  294. * Since we use a number of inlines, this is a nuisance
  295. * warning. It would be nice if the compiler distinguished
  296. * between inlines and regular functions.
  297. *
  298. * 4706: Assignment within conditional expression.
  299. *
  300. * We use this style of programming extensively, so this
  301. * warning is disabled.
  302. */
  303. #pragma warning(disable:4355)
  304. #pragma warning(disable:4068)
  305. /*
  306. * MACROS for Mac/PC core code
  307. *
  308. * The following macros reduce the proliferation of #ifdefs. They
  309. * allow tagging a fragment of code as Mac only, PC only, or with
  310. * variants which differ on the PC and the Mac.
  311. *
  312. * Usage:
  313. *
  314. *
  315. * h = GetHandle();
  316. * Mac(DisposeHandle(h));
  317. *
  318. *
  319. * h = GetHandle();
  320. * MacWin(h2 = h, CopyHandle(h, h2));
  321. *
  322. */
  323. #ifdef _MAC
  324. #define Mac(x) x
  325. #define Win(x)
  326. #define MacWin(x,y) x
  327. #else
  328. #define Mac(x)
  329. #define Win(x) x
  330. #define MacWin(x,y) y
  331. #endif
  332. //
  333. // The following includes an interface that is common between the
  334. // WOW thunk layer, and the 32-bit version of OLE.
  335. //
  336. #include <thunkapi.hxx> // WOW thunking interfaces
  337. //
  338. // A call to CoInitializeWOW will set the following variable. When set,
  339. // it points to a VTABLE of functions that we can call in the thunk
  340. // DLL. Only used when running in a VDM.
  341. //
  342. extern LPOLETHUNKWOW g_pOleThunkWOW;
  343. // debug versions of interlocked increment/decrement; not accurate
  344. // under multi-threading conditions, but better than the return value
  345. // of the Interlocked increment/decrement functions.
  346. inline DWORD InterlockedAddRef(DWORD *pRefs)
  347. {
  348. #if DBG==1
  349. DWORD refs = *pRefs + 1;
  350. InterlockedIncrement((LPLONG)pRefs);
  351. return refs;
  352. #else
  353. return InterlockedIncrement((LPLONG)pRefs);
  354. #endif
  355. }
  356. inline DWORD InterlockedRelease(DWORD *pRefs)
  357. {
  358. #if DBG==1
  359. DWORD refs = *pRefs - 1;
  360. return InterlockedDecrement((LPLONG)pRefs) == 0 ? 0 : refs;
  361. #else
  362. return InterlockedDecrement((LPLONG)pRefs);
  363. #endif
  364. }
  365. // helper for getting stable pointers during destruction or other times;
  366. // NOTE: not thread safe; must provide higher level synchronization
  367. inline void SafeReleaseAndNULL(IUnknown **ppUnk)
  368. {
  369. if (*ppUnk != NULL)
  370. {
  371. IUnknown *pUnkSave = *ppUnk;
  372. *ppUnk = NULL;
  373. pUnkSave->Release();
  374. }
  375. }
  376. /***********************************************************************/
  377. /* FILE FORMAT RELATED INFO ****/
  378. // Coponent object stream information
  379. #define COMPOBJ_STREAM OLESTR("\1CompObj")
  380. #define BYTE_ORDER_INDICATOR 0xfffe // for MAC it could be different
  381. #define COMPOBJ_STREAM_VERSION 0x0001
  382. // OLE defines values for different OSs
  383. #define OS_WIN 0x0000
  384. #define OS_MAC 0x0001
  385. #define OS_NT 0x0002
  386. // HIGH WORD is OS indicator, LOW WORD is OS version number
  387. extern DWORD gdwOrgOSVersion;
  388. extern DWORD gdwOleVersion;
  389. // Ole streams information
  390. #define OLE_STREAM OLESTR("\1Ole")
  391. #define OLE_PRODUCT_VERSION 0x0200 /* (HIGH BYTE major version) */
  392. #define OLE_STREAM_VERSION 0x0001
  393. #define OLE10_NATIVE_STREAM OLESTR("\1Ole10Native")
  394. #define OLE10_ITEMNAME_STREAM OLESTR("\1Ole10ItemName")
  395. #define OLE_PRESENTATION_STREAM OLESTR("\2OlePres000")
  396. #define OLE_MAX_PRES_STREAMS 1000
  397. #define OLE_CONTENTS_STREAM OLESTR("CONTENTS")
  398. #define OLE_INVALID_STREAMNUM (-1)
  399. /************************************************************************/
  400. /**** Storage APIs internally used ****/
  401. /************************************************************************/
  402. STDAPI ReadClipformatStm(LPSTREAM lpstream, DWORD FAR* lpdwCf);
  403. STDAPI WriteClipformatStm(LPSTREAM lpstream, CLIPFORMAT cf);
  404. STDAPI WriteMonikerStm (LPSTREAM pstm, LPMONIKER pmk);
  405. STDAPI ReadMonikerStm (LPSTREAM pstm, LPMONIKER FAR* pmk);
  406. STDAPI_(LPSTREAM) CreateMemStm(DWORD cb, LPHANDLE phMem);
  407. STDAPI_(LPSTREAM) CloneMemStm(HANDLE hMem);
  408. STDAPI_(void) ReleaseMemStm (LPHANDLE hMem, BOOL fInternalOnly = FALSE);
  409. STDAPI GetClassFileEx( LPCWSTR lpszFileName,
  410. CLSID FAR *pcid,
  411. REFCLSID clsidOle1);
  412. /*************************************************************************/
  413. /*** Initialization code for individual modules ***/
  414. /*************************************************************************/
  415. INTERNAL_(void) DDEWEP (
  416. BOOL fSystemExit
  417. );
  418. INTERNAL_(BOOL) DDELibMain (
  419. HANDLE hInst,
  420. WORD wDataSeg,
  421. WORD cbHeapSize,
  422. LPWSTR lpszCmdLine
  423. );
  424. BOOL InitializeRunningObjectTable(void);
  425. HRESULT GetObjectFromRotByPath(
  426. WCHAR *pwszPath,
  427. IUnknown **ppvUnk);
  428. void DestroyRunningObjectTable(void);
  429. /**************************************************************************
  430. 'lindex' related macros
  431. ***************************************************************************/
  432. #define DEF_LINDEX (-1)
  433. //+-------------------------------------------------------------------------
  434. //
  435. // Function: IsValidLINDEX
  436. //
  437. // Synopsis: Tests for valid combination of aspect and lindex
  438. //
  439. // Arguments: [dwAspect] -- aspect (part of FORMATETC)
  440. // [lindex] -- lindex (part of FORMATETC)
  441. //
  442. // Returns: TRUE for valid lindex, else FALSE
  443. //
  444. // History: 20-Jun-94 AlexT Created
  445. //
  446. // Notes: Here is the spec for lindex values:
  447. //
  448. // dwAspect lindex values
  449. // -------- -------------
  450. // DVASPECT_CONTENT -1
  451. // DVASPECT_DOCPRINT anything
  452. // DVASPECT_ICON -1
  453. // DVASPECT_THUMBNAIL -1
  454. //
  455. // So, we test for lindex == -1 or aspect == DOCPRINT
  456. //
  457. //--------------------------------------------------------------------------
  458. inline BOOL IsValidLINDEX(DWORD dwAspect, LONG lindex)
  459. {
  460. return((DEF_LINDEX == lindex) || (DVASPECT_DOCPRINT == dwAspect));
  461. }
  462. //+-------------------------------------------------------------------------
  463. //
  464. // Function: HasValidLINDEX
  465. //
  466. // Synopsis: Tests for valid combination of aspect and lindex
  467. //
  468. // Arguments: [pFormatEtc] -- pFormatEtc to test
  469. //
  470. // Returns: TRUE for valid lindex, else FALSE
  471. //
  472. // History: 20-Jun-94 AlexT Created
  473. //
  474. // Notes: See IsValidLINDEX, above
  475. //
  476. //--------------------------------------------------------------------------
  477. inline BOOL HasValidLINDEX(FORMATETC const *pFormatEtc)
  478. {
  479. return(IsValidLINDEX(pFormatEtc->dwAspect, pFormatEtc->lindex));
  480. }
  481. #define INIT_FORETC(foretc) { \
  482. (foretc).ptd = NULL; \
  483. (foretc).lindex = DEF_LINDEX; \
  484. (foretc).dwAspect = DVASPECT_CONTENT; \
  485. }
  486. // Only DDE layer will test for these values. And only for advises on cached
  487. // formats do we use these values
  488. #define ADVFDDE_ONSAVE 0x40000000
  489. #define ADVFDDE_ONCLOSE 0x80000000
  490. // Used in Ole Private Stream
  491. typedef enum tagOBJFLAGS
  492. {
  493. OBJFLAGS_LINK=1L,
  494. OBJFLAGS_DOCUMENT=2L, // this bit is owned by container and is
  495. // propogated through saves
  496. OBJFLAGS_CONVERT=4L,
  497. OBJFLAGS_CACHEEMPTY=8L // this bit indicates cache empty status
  498. } OBJFLAGS;
  499. /*****************************************
  500. Prototypes for dde\client\ddemnker.cpp
  501. ******************************************/
  502. INTERNAL DdeBindToObject
  503. (LPCOLESTR szFile,
  504. REFCLSID clsid,
  505. BOOL fPackageLink,
  506. REFIID iid,
  507. LPLPVOID ppv);
  508. INTERNAL DdeIsRunning
  509. (CLSID clsid,
  510. LPCOLESTR szFile,
  511. LPBC pbc,
  512. LPMONIKER pmkToLeft,
  513. LPMONIKER pmkNewlyRunning);
  514. /**************************************
  515. Prototypes for moniker\mkparse.cpp
  516. ***************************************/
  517. INTERNAL Ole10_ParseMoniker
  518. (LPMONIKER pmk,
  519. LPOLESTR FAR* pszFile,
  520. LPOLESTR FAR* pszItem);
  521. STDAPI CreateOle1FileMoniker(LPWSTR, REFCLSID, LPMONIKER FAR*);
  522. /****************************************************************************/
  523. /* Utility APIs, might get exposed later */
  524. /****************************************************************************/
  525. STDAPI OleGetData(LPDATAOBJECT lpDataObj, LPFORMATETC pformatetcIn,
  526. LPSTGMEDIUM pmedium, BOOL fGetOwnership);
  527. STDAPI OleSetData(LPDATAOBJECT lpDataObj, LPFORMATETC pformatetc,
  528. STGMEDIUM FAR * pmedium, BOOL fRelease);
  529. STDAPI OleDuplicateMedium(LPSTGMEDIUM lpMediumSrc, LPSTGMEDIUM lpMediumDest);
  530. STDAPI_(BOOL) OleIsDcMeta (HDC hdc);
  531. STDAPI SzFixNet( LPBINDCTX pbc, LPOLESTR szUNCName, LPOLESTR FAR * lplpszReturn,
  532. UINT FAR * pEndServer, BOOL fForceConnection = TRUE);
  533. FARINTERNAL ReadFmtUserTypeProgIdStg
  534. (IStorage FAR * pstg,
  535. CLIPFORMAT FAR* pcf,
  536. LPOLESTR FAR* pszUserType,
  537. LPOLESTR szProgID);
  538. //+-------------------------------------------------------------------------
  539. //
  540. // Function: IsWOWProcess(), BOOL inline
  541. //
  542. // Synopsis: Tests whether or not we are running in a WOW process
  543. //
  544. // Returns: TRUE if in WOW process, FALSE otherwise
  545. //
  546. // Algorithm:
  547. //
  548. // History: dd-mmm-yy Author Comment
  549. // 15-Nov-95 murthys created
  550. //
  551. // Notes:
  552. //
  553. //--------------------------------------------------------------------------
  554. inline BOOL IsWOWProcess()
  555. {
  556. return (BOOL) ( NULL == g_pOleThunkWOW ? FALSE : TRUE );
  557. }
  558. //+-------------------------------------------------------------------------
  559. //
  560. // Function: IsWOWThread(), BOOL inline
  561. //
  562. // Synopsis: Tests whether or not we are running in a 16-bit thread in a
  563. // WOW process
  564. //
  565. // Returns: TRUE if in 16-bit thread in a WOW process, FALSE otherwise
  566. //
  567. // Algorithm:
  568. //
  569. // History: dd-mmm-yy Author Comment
  570. // 15-Nov-95 murthys created
  571. //
  572. // Notes:
  573. //
  574. //--------------------------------------------------------------------------
  575. BOOLEAN TLSIsWOWThread();
  576. inline BOOL IsWOWThread()
  577. {
  578. return (BOOL) ( IsWOWProcess() ? TLSIsWOWThread(): FALSE );
  579. }
  580. //+-------------------------------------------------------------------------
  581. //
  582. // Function: IsWOWThreadCallable(), BOOL inline
  583. //
  584. // Synopsis: Tests whether or not we can call into OLETHK32.
  585. //
  586. // Returns: TRUE if WOW thread is callable, FALSE if not
  587. //
  588. // Algorithm: Tests the g_pOleThunkWOW pointer to see if it is non-zero
  589. // and not set to -1. -1 means we are in wow, but OLETHK32
  590. // has already been unloaded. Also, checks to see if we're in
  591. // amidst a DLL_THREAD_DETACH. We will not allow calls to 16-bit
  592. // side in this case as it may have already been cleaned up.
  593. //
  594. // History: dd-mmm-yy Author Comment
  595. // 19-mar-95 KevinRo Created
  596. // 15-Nov-95 MurthyS Renamed from IsWowCallable
  597. // 29-Jan-95 MurthyS Added check for DLL_THREAD_DETACH
  598. //
  599. // Notes:
  600. // Assumes that IsWOWThread() was called and returned TRUE!
  601. //
  602. //--------------------------------------------------------------------------
  603. BOOLEAN TLSIsThreadDetaching();
  604. inline BOOL IsWOWThreadCallable()
  605. {
  606. return (BOOL) (( NULL == g_pOleThunkWOW ? FALSE :
  607. ( INVALID_HANDLE_VALUE == g_pOleThunkWOW ? FALSE:TRUE)) &&
  608. !(TLSIsThreadDetaching()));
  609. }
  610. /****************************************************************************/
  611. /* Stabilization classes */
  612. /* These are used to stabilize objects during re-entrant calls */
  613. /****************************************************************************/
  614. #ifndef CO_E_RELEASED
  615. #define CO_E_RELEASED -2147467246L
  616. #endif
  617. typedef void * IFBuffer;
  618. //+-------------------------------------------------------------------------
  619. //
  620. // Function: GetMarshalledInterfaceBuffer
  621. //
  622. // Synopsis: marshals the given interface into an allocated buffer. The
  623. // buffer is returned
  624. //
  625. // Effects:
  626. //
  627. // Arguments: [refiid] -- the iid of the interface to marshal
  628. // [punk] -- the IUnknown to marshal
  629. // [pIFBuf] -- where to return the buffer
  630. //
  631. // Requires:
  632. //
  633. // Returns: HRESULT
  634. //
  635. // Signals:
  636. //
  637. // Modifies:
  638. //
  639. // Algorithm: calls CoMarshalInterface(MSHFLAGS_TABLESTRONG)
  640. //
  641. // History: dd-mmm-yy Author Comment
  642. // 03-Dec-94 alexgo author
  643. //
  644. // Notes:
  645. //
  646. //--------------------------------------------------------------------------
  647. HRESULT GetMarshalledInterfaceBuffer( REFIID riid, IUnknown *punk, IFBuffer
  648. *pIFBuf);
  649. //+-------------------------------------------------------------------------
  650. //
  651. // Function: ReleaseMarshalledInterfaceBuffer
  652. //
  653. // Synopsis: releases the buffer allocated by GetMarshalledInterfaceBuffer
  654. //
  655. // Effects:
  656. //
  657. // Arguments: [IFBuf] -- the interface buffer to release
  658. //
  659. // Requires:
  660. //
  661. // Returns: HRESULT
  662. //
  663. // Signals:
  664. //
  665. // Modifies:
  666. //
  667. // Algorithm: calls CoReleaseMarshalData to undo the TABLE_STRONG
  668. // marshalling
  669. //
  670. // History: dd-mmm-yy Author Comment
  671. // 03-Dec-94 alexgo author
  672. //
  673. // Notes:
  674. //
  675. //--------------------------------------------------------------------------
  676. HRESULT ReleaseMarshalledInterfaceBuffer( IFBuffer IFBuf );
  677. #define E_UNSPEC E_FAIL
  678. #include <widewrap.h>
  679. #include <stkswtch.h>
  680. #include <shellapi.h>
  681. #ifdef WIN32 // REVIEW, just using this for tracking
  682. # define OLE_E_NOOLE1 MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x00FE)
  683. #endif // WIN32
  684. /***********************************************************************/
  685. /* Wrap mbstowcs and wcstombs which are unsafe to use */
  686. /* since they rely on crt.dll */
  687. /* */
  688. /* Note: cCh in both cases is the output buffer size, not a */
  689. /* string length. */
  690. /* */
  691. /***********************************************************************/
  692. #define mbstowcs(x, y, z) DONT_USE_mbstowcs___USE_MultiByteToWideChar_INSTEAD
  693. #define wcstombs(x, y, z) DONT_USE_wcstombs___USE_WideCharToMultiByte_INSTEAD
  694. //------------------------------------------------------------------
  695. //
  696. // Dynamically Loaded System APIs
  697. //
  698. // OLEs implementations of these system APIs dynamically load the
  699. // system DLLs. Since these are rarely used APIs we dynamically
  700. // load them to reduce the load time of OLE32.DLL
  701. //
  702. // The implementations can be found in com\util\dynload.cxx
  703. //
  704. //------------------------------------------------------------------
  705. // Our own load library helper.
  706. BOOL LoadSystemProc(LPSTR szDll, LPCSTR szProc,
  707. HINSTANCE *phInst, FARPROC *ppfnProc);
  708. // HOOK OLE macros for wrapping interface pointers
  709. #include <hkole32.h>
  710. // ----------------------------------------------------------------------------
  711. // API/Method trace output
  712. // ----------------------------------------------------------------------------
  713. #include <trace.hxx>
  714. // ----------------------------------------------------------------------------
  715. // Catalog related declarations: these are defined in ..\..\common\ccompapi.cxx
  716. // ----------------------------------------------------------------------------
  717. #include <catalog.h>
  718. HRESULT InitializeCatalogIfNecessary();
  719. HRESULT UninitializeCatalog();
  720. extern IComCatalog *gpCatalog;
  721. extern IComCatalogSCM *gpCatalogSCM;
  722. // ----------------------------------------------------------------------------
  723. // Specialized registry functions for HKCR. These are defined in reghelp.cxx
  724. // ----------------------------------------------------------------------------
  725. #include <reghelp.hxx>
  726. #endif // _OLE2COM_H_