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.

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