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.

6274 lines
141 KiB

  1. // This is a part of the Active Template Library.
  2. // Copyright (C) 1996-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Active Template Library Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Active Template Library product.
  10. #ifndef __ATLBASE_H__
  11. #define __ATLBASE_H__
  12. #ifndef __cplusplus
  13. #error ATL requires C++ compilation (use a .cpp suffix)
  14. #endif
  15. #if defined(_WIN32_WCE) && (_WIN32_WCE < 200)
  16. #error "ATL projects can only be compiled for Windows CE 2.0 or later."
  17. #endif // _WIN32_WCE
  18. #if defined(_WIN32_WCE)
  19. #include "wceatl.h"
  20. #define WCE_DEL /##/
  21. #define WCE_INS
  22. #define WCE_FCTN(fctn) wce_##fctn
  23. #define WCE_IF(wce,base) wce
  24. #define WCE_ATL_LIBNAME WCE_FILENAME_1(atlce,_WIN32_WCE,.lib)
  25. #define WCE_FILENAME_1(name, ver, ext) WCE_FILENAME_2(name, ver, ext)
  26. #define WCE_FILENAME_2(name, ver, ext) #name #ver #ext
  27. #else // _WIN32_WCE
  28. #define _T(x) x
  29. #define WCE_DEL
  30. #define WCE_INS /##/
  31. #define WCE_FCTN(fctn) fctn
  32. #define WCE_IF(wce,base) base
  33. #endif // _WIN32_WCE
  34. #ifndef _ATL_NO_PRAGMA_WARNINGS
  35. #pragma warning(disable: 4201) // nameless unions are part of C++
  36. #pragma warning(disable: 4127) // constant expression
  37. #pragma warning(disable: 4505) // unreferenced local function has been removed
  38. #pragma warning(disable: 4512) // can't generate assignment operator (so what?)
  39. #pragma warning(disable: 4514) // unreferenced inlines are common
  40. #pragma warning(disable: 4103) // pragma pack
  41. #pragma warning(disable: 4702) // unreachable code
  42. #pragma warning(disable: 4237) // bool
  43. #pragma warning(disable: 4710) // function couldn't be inlined
  44. #pragma warning(disable: 4355) // 'this' : used in base member initializer list
  45. #pragma warning(disable: 4097) // typedef name used as synonym for class-name
  46. #pragma warning(disable: 4786) // identifier was truncated in the debug information
  47. #endif //!_ATL_NO_PRAGMA_WARNINGS
  48. #include <atldef.h>
  49. #include <windows.h>
  50. #include <winnls.h>
  51. #include <ole2.h>
  52. WCE_INS typedef GUID CATID; // missed definition from comcat.h
  53. WCE_DEL #include <comcat.h>
  54. WCE_DEL #include <stddef.h>
  55. #include <tchar.h>
  56. #include <malloc.h>
  57. #ifndef _ATL_NO_DEBUG_CRT
  58. // Warning: if you define the above symbol, you will have
  59. // to provide your own definition of the ATLASSERT(x) macro
  60. // in order to compile ATL
  61. #include <crtdbg.h>
  62. #endif
  63. #include <olectl.h>
  64. #include <winreg.h>
  65. #include <atliface.h>
  66. #ifdef _DEBUG
  67. WCE_DEL #include <stdio.h>
  68. #include <stdarg.h>
  69. #endif
  70. #include <atlconv.h>
  71. WCE_DEL #include <shlwapi.h>
  72. #pragma pack(push, _ATL_PACKING)
  73. #if defined(_ATL_DLL)
  74. #if defined(_WIN32_WCE)
  75. #pragma comment(lib, WCE_ATL_LIBNAME)
  76. #else // _WIN32_WCE
  77. #pragma comment(lib, "atl.lib")
  78. #endif // _WIN32_WCE
  79. #endif
  80. #if defined(_WIN32_WCE)
  81. namespace ATL
  82. {
  83. HRESULT wce_OleLoadFromStream ( LPSTREAM pStm, REFIID iidInterface, LPVOID FAR* ppvObj);
  84. HRESULT wce_OleSaveToStream ( LPPERSISTSTREAM pPStm, LPSTREAM pStm);
  85. HRESULT wce_ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *lplpszProgID);
  86. HRESULT wce_CLSIDFromProgID(LPCOLESTR lpszProgID, LPCLSID pclsid);
  87. HRESULT wce_CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm);
  88. int wce_MulDiv(int nNumber, int nNumerator, int nDenominator);
  89. } // namespace ATL
  90. #endif // _WIN32_WCE
  91. extern "C" const __declspec(selectany) GUID LIBID_ATLLib = {0x44EC0535,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
  92. extern "C" const __declspec(selectany) CLSID CLSID_Registrar = {0x44EC053A,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
  93. extern "C" const __declspec(selectany) IID IID_IRegistrar = {0x44EC053B,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
  94. extern "C" const __declspec(selectany) IID IID_IAxWinHostWindow = {0xb6ea2050,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
  95. extern "C" const __declspec(selectany) IID IID_IAxWinAmbientDispatch = {0xb6ea2051,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
  96. WCE_DEL extern "C" const __declspec(selectany) IID IID_IInternalConnection = {0x72AD0770,0x6A9F,0x11d1,{0xBC,0xEC,0x00,0x60,0x08,0x8F,0x44,0x4E}};
  97. WCE_DEL extern "C" const __declspec(selectany) IID IID_IDocHostUIHandlerDispatch = {0x425B5AF0,0x65F1,0x11d1,{0x96,0x11,0x00,0x00,0xF8,0x1E,0x0D,0x0D}};
  98. #ifndef _ATL_DLL_IMPL
  99. namespace ATL
  100. {
  101. #endif
  102. struct _ATL_CATMAP_ENTRY
  103. {
  104. int iType;
  105. const CATID* pcatid;
  106. };
  107. #define _ATL_CATMAP_ENTRY_END 0
  108. #define _ATL_CATMAP_ENTRY_IMPLEMENTED 1
  109. #define _ATL_CATMAP_ENTRY_REQUIRED 2
  110. typedef HRESULT (WINAPI _ATL_CREATORFUNC)(void* pv, REFIID riid, LPVOID* ppv);
  111. typedef HRESULT (WINAPI _ATL_CREATORARGFUNC)(void* pv, REFIID riid, LPVOID* ppv, DWORD dw);
  112. typedef HRESULT (WINAPI _ATL_MODULEFUNC)(DWORD dw);
  113. typedef LPCTSTR (WINAPI _ATL_DESCRIPTIONFUNC)();
  114. typedef const struct _ATL_CATMAP_ENTRY* (_ATL_CATMAPFUNC)();
  115. typedef void (__stdcall _ATL_TERMFUNC)(DWORD dw);
  116. struct _ATL_TERMFUNC_ELEM
  117. {
  118. _ATL_TERMFUNC* pFunc;
  119. DWORD dw;
  120. _ATL_TERMFUNC_ELEM* pNext;
  121. };
  122. struct _ATL_OBJMAP_ENTRY
  123. {
  124. const CLSID* pclsid;
  125. HRESULT (WINAPI *pfnUpdateRegistry)(BOOL bRegister);
  126. _ATL_CREATORFUNC* pfnGetClassObject;
  127. _ATL_CREATORFUNC* pfnCreateInstance;
  128. IUnknown* pCF;
  129. DWORD dwRegister;
  130. _ATL_DESCRIPTIONFUNC* pfnGetObjectDescription;
  131. _ATL_CATMAPFUNC* pfnGetCategoryMap;
  132. #if !defined(_WIN32_WCE)
  133. HRESULT WINAPI RevokeClassObject()
  134. {
  135. return CoRevokeClassObject(dwRegister);
  136. }
  137. HRESULT WINAPI RegisterClassObject(DWORD dwClsContext, DWORD dwFlags)
  138. {
  139. IUnknown* p = NULL;
  140. if (pfnGetClassObject == NULL)
  141. return S_OK;
  142. HRESULT hRes = pfnGetClassObject(pfnCreateInstance, IID_IUnknown, (LPVOID*) &p);
  143. if (SUCCEEDED(hRes))
  144. hRes = CoRegisterClassObject(*pclsid, p, dwClsContext, dwFlags, &dwRegister);
  145. if (p != NULL)
  146. p->Release();
  147. return hRes;
  148. }
  149. #endif // _WIN32_WCE
  150. // Added in ATL 3.0
  151. void (WINAPI *pfnObjectMain)(bool bStarting);
  152. };
  153. struct _ATL_REGMAP_ENTRY
  154. {
  155. LPCOLESTR szKey;
  156. LPCOLESTR szData;
  157. };
  158. struct _AtlCreateWndData
  159. {
  160. void* m_pThis;
  161. DWORD m_dwThreadID;
  162. _AtlCreateWndData* m_pNext;
  163. };
  164. struct _ATL_MODULE
  165. {
  166. // Attributes
  167. public:
  168. UINT cbSize;
  169. HINSTANCE m_hInst;
  170. HINSTANCE m_hInstResource;
  171. HINSTANCE m_hInstTypeLib;
  172. _ATL_OBJMAP_ENTRY* m_pObjMap;
  173. LONG m_nLockCnt;
  174. HANDLE m_hHeap;
  175. union
  176. {
  177. CRITICAL_SECTION m_csTypeInfoHolder;
  178. CRITICAL_SECTION m_csStaticDataInit;
  179. };
  180. CRITICAL_SECTION m_csWindowCreate;
  181. CRITICAL_SECTION m_csObjMap;
  182. // Original Size = 100
  183. // Stuff added in ATL 3.0
  184. DWORD dwAtlBuildVer;
  185. _AtlCreateWndData* m_pCreateWndList;
  186. bool m_bDestroyHeap;
  187. GUID* pguidVer;
  188. DWORD m_dwHeaps; // Number of heaps we have (-1)
  189. HANDLE* m_phHeaps;
  190. int m_nHeap; // Which heap to choose from
  191. _ATL_TERMFUNC_ELEM* m_pTermFuncs;
  192. };
  193. const int _nAtlModuleVer1Size = 100;
  194. //This define makes debugging asserts easier.
  195. #define _ATL_SIMPLEMAPENTRY ((_ATL_CREATORARGFUNC*)1)
  196. struct _ATL_INTMAP_ENTRY
  197. {
  198. const IID* piid; // the interface id (IID)
  199. DWORD dw;
  200. _ATL_CREATORARGFUNC* pFunc; //NULL:end, 1:offset, n:ptr
  201. };
  202. /////////////////////////////////////////////////////////////////////////////
  203. // QI Support
  204. ATLAPI AtlInternalQueryInterface(void* pThis,
  205. const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, void** ppvObject);
  206. /////////////////////////////////////////////////////////////////////////////
  207. // Smart Pointer helpers
  208. ATLAPI_(IUnknown*) AtlComPtrAssign(IUnknown** pp, IUnknown* lp);
  209. ATLAPI_(IUnknown*) AtlComQIPtrAssign(IUnknown** pp, IUnknown* lp, REFIID riid);
  210. /////////////////////////////////////////////////////////////////////////////
  211. // Inproc Marshaling helpers
  212. WCE_DEL ATLAPI AtlFreeMarshalStream(IStream* pStream);
  213. WCE_DEL ATLAPI AtlMarshalPtrInProc(IUnknown* pUnk, const IID& iid, IStream** ppStream);
  214. WCE_DEL ATLAPI AtlUnmarshalPtr(IStream* pStream, const IID& iid, IUnknown** ppUnk);
  215. WCE_DEL ATLAPI_(BOOL) AtlWaitWithMessageLoop(HANDLE hEvent);
  216. /////////////////////////////////////////////////////////////////////////////
  217. // Connection Point Helpers
  218. ATLAPI AtlAdvise(IUnknown* pUnkCP, IUnknown* pUnk, const IID& iid, LPDWORD pdw);
  219. ATLAPI AtlUnadvise(IUnknown* pUnkCP, const IID& iid, DWORD dw);
  220. /////////////////////////////////////////////////////////////////////////////
  221. // IDispatch Error handling
  222. ATLAPI AtlSetErrorInfo(const CLSID& clsid, LPCOLESTR lpszDesc,
  223. DWORD dwHelpID, LPCOLESTR lpszHelpFile, const IID& iid, HRESULT hRes,
  224. HINSTANCE hInst);
  225. /////////////////////////////////////////////////////////////////////////////
  226. // Module
  227. WCE_DEL ATLAPI AtlModuleRegisterClassObjects(_ATL_MODULE* pM, DWORD dwClsContext, DWORD dwFlags);
  228. WCE_DEL ATLAPI AtlModuleRevokeClassObjects(_ATL_MODULE* pM);
  229. ATLAPI AtlModuleGetClassObject(_ATL_MODULE* pM, REFCLSID rclsid, REFIID riid, LPVOID* ppv);
  230. ATLAPI AtlModuleRegisterServer(_ATL_MODULE* pM, BOOL bRegTypeLib, const CLSID* pCLSID = NULL);
  231. ATLAPI AtlModuleUnregisterServer(_ATL_MODULE* pM, const CLSID* pCLSID = NULL);
  232. ATLAPI AtlModuleUnregisterServerEx(_ATL_MODULE* pM, BOOL bUnRegTypeLib, const CLSID* pCLSID = NULL);
  233. ATLAPI AtlModuleUpdateRegistryFromResourceD(_ATL_MODULE*pM, LPCOLESTR lpszRes,
  234. BOOL bRegister, struct _ATL_REGMAP_ENTRY* pMapEntries, IRegistrar* pReg = NULL);
  235. ATLAPI AtlModuleRegisterTypeLib(_ATL_MODULE* pM, LPCOLESTR lpszIndex);
  236. ATLAPI AtlModuleUnRegisterTypeLib(_ATL_MODULE* pM, LPCOLESTR lpszIndex);
  237. ATLAPI AtlModuleLoadTypeLib(_ATL_MODULE* pM, LPCOLESTR lpszIndex, BSTR* pbstrPath, ITypeLib** ppTypeLib);
  238. ATLAPI AtlModuleInit(_ATL_MODULE* pM, _ATL_OBJMAP_ENTRY* p, HINSTANCE h);
  239. ATLAPI AtlModuleTerm(_ATL_MODULE* pM);
  240. ATLAPI_(DWORD) AtlGetVersion(void* pReserved);
  241. ATLAPI_(void) AtlModuleAddCreateWndData(_ATL_MODULE* pM, _AtlCreateWndData* pData, void* pObject);
  242. ATLAPI_(void*) AtlModuleExtractCreateWndData(_ATL_MODULE* pM);
  243. ATLAPI AtlModuleAddTermFunc(_ATL_MODULE* pM, _ATL_TERMFUNC* pFunc, DWORD dw);
  244. #ifndef _ATL_DLL_IMPL
  245. }; //namespace ATL
  246. #endif
  247. namespace ATL
  248. {
  249. enum atlTraceFlags
  250. {
  251. // Application defined categories
  252. atlTraceUser = 0x00000001,
  253. atlTraceUser2 = 0x00000002,
  254. atlTraceUser3 = 0x00000004,
  255. atlTraceUser4 = 0x00000008,
  256. // ATL defined categories
  257. atlTraceGeneral = 0x00000020,
  258. atlTraceCOM = 0x00000040,
  259. atlTraceQI = 0x00000080,
  260. atlTraceRegistrar = 0x00000100,
  261. atlTraceRefcount = 0x00000200,
  262. atlTraceWindowing = 0x00000400,
  263. atlTraceControls = 0x00000800,
  264. atlTraceHosting = 0x00001000,
  265. atlTraceDBClient = 0x00002000,
  266. atlTraceDBProvider = 0x00004000,
  267. atlTraceSnapin = 0x00008000,
  268. atlTraceNotImpl = 0x00010000,
  269. };
  270. #ifndef ATL_TRACE_CATEGORY
  271. #define ATL_TRACE_CATEGORY 0xFFFFFFFF
  272. #endif
  273. #ifdef _DEBUG
  274. #ifndef ATL_TRACE_LEVEL
  275. #define ATL_TRACE_LEVEL 0
  276. #endif
  277. #if !defined(_WIN32_WCE)
  278. inline void _cdecl AtlTrace(LPCSTR lpszFormat, ...)
  279. {
  280. va_list args;
  281. va_start(args, lpszFormat);
  282. int nBuf;
  283. char szBuffer[512];
  284. nBuf = _vsnprintf(szBuffer, sizeof(szBuffer), lpszFormat, args);
  285. ATLASSERT(nBuf < sizeof(szBuffer)); //Output truncated as it was > sizeof(szBuffer)
  286. OutputDebugStringA(szBuffer);
  287. va_end(args);
  288. }
  289. inline void _cdecl AtlTrace2(DWORD category, UINT level, LPCSTR lpszFormat, ...)
  290. {
  291. if (category & ATL_TRACE_CATEGORY && level <= ATL_TRACE_LEVEL)
  292. {
  293. va_list args;
  294. va_start(args, lpszFormat);
  295. int nBuf;
  296. char szBuffer[512];
  297. nBuf = _vsnprintf(szBuffer, sizeof(szBuffer), lpszFormat, args);
  298. ATLASSERT(nBuf < sizeof(szBuffer)); //Output truncated as it was > sizeof(szBuffer)
  299. OutputDebugStringA("ATL: ");
  300. OutputDebugStringA(szBuffer);
  301. va_end(args);
  302. }
  303. }
  304. #endif // _WIN32_WCE
  305. #ifndef OLE2ANSI
  306. inline void _cdecl AtlTrace(LPCWSTR lpszFormat, ...)
  307. {
  308. va_list args;
  309. va_start(args, lpszFormat);
  310. int nBuf;
  311. WCHAR szBuffer[512];
  312. #if defined(_WIN32_WCE)
  313. nBuf = _vstprintf(szBuffer, lpszFormat, args);
  314. #else // _WIN32_WCE
  315. nBuf = _vsnwprintf(szBuffer, sizeof(szBuffer) / sizeof(WCHAR), lpszFormat, args);
  316. #endif // _WIN32_WCE
  317. ATLASSERT(nBuf < sizeof(szBuffer));//Output truncated as it was > sizeof(szBuffer)
  318. OutputDebugStringW(szBuffer);
  319. va_end(args);
  320. }
  321. inline void _cdecl AtlTrace2(DWORD category, UINT level, LPCWSTR lpszFormat, ...)
  322. {
  323. if (category & ATL_TRACE_CATEGORY && level <= ATL_TRACE_LEVEL)
  324. {
  325. va_list args;
  326. va_start(args, lpszFormat);
  327. int nBuf;
  328. WCHAR szBuffer[512];
  329. #if defined(_WIN32_WCE)
  330. nBuf = _vstprintf(szBuffer, lpszFormat, args);
  331. #else // _WIN32_WCE
  332. nBuf = _vsnwprintf(szBuffer, sizeof(szBuffer) / sizeof(WCHAR), lpszFormat, args);
  333. #endif // _WIN32_WCE
  334. ATLASSERT(nBuf < sizeof(szBuffer));//Output truncated as it was > sizeof(szBuffer)
  335. OutputDebugStringW(L"ATL: ");
  336. OutputDebugStringW(szBuffer);
  337. va_end(args);
  338. }
  339. }
  340. #endif //!OLE2ANSI
  341. #ifndef ATLTRACE
  342. #define ATLTRACE AtlTrace
  343. #define ATLTRACE2 AtlTrace2
  344. #endif
  345. #define ATLTRACENOTIMPL(funcname) ATLTRACE2(atlTraceNotImpl, 2, _T("ATL: %s not implemented.\n"), funcname); return E_NOTIMPL
  346. #else // !DEBUG
  347. inline void _cdecl AtlTrace(LPCSTR , ...){}
  348. inline void _cdecl AtlTrace2(DWORD, UINT, LPCSTR , ...){}
  349. #ifndef OLE2ANSI
  350. inline void _cdecl AtlTrace(LPCWSTR , ...){}
  351. inline void _cdecl AtlTrace2(DWORD, UINT, LPCWSTR , ...){}
  352. #endif //OLE2ANSI
  353. #ifndef ATLTRACE
  354. #define ATLTRACE 1 ? (void)0 : AtlTrace
  355. #define ATLTRACE2 1 ? (void)0 : AtlTrace2
  356. #endif //ATLTRACE
  357. #define ATLTRACENOTIMPL(funcname) return E_NOTIMPL
  358. #endif //_DEBUG
  359. /////////////////////////////////////////////////////////////////////////////
  360. // Win32 libraries
  361. #ifndef _ATL_NO_FORCE_LIBS
  362. #if defined(_WIN32_WCE)
  363. #pragma comment(lib, "coredll.lib")
  364. #pragma comment(lib, "commctrl.lib")
  365. #pragma comment(lib, "uuid.lib")
  366. #if defined(_WIN32_WCE_EMULATION) && (_WIN32_WCE < 210)
  367. #pragma comment(lib, "ole32m.lib")
  368. #pragma comment(lib, "oleautm.lib")
  369. #else
  370. #pragma comment(lib, "ole32.lib")
  371. #pragma comment(lib, "oleaut32.lib")
  372. #endif // _WIN32_WCE_EMULATION
  373. #if (_WIN32_WCE > 200)
  374. #pragma comment(lib, "corelibc.lib")
  375. #pragma comment(linker, "/nodefaultlib:libc.lib")
  376. #pragma comment(linker, "/nodefaultlib:libcd.lib")
  377. #pragma comment(linker, "/nodefaultlib:libcmt.lib")
  378. #pragma comment(linker, "/nodefaultlib:libcmtd.lib")
  379. #pragma comment(linker, "/nodefaultlib:oldnames.lib")
  380. #else // _WIN32_WCE > 200
  381. #if defined(_DEBUG)
  382. #pragma comment(lib, "libcmtd.lib")
  383. #pragma comment(linker, "/nodefaultlib:corelibc.lib")
  384. #else
  385. #pragma comment(lib, "libcmt.lib")
  386. #pragma comment(linker, "/nodefaultlib:corelibc.lib")
  387. #endif
  388. #endif // _WIN32_WCE > 200
  389. #else // Win32
  390. #pragma comment(lib, "kernel32.lib")
  391. #pragma comment(lib, "user32.lib")
  392. #pragma comment(lib, "olepro32.lib")
  393. #pragma comment(lib, "advapi32.lib")
  394. #pragma comment(lib, "ole32.lib")
  395. #pragma comment(lib, "oleaut32.lib")
  396. #pragma comment(lib, "uuid.lib")
  397. #endif // _WIN32_WCE
  398. #endif // _ATL_NO_FORCE_LIBS
  399. static HRESULT AtlSetChildSite(IUnknown* punkChild, IUnknown* punkParent)
  400. {
  401. if (punkChild == NULL)
  402. return E_POINTER;
  403. HRESULT hr;
  404. IObjectWithSite* pChildSite = NULL;
  405. hr = punkChild->QueryInterface(IID_IObjectWithSite, (void**)&pChildSite);
  406. if (SUCCEEDED(hr) && pChildSite != NULL)
  407. {
  408. hr = pChildSite->SetSite(punkParent);
  409. pChildSite->Release();
  410. }
  411. return hr;
  412. }
  413. template <class T>
  414. class _NoAddRefReleaseOnCComPtr : public T
  415. {
  416. private:
  417. STDMETHOD_(ULONG, AddRef)()=0;
  418. STDMETHOD_(ULONG, Release)()=0;
  419. };
  420. template <class T>
  421. class CComPtr
  422. {
  423. public:
  424. typedef T _PtrClass;
  425. CComPtr()
  426. {
  427. p=NULL;
  428. }
  429. CComPtr(T* lp)
  430. {
  431. if ((p = lp) != NULL)
  432. p->AddRef();
  433. }
  434. CComPtr(const CComPtr<T>& lp)
  435. {
  436. if ((p = lp.p) != NULL)
  437. p->AddRef();
  438. }
  439. ~CComPtr()
  440. {
  441. if (p)
  442. p->Release();
  443. }
  444. void Release()
  445. {
  446. IUnknown* pTemp = p;
  447. if (pTemp)
  448. {
  449. p = NULL;
  450. pTemp->Release();
  451. }
  452. }
  453. operator T*() const
  454. {
  455. return (T*)p;
  456. }
  457. T& operator*() const
  458. {
  459. ATLASSERT(p!=NULL);
  460. return *p;
  461. }
  462. //The assert on operator& usually indicates a bug. If this is really
  463. //what is needed, however, take the address of the p member explicitly.
  464. T** operator&()
  465. {
  466. ATLASSERT(p==NULL);
  467. return &p;
  468. }
  469. _NoAddRefReleaseOnCComPtr<T>* operator->() const
  470. {
  471. ATLASSERT(p!=NULL);
  472. return (_NoAddRefReleaseOnCComPtr<T>*)p;
  473. }
  474. T* operator=(T* lp)
  475. {
  476. return (T*)AtlComPtrAssign((IUnknown**)&p, lp);
  477. }
  478. T* operator=(const CComPtr<T>& lp)
  479. {
  480. return (T*)AtlComPtrAssign((IUnknown**)&p, lp.p);
  481. }
  482. bool operator!() const
  483. {
  484. return (p == NULL);
  485. }
  486. bool operator<(T* pT) const
  487. {
  488. return p < pT;
  489. }
  490. bool operator==(T* pT) const
  491. {
  492. return p == pT;
  493. }
  494. // Compare two objects for equivalence
  495. bool IsEqualObject(IUnknown* pOther)
  496. {
  497. if (p == NULL && pOther == NULL)
  498. return true; // They are both NULL objects
  499. if (p == NULL || pOther == NULL)
  500. return false; // One is NULL the other is not
  501. CComPtr<IUnknown> punk1;
  502. CComPtr<IUnknown> punk2;
  503. p->QueryInterface(IID_IUnknown, (void**)&punk1);
  504. pOther->QueryInterface(IID_IUnknown, (void**)&punk2);
  505. return punk1 == punk2;
  506. }
  507. void Attach(T* p2)
  508. {
  509. if (p)
  510. p->Release();
  511. p = p2;
  512. }
  513. T* Detach()
  514. {
  515. T* pt = p;
  516. p = NULL;
  517. return pt;
  518. }
  519. HRESULT CopyTo(T** ppT)
  520. {
  521. ATLASSERT(ppT != NULL);
  522. if (ppT == NULL)
  523. return E_POINTER;
  524. *ppT = p;
  525. if (p)
  526. p->AddRef();
  527. return S_OK;
  528. }
  529. HRESULT SetSite(IUnknown* punkParent)
  530. {
  531. return AtlSetChildSite(p, punkParent);
  532. }
  533. HRESULT Advise(IUnknown* pUnk, const IID& iid, LPDWORD pdw)
  534. {
  535. return AtlAdvise(p, pUnk, iid, pdw);
  536. }
  537. HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
  538. {
  539. ATLASSERT(p == NULL);
  540. return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
  541. }
  542. HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
  543. {
  544. CLSID clsid;
  545. HRESULT hr = WCE_FCTN(CLSIDFromProgID)(szProgID, &clsid);
  546. ATLASSERT(p == NULL);
  547. if (SUCCEEDED(hr))
  548. hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
  549. return hr;
  550. }
  551. #if 1//!defined(_WIN32_WCE)
  552. // WinCE: our compilers don't support this kind of overloaded templated function
  553. template <class Q>
  554. HRESULT QueryInterface(Q** pp) const
  555. {
  556. ATLASSERT(pp != NULL && *pp == NULL);
  557. return p->QueryInterface(__uuidof(Q), (void**)pp);
  558. }
  559. #endif // _WIN32_WCE
  560. T* p;
  561. };
  562. template <class T, const IID* piid = &__uuidof(T)>
  563. class CComQIPtr
  564. {
  565. public:
  566. typedef T _PtrClass;
  567. CComQIPtr()
  568. {
  569. p=NULL;
  570. }
  571. CComQIPtr(T* lp)
  572. {
  573. if ((p = lp) != NULL)
  574. p->AddRef();
  575. }
  576. CComQIPtr(const CComQIPtr<T,piid>& lp)
  577. {
  578. if ((p = lp.p) != NULL)
  579. p->AddRef();
  580. }
  581. CComQIPtr(IUnknown* lp)
  582. {
  583. p=NULL;
  584. if (lp != NULL)
  585. lp->QueryInterface(*piid, (void **)&p);
  586. }
  587. ~CComQIPtr()
  588. {
  589. if (p)
  590. p->Release();
  591. }
  592. void Release()
  593. {
  594. IUnknown* pTemp = p;
  595. if (pTemp)
  596. {
  597. p = NULL;
  598. pTemp->Release();
  599. }
  600. }
  601. operator T*() const
  602. {
  603. return p;
  604. }
  605. T& operator*() const
  606. {
  607. ATLASSERT(p!=NULL); return *p;
  608. }
  609. //The assert on operator& usually indicates a bug. If this is really
  610. //what is needed, however, take the address of the p member explicitly.
  611. T** operator&()
  612. {
  613. ATLASSERT(p==NULL);
  614. return &p;
  615. }
  616. _NoAddRefReleaseOnCComPtr<T>* operator->() const
  617. {
  618. ATLASSERT(p!=NULL);
  619. return (_NoAddRefReleaseOnCComPtr<T>*)p;
  620. }
  621. T* operator=(T* lp)
  622. {
  623. return (T*)AtlComPtrAssign((IUnknown**)&p, lp);
  624. }
  625. T* operator=(const CComQIPtr<T,piid>& lp)
  626. {
  627. return (T*)AtlComPtrAssign((IUnknown**)&p, lp.p);
  628. }
  629. T* operator=(IUnknown* lp)
  630. {
  631. return (T*)AtlComQIPtrAssign((IUnknown**)&p, lp, *piid);
  632. }
  633. bool operator!() const
  634. {
  635. return (p == NULL);
  636. }
  637. bool operator<(T* pT) const
  638. {
  639. return p < pT;
  640. }
  641. bool operator==(T* pT) const
  642. {
  643. return p == pT;
  644. }
  645. // Compare two objects for equivalence
  646. bool IsEqualObject(IUnknown* pOther)
  647. {
  648. if (p == NULL && pOther == NULL)
  649. return true; // They are both NULL objects
  650. if (p == NULL || pOther == NULL)
  651. return false; // One is NULL the other is not
  652. CComPtr<IUnknown> punk1;
  653. CComPtr<IUnknown> punk2;
  654. p->QueryInterface(IID_IUnknown, (void**)&punk1);
  655. pOther->QueryInterface(IID_IUnknown, (void**)&punk2);
  656. return punk1 == punk2;
  657. }
  658. void Attach(T* p2)
  659. {
  660. if (p)
  661. p->Release();
  662. p = p2;
  663. }
  664. T* Detach()
  665. {
  666. T* pt = p;
  667. p = NULL;
  668. return pt;
  669. }
  670. HRESULT CopyTo(T** ppT)
  671. {
  672. ATLASSERT(ppT != NULL);
  673. if (ppT == NULL)
  674. return E_POINTER;
  675. *ppT = p;
  676. if (p)
  677. p->AddRef();
  678. return S_OK;
  679. }
  680. HRESULT SetSite(IUnknown* punkParent)
  681. {
  682. return AtlSetChildSite(p, punkParent);
  683. }
  684. HRESULT Advise(IUnknown* pUnk, const IID& iid, LPDWORD pdw)
  685. {
  686. return AtlAdvise(p, pUnk, iid, pdw);
  687. }
  688. HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
  689. {
  690. ATLASSERT(p == NULL);
  691. return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
  692. }
  693. HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
  694. {
  695. CLSID clsid;
  696. HRESULT hr = WCE_FCTN(CLSIDFromProgID)(szProgID, &clsid);
  697. ATLASSERT(p == NULL);
  698. if (SUCCEEDED(hr))
  699. hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
  700. return hr;
  701. }
  702. template <class Q>
  703. HRESULT QueryInterface(Q** pp)
  704. {
  705. ATLASSERT(pp != NULL && *pp == NULL);
  706. return p->QueryInterface(__uuidof(Q), (void**)pp);
  707. }
  708. T* p;
  709. };
  710. //Specialization to make it work
  711. template<>
  712. class CComQIPtr<IUnknown, &IID_IUnknown>
  713. {
  714. public:
  715. typedef IUnknown _PtrClass;
  716. CComQIPtr()
  717. {
  718. p=NULL;
  719. }
  720. CComQIPtr(IUnknown* lp)
  721. {
  722. //Actually do a QI to get identity
  723. p=NULL;
  724. if (lp != NULL)
  725. lp->QueryInterface(IID_IUnknown, (void **)&p);
  726. }
  727. CComQIPtr(const CComQIPtr<IUnknown,&IID_IUnknown>& lp)
  728. {
  729. if ((p = lp.p) != NULL)
  730. p->AddRef();
  731. }
  732. ~CComQIPtr()
  733. {
  734. if (p)
  735. p->Release();
  736. }
  737. void Release()
  738. {
  739. IUnknown* pTemp = p;
  740. if (pTemp)
  741. {
  742. p = NULL;
  743. pTemp->Release();
  744. }
  745. }
  746. operator IUnknown*() const
  747. {
  748. return p;
  749. }
  750. IUnknown& operator*() const
  751. {
  752. ATLASSERT(p!=NULL);
  753. return *p;
  754. }
  755. //The assert on operator& usually indicates a bug. If this is really
  756. //what is needed, however, take the address of the p member explicitly.
  757. IUnknown** operator&()
  758. {
  759. ATLASSERT(p==NULL);
  760. return &p;
  761. }
  762. _NoAddRefReleaseOnCComPtr<T>* operator->() const
  763. {
  764. ATLASSERT(p!=NULL);
  765. return (_NoAddRefReleaseOnCComPtr<T>*)p;
  766. }
  767. IUnknown* operator=(IUnknown* lp)
  768. {
  769. //Actually do a QI to get identity
  770. return (IUnknown*)AtlComQIPtrAssign((IUnknown**)&p, lp, IID_IUnknown);
  771. }
  772. IUnknown* operator=(const CComQIPtr<IUnknown,&IID_IUnknown>& lp)
  773. {
  774. return (IUnknown*)AtlComPtrAssign((IUnknown**)&p, lp.p);
  775. }
  776. bool operator!() const
  777. {
  778. return (p == NULL);
  779. }
  780. bool operator<(IUnknown* pT) const
  781. {
  782. return p < pT;
  783. }
  784. bool operator==(IUnknown* pT) const
  785. {
  786. return p == pT;
  787. }
  788. // Compare two objects for equivalence
  789. bool IsEqualObject(IUnknown* pOther)
  790. {
  791. if (p == NULL && pOther == NULL)
  792. return true; // They are both NULL objects
  793. if (p == NULL || pOther == NULL)
  794. return false; // One is NULL the other is not
  795. CComPtr<IUnknown> punk1;
  796. CComPtr<IUnknown> punk2;
  797. p->QueryInterface(IID_IUnknown, (void**)&punk1);
  798. pOther->QueryInterface(IID_IUnknown, (void**)&punk2);
  799. return punk1 == punk2;
  800. }
  801. IUnknown* Detach()
  802. {
  803. IUnknown* pt = p;
  804. p = NULL;
  805. return pt;
  806. }
  807. HRESULT CopyTo(T** ppT)
  808. {
  809. ATLASSERT(ppT != NULL);
  810. if (ppT == NULL)
  811. return E_POINTER;
  812. *ppT = p;
  813. if (p)
  814. p->AddRef();
  815. return S_OK;
  816. }
  817. HRESULT SetSite(IUnknown* punkParent)
  818. {
  819. return AtlSetChildSite(p, punkParent);
  820. }
  821. HRESULT Advise(IUnknown* pUnk, const IID& iid, LPDWORD pdw)
  822. {
  823. return AtlAdvise(p, pUnk, iid, pdw);
  824. }
  825. HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
  826. {
  827. ATLASSERT(p == NULL);
  828. return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
  829. }
  830. HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
  831. {
  832. CLSID clsid;
  833. HRESULT hr = WCE_FCTN(CLSIDFromProgID)(szProgID, &clsid);
  834. ATLASSERT(p == NULL);
  835. if (SUCCEEDED(hr))
  836. hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
  837. return hr;
  838. }
  839. template <class Q>
  840. HRESULT QueryInterface(Q** pp)
  841. {
  842. ATLASSERT(pp != NULL && *pp == NULL);
  843. return p->QueryInterface(__uuidof(Q), (void**)pp);
  844. }
  845. IUnknown* p;
  846. };
  847. #define com_cast CComQIPtr
  848. /////////////////////////////////////////////////////////////
  849. // Class to Adapt CComBSTR and CComPtr for use with STL containers
  850. // the syntax to use it is
  851. // std::vector< CAdapt <CComBSTR> > vect;
  852. template <class T>
  853. class CAdapt
  854. {
  855. public:
  856. CAdapt()
  857. {
  858. }
  859. CAdapt(const T& rSrc)
  860. {
  861. m_T = rSrc;
  862. }
  863. CAdapt(const CAdapt& rSrCA)
  864. {
  865. m_T = rSrCA.m_T;
  866. }
  867. CAdapt& operator=(const T& rSrc)
  868. {
  869. m_T = rSrc;
  870. return *this;
  871. }
  872. bool operator<(const T& rSrc) const
  873. {
  874. return m_T < rSrc;
  875. }
  876. bool operator==(const T& rSrc) const
  877. {
  878. return m_T == rSrc;
  879. }
  880. operator T&()
  881. {
  882. return m_T;
  883. }
  884. operator const T&() const
  885. {
  886. return m_T;
  887. }
  888. T m_T;
  889. };
  890. /////////////////////////////////////////////////////////////////////////////
  891. // GUID comparison
  892. inline BOOL InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
  893. {
  894. return (
  895. ((PLONG) &rguid1)[0] == ((PLONG) &rguid2)[0] &&
  896. ((PLONG) &rguid1)[1] == ((PLONG) &rguid2)[1] &&
  897. ((PLONG) &rguid1)[2] == ((PLONG) &rguid2)[2] &&
  898. ((PLONG) &rguid1)[3] == ((PLONG) &rguid2)[3]);
  899. }
  900. inline BOOL InlineIsEqualUnknown(REFGUID rguid1)
  901. {
  902. return (
  903. ((PLONG) &rguid1)[0] == 0 &&
  904. ((PLONG) &rguid1)[1] == 0 &&
  905. #ifdef _ATL_BYTESWAP
  906. ((PLONG) &rguid1)[2] == 0xC0000000 &&
  907. ((PLONG) &rguid1)[3] == 0x00000046);
  908. #else
  909. ((PLONG) &rguid1)[2] == 0x000000C0 &&
  910. ((PLONG) &rguid1)[3] == 0x46000000);
  911. #endif
  912. }
  913. /////////////////////////////////////////////////////////////////////////////
  914. // Threading Model Support
  915. class CComCriticalSection
  916. {
  917. public:
  918. void Lock() {EnterCriticalSection(&m_sec);}
  919. void Unlock() {LeaveCriticalSection(&m_sec);}
  920. void Init() {InitializeCriticalSection(&m_sec);}
  921. void Term() {DeleteCriticalSection(&m_sec);}
  922. CRITICAL_SECTION m_sec;
  923. };
  924. class CComAutoCriticalSection
  925. {
  926. public:
  927. void Lock() {EnterCriticalSection(&m_sec);}
  928. void Unlock() {LeaveCriticalSection(&m_sec);}
  929. CComAutoCriticalSection() {InitializeCriticalSection(&m_sec);}
  930. ~CComAutoCriticalSection() {DeleteCriticalSection(&m_sec);}
  931. CRITICAL_SECTION m_sec;
  932. };
  933. class CComFakeCriticalSection
  934. {
  935. public:
  936. void Lock() {}
  937. void Unlock() {}
  938. void Init() {}
  939. void Term() {}
  940. };
  941. class CComMultiThreadModelNoCS
  942. {
  943. public:
  944. static ULONG WINAPI Increment(LPLONG p) {return InterlockedIncrement(p);}
  945. static ULONG WINAPI Decrement(LPLONG p) {return InterlockedDecrement(p);}
  946. typedef CComFakeCriticalSection AutoCriticalSection;
  947. typedef CComFakeCriticalSection CriticalSection;
  948. typedef CComMultiThreadModelNoCS ThreadModelNoCS;
  949. };
  950. class CComMultiThreadModel
  951. {
  952. public:
  953. static ULONG WINAPI Increment(LPLONG p) {return InterlockedIncrement(p);}
  954. static ULONG WINAPI Decrement(LPLONG p) {return InterlockedDecrement(p);}
  955. typedef CComAutoCriticalSection AutoCriticalSection;
  956. typedef CComCriticalSection CriticalSection;
  957. typedef CComMultiThreadModelNoCS ThreadModelNoCS;
  958. };
  959. class CComSingleThreadModel
  960. {
  961. public:
  962. static ULONG WINAPI Increment(LPLONG p) {return ++(*p);}
  963. static ULONG WINAPI Decrement(LPLONG p) {return --(*p);}
  964. typedef CComFakeCriticalSection AutoCriticalSection;
  965. typedef CComFakeCriticalSection CriticalSection;
  966. typedef CComSingleThreadModel ThreadModelNoCS;
  967. };
  968. #if defined(_ATL_SINGLE_THREADED)
  969. typedef CComSingleThreadModel CComObjectThreadModel;
  970. typedef CComSingleThreadModel CComGlobalsThreadModel;
  971. #elif defined(_ATL_APARTMENT_THREADED)
  972. typedef CComSingleThreadModel CComObjectThreadModel;
  973. typedef CComMultiThreadModel CComGlobalsThreadModel;
  974. #else
  975. typedef CComMultiThreadModel CComObjectThreadModel;
  976. typedef CComMultiThreadModel CComGlobalsThreadModel;
  977. #endif
  978. /////////////////////////////////////////////////////////////////////////////
  979. // CComModule
  980. #define THREADFLAGS_APARTMENT 0x1
  981. #define THREADFLAGS_BOTH 0x2
  982. #define AUTPRXFLAG 0x4
  983. HRESULT WINAPI AtlDumpIID(REFIID iid, LPCTSTR pszClassName, HRESULT hr);
  984. #ifdef _ATL_DEBUG_INTERFACES
  985. struct _QIThunk
  986. {
  987. STDMETHOD(QueryInterface)(REFIID iid, void** pp)
  988. {
  989. ATLASSERT(m_dwRef >= 0);
  990. return pUnk->QueryInterface(iid, pp);
  991. }
  992. STDMETHOD_(ULONG, AddRef)()
  993. {
  994. if (bBreak)
  995. DebugBreak();
  996. pUnk->AddRef();
  997. return InternalAddRef();
  998. }
  999. ULONG InternalAddRef()
  1000. {
  1001. if (bBreak)
  1002. DebugBreak();
  1003. ATLASSERT(m_dwRef >= 0);
  1004. long l = InterlockedIncrement(&m_dwRef);
  1005. ATLTRACE(_T("%d> "), m_dwRef);
  1006. AtlDumpIID(iid, lpszClassName, S_OK);
  1007. if (l > m_dwMaxRef)
  1008. m_dwMaxRef = l;
  1009. return l;
  1010. }
  1011. STDMETHOD_(ULONG, Release)();
  1012. STDMETHOD(f3)();
  1013. STDMETHOD(f4)();
  1014. STDMETHOD(f5)();
  1015. STDMETHOD(f6)();
  1016. STDMETHOD(f7)();
  1017. STDMETHOD(f8)();
  1018. STDMETHOD(f9)();
  1019. STDMETHOD(f10)();
  1020. STDMETHOD(f11)();
  1021. STDMETHOD(f12)();
  1022. STDMETHOD(f13)();
  1023. STDMETHOD(f14)();
  1024. STDMETHOD(f15)();
  1025. STDMETHOD(f16)();
  1026. STDMETHOD(f17)();
  1027. STDMETHOD(f18)();
  1028. STDMETHOD(f19)();
  1029. STDMETHOD(f20)();
  1030. STDMETHOD(f21)();
  1031. STDMETHOD(f22)();
  1032. STDMETHOD(f23)();
  1033. STDMETHOD(f24)();
  1034. STDMETHOD(f25)();
  1035. STDMETHOD(f26)();
  1036. STDMETHOD(f27)();
  1037. STDMETHOD(f28)();
  1038. STDMETHOD(f29)();
  1039. STDMETHOD(f30)();
  1040. STDMETHOD(f31)();
  1041. STDMETHOD(f32)();
  1042. STDMETHOD(f33)();
  1043. STDMETHOD(f34)();
  1044. STDMETHOD(f35)();
  1045. STDMETHOD(f36)();
  1046. STDMETHOD(f37)();
  1047. STDMETHOD(f38)();
  1048. STDMETHOD(f39)();
  1049. STDMETHOD(f40)();
  1050. STDMETHOD(f41)();
  1051. STDMETHOD(f42)();
  1052. STDMETHOD(f43)();
  1053. STDMETHOD(f44)();
  1054. STDMETHOD(f45)();
  1055. STDMETHOD(f46)();
  1056. STDMETHOD(f47)();
  1057. STDMETHOD(f48)();
  1058. STDMETHOD(f49)();
  1059. STDMETHOD(f50)();
  1060. STDMETHOD(f51)();
  1061. STDMETHOD(f52)();
  1062. STDMETHOD(f53)();
  1063. STDMETHOD(f54)();
  1064. STDMETHOD(f55)();
  1065. STDMETHOD(f56)();
  1066. STDMETHOD(f57)();
  1067. STDMETHOD(f58)();
  1068. STDMETHOD(f59)();
  1069. STDMETHOD(f60)();
  1070. STDMETHOD(f61)();
  1071. STDMETHOD(f62)();
  1072. STDMETHOD(f63)();
  1073. STDMETHOD(f64)();
  1074. STDMETHOD(f65)();
  1075. STDMETHOD(f66)();
  1076. STDMETHOD(f67)();
  1077. STDMETHOD(f68)();
  1078. STDMETHOD(f69)();
  1079. STDMETHOD(f70)();
  1080. STDMETHOD(f71)();
  1081. STDMETHOD(f72)();
  1082. STDMETHOD(f73)();
  1083. STDMETHOD(f74)();
  1084. STDMETHOD(f75)();
  1085. STDMETHOD(f76)();
  1086. STDMETHOD(f77)();
  1087. STDMETHOD(f78)();
  1088. STDMETHOD(f79)();
  1089. STDMETHOD(f80)();
  1090. STDMETHOD(f81)();
  1091. STDMETHOD(f82)();
  1092. STDMETHOD(f83)();
  1093. STDMETHOD(f84)();
  1094. STDMETHOD(f85)();
  1095. STDMETHOD(f86)();
  1096. STDMETHOD(f87)();
  1097. STDMETHOD(f88)();
  1098. STDMETHOD(f89)();
  1099. STDMETHOD(f90)();
  1100. STDMETHOD(f91)();
  1101. STDMETHOD(f92)();
  1102. STDMETHOD(f93)();
  1103. STDMETHOD(f94)();
  1104. STDMETHOD(f95)();
  1105. STDMETHOD(f96)();
  1106. STDMETHOD(f97)();
  1107. STDMETHOD(f98)();
  1108. STDMETHOD(f99)();
  1109. STDMETHOD(f100)();
  1110. STDMETHOD(f101)();
  1111. STDMETHOD(f102)();
  1112. STDMETHOD(f103)();
  1113. STDMETHOD(f104)();
  1114. STDMETHOD(f105)();
  1115. STDMETHOD(f106)();
  1116. STDMETHOD(f107)();
  1117. STDMETHOD(f108)();
  1118. STDMETHOD(f109)();
  1119. STDMETHOD(f110)();
  1120. STDMETHOD(f111)();
  1121. STDMETHOD(f112)();
  1122. STDMETHOD(f113)();
  1123. STDMETHOD(f114)();
  1124. STDMETHOD(f115)();
  1125. STDMETHOD(f116)();
  1126. STDMETHOD(f117)();
  1127. STDMETHOD(f118)();
  1128. STDMETHOD(f119)();
  1129. STDMETHOD(f120)();
  1130. STDMETHOD(f121)();
  1131. STDMETHOD(f122)();
  1132. STDMETHOD(f123)();
  1133. STDMETHOD(f124)();
  1134. STDMETHOD(f125)();
  1135. STDMETHOD(f126)();
  1136. STDMETHOD(f127)();
  1137. STDMETHOD(f128)();
  1138. STDMETHOD(f129)();
  1139. STDMETHOD(f130)();
  1140. STDMETHOD(f131)();
  1141. STDMETHOD(f132)();
  1142. STDMETHOD(f133)();
  1143. STDMETHOD(f134)();
  1144. STDMETHOD(f135)();
  1145. STDMETHOD(f136)();
  1146. STDMETHOD(f137)();
  1147. STDMETHOD(f138)();
  1148. STDMETHOD(f139)();
  1149. STDMETHOD(f140)();
  1150. STDMETHOD(f141)();
  1151. STDMETHOD(f142)();
  1152. STDMETHOD(f143)();
  1153. STDMETHOD(f144)();
  1154. STDMETHOD(f145)();
  1155. STDMETHOD(f146)();
  1156. STDMETHOD(f147)();
  1157. STDMETHOD(f148)();
  1158. STDMETHOD(f149)();
  1159. STDMETHOD(f150)();
  1160. STDMETHOD(f151)();
  1161. STDMETHOD(f152)();
  1162. STDMETHOD(f153)();
  1163. STDMETHOD(f154)();
  1164. STDMETHOD(f155)();
  1165. STDMETHOD(f156)();
  1166. STDMETHOD(f157)();
  1167. STDMETHOD(f158)();
  1168. STDMETHOD(f159)();
  1169. STDMETHOD(f160)();
  1170. STDMETHOD(f161)();
  1171. STDMETHOD(f162)();
  1172. STDMETHOD(f163)();
  1173. STDMETHOD(f164)();
  1174. STDMETHOD(f165)();
  1175. STDMETHOD(f166)();
  1176. STDMETHOD(f167)();
  1177. STDMETHOD(f168)();
  1178. STDMETHOD(f169)();
  1179. STDMETHOD(f170)();
  1180. STDMETHOD(f171)();
  1181. STDMETHOD(f172)();
  1182. STDMETHOD(f173)();
  1183. STDMETHOD(f174)();
  1184. STDMETHOD(f175)();
  1185. STDMETHOD(f176)();
  1186. STDMETHOD(f177)();
  1187. STDMETHOD(f178)();
  1188. STDMETHOD(f179)();
  1189. STDMETHOD(f180)();
  1190. STDMETHOD(f181)();
  1191. STDMETHOD(f182)();
  1192. STDMETHOD(f183)();
  1193. STDMETHOD(f184)();
  1194. STDMETHOD(f185)();
  1195. STDMETHOD(f186)();
  1196. STDMETHOD(f187)();
  1197. STDMETHOD(f188)();
  1198. STDMETHOD(f189)();
  1199. STDMETHOD(f190)();
  1200. STDMETHOD(f191)();
  1201. STDMETHOD(f192)();
  1202. STDMETHOD(f193)();
  1203. STDMETHOD(f194)();
  1204. STDMETHOD(f195)();
  1205. STDMETHOD(f196)();
  1206. STDMETHOD(f197)();
  1207. STDMETHOD(f198)();
  1208. STDMETHOD(f199)();
  1209. STDMETHOD(f200)();
  1210. STDMETHOD(f201)();
  1211. STDMETHOD(f202)();
  1212. STDMETHOD(f203)();
  1213. STDMETHOD(f204)();
  1214. STDMETHOD(f205)();
  1215. STDMETHOD(f206)();
  1216. STDMETHOD(f207)();
  1217. STDMETHOD(f208)();
  1218. STDMETHOD(f209)();
  1219. STDMETHOD(f210)();
  1220. STDMETHOD(f211)();
  1221. STDMETHOD(f212)();
  1222. STDMETHOD(f213)();
  1223. STDMETHOD(f214)();
  1224. STDMETHOD(f215)();
  1225. STDMETHOD(f216)();
  1226. STDMETHOD(f217)();
  1227. STDMETHOD(f218)();
  1228. STDMETHOD(f219)();
  1229. STDMETHOD(f220)();
  1230. STDMETHOD(f221)();
  1231. STDMETHOD(f222)();
  1232. STDMETHOD(f223)();
  1233. STDMETHOD(f224)();
  1234. STDMETHOD(f225)();
  1235. STDMETHOD(f226)();
  1236. STDMETHOD(f227)();
  1237. STDMETHOD(f228)();
  1238. STDMETHOD(f229)();
  1239. STDMETHOD(f230)();
  1240. STDMETHOD(f231)();
  1241. STDMETHOD(f232)();
  1242. STDMETHOD(f233)();
  1243. STDMETHOD(f234)();
  1244. STDMETHOD(f235)();
  1245. STDMETHOD(f236)();
  1246. STDMETHOD(f237)();
  1247. STDMETHOD(f238)();
  1248. STDMETHOD(f239)();
  1249. STDMETHOD(f240)();
  1250. STDMETHOD(f241)();
  1251. STDMETHOD(f242)();
  1252. STDMETHOD(f243)();
  1253. STDMETHOD(f244)();
  1254. STDMETHOD(f245)();
  1255. STDMETHOD(f246)();
  1256. STDMETHOD(f247)();
  1257. STDMETHOD(f248)();
  1258. STDMETHOD(f249)();
  1259. STDMETHOD(f250)();
  1260. STDMETHOD(f251)();
  1261. STDMETHOD(f252)();
  1262. STDMETHOD(f253)();
  1263. STDMETHOD(f254)();
  1264. STDMETHOD(f255)();
  1265. STDMETHOD(f256)();
  1266. STDMETHOD(f257)();
  1267. STDMETHOD(f258)();
  1268. STDMETHOD(f259)();
  1269. STDMETHOD(f260)();
  1270. STDMETHOD(f261)();
  1271. STDMETHOD(f262)();
  1272. STDMETHOD(f263)();
  1273. STDMETHOD(f264)();
  1274. STDMETHOD(f265)();
  1275. STDMETHOD(f266)();
  1276. STDMETHOD(f267)();
  1277. STDMETHOD(f268)();
  1278. STDMETHOD(f269)();
  1279. STDMETHOD(f270)();
  1280. STDMETHOD(f271)();
  1281. STDMETHOD(f272)();
  1282. STDMETHOD(f273)();
  1283. STDMETHOD(f274)();
  1284. STDMETHOD(f275)();
  1285. STDMETHOD(f276)();
  1286. STDMETHOD(f277)();
  1287. STDMETHOD(f278)();
  1288. STDMETHOD(f279)();
  1289. STDMETHOD(f280)();
  1290. STDMETHOD(f281)();
  1291. STDMETHOD(f282)();
  1292. STDMETHOD(f283)();
  1293. STDMETHOD(f284)();
  1294. STDMETHOD(f285)();
  1295. STDMETHOD(f286)();
  1296. STDMETHOD(f287)();
  1297. STDMETHOD(f288)();
  1298. STDMETHOD(f289)();
  1299. STDMETHOD(f290)();
  1300. STDMETHOD(f291)();
  1301. STDMETHOD(f292)();
  1302. STDMETHOD(f293)();
  1303. STDMETHOD(f294)();
  1304. STDMETHOD(f295)();
  1305. STDMETHOD(f296)();
  1306. STDMETHOD(f297)();
  1307. STDMETHOD(f298)();
  1308. STDMETHOD(f299)();
  1309. STDMETHOD(f300)();
  1310. STDMETHOD(f301)();
  1311. STDMETHOD(f302)();
  1312. STDMETHOD(f303)();
  1313. STDMETHOD(f304)();
  1314. STDMETHOD(f305)();
  1315. STDMETHOD(f306)();
  1316. STDMETHOD(f307)();
  1317. STDMETHOD(f308)();
  1318. STDMETHOD(f309)();
  1319. STDMETHOD(f310)();
  1320. STDMETHOD(f311)();
  1321. STDMETHOD(f312)();
  1322. STDMETHOD(f313)();
  1323. STDMETHOD(f314)();
  1324. STDMETHOD(f315)();
  1325. STDMETHOD(f316)();
  1326. STDMETHOD(f317)();
  1327. STDMETHOD(f318)();
  1328. STDMETHOD(f319)();
  1329. STDMETHOD(f320)();
  1330. STDMETHOD(f321)();
  1331. STDMETHOD(f322)();
  1332. STDMETHOD(f323)();
  1333. STDMETHOD(f324)();
  1334. STDMETHOD(f325)();
  1335. STDMETHOD(f326)();
  1336. STDMETHOD(f327)();
  1337. STDMETHOD(f328)();
  1338. STDMETHOD(f329)();
  1339. STDMETHOD(f330)();
  1340. STDMETHOD(f331)();
  1341. STDMETHOD(f332)();
  1342. STDMETHOD(f333)();
  1343. STDMETHOD(f334)();
  1344. STDMETHOD(f335)();
  1345. STDMETHOD(f336)();
  1346. STDMETHOD(f337)();
  1347. STDMETHOD(f338)();
  1348. STDMETHOD(f339)();
  1349. STDMETHOD(f340)();
  1350. STDMETHOD(f341)();
  1351. STDMETHOD(f342)();
  1352. STDMETHOD(f343)();
  1353. STDMETHOD(f344)();
  1354. STDMETHOD(f345)();
  1355. STDMETHOD(f346)();
  1356. STDMETHOD(f347)();
  1357. STDMETHOD(f348)();
  1358. STDMETHOD(f349)();
  1359. STDMETHOD(f350)();
  1360. STDMETHOD(f351)();
  1361. STDMETHOD(f352)();
  1362. STDMETHOD(f353)();
  1363. STDMETHOD(f354)();
  1364. STDMETHOD(f355)();
  1365. STDMETHOD(f356)();
  1366. STDMETHOD(f357)();
  1367. STDMETHOD(f358)();
  1368. STDMETHOD(f359)();
  1369. STDMETHOD(f360)();
  1370. STDMETHOD(f361)();
  1371. STDMETHOD(f362)();
  1372. STDMETHOD(f363)();
  1373. STDMETHOD(f364)();
  1374. STDMETHOD(f365)();
  1375. STDMETHOD(f366)();
  1376. STDMETHOD(f367)();
  1377. STDMETHOD(f368)();
  1378. STDMETHOD(f369)();
  1379. STDMETHOD(f370)();
  1380. STDMETHOD(f371)();
  1381. STDMETHOD(f372)();
  1382. STDMETHOD(f373)();
  1383. STDMETHOD(f374)();
  1384. STDMETHOD(f375)();
  1385. STDMETHOD(f376)();
  1386. STDMETHOD(f377)();
  1387. STDMETHOD(f378)();
  1388. STDMETHOD(f379)();
  1389. STDMETHOD(f380)();
  1390. STDMETHOD(f381)();
  1391. STDMETHOD(f382)();
  1392. STDMETHOD(f383)();
  1393. STDMETHOD(f384)();
  1394. STDMETHOD(f385)();
  1395. STDMETHOD(f386)();
  1396. STDMETHOD(f387)();
  1397. STDMETHOD(f388)();
  1398. STDMETHOD(f389)();
  1399. STDMETHOD(f390)();
  1400. STDMETHOD(f391)();
  1401. STDMETHOD(f392)();
  1402. STDMETHOD(f393)();
  1403. STDMETHOD(f394)();
  1404. STDMETHOD(f395)();
  1405. STDMETHOD(f396)();
  1406. STDMETHOD(f397)();
  1407. STDMETHOD(f398)();
  1408. STDMETHOD(f399)();
  1409. STDMETHOD(f400)();
  1410. STDMETHOD(f401)();
  1411. STDMETHOD(f402)();
  1412. STDMETHOD(f403)();
  1413. STDMETHOD(f404)();
  1414. STDMETHOD(f405)();
  1415. STDMETHOD(f406)();
  1416. STDMETHOD(f407)();
  1417. STDMETHOD(f408)();
  1418. STDMETHOD(f409)();
  1419. STDMETHOD(f410)();
  1420. STDMETHOD(f411)();
  1421. STDMETHOD(f412)();
  1422. STDMETHOD(f413)();
  1423. STDMETHOD(f414)();
  1424. STDMETHOD(f415)();
  1425. STDMETHOD(f416)();
  1426. STDMETHOD(f417)();
  1427. STDMETHOD(f418)();
  1428. STDMETHOD(f419)();
  1429. STDMETHOD(f420)();
  1430. STDMETHOD(f421)();
  1431. STDMETHOD(f422)();
  1432. STDMETHOD(f423)();
  1433. STDMETHOD(f424)();
  1434. STDMETHOD(f425)();
  1435. STDMETHOD(f426)();
  1436. STDMETHOD(f427)();
  1437. STDMETHOD(f428)();
  1438. STDMETHOD(f429)();
  1439. STDMETHOD(f430)();
  1440. STDMETHOD(f431)();
  1441. STDMETHOD(f432)();
  1442. STDMETHOD(f433)();
  1443. STDMETHOD(f434)();
  1444. STDMETHOD(f435)();
  1445. STDMETHOD(f436)();
  1446. STDMETHOD(f437)();
  1447. STDMETHOD(f438)();
  1448. STDMETHOD(f439)();
  1449. STDMETHOD(f440)();
  1450. STDMETHOD(f441)();
  1451. STDMETHOD(f442)();
  1452. STDMETHOD(f443)();
  1453. STDMETHOD(f444)();
  1454. STDMETHOD(f445)();
  1455. STDMETHOD(f446)();
  1456. STDMETHOD(f447)();
  1457. STDMETHOD(f448)();
  1458. STDMETHOD(f449)();
  1459. STDMETHOD(f450)();
  1460. STDMETHOD(f451)();
  1461. STDMETHOD(f452)();
  1462. STDMETHOD(f453)();
  1463. STDMETHOD(f454)();
  1464. STDMETHOD(f455)();
  1465. STDMETHOD(f456)();
  1466. STDMETHOD(f457)();
  1467. STDMETHOD(f458)();
  1468. STDMETHOD(f459)();
  1469. STDMETHOD(f460)();
  1470. STDMETHOD(f461)();
  1471. STDMETHOD(f462)();
  1472. STDMETHOD(f463)();
  1473. STDMETHOD(f464)();
  1474. STDMETHOD(f465)();
  1475. STDMETHOD(f466)();
  1476. STDMETHOD(f467)();
  1477. STDMETHOD(f468)();
  1478. STDMETHOD(f469)();
  1479. STDMETHOD(f470)();
  1480. STDMETHOD(f471)();
  1481. STDMETHOD(f472)();
  1482. STDMETHOD(f473)();
  1483. STDMETHOD(f474)();
  1484. STDMETHOD(f475)();
  1485. STDMETHOD(f476)();
  1486. STDMETHOD(f477)();
  1487. STDMETHOD(f478)();
  1488. STDMETHOD(f479)();
  1489. STDMETHOD(f480)();
  1490. STDMETHOD(f481)();
  1491. STDMETHOD(f482)();
  1492. STDMETHOD(f483)();
  1493. STDMETHOD(f484)();
  1494. STDMETHOD(f485)();
  1495. STDMETHOD(f486)();
  1496. STDMETHOD(f487)();
  1497. STDMETHOD(f488)();
  1498. STDMETHOD(f489)();
  1499. STDMETHOD(f490)();
  1500. STDMETHOD(f491)();
  1501. STDMETHOD(f492)();
  1502. STDMETHOD(f493)();
  1503. STDMETHOD(f494)();
  1504. STDMETHOD(f495)();
  1505. STDMETHOD(f496)();
  1506. STDMETHOD(f497)();
  1507. STDMETHOD(f498)();
  1508. STDMETHOD(f499)();
  1509. STDMETHOD(f500)();
  1510. STDMETHOD(f501)();
  1511. STDMETHOD(f502)();
  1512. STDMETHOD(f503)();
  1513. STDMETHOD(f504)();
  1514. STDMETHOD(f505)();
  1515. STDMETHOD(f506)();
  1516. STDMETHOD(f507)();
  1517. STDMETHOD(f508)();
  1518. STDMETHOD(f509)();
  1519. STDMETHOD(f510)();
  1520. STDMETHOD(f511)();
  1521. STDMETHOD(f512)();
  1522. STDMETHOD(f513)();
  1523. STDMETHOD(f514)();
  1524. STDMETHOD(f515)();
  1525. STDMETHOD(f516)();
  1526. STDMETHOD(f517)();
  1527. STDMETHOD(f518)();
  1528. STDMETHOD(f519)();
  1529. STDMETHOD(f520)();
  1530. STDMETHOD(f521)();
  1531. STDMETHOD(f522)();
  1532. STDMETHOD(f523)();
  1533. STDMETHOD(f524)();
  1534. STDMETHOD(f525)();
  1535. STDMETHOD(f526)();
  1536. STDMETHOD(f527)();
  1537. STDMETHOD(f528)();
  1538. STDMETHOD(f529)();
  1539. STDMETHOD(f530)();
  1540. STDMETHOD(f531)();
  1541. STDMETHOD(f532)();
  1542. STDMETHOD(f533)();
  1543. STDMETHOD(f534)();
  1544. STDMETHOD(f535)();
  1545. STDMETHOD(f536)();
  1546. STDMETHOD(f537)();
  1547. STDMETHOD(f538)();
  1548. STDMETHOD(f539)();
  1549. STDMETHOD(f540)();
  1550. STDMETHOD(f541)();
  1551. STDMETHOD(f542)();
  1552. STDMETHOD(f543)();
  1553. STDMETHOD(f544)();
  1554. STDMETHOD(f545)();
  1555. STDMETHOD(f546)();
  1556. STDMETHOD(f547)();
  1557. STDMETHOD(f548)();
  1558. STDMETHOD(f549)();
  1559. STDMETHOD(f550)();
  1560. STDMETHOD(f551)();
  1561. STDMETHOD(f552)();
  1562. STDMETHOD(f553)();
  1563. STDMETHOD(f554)();
  1564. STDMETHOD(f555)();
  1565. STDMETHOD(f556)();
  1566. STDMETHOD(f557)();
  1567. STDMETHOD(f558)();
  1568. STDMETHOD(f559)();
  1569. STDMETHOD(f560)();
  1570. STDMETHOD(f561)();
  1571. STDMETHOD(f562)();
  1572. STDMETHOD(f563)();
  1573. STDMETHOD(f564)();
  1574. STDMETHOD(f565)();
  1575. STDMETHOD(f566)();
  1576. STDMETHOD(f567)();
  1577. STDMETHOD(f568)();
  1578. STDMETHOD(f569)();
  1579. STDMETHOD(f570)();
  1580. STDMETHOD(f571)();
  1581. STDMETHOD(f572)();
  1582. STDMETHOD(f573)();
  1583. STDMETHOD(f574)();
  1584. STDMETHOD(f575)();
  1585. STDMETHOD(f576)();
  1586. STDMETHOD(f577)();
  1587. STDMETHOD(f578)();
  1588. STDMETHOD(f579)();
  1589. STDMETHOD(f580)();
  1590. STDMETHOD(f581)();
  1591. STDMETHOD(f582)();
  1592. STDMETHOD(f583)();
  1593. STDMETHOD(f584)();
  1594. STDMETHOD(f585)();
  1595. STDMETHOD(f586)();
  1596. STDMETHOD(f587)();
  1597. STDMETHOD(f588)();
  1598. STDMETHOD(f589)();
  1599. STDMETHOD(f590)();
  1600. STDMETHOD(f591)();
  1601. STDMETHOD(f592)();
  1602. STDMETHOD(f593)();
  1603. STDMETHOD(f594)();
  1604. STDMETHOD(f595)();
  1605. STDMETHOD(f596)();
  1606. STDMETHOD(f597)();
  1607. STDMETHOD(f598)();
  1608. STDMETHOD(f599)();
  1609. STDMETHOD(f600)();
  1610. STDMETHOD(f601)();
  1611. STDMETHOD(f602)();
  1612. STDMETHOD(f603)();
  1613. STDMETHOD(f604)();
  1614. STDMETHOD(f605)();
  1615. STDMETHOD(f606)();
  1616. STDMETHOD(f607)();
  1617. STDMETHOD(f608)();
  1618. STDMETHOD(f609)();
  1619. STDMETHOD(f610)();
  1620. STDMETHOD(f611)();
  1621. STDMETHOD(f612)();
  1622. STDMETHOD(f613)();
  1623. STDMETHOD(f614)();
  1624. STDMETHOD(f615)();
  1625. STDMETHOD(f616)();
  1626. STDMETHOD(f617)();
  1627. STDMETHOD(f618)();
  1628. STDMETHOD(f619)();
  1629. STDMETHOD(f620)();
  1630. STDMETHOD(f621)();
  1631. STDMETHOD(f622)();
  1632. STDMETHOD(f623)();
  1633. STDMETHOD(f624)();
  1634. STDMETHOD(f625)();
  1635. STDMETHOD(f626)();
  1636. STDMETHOD(f627)();
  1637. STDMETHOD(f628)();
  1638. STDMETHOD(f629)();
  1639. STDMETHOD(f630)();
  1640. STDMETHOD(f631)();
  1641. STDMETHOD(f632)();
  1642. STDMETHOD(f633)();
  1643. STDMETHOD(f634)();
  1644. STDMETHOD(f635)();
  1645. STDMETHOD(f636)();
  1646. STDMETHOD(f637)();
  1647. STDMETHOD(f638)();
  1648. STDMETHOD(f639)();
  1649. STDMETHOD(f640)();
  1650. STDMETHOD(f641)();
  1651. STDMETHOD(f642)();
  1652. STDMETHOD(f643)();
  1653. STDMETHOD(f644)();
  1654. STDMETHOD(f645)();
  1655. STDMETHOD(f646)();
  1656. STDMETHOD(f647)();
  1657. STDMETHOD(f648)();
  1658. STDMETHOD(f649)();
  1659. STDMETHOD(f650)();
  1660. STDMETHOD(f651)();
  1661. STDMETHOD(f652)();
  1662. STDMETHOD(f653)();
  1663. STDMETHOD(f654)();
  1664. STDMETHOD(f655)();
  1665. STDMETHOD(f656)();
  1666. STDMETHOD(f657)();
  1667. STDMETHOD(f658)();
  1668. STDMETHOD(f659)();
  1669. STDMETHOD(f660)();
  1670. STDMETHOD(f661)();
  1671. STDMETHOD(f662)();
  1672. STDMETHOD(f663)();
  1673. STDMETHOD(f664)();
  1674. STDMETHOD(f665)();
  1675. STDMETHOD(f666)();
  1676. STDMETHOD(f667)();
  1677. STDMETHOD(f668)();
  1678. STDMETHOD(f669)();
  1679. STDMETHOD(f670)();
  1680. STDMETHOD(f671)();
  1681. STDMETHOD(f672)();
  1682. STDMETHOD(f673)();
  1683. STDMETHOD(f674)();
  1684. STDMETHOD(f675)();
  1685. STDMETHOD(f676)();
  1686. STDMETHOD(f677)();
  1687. STDMETHOD(f678)();
  1688. STDMETHOD(f679)();
  1689. STDMETHOD(f680)();
  1690. STDMETHOD(f681)();
  1691. STDMETHOD(f682)();
  1692. STDMETHOD(f683)();
  1693. STDMETHOD(f684)();
  1694. STDMETHOD(f685)();
  1695. STDMETHOD(f686)();
  1696. STDMETHOD(f687)();
  1697. STDMETHOD(f688)();
  1698. STDMETHOD(f689)();
  1699. STDMETHOD(f690)();
  1700. STDMETHOD(f691)();
  1701. STDMETHOD(f692)();
  1702. STDMETHOD(f693)();
  1703. STDMETHOD(f694)();
  1704. STDMETHOD(f695)();
  1705. STDMETHOD(f696)();
  1706. STDMETHOD(f697)();
  1707. STDMETHOD(f698)();
  1708. STDMETHOD(f699)();
  1709. STDMETHOD(f700)();
  1710. STDMETHOD(f701)();
  1711. STDMETHOD(f702)();
  1712. STDMETHOD(f703)();
  1713. STDMETHOD(f704)();
  1714. STDMETHOD(f705)();
  1715. STDMETHOD(f706)();
  1716. STDMETHOD(f707)();
  1717. STDMETHOD(f708)();
  1718. STDMETHOD(f709)();
  1719. STDMETHOD(f710)();
  1720. STDMETHOD(f711)();
  1721. STDMETHOD(f712)();
  1722. STDMETHOD(f713)();
  1723. STDMETHOD(f714)();
  1724. STDMETHOD(f715)();
  1725. STDMETHOD(f716)();
  1726. STDMETHOD(f717)();
  1727. STDMETHOD(f718)();
  1728. STDMETHOD(f719)();
  1729. STDMETHOD(f720)();
  1730. STDMETHOD(f721)();
  1731. STDMETHOD(f722)();
  1732. STDMETHOD(f723)();
  1733. STDMETHOD(f724)();
  1734. STDMETHOD(f725)();
  1735. STDMETHOD(f726)();
  1736. STDMETHOD(f727)();
  1737. STDMETHOD(f728)();
  1738. STDMETHOD(f729)();
  1739. STDMETHOD(f730)();
  1740. STDMETHOD(f731)();
  1741. STDMETHOD(f732)();
  1742. STDMETHOD(f733)();
  1743. STDMETHOD(f734)();
  1744. STDMETHOD(f735)();
  1745. STDMETHOD(f736)();
  1746. STDMETHOD(f737)();
  1747. STDMETHOD(f738)();
  1748. STDMETHOD(f739)();
  1749. STDMETHOD(f740)();
  1750. STDMETHOD(f741)();
  1751. STDMETHOD(f742)();
  1752. STDMETHOD(f743)();
  1753. STDMETHOD(f744)();
  1754. STDMETHOD(f745)();
  1755. STDMETHOD(f746)();
  1756. STDMETHOD(f747)();
  1757. STDMETHOD(f748)();
  1758. STDMETHOD(f749)();
  1759. STDMETHOD(f750)();
  1760. STDMETHOD(f751)();
  1761. STDMETHOD(f752)();
  1762. STDMETHOD(f753)();
  1763. STDMETHOD(f754)();
  1764. STDMETHOD(f755)();
  1765. STDMETHOD(f756)();
  1766. STDMETHOD(f757)();
  1767. STDMETHOD(f758)();
  1768. STDMETHOD(f759)();
  1769. STDMETHOD(f760)();
  1770. STDMETHOD(f761)();
  1771. STDMETHOD(f762)();
  1772. STDMETHOD(f763)();
  1773. STDMETHOD(f764)();
  1774. STDMETHOD(f765)();
  1775. STDMETHOD(f766)();
  1776. STDMETHOD(f767)();
  1777. STDMETHOD(f768)();
  1778. STDMETHOD(f769)();
  1779. STDMETHOD(f770)();
  1780. STDMETHOD(f771)();
  1781. STDMETHOD(f772)();
  1782. STDMETHOD(f773)();
  1783. STDMETHOD(f774)();
  1784. STDMETHOD(f775)();
  1785. STDMETHOD(f776)();
  1786. STDMETHOD(f777)();
  1787. STDMETHOD(f778)();
  1788. STDMETHOD(f779)();
  1789. STDMETHOD(f780)();
  1790. STDMETHOD(f781)();
  1791. STDMETHOD(f782)();
  1792. STDMETHOD(f783)();
  1793. STDMETHOD(f784)();
  1794. STDMETHOD(f785)();
  1795. STDMETHOD(f786)();
  1796. STDMETHOD(f787)();
  1797. STDMETHOD(f788)();
  1798. STDMETHOD(f789)();
  1799. STDMETHOD(f790)();
  1800. STDMETHOD(f791)();
  1801. STDMETHOD(f792)();
  1802. STDMETHOD(f793)();
  1803. STDMETHOD(f794)();
  1804. STDMETHOD(f795)();
  1805. STDMETHOD(f796)();
  1806. STDMETHOD(f797)();
  1807. STDMETHOD(f798)();
  1808. STDMETHOD(f799)();
  1809. STDMETHOD(f800)();
  1810. STDMETHOD(f801)();
  1811. STDMETHOD(f802)();
  1812. STDMETHOD(f803)();
  1813. STDMETHOD(f804)();
  1814. STDMETHOD(f805)();
  1815. STDMETHOD(f806)();
  1816. STDMETHOD(f807)();
  1817. STDMETHOD(f808)();
  1818. STDMETHOD(f809)();
  1819. STDMETHOD(f810)();
  1820. STDMETHOD(f811)();
  1821. STDMETHOD(f812)();
  1822. STDMETHOD(f813)();
  1823. STDMETHOD(f814)();
  1824. STDMETHOD(f815)();
  1825. STDMETHOD(f816)();
  1826. STDMETHOD(f817)();
  1827. STDMETHOD(f818)();
  1828. STDMETHOD(f819)();
  1829. STDMETHOD(f820)();
  1830. STDMETHOD(f821)();
  1831. STDMETHOD(f822)();
  1832. STDMETHOD(f823)();
  1833. STDMETHOD(f824)();
  1834. STDMETHOD(f825)();
  1835. STDMETHOD(f826)();
  1836. STDMETHOD(f827)();
  1837. STDMETHOD(f828)();
  1838. STDMETHOD(f829)();
  1839. STDMETHOD(f830)();
  1840. STDMETHOD(f831)();
  1841. STDMETHOD(f832)();
  1842. STDMETHOD(f833)();
  1843. STDMETHOD(f834)();
  1844. STDMETHOD(f835)();
  1845. STDMETHOD(f836)();
  1846. STDMETHOD(f837)();
  1847. STDMETHOD(f838)();
  1848. STDMETHOD(f839)();
  1849. STDMETHOD(f840)();
  1850. STDMETHOD(f841)();
  1851. STDMETHOD(f842)();
  1852. STDMETHOD(f843)();
  1853. STDMETHOD(f844)();
  1854. STDMETHOD(f845)();
  1855. STDMETHOD(f846)();
  1856. STDMETHOD(f847)();
  1857. STDMETHOD(f848)();
  1858. STDMETHOD(f849)();
  1859. STDMETHOD(f850)();
  1860. STDMETHOD(f851)();
  1861. STDMETHOD(f852)();
  1862. STDMETHOD(f853)();
  1863. STDMETHOD(f854)();
  1864. STDMETHOD(f855)();
  1865. STDMETHOD(f856)();
  1866. STDMETHOD(f857)();
  1867. STDMETHOD(f858)();
  1868. STDMETHOD(f859)();
  1869. STDMETHOD(f860)();
  1870. STDMETHOD(f861)();
  1871. STDMETHOD(f862)();
  1872. STDMETHOD(f863)();
  1873. STDMETHOD(f864)();
  1874. STDMETHOD(f865)();
  1875. STDMETHOD(f866)();
  1876. STDMETHOD(f867)();
  1877. STDMETHOD(f868)();
  1878. STDMETHOD(f869)();
  1879. STDMETHOD(f870)();
  1880. STDMETHOD(f871)();
  1881. STDMETHOD(f872)();
  1882. STDMETHOD(f873)();
  1883. STDMETHOD(f874)();
  1884. STDMETHOD(f875)();
  1885. STDMETHOD(f876)();
  1886. STDMETHOD(f877)();
  1887. STDMETHOD(f878)();
  1888. STDMETHOD(f879)();
  1889. STDMETHOD(f880)();
  1890. STDMETHOD(f881)();
  1891. STDMETHOD(f882)();
  1892. STDMETHOD(f883)();
  1893. STDMETHOD(f884)();
  1894. STDMETHOD(f885)();
  1895. STDMETHOD(f886)();
  1896. STDMETHOD(f887)();
  1897. STDMETHOD(f888)();
  1898. STDMETHOD(f889)();
  1899. STDMETHOD(f890)();
  1900. STDMETHOD(f891)();
  1901. STDMETHOD(f892)();
  1902. STDMETHOD(f893)();
  1903. STDMETHOD(f894)();
  1904. STDMETHOD(f895)();
  1905. STDMETHOD(f896)();
  1906. STDMETHOD(f897)();
  1907. STDMETHOD(f898)();
  1908. STDMETHOD(f899)();
  1909. STDMETHOD(f900)();
  1910. STDMETHOD(f901)();
  1911. STDMETHOD(f902)();
  1912. STDMETHOD(f903)();
  1913. STDMETHOD(f904)();
  1914. STDMETHOD(f905)();
  1915. STDMETHOD(f906)();
  1916. STDMETHOD(f907)();
  1917. STDMETHOD(f908)();
  1918. STDMETHOD(f909)();
  1919. STDMETHOD(f910)();
  1920. STDMETHOD(f911)();
  1921. STDMETHOD(f912)();
  1922. STDMETHOD(f913)();
  1923. STDMETHOD(f914)();
  1924. STDMETHOD(f915)();
  1925. STDMETHOD(f916)();
  1926. STDMETHOD(f917)();
  1927. STDMETHOD(f918)();
  1928. STDMETHOD(f919)();
  1929. STDMETHOD(f920)();
  1930. STDMETHOD(f921)();
  1931. STDMETHOD(f922)();
  1932. STDMETHOD(f923)();
  1933. STDMETHOD(f924)();
  1934. STDMETHOD(f925)();
  1935. STDMETHOD(f926)();
  1936. STDMETHOD(f927)();
  1937. STDMETHOD(f928)();
  1938. STDMETHOD(f929)();
  1939. STDMETHOD(f930)();
  1940. STDMETHOD(f931)();
  1941. STDMETHOD(f932)();
  1942. STDMETHOD(f933)();
  1943. STDMETHOD(f934)();
  1944. STDMETHOD(f935)();
  1945. STDMETHOD(f936)();
  1946. STDMETHOD(f937)();
  1947. STDMETHOD(f938)();
  1948. STDMETHOD(f939)();
  1949. STDMETHOD(f940)();
  1950. STDMETHOD(f941)();
  1951. STDMETHOD(f942)();
  1952. STDMETHOD(f943)();
  1953. STDMETHOD(f944)();
  1954. STDMETHOD(f945)();
  1955. STDMETHOD(f946)();
  1956. STDMETHOD(f947)();
  1957. STDMETHOD(f948)();
  1958. STDMETHOD(f949)();
  1959. STDMETHOD(f950)();
  1960. STDMETHOD(f951)();
  1961. STDMETHOD(f952)();
  1962. STDMETHOD(f953)();
  1963. STDMETHOD(f954)();
  1964. STDMETHOD(f955)();
  1965. STDMETHOD(f956)();
  1966. STDMETHOD(f957)();
  1967. STDMETHOD(f958)();
  1968. STDMETHOD(f959)();
  1969. STDMETHOD(f960)();
  1970. STDMETHOD(f961)();
  1971. STDMETHOD(f962)();
  1972. STDMETHOD(f963)();
  1973. STDMETHOD(f964)();
  1974. STDMETHOD(f965)();
  1975. STDMETHOD(f966)();
  1976. STDMETHOD(f967)();
  1977. STDMETHOD(f968)();
  1978. STDMETHOD(f969)();
  1979. STDMETHOD(f970)();
  1980. STDMETHOD(f971)();
  1981. STDMETHOD(f972)();
  1982. STDMETHOD(f973)();
  1983. STDMETHOD(f974)();
  1984. STDMETHOD(f975)();
  1985. STDMETHOD(f976)();
  1986. STDMETHOD(f977)();
  1987. STDMETHOD(f978)();
  1988. STDMETHOD(f979)();
  1989. STDMETHOD(f980)();
  1990. STDMETHOD(f981)();
  1991. STDMETHOD(f982)();
  1992. STDMETHOD(f983)();
  1993. STDMETHOD(f984)();
  1994. STDMETHOD(f985)();
  1995. STDMETHOD(f986)();
  1996. STDMETHOD(f987)();
  1997. STDMETHOD(f988)();
  1998. STDMETHOD(f989)();
  1999. STDMETHOD(f990)();
  2000. STDMETHOD(f991)();
  2001. STDMETHOD(f992)();
  2002. STDMETHOD(f993)();
  2003. STDMETHOD(f994)();
  2004. STDMETHOD(f995)();
  2005. STDMETHOD(f996)();
  2006. STDMETHOD(f997)();
  2007. STDMETHOD(f998)();
  2008. STDMETHOD(f999)();
  2009. STDMETHOD(f1000)();
  2010. STDMETHOD(f1001)();
  2011. STDMETHOD(f1002)();
  2012. STDMETHOD(f1003)();
  2013. STDMETHOD(f1004)();
  2014. STDMETHOD(f1005)();
  2015. STDMETHOD(f1006)();
  2016. STDMETHOD(f1007)();
  2017. STDMETHOD(f1008)();
  2018. STDMETHOD(f1009)();
  2019. STDMETHOD(f1010)();
  2020. STDMETHOD(f1011)();
  2021. STDMETHOD(f1012)();
  2022. STDMETHOD(f1013)();
  2023. STDMETHOD(f1014)();
  2024. STDMETHOD(f1015)();
  2025. STDMETHOD(f1016)();
  2026. STDMETHOD(f1017)();
  2027. STDMETHOD(f1018)();
  2028. STDMETHOD(f1019)();
  2029. STDMETHOD(f1020)();
  2030. STDMETHOD(f1021)();
  2031. STDMETHOD(f1022)();
  2032. STDMETHOD(f1023)();
  2033. STDMETHOD(f1024)();
  2034. _QIThunk(IUnknown* pOrig, LPCTSTR p, const IID& i, UINT n, bool b)
  2035. {
  2036. lpszClassName = p;
  2037. iid = i;
  2038. nIndex = n;
  2039. m_dwRef = 0;
  2040. m_dwMaxRef = 0;
  2041. pUnk = pOrig;
  2042. bBreak = b;
  2043. bNonAddRefThunk = false;
  2044. }
  2045. IUnknown* pUnk;
  2046. long m_dwRef;
  2047. long m_dwMaxRef;
  2048. LPCTSTR lpszClassName;
  2049. IID iid;
  2050. UINT nIndex;
  2051. bool bBreak;
  2052. bool bNonAddRefThunk;
  2053. void Dump()
  2054. {
  2055. TCHAR buf[256];
  2056. if (m_dwRef != 0)
  2057. {
  2058. wsprintf(buf, _T("INTERFACE LEAK: RefCount = %d, MaxRefCount = %d, {Allocation = %d} "), m_dwRef, m_dwMaxRef, nIndex);
  2059. OutputDebugString(buf);
  2060. AtlDumpIID(iid, lpszClassName, S_OK);
  2061. }
  2062. else
  2063. {
  2064. wsprintf(buf, _T("NonAddRef Thunk LEAK: {Allocation = %d}\n"), nIndex);
  2065. OutputDebugString(buf);
  2066. }
  2067. }
  2068. };
  2069. #endif
  2070. /////////////////////////////////////////////////////////////////////////////
  2071. // Collection helpers - CSimpleArray & CSimpleMap
  2072. template <class T>
  2073. class CSimpleArray
  2074. {
  2075. public:
  2076. T* m_aT;
  2077. int m_nSize;
  2078. int m_nAllocSize;
  2079. // Construction/destruction
  2080. CSimpleArray() : m_aT(NULL), m_nSize(0), m_nAllocSize(0)
  2081. { }
  2082. ~CSimpleArray()
  2083. {
  2084. RemoveAll();
  2085. }
  2086. // Operations
  2087. int GetSize() const
  2088. {
  2089. return m_nSize;
  2090. }
  2091. BOOL Add(T& t)
  2092. {
  2093. if(m_nSize == m_nAllocSize)
  2094. {
  2095. T* aT;
  2096. int nNewAllocSize = (m_nAllocSize == 0) ? 1 : (m_nSize * 2);
  2097. aT = (T*)realloc(m_aT, nNewAllocSize * sizeof(T));
  2098. if(aT == NULL)
  2099. return FALSE;
  2100. m_nAllocSize = nNewAllocSize;
  2101. m_aT = aT;
  2102. }
  2103. m_nSize++;
  2104. SetAtIndex(m_nSize - 1, t);
  2105. return TRUE;
  2106. }
  2107. BOOL Remove(T& t)
  2108. {
  2109. int nIndex = Find(t);
  2110. if(nIndex == -1)
  2111. return FALSE;
  2112. return RemoveAt(nIndex);
  2113. }
  2114. BOOL RemoveAt(int nIndex)
  2115. {
  2116. if(nIndex != (m_nSize - 1))
  2117. {
  2118. #if (_WIN32_WCE == 200)
  2119. if(m_aT[nIndex] != NULL)
  2120. delete m_aT[nIndex];
  2121. #else // _WIN32_WCE
  2122. m_aT[nIndex].~T();
  2123. #endif // _WIN32_WCE
  2124. memmove((void*)&m_aT[nIndex], (void*)&m_aT[nIndex + 1], (m_nSize - (nIndex + 1)) * sizeof(T));
  2125. }
  2126. m_nSize--;
  2127. return TRUE;
  2128. }
  2129. void RemoveAll()
  2130. {
  2131. if(m_aT != NULL)
  2132. {
  2133. for(int i = 0; i < m_nSize; i++)
  2134. #if (_WIN32_WCE == 200)
  2135. if(m_aT[i] != NULL)
  2136. delete m_aT[i];
  2137. #else // _WIN32_WCE
  2138. m_aT[i].~T();
  2139. #endif // _WIN32_WCE
  2140. free(m_aT);
  2141. m_aT = NULL;
  2142. }
  2143. m_nSize = 0;
  2144. m_nAllocSize = 0;
  2145. }
  2146. T& operator[] (int nIndex) const
  2147. {
  2148. ATLASSERT(nIndex >= 0 && nIndex < m_nSize);
  2149. return m_aT[nIndex];
  2150. }
  2151. T* GetData() const
  2152. {
  2153. return m_aT;
  2154. }
  2155. // Implementation
  2156. class Wrapper
  2157. {
  2158. public:
  2159. Wrapper(T& _t) : t(_t)
  2160. {
  2161. }
  2162. template <class _Ty>
  2163. void *operator new(size_t, _Ty* p)
  2164. {
  2165. return p;
  2166. }
  2167. T t;
  2168. };
  2169. void SetAtIndex(int nIndex, T& t)
  2170. {
  2171. ATLASSERT(nIndex >= 0 && nIndex < m_nSize);
  2172. new(&m_aT[nIndex]) Wrapper(t);
  2173. }
  2174. int Find(T& t) const
  2175. {
  2176. for(int i = 0; i < m_nSize; i++)
  2177. {
  2178. if(m_aT[i] == t)
  2179. return i;
  2180. }
  2181. return -1; // not found
  2182. }
  2183. };
  2184. // for arrays of simple types
  2185. template <class T>
  2186. class CSimpleValArray : public CSimpleArray< T >
  2187. {
  2188. public:
  2189. BOOL Add(T t)
  2190. {
  2191. return CSimpleArray< T >::Add(t);
  2192. }
  2193. BOOL Remove(T t)
  2194. {
  2195. return CSimpleArray< T >::Remove(t);
  2196. }
  2197. T operator[] (int nIndex) const
  2198. {
  2199. return CSimpleArray< T >::operator[](nIndex);
  2200. }
  2201. };
  2202. // intended for small number of simple types or pointers
  2203. template <class TKey, class TVal>
  2204. class CSimpleMap
  2205. {
  2206. public:
  2207. TKey* m_aKey;
  2208. TVal* m_aVal;
  2209. int m_nSize;
  2210. // Construction/destruction
  2211. CSimpleMap() : m_aKey(NULL), m_aVal(NULL), m_nSize(0)
  2212. { }
  2213. ~CSimpleMap()
  2214. {
  2215. RemoveAll();
  2216. }
  2217. // Operations
  2218. int GetSize() const
  2219. {
  2220. return m_nSize;
  2221. }
  2222. BOOL Add(TKey key, TVal val)
  2223. {
  2224. TKey* pKey;
  2225. pKey = (TKey*)realloc(m_aKey, (m_nSize + 1) * sizeof(TKey));
  2226. if(pKey == NULL)
  2227. return FALSE;
  2228. m_aKey = pKey;
  2229. TVal* pVal;
  2230. pVal = (TVal*)realloc(m_aVal, (m_nSize + 1) * sizeof(TVal));
  2231. if(pVal == NULL)
  2232. return FALSE;
  2233. m_aVal = pVal;
  2234. m_nSize++;
  2235. SetAtIndex(m_nSize - 1, key, val);
  2236. return TRUE;
  2237. }
  2238. BOOL Remove(TKey key)
  2239. {
  2240. int nIndex = FindKey(key);
  2241. if(nIndex == -1)
  2242. return FALSE;
  2243. if(nIndex != (m_nSize - 1))
  2244. {
  2245. #if (_WIN32_WCE == 200)
  2246. if(m_aKey[nIndex] != NULL)
  2247. delete m_aKey[nIndex];
  2248. if(m_aVal[nIndex] != NULL)
  2249. delete m_aVal[nIndex];
  2250. #else // _WIN32_WCE
  2251. m_aKey[nIndex].~TKey();
  2252. m_aVal[nIndex].~TVal();
  2253. #endif // _WIN32_WCE
  2254. memmove((void*)&m_aKey[nIndex], (void*)&m_aKey[nIndex + 1], (m_nSize - (nIndex + 1)) * sizeof(TKey));
  2255. memmove((void*)&m_aVal[nIndex], (void*)&m_aVal[nIndex + 1], (m_nSize - (nIndex + 1)) * sizeof(TVal));
  2256. }
  2257. TKey* pKey;
  2258. pKey = (TKey*)realloc(m_aKey, (m_nSize - 1) * sizeof(TKey));
  2259. if(pKey != NULL || m_nSize == 1)
  2260. m_aKey = pKey;
  2261. TVal* pVal;
  2262. pVal = (TVal*)realloc(m_aVal, (m_nSize - 1) * sizeof(TVal));
  2263. if(pVal != NULL || m_nSize == 1)
  2264. m_aVal = pVal;
  2265. m_nSize--;
  2266. return TRUE;
  2267. }
  2268. void RemoveAll()
  2269. {
  2270. if(m_aKey != NULL)
  2271. {
  2272. for(int i = 0; i < m_nSize; i++)
  2273. {
  2274. #if (_WIN32_WCE == 200)
  2275. if(m_aKey[i] != NULL)
  2276. delete m_aKey[nIndex];
  2277. if(m_aVal[i] != NULL)
  2278. delete m_aVal[nIndex];
  2279. #else // _WIN32_WCE
  2280. m_aKey[i].~TKey();
  2281. m_aVal[i].~TVal();
  2282. #endif // _WIN32_WCE
  2283. }
  2284. free(m_aKey);
  2285. m_aKey = NULL;
  2286. }
  2287. if(m_aVal != NULL)
  2288. {
  2289. free(m_aVal);
  2290. m_aVal = NULL;
  2291. }
  2292. m_nSize = 0;
  2293. }
  2294. BOOL SetAt(TKey key, TVal val)
  2295. {
  2296. int nIndex = FindKey(key);
  2297. if(nIndex == -1)
  2298. return FALSE;
  2299. SetAtIndex(nIndex, key, val);
  2300. return TRUE;
  2301. }
  2302. TVal Lookup(TKey key) const
  2303. {
  2304. int nIndex = FindKey(key);
  2305. if(nIndex == -1)
  2306. return NULL; // must be able to convert
  2307. return GetValueAt(nIndex);
  2308. }
  2309. TKey ReverseLookup(TVal val) const
  2310. {
  2311. int nIndex = FindVal(val);
  2312. if(nIndex == -1)
  2313. return NULL; // must be able to convert
  2314. return GetKeyAt(nIndex);
  2315. }
  2316. TKey& GetKeyAt(int nIndex) const
  2317. {
  2318. ATLASSERT(nIndex >= 0 && nIndex < m_nSize);
  2319. return m_aKey[nIndex];
  2320. }
  2321. TVal& GetValueAt(int nIndex) const
  2322. {
  2323. ATLASSERT(nIndex >= 0 && nIndex < m_nSize);
  2324. return m_aVal[nIndex];
  2325. }
  2326. // Implementation
  2327. template <typename T>
  2328. class Wrapper
  2329. {
  2330. public:
  2331. Wrapper(T& _t) : t(_t)
  2332. {
  2333. }
  2334. template <typename _Ty>
  2335. void *operator new(size_t, _Ty* p)
  2336. {
  2337. return p;
  2338. }
  2339. T t;
  2340. };
  2341. void SetAtIndex(int nIndex, TKey& key, TVal& val)
  2342. {
  2343. ATLASSERT(nIndex >= 0 && nIndex < m_nSize);
  2344. new(&m_aKey[nIndex]) Wrapper<TKey>(key);
  2345. new(&m_aVal[nIndex]) Wrapper<TVal>(val);
  2346. }
  2347. int FindKey(TKey& key) const
  2348. {
  2349. for(int i = 0; i < m_nSize; i++)
  2350. {
  2351. if(m_aKey[i] == key)
  2352. return i;
  2353. }
  2354. return -1; // not found
  2355. }
  2356. int FindVal(TVal& val) const
  2357. {
  2358. for(int i = 0; i < m_nSize; i++)
  2359. {
  2360. if(m_aVal[i] == val)
  2361. return i;
  2362. }
  2363. return -1; // not found
  2364. }
  2365. };
  2366. class CComModule;
  2367. __declspec(selectany) CComModule* _pModule=NULL;
  2368. // {B62F5910-6528-11d1-9611-0000F81E0D0D}
  2369. _declspec(selectany) GUID GUID_ATLVer30 = { 0xb62f5910, 0x6528, 0x11d1, { 0x96, 0x11, 0x0, 0x0, 0xf8, 0x1e, 0xd, 0xd } };
  2370. class CComModule : public _ATL_MODULE
  2371. {
  2372. // Operations
  2373. public:
  2374. static GUID m_libid;
  2375. #ifdef _ATL_DEBUG_INTERFACES
  2376. UINT m_nIndexQI;
  2377. UINT m_nIndexBreakAt;
  2378. CSimpleArray<_QIThunk*>* m_paThunks;
  2379. #endif // _ATL_DEBUG_INTERFACES
  2380. void AddCreateWndData(_AtlCreateWndData* pData, void* pObject)
  2381. {
  2382. AtlModuleAddCreateWndData(this, pData, pObject);
  2383. }
  2384. void* ExtractCreateWndData()
  2385. {
  2386. return AtlModuleExtractCreateWndData(this);
  2387. }
  2388. HRESULT Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h, const GUID* plibid = NULL)
  2389. {
  2390. pguidVer = &GUID_ATLVer30;
  2391. _pModule = this;
  2392. cbSize = sizeof(_ATL_MODULE);
  2393. dwAtlBuildVer = _ATL_VER;
  2394. AtlModuleInit(this, p, h);
  2395. if (plibid != NULL)
  2396. memcpy((void*)&m_libid, plibid, sizeof(GUID));
  2397. #ifdef _ATL_MIN_CRT
  2398. // Create a base heap
  2399. m_hHeap = HeapCreate(0, 0, 0);
  2400. #ifndef _ATL_NO_MP_HEAP
  2401. SYSTEM_INFO si;
  2402. GetSystemInfo(&si);
  2403. if (si.dwNumberOfProcessors > 1)
  2404. {
  2405. DWORD dwHeaps = si.dwNumberOfProcessors * 2;
  2406. m_dwHeaps = 0xFFFFFFFF;
  2407. for (int bits=0; bits<32; bits++)
  2408. {
  2409. if (dwHeaps & 0x80000000)
  2410. break;
  2411. dwHeaps <<= 1;
  2412. m_dwHeaps >>= 1;
  2413. }
  2414. m_dwHeaps >>= 1;
  2415. // Allocate more heaps for each processor
  2416. m_phHeaps = (HANDLE*) HeapAlloc(m_hHeap, _ATL_HEAPFLAGS, sizeof(HANDLE) * (m_dwHeaps + 1));
  2417. for (DWORD i=0; i<=m_dwHeaps; i++)
  2418. m_phHeaps[i] = HeapCreate(0, 0, 0);
  2419. }
  2420. else
  2421. #endif
  2422. {
  2423. m_phHeaps = NULL;
  2424. m_dwHeaps = 0;
  2425. }
  2426. #endif
  2427. #ifdef _ATL_DEBUG_INTERFACES
  2428. m_nIndexQI = 0;
  2429. m_nIndexBreakAt = 0;
  2430. m_paThunks = NULL;
  2431. ATLTRY(m_paThunks = new CSimpleArray<_QIThunk*>);
  2432. if (m_paThunks == NULL)
  2433. return E_OUTOFMEMORY;
  2434. #endif // _ATL_DEBUG_INTERFACES
  2435. return S_OK;
  2436. }
  2437. #ifdef _ATL_DEBUG_INTERFACES
  2438. HRESULT AddThunk(IUnknown** pp, LPCTSTR lpsz, REFIID iid)
  2439. {
  2440. if ((pp == NULL) || (*pp == NULL))
  2441. return E_POINTER;
  2442. IUnknown* p = *pp;
  2443. _QIThunk* pThunk = NULL;
  2444. EnterCriticalSection(&m_csObjMap);
  2445. // Check if exists already for identity
  2446. if (InlineIsEqualUnknown(iid))
  2447. {
  2448. for (int i=0; i<m_paThunks->GetSize(); i++)
  2449. {
  2450. if (m_paThunks->operator[](i)->pUnk == p)
  2451. {
  2452. m_paThunks->operator[](i)->InternalAddRef();
  2453. pThunk = m_paThunks->operator[](i);
  2454. break;
  2455. }
  2456. }
  2457. }
  2458. if (pThunk == NULL)
  2459. {
  2460. ++m_nIndexQI;
  2461. if (m_nIndexBreakAt == m_nIndexQI)
  2462. DebugBreak();
  2463. ATLTRY(pThunk = new _QIThunk(p, lpsz, iid, m_nIndexQI, (m_nIndexBreakAt == m_nIndexQI)));
  2464. if (pThunk == NULL)
  2465. return E_OUTOFMEMORY;
  2466. pThunk->InternalAddRef();
  2467. m_paThunks->Add(pThunk);
  2468. }
  2469. LeaveCriticalSection(&m_csObjMap);
  2470. *pp = (IUnknown*)pThunk;
  2471. return S_OK;
  2472. }
  2473. HRESULT AddNonAddRefThunk(IUnknown* p, LPCTSTR lpsz, IUnknown** ppThunkRet)
  2474. {
  2475. _QIThunk* pThunk = NULL;
  2476. EnterCriticalSection(&m_csObjMap);
  2477. // Check if exists already for identity
  2478. for (int i=0; i<m_paThunks->GetSize(); i++)
  2479. {
  2480. if (m_paThunks->operator[](i)->pUnk == p)
  2481. {
  2482. m_paThunks->operator[](i)->bNonAddRefThunk = true;
  2483. pThunk = m_paThunks->operator[](i);
  2484. break;
  2485. }
  2486. }
  2487. if (pThunk == NULL)
  2488. {
  2489. ++m_nIndexQI;
  2490. if (m_nIndexBreakAt == m_nIndexQI)
  2491. DebugBreak();
  2492. ATLTRY(pThunk = new _QIThunk(p, lpsz, IID_IUnknown, m_nIndexQI, (m_nIndexBreakAt == m_nIndexQI)));
  2493. if (pThunk == NULL)
  2494. {
  2495. *ppThunkRet = NULL;
  2496. return E_OUTOFMEMORY;
  2497. }
  2498. pThunk->bNonAddRefThunk = true;
  2499. m_paThunks->Add(pThunk);
  2500. }
  2501. LeaveCriticalSection(&m_csObjMap);
  2502. *ppThunkRet = (IUnknown*)pThunk;
  2503. return S_OK;;
  2504. }
  2505. void DeleteNonAddRefThunk(IUnknown* pUnk)
  2506. {
  2507. EnterCriticalSection(&m_csObjMap);
  2508. for (int i=0; i<m_paThunks->GetSize(); i++)
  2509. {
  2510. if (m_paThunks->operator[](i)->pUnk == pUnk)
  2511. {
  2512. delete m_paThunks->operator[](i);
  2513. m_paThunks->RemoveAt(i);
  2514. break;
  2515. }
  2516. }
  2517. LeaveCriticalSection(&m_csObjMap);
  2518. }
  2519. void DeleteThunk(_QIThunk* p)
  2520. {
  2521. EnterCriticalSection(&m_csObjMap);
  2522. int nIndex = m_paThunks->Find(p);
  2523. if (nIndex != -1)
  2524. {
  2525. delete m_paThunks->operator[](nIndex);
  2526. m_paThunks->RemoveAt(nIndex);
  2527. }
  2528. LeaveCriticalSection(&m_csObjMap);
  2529. }
  2530. bool DumpLeakedThunks()
  2531. {
  2532. bool b = false;
  2533. for (int i=0; i<m_paThunks->GetSize(); i++)
  2534. {
  2535. b = true;
  2536. m_paThunks->operator[](i)->Dump();
  2537. delete m_paThunks->operator[](i);
  2538. }
  2539. m_paThunks->RemoveAll();
  2540. return b;
  2541. }
  2542. #endif // _ATL_DEBUG_INTERFACES
  2543. void Term()
  2544. {
  2545. #ifdef _ATL_DEBUG_INTERFACES
  2546. m_bDestroyHeap = false; // prevent heap from going away
  2547. AtlModuleTerm(this);
  2548. DumpLeakedThunks();
  2549. delete m_paThunks;
  2550. #ifndef _ATL_NO_MP_HEAP
  2551. if (m_phHeaps != NULL)
  2552. {
  2553. for (DWORD i = 0; i <= m_dwHeaps; i++)
  2554. HeapDestroy(m_phHeaps[i]);
  2555. }
  2556. #endif
  2557. if (m_hHeap != NULL)
  2558. HeapDestroy(m_hHeap);
  2559. #else
  2560. AtlModuleTerm(this);
  2561. #endif // _ATL_DEBUG_INTERFACES
  2562. }
  2563. HRESULT AddTermFunc(_ATL_TERMFUNC* pFunc, DWORD dw)
  2564. {
  2565. return AtlModuleAddTermFunc(this, pFunc, dw);
  2566. }
  2567. LONG Lock()
  2568. {
  2569. return CComGlobalsThreadModel::Increment(&m_nLockCnt);
  2570. }
  2571. LONG Unlock()
  2572. {
  2573. return CComGlobalsThreadModel::Decrement(&m_nLockCnt);
  2574. }
  2575. LONG GetLockCount()
  2576. {
  2577. return m_nLockCnt;
  2578. }
  2579. HINSTANCE GetModuleInstance() {return m_hInst;}
  2580. HINSTANCE GetResourceInstance() {return m_hInstResource;}
  2581. HINSTANCE GetTypeLibInstance() {return m_hInstTypeLib;}
  2582. // Registry support (helpers)
  2583. HRESULT RegisterTypeLib()
  2584. {
  2585. return AtlModuleRegisterTypeLib(this, NULL);
  2586. }
  2587. HRESULT RegisterTypeLib(LPCTSTR lpszIndex)
  2588. {
  2589. USES_CONVERSION;
  2590. return AtlModuleRegisterTypeLib(this, T2COLE(lpszIndex));
  2591. }
  2592. HRESULT UnRegisterTypeLib()
  2593. {
  2594. return AtlModuleUnRegisterTypeLib(this, NULL);
  2595. }
  2596. HRESULT UnRegisterTypeLib(LPCTSTR lpszIndex)
  2597. {
  2598. USES_CONVERSION;
  2599. return AtlModuleUnRegisterTypeLib(this, T2COLE(lpszIndex));
  2600. }
  2601. HRESULT RegisterServer(BOOL bRegTypeLib = FALSE, const CLSID* pCLSID = NULL)
  2602. {
  2603. return AtlModuleRegisterServer(this, bRegTypeLib, pCLSID);
  2604. }
  2605. HRESULT UnregisterServer(const CLSID* pCLSID = NULL)
  2606. {
  2607. return AtlModuleUnregisterServer(this, pCLSID);
  2608. }
  2609. HRESULT UnregisterServer(BOOL bUnRegTypeLib, const CLSID* pCLSID = NULL)
  2610. {
  2611. return AtlModuleUnregisterServerEx(this, bUnRegTypeLib, pCLSID);
  2612. }
  2613. // Resource-based Registration
  2614. HRESULT WINAPI UpdateRegistryFromResourceD(LPCTSTR lpszRes, BOOL bRegister,
  2615. struct _ATL_REGMAP_ENTRY* pMapEntries = NULL)
  2616. {
  2617. USES_CONVERSION;
  2618. return AtlModuleUpdateRegistryFromResourceD(this, T2COLE(lpszRes), bRegister,
  2619. pMapEntries);
  2620. }
  2621. HRESULT WINAPI UpdateRegistryFromResourceD(UINT nResID, BOOL bRegister,
  2622. struct _ATL_REGMAP_ENTRY* pMapEntries = NULL)
  2623. {
  2624. return AtlModuleUpdateRegistryFromResourceD(this,
  2625. (LPCOLESTR)MAKEINTRESOURCE(nResID), bRegister, pMapEntries);
  2626. }
  2627. #ifdef _ATL_STATIC_REGISTRY
  2628. // Statically linking to Registry Ponent
  2629. HRESULT WINAPI UpdateRegistryFromResourceS(LPCTSTR lpszRes, BOOL bRegister,
  2630. struct _ATL_REGMAP_ENTRY* pMapEntries = NULL);
  2631. HRESULT WINAPI UpdateRegistryFromResourceS(UINT nResID, BOOL bRegister,
  2632. struct _ATL_REGMAP_ENTRY* pMapEntries = NULL);
  2633. #endif
  2634. // Standard Registration
  2635. HRESULT WINAPI UpdateRegistryClass(const CLSID& clsid, LPCTSTR lpszProgID,
  2636. LPCTSTR lpszVerIndProgID, UINT nDescID, DWORD dwFlags, BOOL bRegister);
  2637. HRESULT WINAPI RegisterClassHelper(const CLSID& clsid, LPCTSTR lpszProgID,
  2638. LPCTSTR lpszVerIndProgID, UINT nDescID, DWORD dwFlags);
  2639. HRESULT WINAPI UnregisterClassHelper(const CLSID& clsid, LPCTSTR lpszProgID,
  2640. LPCTSTR lpszVerIndProgID);
  2641. // Register/Revoke All Class Factories with the OS (EXE only)
  2642. #if !defined(_WIN32_WCE)
  2643. HRESULT RegisterClassObjects(DWORD dwClsContext, DWORD dwFlags)
  2644. {
  2645. return AtlModuleRegisterClassObjects(this, dwClsContext, dwFlags);
  2646. }
  2647. HRESULT RevokeClassObjects()
  2648. {
  2649. return AtlModuleRevokeClassObjects(this);
  2650. }
  2651. #endif // _WIN32_WCE
  2652. // Obtain a Class Factory (DLL only)
  2653. HRESULT GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  2654. {
  2655. return AtlModuleGetClassObject(this, rclsid, riid, ppv);
  2656. }
  2657. // Only used in CComAutoThreadModule
  2658. HRESULT CreateInstance(void* /*pfnCreateInstance*/, REFIID /*riid*/, void** /*ppvObj*/)
  2659. {
  2660. ATLASSERT(FALSE);
  2661. return E_NOTIMPL;
  2662. }
  2663. static HRESULT RegisterProgID(LPCTSTR lpszCLSID, LPCTSTR lpszProgID, LPCTSTR lpszUserDesc);
  2664. static void ReplaceSingleQuote(LPOLESTR lpDest, LPCOLESTR lp)
  2665. {
  2666. while (*lp)
  2667. {
  2668. *lpDest++ = *lp;
  2669. if (*lp == OLESTR('\''))
  2670. *lpDest++ = *lp;
  2671. lp++;
  2672. }
  2673. *lpDest = NULL;
  2674. }
  2675. };
  2676. #ifdef _ATL_DEBUG_INTERFACES
  2677. inline ULONG _QIThunk::Release()
  2678. {
  2679. if (bBreak)
  2680. DebugBreak();
  2681. ATLASSERT(m_dwRef > 0);
  2682. ULONG l = InterlockedDecrement(&m_dwRef);
  2683. ATLTRACE(_T("%d< "), m_dwRef);
  2684. AtlDumpIID(iid, lpszClassName, S_OK);
  2685. pUnk->Release();
  2686. if (l == 0 && !bNonAddRefThunk)
  2687. _pModule->DeleteThunk(this);
  2688. return l;
  2689. }
  2690. inline static void atlBadThunkCall()
  2691. {
  2692. ATLASSERT(FALSE && "Call through deleted thunk");
  2693. }
  2694. #define IMPL_THUNK(n)\
  2695. __declspec(naked) inline HRESULT _QIThunk::f##n()\
  2696. {\
  2697. __asm mov eax, [esp+4]\
  2698. __asm cmp dword ptr [eax+8], 0\
  2699. __asm jg goodref\
  2700. __asm call atlBadThunkCall\
  2701. __asm goodref:\
  2702. __asm mov eax, [esp+4]\
  2703. __asm mov eax, dword ptr [eax+4]\
  2704. __asm mov [esp+4], eax\
  2705. __asm mov eax, dword ptr [eax]\
  2706. __asm mov eax, dword ptr [eax+4*n]\
  2707. __asm jmp eax\
  2708. }
  2709. IMPL_THUNK(3)
  2710. IMPL_THUNK(4)
  2711. IMPL_THUNK(5)
  2712. IMPL_THUNK(6)
  2713. IMPL_THUNK(7)
  2714. IMPL_THUNK(8)
  2715. IMPL_THUNK(9)
  2716. IMPL_THUNK(10)
  2717. IMPL_THUNK(11)
  2718. IMPL_THUNK(12)
  2719. IMPL_THUNK(13)
  2720. IMPL_THUNK(14)
  2721. IMPL_THUNK(15)
  2722. IMPL_THUNK(16)
  2723. IMPL_THUNK(17)
  2724. IMPL_THUNK(18)
  2725. IMPL_THUNK(19)
  2726. IMPL_THUNK(20)
  2727. IMPL_THUNK(21)
  2728. IMPL_THUNK(22)
  2729. IMPL_THUNK(23)
  2730. IMPL_THUNK(24)
  2731. IMPL_THUNK(25)
  2732. IMPL_THUNK(26)
  2733. IMPL_THUNK(27)
  2734. IMPL_THUNK(28)
  2735. IMPL_THUNK(29)
  2736. IMPL_THUNK(30)
  2737. IMPL_THUNK(31)
  2738. IMPL_THUNK(32)
  2739. IMPL_THUNK(33)
  2740. IMPL_THUNK(34)
  2741. IMPL_THUNK(35)
  2742. IMPL_THUNK(36)
  2743. IMPL_THUNK(37)
  2744. IMPL_THUNK(38)
  2745. IMPL_THUNK(39)
  2746. IMPL_THUNK(40)
  2747. IMPL_THUNK(41)
  2748. IMPL_THUNK(42)
  2749. IMPL_THUNK(43)
  2750. IMPL_THUNK(44)
  2751. IMPL_THUNK(45)
  2752. IMPL_THUNK(46)
  2753. IMPL_THUNK(47)
  2754. IMPL_THUNK(48)
  2755. IMPL_THUNK(49)
  2756. IMPL_THUNK(50)
  2757. IMPL_THUNK(51)
  2758. IMPL_THUNK(52)
  2759. IMPL_THUNK(53)
  2760. IMPL_THUNK(54)
  2761. IMPL_THUNK(55)
  2762. IMPL_THUNK(56)
  2763. IMPL_THUNK(57)
  2764. IMPL_THUNK(58)
  2765. IMPL_THUNK(59)
  2766. IMPL_THUNK(60)
  2767. IMPL_THUNK(61)
  2768. IMPL_THUNK(62)
  2769. IMPL_THUNK(63)
  2770. IMPL_THUNK(64)
  2771. IMPL_THUNK(65)
  2772. IMPL_THUNK(66)
  2773. IMPL_THUNK(67)
  2774. IMPL_THUNK(68)
  2775. IMPL_THUNK(69)
  2776. IMPL_THUNK(70)
  2777. IMPL_THUNK(71)
  2778. IMPL_THUNK(72)
  2779. IMPL_THUNK(73)
  2780. IMPL_THUNK(74)
  2781. IMPL_THUNK(75)
  2782. IMPL_THUNK(76)
  2783. IMPL_THUNK(77)
  2784. IMPL_THUNK(78)
  2785. IMPL_THUNK(79)
  2786. IMPL_THUNK(80)
  2787. IMPL_THUNK(81)
  2788. IMPL_THUNK(82)
  2789. IMPL_THUNK(83)
  2790. IMPL_THUNK(84)
  2791. IMPL_THUNK(85)
  2792. IMPL_THUNK(86)
  2793. IMPL_THUNK(87)
  2794. IMPL_THUNK(88)
  2795. IMPL_THUNK(89)
  2796. IMPL_THUNK(90)
  2797. IMPL_THUNK(91)
  2798. IMPL_THUNK(92)
  2799. IMPL_THUNK(93)
  2800. IMPL_THUNK(94)
  2801. IMPL_THUNK(95)
  2802. IMPL_THUNK(96)
  2803. IMPL_THUNK(97)
  2804. IMPL_THUNK(98)
  2805. IMPL_THUNK(99)
  2806. IMPL_THUNK(100)
  2807. IMPL_THUNK(101)
  2808. IMPL_THUNK(102)
  2809. IMPL_THUNK(103)
  2810. IMPL_THUNK(104)
  2811. IMPL_THUNK(105)
  2812. IMPL_THUNK(106)
  2813. IMPL_THUNK(107)
  2814. IMPL_THUNK(108)
  2815. IMPL_THUNK(109)
  2816. IMPL_THUNK(110)
  2817. IMPL_THUNK(111)
  2818. IMPL_THUNK(112)
  2819. IMPL_THUNK(113)
  2820. IMPL_THUNK(114)
  2821. IMPL_THUNK(115)
  2822. IMPL_THUNK(116)
  2823. IMPL_THUNK(117)
  2824. IMPL_THUNK(118)
  2825. IMPL_THUNK(119)
  2826. IMPL_THUNK(120)
  2827. IMPL_THUNK(121)
  2828. IMPL_THUNK(122)
  2829. IMPL_THUNK(123)
  2830. IMPL_THUNK(124)
  2831. IMPL_THUNK(125)
  2832. IMPL_THUNK(126)
  2833. IMPL_THUNK(127)
  2834. IMPL_THUNK(128)
  2835. IMPL_THUNK(129)
  2836. IMPL_THUNK(130)
  2837. IMPL_THUNK(131)
  2838. IMPL_THUNK(132)
  2839. IMPL_THUNK(133)
  2840. IMPL_THUNK(134)
  2841. IMPL_THUNK(135)
  2842. IMPL_THUNK(136)
  2843. IMPL_THUNK(137)
  2844. IMPL_THUNK(138)
  2845. IMPL_THUNK(139)
  2846. IMPL_THUNK(140)
  2847. IMPL_THUNK(141)
  2848. IMPL_THUNK(142)
  2849. IMPL_THUNK(143)
  2850. IMPL_THUNK(144)
  2851. IMPL_THUNK(145)
  2852. IMPL_THUNK(146)
  2853. IMPL_THUNK(147)
  2854. IMPL_THUNK(148)
  2855. IMPL_THUNK(149)
  2856. IMPL_THUNK(150)
  2857. IMPL_THUNK(151)
  2858. IMPL_THUNK(152)
  2859. IMPL_THUNK(153)
  2860. IMPL_THUNK(154)
  2861. IMPL_THUNK(155)
  2862. IMPL_THUNK(156)
  2863. IMPL_THUNK(157)
  2864. IMPL_THUNK(158)
  2865. IMPL_THUNK(159)
  2866. IMPL_THUNK(160)
  2867. IMPL_THUNK(161)
  2868. IMPL_THUNK(162)
  2869. IMPL_THUNK(163)
  2870. IMPL_THUNK(164)
  2871. IMPL_THUNK(165)
  2872. IMPL_THUNK(166)
  2873. IMPL_THUNK(167)
  2874. IMPL_THUNK(168)
  2875. IMPL_THUNK(169)
  2876. IMPL_THUNK(170)
  2877. IMPL_THUNK(171)
  2878. IMPL_THUNK(172)
  2879. IMPL_THUNK(173)
  2880. IMPL_THUNK(174)
  2881. IMPL_THUNK(175)
  2882. IMPL_THUNK(176)
  2883. IMPL_THUNK(177)
  2884. IMPL_THUNK(178)
  2885. IMPL_THUNK(179)
  2886. IMPL_THUNK(180)
  2887. IMPL_THUNK(181)
  2888. IMPL_THUNK(182)
  2889. IMPL_THUNK(183)
  2890. IMPL_THUNK(184)
  2891. IMPL_THUNK(185)
  2892. IMPL_THUNK(186)
  2893. IMPL_THUNK(187)
  2894. IMPL_THUNK(188)
  2895. IMPL_THUNK(189)
  2896. IMPL_THUNK(190)
  2897. IMPL_THUNK(191)
  2898. IMPL_THUNK(192)
  2899. IMPL_THUNK(193)
  2900. IMPL_THUNK(194)
  2901. IMPL_THUNK(195)
  2902. IMPL_THUNK(196)
  2903. IMPL_THUNK(197)
  2904. IMPL_THUNK(198)
  2905. IMPL_THUNK(199)
  2906. IMPL_THUNK(200)
  2907. IMPL_THUNK(201)
  2908. IMPL_THUNK(202)
  2909. IMPL_THUNK(203)
  2910. IMPL_THUNK(204)
  2911. IMPL_THUNK(205)
  2912. IMPL_THUNK(206)
  2913. IMPL_THUNK(207)
  2914. IMPL_THUNK(208)
  2915. IMPL_THUNK(209)
  2916. IMPL_THUNK(210)
  2917. IMPL_THUNK(211)
  2918. IMPL_THUNK(212)
  2919. IMPL_THUNK(213)
  2920. IMPL_THUNK(214)
  2921. IMPL_THUNK(215)
  2922. IMPL_THUNK(216)
  2923. IMPL_THUNK(217)
  2924. IMPL_THUNK(218)
  2925. IMPL_THUNK(219)
  2926. IMPL_THUNK(220)
  2927. IMPL_THUNK(221)
  2928. IMPL_THUNK(222)
  2929. IMPL_THUNK(223)
  2930. IMPL_THUNK(224)
  2931. IMPL_THUNK(225)
  2932. IMPL_THUNK(226)
  2933. IMPL_THUNK(227)
  2934. IMPL_THUNK(228)
  2935. IMPL_THUNK(229)
  2936. IMPL_THUNK(230)
  2937. IMPL_THUNK(231)
  2938. IMPL_THUNK(232)
  2939. IMPL_THUNK(233)
  2940. IMPL_THUNK(234)
  2941. IMPL_THUNK(235)
  2942. IMPL_THUNK(236)
  2943. IMPL_THUNK(237)
  2944. IMPL_THUNK(238)
  2945. IMPL_THUNK(239)
  2946. IMPL_THUNK(240)
  2947. IMPL_THUNK(241)
  2948. IMPL_THUNK(242)
  2949. IMPL_THUNK(243)
  2950. IMPL_THUNK(244)
  2951. IMPL_THUNK(245)
  2952. IMPL_THUNK(246)
  2953. IMPL_THUNK(247)
  2954. IMPL_THUNK(248)
  2955. IMPL_THUNK(249)
  2956. IMPL_THUNK(250)
  2957. IMPL_THUNK(251)
  2958. IMPL_THUNK(252)
  2959. IMPL_THUNK(253)
  2960. IMPL_THUNK(254)
  2961. IMPL_THUNK(255)
  2962. IMPL_THUNK(256)
  2963. IMPL_THUNK(257)
  2964. IMPL_THUNK(258)
  2965. IMPL_THUNK(259)
  2966. IMPL_THUNK(260)
  2967. IMPL_THUNK(261)
  2968. IMPL_THUNK(262)
  2969. IMPL_THUNK(263)
  2970. IMPL_THUNK(264)
  2971. IMPL_THUNK(265)
  2972. IMPL_THUNK(266)
  2973. IMPL_THUNK(267)
  2974. IMPL_THUNK(268)
  2975. IMPL_THUNK(269)
  2976. IMPL_THUNK(270)
  2977. IMPL_THUNK(271)
  2978. IMPL_THUNK(272)
  2979. IMPL_THUNK(273)
  2980. IMPL_THUNK(274)
  2981. IMPL_THUNK(275)
  2982. IMPL_THUNK(276)
  2983. IMPL_THUNK(277)
  2984. IMPL_THUNK(278)
  2985. IMPL_THUNK(279)
  2986. IMPL_THUNK(280)
  2987. IMPL_THUNK(281)
  2988. IMPL_THUNK(282)
  2989. IMPL_THUNK(283)
  2990. IMPL_THUNK(284)
  2991. IMPL_THUNK(285)
  2992. IMPL_THUNK(286)
  2993. IMPL_THUNK(287)
  2994. IMPL_THUNK(288)
  2995. IMPL_THUNK(289)
  2996. IMPL_THUNK(290)
  2997. IMPL_THUNK(291)
  2998. IMPL_THUNK(292)
  2999. IMPL_THUNK(293)
  3000. IMPL_THUNK(294)
  3001. IMPL_THUNK(295)
  3002. IMPL_THUNK(296)
  3003. IMPL_THUNK(297)
  3004. IMPL_THUNK(298)
  3005. IMPL_THUNK(299)
  3006. IMPL_THUNK(300)
  3007. IMPL_THUNK(301)
  3008. IMPL_THUNK(302)
  3009. IMPL_THUNK(303)
  3010. IMPL_THUNK(304)
  3011. IMPL_THUNK(305)
  3012. IMPL_THUNK(306)
  3013. IMPL_THUNK(307)
  3014. IMPL_THUNK(308)
  3015. IMPL_THUNK(309)
  3016. IMPL_THUNK(310)
  3017. IMPL_THUNK(311)
  3018. IMPL_THUNK(312)
  3019. IMPL_THUNK(313)
  3020. IMPL_THUNK(314)
  3021. IMPL_THUNK(315)
  3022. IMPL_THUNK(316)
  3023. IMPL_THUNK(317)
  3024. IMPL_THUNK(318)
  3025. IMPL_THUNK(319)
  3026. IMPL_THUNK(320)
  3027. IMPL_THUNK(321)
  3028. IMPL_THUNK(322)
  3029. IMPL_THUNK(323)
  3030. IMPL_THUNK(324)
  3031. IMPL_THUNK(325)
  3032. IMPL_THUNK(326)
  3033. IMPL_THUNK(327)
  3034. IMPL_THUNK(328)
  3035. IMPL_THUNK(329)
  3036. IMPL_THUNK(330)
  3037. IMPL_THUNK(331)
  3038. IMPL_THUNK(332)
  3039. IMPL_THUNK(333)
  3040. IMPL_THUNK(334)
  3041. IMPL_THUNK(335)
  3042. IMPL_THUNK(336)
  3043. IMPL_THUNK(337)
  3044. IMPL_THUNK(338)
  3045. IMPL_THUNK(339)
  3046. IMPL_THUNK(340)
  3047. IMPL_THUNK(341)
  3048. IMPL_THUNK(342)
  3049. IMPL_THUNK(343)
  3050. IMPL_THUNK(344)
  3051. IMPL_THUNK(345)
  3052. IMPL_THUNK(346)
  3053. IMPL_THUNK(347)
  3054. IMPL_THUNK(348)
  3055. IMPL_THUNK(349)
  3056. IMPL_THUNK(350)
  3057. IMPL_THUNK(351)
  3058. IMPL_THUNK(352)
  3059. IMPL_THUNK(353)
  3060. IMPL_THUNK(354)
  3061. IMPL_THUNK(355)
  3062. IMPL_THUNK(356)
  3063. IMPL_THUNK(357)
  3064. IMPL_THUNK(358)
  3065. IMPL_THUNK(359)
  3066. IMPL_THUNK(360)
  3067. IMPL_THUNK(361)
  3068. IMPL_THUNK(362)
  3069. IMPL_THUNK(363)
  3070. IMPL_THUNK(364)
  3071. IMPL_THUNK(365)
  3072. IMPL_THUNK(366)
  3073. IMPL_THUNK(367)
  3074. IMPL_THUNK(368)
  3075. IMPL_THUNK(369)
  3076. IMPL_THUNK(370)
  3077. IMPL_THUNK(371)
  3078. IMPL_THUNK(372)
  3079. IMPL_THUNK(373)
  3080. IMPL_THUNK(374)
  3081. IMPL_THUNK(375)
  3082. IMPL_THUNK(376)
  3083. IMPL_THUNK(377)
  3084. IMPL_THUNK(378)
  3085. IMPL_THUNK(379)
  3086. IMPL_THUNK(380)
  3087. IMPL_THUNK(381)
  3088. IMPL_THUNK(382)
  3089. IMPL_THUNK(383)
  3090. IMPL_THUNK(384)
  3091. IMPL_THUNK(385)
  3092. IMPL_THUNK(386)
  3093. IMPL_THUNK(387)
  3094. IMPL_THUNK(388)
  3095. IMPL_THUNK(389)
  3096. IMPL_THUNK(390)
  3097. IMPL_THUNK(391)
  3098. IMPL_THUNK(392)
  3099. IMPL_THUNK(393)
  3100. IMPL_THUNK(394)
  3101. IMPL_THUNK(395)
  3102. IMPL_THUNK(396)
  3103. IMPL_THUNK(397)
  3104. IMPL_THUNK(398)
  3105. IMPL_THUNK(399)
  3106. IMPL_THUNK(400)
  3107. IMPL_THUNK(401)
  3108. IMPL_THUNK(402)
  3109. IMPL_THUNK(403)
  3110. IMPL_THUNK(404)
  3111. IMPL_THUNK(405)
  3112. IMPL_THUNK(406)
  3113. IMPL_THUNK(407)
  3114. IMPL_THUNK(408)
  3115. IMPL_THUNK(409)
  3116. IMPL_THUNK(410)
  3117. IMPL_THUNK(411)
  3118. IMPL_THUNK(412)
  3119. IMPL_THUNK(413)
  3120. IMPL_THUNK(414)
  3121. IMPL_THUNK(415)
  3122. IMPL_THUNK(416)
  3123. IMPL_THUNK(417)
  3124. IMPL_THUNK(418)
  3125. IMPL_THUNK(419)
  3126. IMPL_THUNK(420)
  3127. IMPL_THUNK(421)
  3128. IMPL_THUNK(422)
  3129. IMPL_THUNK(423)
  3130. IMPL_THUNK(424)
  3131. IMPL_THUNK(425)
  3132. IMPL_THUNK(426)
  3133. IMPL_THUNK(427)
  3134. IMPL_THUNK(428)
  3135. IMPL_THUNK(429)
  3136. IMPL_THUNK(430)
  3137. IMPL_THUNK(431)
  3138. IMPL_THUNK(432)
  3139. IMPL_THUNK(433)
  3140. IMPL_THUNK(434)
  3141. IMPL_THUNK(435)
  3142. IMPL_THUNK(436)
  3143. IMPL_THUNK(437)
  3144. IMPL_THUNK(438)
  3145. IMPL_THUNK(439)
  3146. IMPL_THUNK(440)
  3147. IMPL_THUNK(441)
  3148. IMPL_THUNK(442)
  3149. IMPL_THUNK(443)
  3150. IMPL_THUNK(444)
  3151. IMPL_THUNK(445)
  3152. IMPL_THUNK(446)
  3153. IMPL_THUNK(447)
  3154. IMPL_THUNK(448)
  3155. IMPL_THUNK(449)
  3156. IMPL_THUNK(450)
  3157. IMPL_THUNK(451)
  3158. IMPL_THUNK(452)
  3159. IMPL_THUNK(453)
  3160. IMPL_THUNK(454)
  3161. IMPL_THUNK(455)
  3162. IMPL_THUNK(456)
  3163. IMPL_THUNK(457)
  3164. IMPL_THUNK(458)
  3165. IMPL_THUNK(459)
  3166. IMPL_THUNK(460)
  3167. IMPL_THUNK(461)
  3168. IMPL_THUNK(462)
  3169. IMPL_THUNK(463)
  3170. IMPL_THUNK(464)
  3171. IMPL_THUNK(465)
  3172. IMPL_THUNK(466)
  3173. IMPL_THUNK(467)
  3174. IMPL_THUNK(468)
  3175. IMPL_THUNK(469)
  3176. IMPL_THUNK(470)
  3177. IMPL_THUNK(471)
  3178. IMPL_THUNK(472)
  3179. IMPL_THUNK(473)
  3180. IMPL_THUNK(474)
  3181. IMPL_THUNK(475)
  3182. IMPL_THUNK(476)
  3183. IMPL_THUNK(477)
  3184. IMPL_THUNK(478)
  3185. IMPL_THUNK(479)
  3186. IMPL_THUNK(480)
  3187. IMPL_THUNK(481)
  3188. IMPL_THUNK(482)
  3189. IMPL_THUNK(483)
  3190. IMPL_THUNK(484)
  3191. IMPL_THUNK(485)
  3192. IMPL_THUNK(486)
  3193. IMPL_THUNK(487)
  3194. IMPL_THUNK(488)
  3195. IMPL_THUNK(489)
  3196. IMPL_THUNK(490)
  3197. IMPL_THUNK(491)
  3198. IMPL_THUNK(492)
  3199. IMPL_THUNK(493)
  3200. IMPL_THUNK(494)
  3201. IMPL_THUNK(495)
  3202. IMPL_THUNK(496)
  3203. IMPL_THUNK(497)
  3204. IMPL_THUNK(498)
  3205. IMPL_THUNK(499)
  3206. IMPL_THUNK(500)
  3207. IMPL_THUNK(501)
  3208. IMPL_THUNK(502)
  3209. IMPL_THUNK(503)
  3210. IMPL_THUNK(504)
  3211. IMPL_THUNK(505)
  3212. IMPL_THUNK(506)
  3213. IMPL_THUNK(507)
  3214. IMPL_THUNK(508)
  3215. IMPL_THUNK(509)
  3216. IMPL_THUNK(510)
  3217. IMPL_THUNK(511)
  3218. IMPL_THUNK(512)
  3219. IMPL_THUNK(513)
  3220. IMPL_THUNK(514)
  3221. IMPL_THUNK(515)
  3222. IMPL_THUNK(516)
  3223. IMPL_THUNK(517)
  3224. IMPL_THUNK(518)
  3225. IMPL_THUNK(519)
  3226. IMPL_THUNK(520)
  3227. IMPL_THUNK(521)
  3228. IMPL_THUNK(522)
  3229. IMPL_THUNK(523)
  3230. IMPL_THUNK(524)
  3231. IMPL_THUNK(525)
  3232. IMPL_THUNK(526)
  3233. IMPL_THUNK(527)
  3234. IMPL_THUNK(528)
  3235. IMPL_THUNK(529)
  3236. IMPL_THUNK(530)
  3237. IMPL_THUNK(531)
  3238. IMPL_THUNK(532)
  3239. IMPL_THUNK(533)
  3240. IMPL_THUNK(534)
  3241. IMPL_THUNK(535)
  3242. IMPL_THUNK(536)
  3243. IMPL_THUNK(537)
  3244. IMPL_THUNK(538)
  3245. IMPL_THUNK(539)
  3246. IMPL_THUNK(540)
  3247. IMPL_THUNK(541)
  3248. IMPL_THUNK(542)
  3249. IMPL_THUNK(543)
  3250. IMPL_THUNK(544)
  3251. IMPL_THUNK(545)
  3252. IMPL_THUNK(546)
  3253. IMPL_THUNK(547)
  3254. IMPL_THUNK(548)
  3255. IMPL_THUNK(549)
  3256. IMPL_THUNK(550)
  3257. IMPL_THUNK(551)
  3258. IMPL_THUNK(552)
  3259. IMPL_THUNK(553)
  3260. IMPL_THUNK(554)
  3261. IMPL_THUNK(555)
  3262. IMPL_THUNK(556)
  3263. IMPL_THUNK(557)
  3264. IMPL_THUNK(558)
  3265. IMPL_THUNK(559)
  3266. IMPL_THUNK(560)
  3267. IMPL_THUNK(561)
  3268. IMPL_THUNK(562)
  3269. IMPL_THUNK(563)
  3270. IMPL_THUNK(564)
  3271. IMPL_THUNK(565)
  3272. IMPL_THUNK(566)
  3273. IMPL_THUNK(567)
  3274. IMPL_THUNK(568)
  3275. IMPL_THUNK(569)
  3276. IMPL_THUNK(570)
  3277. IMPL_THUNK(571)
  3278. IMPL_THUNK(572)
  3279. IMPL_THUNK(573)
  3280. IMPL_THUNK(574)
  3281. IMPL_THUNK(575)
  3282. IMPL_THUNK(576)
  3283. IMPL_THUNK(577)
  3284. IMPL_THUNK(578)
  3285. IMPL_THUNK(579)
  3286. IMPL_THUNK(580)
  3287. IMPL_THUNK(581)
  3288. IMPL_THUNK(582)
  3289. IMPL_THUNK(583)
  3290. IMPL_THUNK(584)
  3291. IMPL_THUNK(585)
  3292. IMPL_THUNK(586)
  3293. IMPL_THUNK(587)
  3294. IMPL_THUNK(588)
  3295. IMPL_THUNK(589)
  3296. IMPL_THUNK(590)
  3297. IMPL_THUNK(591)
  3298. IMPL_THUNK(592)
  3299. IMPL_THUNK(593)
  3300. IMPL_THUNK(594)
  3301. IMPL_THUNK(595)
  3302. IMPL_THUNK(596)
  3303. IMPL_THUNK(597)
  3304. IMPL_THUNK(598)
  3305. IMPL_THUNK(599)
  3306. IMPL_THUNK(600)
  3307. IMPL_THUNK(601)
  3308. IMPL_THUNK(602)
  3309. IMPL_THUNK(603)
  3310. IMPL_THUNK(604)
  3311. IMPL_THUNK(605)
  3312. IMPL_THUNK(606)
  3313. IMPL_THUNK(607)
  3314. IMPL_THUNK(608)
  3315. IMPL_THUNK(609)
  3316. IMPL_THUNK(610)
  3317. IMPL_THUNK(611)
  3318. IMPL_THUNK(612)
  3319. IMPL_THUNK(613)
  3320. IMPL_THUNK(614)
  3321. IMPL_THUNK(615)
  3322. IMPL_THUNK(616)
  3323. IMPL_THUNK(617)
  3324. IMPL_THUNK(618)
  3325. IMPL_THUNK(619)
  3326. IMPL_THUNK(620)
  3327. IMPL_THUNK(621)
  3328. IMPL_THUNK(622)
  3329. IMPL_THUNK(623)
  3330. IMPL_THUNK(624)
  3331. IMPL_THUNK(625)
  3332. IMPL_THUNK(626)
  3333. IMPL_THUNK(627)
  3334. IMPL_THUNK(628)
  3335. IMPL_THUNK(629)
  3336. IMPL_THUNK(630)
  3337. IMPL_THUNK(631)
  3338. IMPL_THUNK(632)
  3339. IMPL_THUNK(633)
  3340. IMPL_THUNK(634)
  3341. IMPL_THUNK(635)
  3342. IMPL_THUNK(636)
  3343. IMPL_THUNK(637)
  3344. IMPL_THUNK(638)
  3345. IMPL_THUNK(639)
  3346. IMPL_THUNK(640)
  3347. IMPL_THUNK(641)
  3348. IMPL_THUNK(642)
  3349. IMPL_THUNK(643)
  3350. IMPL_THUNK(644)
  3351. IMPL_THUNK(645)
  3352. IMPL_THUNK(646)
  3353. IMPL_THUNK(647)
  3354. IMPL_THUNK(648)
  3355. IMPL_THUNK(649)
  3356. IMPL_THUNK(650)
  3357. IMPL_THUNK(651)
  3358. IMPL_THUNK(652)
  3359. IMPL_THUNK(653)
  3360. IMPL_THUNK(654)
  3361. IMPL_THUNK(655)
  3362. IMPL_THUNK(656)
  3363. IMPL_THUNK(657)
  3364. IMPL_THUNK(658)
  3365. IMPL_THUNK(659)
  3366. IMPL_THUNK(660)
  3367. IMPL_THUNK(661)
  3368. IMPL_THUNK(662)
  3369. IMPL_THUNK(663)
  3370. IMPL_THUNK(664)
  3371. IMPL_THUNK(665)
  3372. IMPL_THUNK(666)
  3373. IMPL_THUNK(667)
  3374. IMPL_THUNK(668)
  3375. IMPL_THUNK(669)
  3376. IMPL_THUNK(670)
  3377. IMPL_THUNK(671)
  3378. IMPL_THUNK(672)
  3379. IMPL_THUNK(673)
  3380. IMPL_THUNK(674)
  3381. IMPL_THUNK(675)
  3382. IMPL_THUNK(676)
  3383. IMPL_THUNK(677)
  3384. IMPL_THUNK(678)
  3385. IMPL_THUNK(679)
  3386. IMPL_THUNK(680)
  3387. IMPL_THUNK(681)
  3388. IMPL_THUNK(682)
  3389. IMPL_THUNK(683)
  3390. IMPL_THUNK(684)
  3391. IMPL_THUNK(685)
  3392. IMPL_THUNK(686)
  3393. IMPL_THUNK(687)
  3394. IMPL_THUNK(688)
  3395. IMPL_THUNK(689)
  3396. IMPL_THUNK(690)
  3397. IMPL_THUNK(691)
  3398. IMPL_THUNK(692)
  3399. IMPL_THUNK(693)
  3400. IMPL_THUNK(694)
  3401. IMPL_THUNK(695)
  3402. IMPL_THUNK(696)
  3403. IMPL_THUNK(697)
  3404. IMPL_THUNK(698)
  3405. IMPL_THUNK(699)
  3406. IMPL_THUNK(700)
  3407. IMPL_THUNK(701)
  3408. IMPL_THUNK(702)
  3409. IMPL_THUNK(703)
  3410. IMPL_THUNK(704)
  3411. IMPL_THUNK(705)
  3412. IMPL_THUNK(706)
  3413. IMPL_THUNK(707)
  3414. IMPL_THUNK(708)
  3415. IMPL_THUNK(709)
  3416. IMPL_THUNK(710)
  3417. IMPL_THUNK(711)
  3418. IMPL_THUNK(712)
  3419. IMPL_THUNK(713)
  3420. IMPL_THUNK(714)
  3421. IMPL_THUNK(715)
  3422. IMPL_THUNK(716)
  3423. IMPL_THUNK(717)
  3424. IMPL_THUNK(718)
  3425. IMPL_THUNK(719)
  3426. IMPL_THUNK(720)
  3427. IMPL_THUNK(721)
  3428. IMPL_THUNK(722)
  3429. IMPL_THUNK(723)
  3430. IMPL_THUNK(724)
  3431. IMPL_THUNK(725)
  3432. IMPL_THUNK(726)
  3433. IMPL_THUNK(727)
  3434. IMPL_THUNK(728)
  3435. IMPL_THUNK(729)
  3436. IMPL_THUNK(730)
  3437. IMPL_THUNK(731)
  3438. IMPL_THUNK(732)
  3439. IMPL_THUNK(733)
  3440. IMPL_THUNK(734)
  3441. IMPL_THUNK(735)
  3442. IMPL_THUNK(736)
  3443. IMPL_THUNK(737)
  3444. IMPL_THUNK(738)
  3445. IMPL_THUNK(739)
  3446. IMPL_THUNK(740)
  3447. IMPL_THUNK(741)
  3448. IMPL_THUNK(742)
  3449. IMPL_THUNK(743)
  3450. IMPL_THUNK(744)
  3451. IMPL_THUNK(745)
  3452. IMPL_THUNK(746)
  3453. IMPL_THUNK(747)
  3454. IMPL_THUNK(748)
  3455. IMPL_THUNK(749)
  3456. IMPL_THUNK(750)
  3457. IMPL_THUNK(751)
  3458. IMPL_THUNK(752)
  3459. IMPL_THUNK(753)
  3460. IMPL_THUNK(754)
  3461. IMPL_THUNK(755)
  3462. IMPL_THUNK(756)
  3463. IMPL_THUNK(757)
  3464. IMPL_THUNK(758)
  3465. IMPL_THUNK(759)
  3466. IMPL_THUNK(760)
  3467. IMPL_THUNK(761)
  3468. IMPL_THUNK(762)
  3469. IMPL_THUNK(763)
  3470. IMPL_THUNK(764)
  3471. IMPL_THUNK(765)
  3472. IMPL_THUNK(766)
  3473. IMPL_THUNK(767)
  3474. IMPL_THUNK(768)
  3475. IMPL_THUNK(769)
  3476. IMPL_THUNK(770)
  3477. IMPL_THUNK(771)
  3478. IMPL_THUNK(772)
  3479. IMPL_THUNK(773)
  3480. IMPL_THUNK(774)
  3481. IMPL_THUNK(775)
  3482. IMPL_THUNK(776)
  3483. IMPL_THUNK(777)
  3484. IMPL_THUNK(778)
  3485. IMPL_THUNK(779)
  3486. IMPL_THUNK(780)
  3487. IMPL_THUNK(781)
  3488. IMPL_THUNK(782)
  3489. IMPL_THUNK(783)
  3490. IMPL_THUNK(784)
  3491. IMPL_THUNK(785)
  3492. IMPL_THUNK(786)
  3493. IMPL_THUNK(787)
  3494. IMPL_THUNK(788)
  3495. IMPL_THUNK(789)
  3496. IMPL_THUNK(790)
  3497. IMPL_THUNK(791)
  3498. IMPL_THUNK(792)
  3499. IMPL_THUNK(793)
  3500. IMPL_THUNK(794)
  3501. IMPL_THUNK(795)
  3502. IMPL_THUNK(796)
  3503. IMPL_THUNK(797)
  3504. IMPL_THUNK(798)
  3505. IMPL_THUNK(799)
  3506. IMPL_THUNK(800)
  3507. IMPL_THUNK(801)
  3508. IMPL_THUNK(802)
  3509. IMPL_THUNK(803)
  3510. IMPL_THUNK(804)
  3511. IMPL_THUNK(805)
  3512. IMPL_THUNK(806)
  3513. IMPL_THUNK(807)
  3514. IMPL_THUNK(808)
  3515. IMPL_THUNK(809)
  3516. IMPL_THUNK(810)
  3517. IMPL_THUNK(811)
  3518. IMPL_THUNK(812)
  3519. IMPL_THUNK(813)
  3520. IMPL_THUNK(814)
  3521. IMPL_THUNK(815)
  3522. IMPL_THUNK(816)
  3523. IMPL_THUNK(817)
  3524. IMPL_THUNK(818)
  3525. IMPL_THUNK(819)
  3526. IMPL_THUNK(820)
  3527. IMPL_THUNK(821)
  3528. IMPL_THUNK(822)
  3529. IMPL_THUNK(823)
  3530. IMPL_THUNK(824)
  3531. IMPL_THUNK(825)
  3532. IMPL_THUNK(826)
  3533. IMPL_THUNK(827)
  3534. IMPL_THUNK(828)
  3535. IMPL_THUNK(829)
  3536. IMPL_THUNK(830)
  3537. IMPL_THUNK(831)
  3538. IMPL_THUNK(832)
  3539. IMPL_THUNK(833)
  3540. IMPL_THUNK(834)
  3541. IMPL_THUNK(835)
  3542. IMPL_THUNK(836)
  3543. IMPL_THUNK(837)
  3544. IMPL_THUNK(838)
  3545. IMPL_THUNK(839)
  3546. IMPL_THUNK(840)
  3547. IMPL_THUNK(841)
  3548. IMPL_THUNK(842)
  3549. IMPL_THUNK(843)
  3550. IMPL_THUNK(844)
  3551. IMPL_THUNK(845)
  3552. IMPL_THUNK(846)
  3553. IMPL_THUNK(847)
  3554. IMPL_THUNK(848)
  3555. IMPL_THUNK(849)
  3556. IMPL_THUNK(850)
  3557. IMPL_THUNK(851)
  3558. IMPL_THUNK(852)
  3559. IMPL_THUNK(853)
  3560. IMPL_THUNK(854)
  3561. IMPL_THUNK(855)
  3562. IMPL_THUNK(856)
  3563. IMPL_THUNK(857)
  3564. IMPL_THUNK(858)
  3565. IMPL_THUNK(859)
  3566. IMPL_THUNK(860)
  3567. IMPL_THUNK(861)
  3568. IMPL_THUNK(862)
  3569. IMPL_THUNK(863)
  3570. IMPL_THUNK(864)
  3571. IMPL_THUNK(865)
  3572. IMPL_THUNK(866)
  3573. IMPL_THUNK(867)
  3574. IMPL_THUNK(868)
  3575. IMPL_THUNK(869)
  3576. IMPL_THUNK(870)
  3577. IMPL_THUNK(871)
  3578. IMPL_THUNK(872)
  3579. IMPL_THUNK(873)
  3580. IMPL_THUNK(874)
  3581. IMPL_THUNK(875)
  3582. IMPL_THUNK(876)
  3583. IMPL_THUNK(877)
  3584. IMPL_THUNK(878)
  3585. IMPL_THUNK(879)
  3586. IMPL_THUNK(880)
  3587. IMPL_THUNK(881)
  3588. IMPL_THUNK(882)
  3589. IMPL_THUNK(883)
  3590. IMPL_THUNK(884)
  3591. IMPL_THUNK(885)
  3592. IMPL_THUNK(886)
  3593. IMPL_THUNK(887)
  3594. IMPL_THUNK(888)
  3595. IMPL_THUNK(889)
  3596. IMPL_THUNK(890)
  3597. IMPL_THUNK(891)
  3598. IMPL_THUNK(892)
  3599. IMPL_THUNK(893)
  3600. IMPL_THUNK(894)
  3601. IMPL_THUNK(895)
  3602. IMPL_THUNK(896)
  3603. IMPL_THUNK(897)
  3604. IMPL_THUNK(898)
  3605. IMPL_THUNK(899)
  3606. IMPL_THUNK(900)
  3607. IMPL_THUNK(901)
  3608. IMPL_THUNK(902)
  3609. IMPL_THUNK(903)
  3610. IMPL_THUNK(904)
  3611. IMPL_THUNK(905)
  3612. IMPL_THUNK(906)
  3613. IMPL_THUNK(907)
  3614. IMPL_THUNK(908)
  3615. IMPL_THUNK(909)
  3616. IMPL_THUNK(910)
  3617. IMPL_THUNK(911)
  3618. IMPL_THUNK(912)
  3619. IMPL_THUNK(913)
  3620. IMPL_THUNK(914)
  3621. IMPL_THUNK(915)
  3622. IMPL_THUNK(916)
  3623. IMPL_THUNK(917)
  3624. IMPL_THUNK(918)
  3625. IMPL_THUNK(919)
  3626. IMPL_THUNK(920)
  3627. IMPL_THUNK(921)
  3628. IMPL_THUNK(922)
  3629. IMPL_THUNK(923)
  3630. IMPL_THUNK(924)
  3631. IMPL_THUNK(925)
  3632. IMPL_THUNK(926)
  3633. IMPL_THUNK(927)
  3634. IMPL_THUNK(928)
  3635. IMPL_THUNK(929)
  3636. IMPL_THUNK(930)
  3637. IMPL_THUNK(931)
  3638. IMPL_THUNK(932)
  3639. IMPL_THUNK(933)
  3640. IMPL_THUNK(934)
  3641. IMPL_THUNK(935)
  3642. IMPL_THUNK(936)
  3643. IMPL_THUNK(937)
  3644. IMPL_THUNK(938)
  3645. IMPL_THUNK(939)
  3646. IMPL_THUNK(940)
  3647. IMPL_THUNK(941)
  3648. IMPL_THUNK(942)
  3649. IMPL_THUNK(943)
  3650. IMPL_THUNK(944)
  3651. IMPL_THUNK(945)
  3652. IMPL_THUNK(946)
  3653. IMPL_THUNK(947)
  3654. IMPL_THUNK(948)
  3655. IMPL_THUNK(949)
  3656. IMPL_THUNK(950)
  3657. IMPL_THUNK(951)
  3658. IMPL_THUNK(952)
  3659. IMPL_THUNK(953)
  3660. IMPL_THUNK(954)
  3661. IMPL_THUNK(955)
  3662. IMPL_THUNK(956)
  3663. IMPL_THUNK(957)
  3664. IMPL_THUNK(958)
  3665. IMPL_THUNK(959)
  3666. IMPL_THUNK(960)
  3667. IMPL_THUNK(961)
  3668. IMPL_THUNK(962)
  3669. IMPL_THUNK(963)
  3670. IMPL_THUNK(964)
  3671. IMPL_THUNK(965)
  3672. IMPL_THUNK(966)
  3673. IMPL_THUNK(967)
  3674. IMPL_THUNK(968)
  3675. IMPL_THUNK(969)
  3676. IMPL_THUNK(970)
  3677. IMPL_THUNK(971)
  3678. IMPL_THUNK(972)
  3679. IMPL_THUNK(973)
  3680. IMPL_THUNK(974)
  3681. IMPL_THUNK(975)
  3682. IMPL_THUNK(976)
  3683. IMPL_THUNK(977)
  3684. IMPL_THUNK(978)
  3685. IMPL_THUNK(979)
  3686. IMPL_THUNK(980)
  3687. IMPL_THUNK(981)
  3688. IMPL_THUNK(982)
  3689. IMPL_THUNK(983)
  3690. IMPL_THUNK(984)
  3691. IMPL_THUNK(985)
  3692. IMPL_THUNK(986)
  3693. IMPL_THUNK(987)
  3694. IMPL_THUNK(988)
  3695. IMPL_THUNK(989)
  3696. IMPL_THUNK(990)
  3697. IMPL_THUNK(991)
  3698. IMPL_THUNK(992)
  3699. IMPL_THUNK(993)
  3700. IMPL_THUNK(994)
  3701. IMPL_THUNK(995)
  3702. IMPL_THUNK(996)
  3703. IMPL_THUNK(997)
  3704. IMPL_THUNK(998)
  3705. IMPL_THUNK(999)
  3706. IMPL_THUNK(1000)
  3707. IMPL_THUNK(1001)
  3708. IMPL_THUNK(1002)
  3709. IMPL_THUNK(1003)
  3710. IMPL_THUNK(1004)
  3711. IMPL_THUNK(1005)
  3712. IMPL_THUNK(1006)
  3713. IMPL_THUNK(1007)
  3714. IMPL_THUNK(1008)
  3715. IMPL_THUNK(1009)
  3716. IMPL_THUNK(1010)
  3717. IMPL_THUNK(1011)
  3718. IMPL_THUNK(1012)
  3719. IMPL_THUNK(1013)
  3720. IMPL_THUNK(1014)
  3721. IMPL_THUNK(1015)
  3722. IMPL_THUNK(1016)
  3723. IMPL_THUNK(1017)
  3724. IMPL_THUNK(1018)
  3725. IMPL_THUNK(1019)
  3726. IMPL_THUNK(1020)
  3727. IMPL_THUNK(1021)
  3728. IMPL_THUNK(1022)
  3729. IMPL_THUNK(1023)
  3730. IMPL_THUNK(1024)
  3731. #endif
  3732. __declspec(selectany) GUID CComModule::m_libid = {0x0,0x0,0x0,{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}};
  3733. #ifdef _ATL_STATIC_REGISTRY
  3734. #define UpdateRegistryFromResource UpdateRegistryFromResourceS
  3735. #else
  3736. #define UpdateRegistryFromResource UpdateRegistryFromResourceD
  3737. #endif
  3738. /////////////////////////////////////////////////////////////////////////////////////////////
  3739. // Thread Pooling classes
  3740. class _AtlAptCreateObjData
  3741. {
  3742. public:
  3743. _ATL_CREATORFUNC* pfnCreateInstance;
  3744. const IID* piid;
  3745. HANDLE hEvent;
  3746. LPSTREAM pStream;
  3747. HRESULT hRes;
  3748. };
  3749. class CComApartment
  3750. {
  3751. public:
  3752. CComApartment()
  3753. {
  3754. m_nLockCnt = 0;
  3755. }
  3756. static UINT ATL_CREATE_OBJECT;
  3757. static DWORD WINAPI _Apartment(void* pv)
  3758. {
  3759. return ((CComApartment*)pv)->Apartment();
  3760. }
  3761. DWORD Apartment()
  3762. {
  3763. #if !defined(_WIN32_WCE)
  3764. CoInitialize(NULL);
  3765. MSG msg;
  3766. while(GetMessage(&msg, 0, 0, 0))
  3767. {
  3768. if (msg.message == ATL_CREATE_OBJECT)
  3769. {
  3770. _AtlAptCreateObjData* pdata = (_AtlAptCreateObjData*)msg.lParam;
  3771. IUnknown* pUnk = NULL;
  3772. pdata->hRes = pdata->pfnCreateInstance(NULL, IID_IUnknown, (void**)&pUnk);
  3773. if (SUCCEEDED(pdata->hRes))
  3774. pdata->hRes = CoMarshalInterThreadInterfaceInStream(*pdata->piid, pUnk, &pdata->pStream);
  3775. if (SUCCEEDED(pdata->hRes))
  3776. {
  3777. pUnk->Release();
  3778. ATLTRACE2(atlTraceCOM, 2, _T("Object created on thread = %d\n"), GetCurrentThreadId());
  3779. }
  3780. SetEvent(pdata->hEvent);
  3781. }
  3782. DispatchMessage(&msg);
  3783. }
  3784. CoUninitialize();
  3785. #endif // _WIN32_WCE
  3786. return 0;
  3787. }
  3788. LONG Lock() {return CComGlobalsThreadModel::Increment(&m_nLockCnt);}
  3789. LONG Unlock(){return CComGlobalsThreadModel::Decrement(&m_nLockCnt);
  3790. }
  3791. LONG GetLockCount() {return m_nLockCnt;}
  3792. DWORD m_dwThreadID;
  3793. HANDLE m_hThread;
  3794. LONG m_nLockCnt;
  3795. };
  3796. __declspec(selectany) UINT CComApartment::ATL_CREATE_OBJECT = 0;
  3797. class CComSimpleThreadAllocator
  3798. {
  3799. public:
  3800. CComSimpleThreadAllocator()
  3801. {
  3802. m_nThread = 0;
  3803. }
  3804. int GetThread(CComApartment* /*pApt*/, int nThreads)
  3805. {
  3806. if (++m_nThread == nThreads)
  3807. m_nThread = 0;
  3808. return m_nThread;
  3809. }
  3810. int m_nThread;
  3811. };
  3812. template <class ThreadAllocator = CComSimpleThreadAllocator>
  3813. class CComAutoThreadModule : public CComModule
  3814. {
  3815. public:
  3816. HRESULT Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h, const GUID* plibid = NULL, int nThreads = GetDefaultThreads());
  3817. ~CComAutoThreadModule();
  3818. HRESULT CreateInstance(void* pfnCreateInstance, REFIID riid, void** ppvObj);
  3819. LONG Lock();
  3820. LONG Unlock();
  3821. DWORD dwThreadID;
  3822. int m_nThreads;
  3823. CComApartment* m_pApartments;
  3824. ThreadAllocator m_Allocator;
  3825. static int GetDefaultThreads()
  3826. {
  3827. SYSTEM_INFO si;
  3828. GetSystemInfo(&si);
  3829. return si.dwNumberOfProcessors * 4;
  3830. }
  3831. };
  3832. /////////////////////////////////////////////////////////////////////////////
  3833. // CComBSTR
  3834. class CComBSTR
  3835. {
  3836. public:
  3837. BSTR m_str;
  3838. CComBSTR()
  3839. {
  3840. m_str = NULL;
  3841. }
  3842. /*explicit*/ CComBSTR(int nSize)
  3843. {
  3844. m_str = ::SysAllocStringLen(NULL, nSize);
  3845. }
  3846. /*explicit*/ CComBSTR(int nSize, LPCOLESTR sz)
  3847. {
  3848. m_str = ::SysAllocStringLen(sz, nSize);
  3849. }
  3850. /*explicit*/ CComBSTR(LPCOLESTR pSrc)
  3851. {
  3852. m_str = ::SysAllocString(pSrc);
  3853. }
  3854. /*explicit*/ CComBSTR(const CComBSTR& src)
  3855. {
  3856. m_str = src.Copy();
  3857. }
  3858. /*explicit*/ CComBSTR(REFGUID src)
  3859. {
  3860. LPOLESTR szGuid;
  3861. StringFromCLSID(src, &szGuid);
  3862. m_str = ::SysAllocString(szGuid);
  3863. CoTaskMemFree(szGuid);
  3864. }
  3865. CComBSTR& operator=(const CComBSTR& src)
  3866. {
  3867. if (m_str != src.m_str)
  3868. {
  3869. if (m_str)
  3870. ::SysFreeString(m_str);
  3871. m_str = src.Copy();
  3872. }
  3873. return *this;
  3874. }
  3875. CComBSTR& operator=(LPCOLESTR pSrc)
  3876. {
  3877. ::SysFreeString(m_str);
  3878. m_str = ::SysAllocString(pSrc);
  3879. return *this;
  3880. }
  3881. ~CComBSTR()
  3882. {
  3883. ::SysFreeString(m_str);
  3884. }
  3885. unsigned int Length() const
  3886. {
  3887. return (m_str == NULL)? 0 : SysStringLen(m_str);
  3888. }
  3889. operator BSTR() const
  3890. {
  3891. return m_str;
  3892. }
  3893. BSTR* operator&()
  3894. {
  3895. return &m_str;
  3896. }
  3897. BSTR Copy() const
  3898. {
  3899. return ::SysAllocStringLen(m_str, ::SysStringLen(m_str));
  3900. }
  3901. HRESULT CopyTo(BSTR* pbstr)
  3902. {
  3903. ATLASSERT(pbstr != NULL);
  3904. if (pbstr == NULL)
  3905. return E_POINTER;
  3906. *pbstr = ::SysAllocStringLen(m_str, ::SysStringLen(m_str));
  3907. if (*pbstr == NULL)
  3908. return E_OUTOFMEMORY;
  3909. return S_OK;
  3910. }
  3911. void Attach(BSTR src)
  3912. {
  3913. ATLASSERT(m_str == NULL);
  3914. m_str = src;
  3915. }
  3916. BSTR Detach()
  3917. {
  3918. BSTR s = m_str;
  3919. m_str = NULL;
  3920. return s;
  3921. }
  3922. void Empty()
  3923. {
  3924. ::SysFreeString(m_str);
  3925. m_str = NULL;
  3926. }
  3927. bool operator!() const
  3928. {
  3929. return (m_str == NULL);
  3930. }
  3931. HRESULT Append(const CComBSTR& bstrSrc)
  3932. {
  3933. return Append(bstrSrc.m_str, SysStringLen(bstrSrc.m_str));
  3934. }
  3935. HRESULT Append(LPCOLESTR lpsz)
  3936. {
  3937. return Append(lpsz, ocslen(lpsz));
  3938. }
  3939. // a BSTR is just a LPCOLESTR so we need a special version to signify
  3940. // that we are appending a BSTR
  3941. HRESULT AppendBSTR(BSTR p)
  3942. {
  3943. return Append(p, SysStringLen(p));
  3944. }
  3945. HRESULT Append(LPCOLESTR lpsz, int nLen)
  3946. {
  3947. int n1 = Length();
  3948. BSTR b;
  3949. b = ::SysAllocStringLen(NULL, n1+nLen);
  3950. if (b == NULL)
  3951. return E_OUTOFMEMORY;
  3952. memcpy(b, m_str, n1*sizeof(OLECHAR));
  3953. memcpy(b+n1, lpsz, nLen*sizeof(OLECHAR));
  3954. b[n1+nLen] = NULL;
  3955. SysFreeString(m_str);
  3956. m_str = b;
  3957. return S_OK;
  3958. }
  3959. HRESULT ToLower()
  3960. {
  3961. USES_CONVERSION;
  3962. if (m_str != NULL)
  3963. {
  3964. LPTSTR psz = CharLower(OLE2T(m_str));
  3965. if (psz == NULL)
  3966. return E_OUTOFMEMORY;
  3967. BSTR b = T2BSTR(psz);
  3968. if (psz == NULL)
  3969. return E_OUTOFMEMORY;
  3970. SysFreeString(m_str);
  3971. m_str = b;
  3972. }
  3973. return S_OK;
  3974. }
  3975. HRESULT ToUpper()
  3976. {
  3977. USES_CONVERSION;
  3978. if (m_str != NULL)
  3979. {
  3980. LPTSTR psz = CharUpper(OLE2T(m_str));
  3981. if (psz == NULL)
  3982. return E_OUTOFMEMORY;
  3983. BSTR b = T2BSTR(psz);
  3984. if (psz == NULL)
  3985. return E_OUTOFMEMORY;
  3986. SysFreeString(m_str);
  3987. m_str = b;
  3988. }
  3989. return S_OK;
  3990. }
  3991. bool LoadString(HINSTANCE hInst, UINT nID)
  3992. {
  3993. USES_CONVERSION;
  3994. TCHAR sz[512];
  3995. UINT nLen = ::LoadString(hInst, nID, sz, 512);
  3996. ATLASSERT(nLen < 511);
  3997. SysFreeString(m_str);
  3998. m_str = (nLen != 0) ? SysAllocString(T2OLE(sz)) : NULL;
  3999. return (nLen != 0);
  4000. }
  4001. bool LoadString(UINT nID)
  4002. {
  4003. return LoadString(_pModule->m_hInstResource, nID);
  4004. }
  4005. CComBSTR& operator+=(const CComBSTR& bstrSrc)
  4006. {
  4007. AppendBSTR(bstrSrc.m_str);
  4008. return *this;
  4009. }
  4010. bool operator<(BSTR bstrSrc) const
  4011. {
  4012. if (bstrSrc == NULL && m_str == NULL)
  4013. return false;
  4014. if (bstrSrc != NULL && m_str != NULL)
  4015. return wcscmp(m_str, bstrSrc) < 0;
  4016. return m_str == NULL;
  4017. }
  4018. bool operator==(BSTR bstrSrc) const
  4019. {
  4020. if (bstrSrc == NULL && m_str == NULL)
  4021. return true;
  4022. if (bstrSrc != NULL && m_str != NULL)
  4023. return wcscmp(m_str, bstrSrc) == 0;
  4024. return false;
  4025. }
  4026. bool operator<(LPCSTR pszSrc) const
  4027. {
  4028. if (pszSrc == NULL && m_str == NULL)
  4029. return false;
  4030. USES_CONVERSION;
  4031. if (pszSrc != NULL && m_str != NULL)
  4032. return wcscmp(m_str, A2W(pszSrc)) < 0;
  4033. return m_str == NULL;
  4034. }
  4035. bool operator==(LPCSTR pszSrc) const
  4036. {
  4037. if (pszSrc == NULL && m_str == NULL)
  4038. return true;
  4039. USES_CONVERSION;
  4040. if (pszSrc != NULL && m_str != NULL)
  4041. return wcscmp(m_str, A2W(pszSrc)) == 0;
  4042. return false;
  4043. }
  4044. #ifndef OLE2ANSI
  4045. CComBSTR(LPCSTR pSrc)
  4046. {
  4047. m_str = A2WBSTR(pSrc);
  4048. }
  4049. CComBSTR(int nSize, LPCSTR sz)
  4050. {
  4051. m_str = A2WBSTR(sz, nSize);
  4052. }
  4053. void Append(LPCSTR lpsz)
  4054. {
  4055. USES_CONVERSION;
  4056. LPCOLESTR lpo = A2COLE(lpsz);
  4057. Append(lpo, ocslen(lpo));
  4058. }
  4059. CComBSTR& operator=(LPCSTR pSrc)
  4060. {
  4061. ::SysFreeString(m_str);
  4062. m_str = A2WBSTR(pSrc);
  4063. return *this;
  4064. }
  4065. #endif
  4066. HRESULT WriteToStream(IStream* pStream)
  4067. {
  4068. ATLASSERT(pStream != NULL);
  4069. ULONG cb;
  4070. ULONG cbStrLen = m_str ? SysStringByteLen(m_str)+sizeof(OLECHAR) : 0;
  4071. HRESULT hr = pStream->Write((void*) &cbStrLen, sizeof(cbStrLen), &cb);
  4072. if (FAILED(hr))
  4073. return hr;
  4074. return cbStrLen ? pStream->Write((void*) m_str, cbStrLen, &cb) : S_OK;
  4075. }
  4076. HRESULT ReadFromStream(IStream* pStream)
  4077. {
  4078. ATLASSERT(pStream != NULL);
  4079. ATLASSERT(m_str == NULL); // should be empty
  4080. ULONG cbStrLen = 0;
  4081. HRESULT hr = pStream->Read((void*) &cbStrLen, sizeof(cbStrLen), NULL);
  4082. if ((hr == S_OK) && (cbStrLen != 0))
  4083. {
  4084. //subtract size for terminating NULL which we wrote out
  4085. //since SysAllocStringByteLen overallocates for the NULL
  4086. m_str = SysAllocStringByteLen(NULL, cbStrLen-sizeof(OLECHAR));
  4087. if (m_str == NULL)
  4088. hr = E_OUTOFMEMORY;
  4089. else
  4090. hr = pStream->Read((void*) m_str, cbStrLen, NULL);
  4091. }
  4092. if (hr == S_FALSE)
  4093. hr = E_FAIL;
  4094. return hr;
  4095. }
  4096. };
  4097. /////////////////////////////////////////////////////////////////////////////
  4098. // CComVariant
  4099. class CComVariant : public tagVARIANT
  4100. {
  4101. // Constructors
  4102. public:
  4103. CComVariant()
  4104. {
  4105. vt = VT_EMPTY;
  4106. }
  4107. ~CComVariant()
  4108. {
  4109. Clear();
  4110. }
  4111. CComVariant(const VARIANT& varSrc)
  4112. {
  4113. vt = VT_EMPTY;
  4114. InternalCopy(&varSrc);
  4115. }
  4116. CComVariant(const CComVariant& varSrc)
  4117. {
  4118. vt = VT_EMPTY;
  4119. InternalCopy(&varSrc);
  4120. }
  4121. CComVariant(BSTR bstrSrc)
  4122. {
  4123. vt = VT_EMPTY;
  4124. *this = bstrSrc;
  4125. }
  4126. CComVariant(LPCOLESTR lpszSrc)
  4127. {
  4128. vt = VT_EMPTY;
  4129. *this = lpszSrc;
  4130. }
  4131. #ifndef OLE2ANSI
  4132. CComVariant(LPCSTR lpszSrc)
  4133. {
  4134. vt = VT_EMPTY;
  4135. *this = lpszSrc;
  4136. }
  4137. #endif
  4138. CComVariant(bool bSrc)
  4139. {
  4140. vt = VT_BOOL;
  4141. #pragma warning(disable: 4310) // cast truncates constant value
  4142. boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
  4143. #pragma warning(default: 4310) // cast truncates constant value
  4144. }
  4145. CComVariant(int nSrc)
  4146. {
  4147. vt = VT_I4;
  4148. lVal = nSrc;
  4149. }
  4150. CComVariant(BYTE nSrc)
  4151. {
  4152. vt = VT_UI1;
  4153. bVal = nSrc;
  4154. }
  4155. CComVariant(short nSrc)
  4156. {
  4157. vt = VT_I2;
  4158. iVal = nSrc;
  4159. }
  4160. CComVariant(long nSrc, VARTYPE vtSrc = VT_I4)
  4161. {
  4162. ATLASSERT(vtSrc == VT_I4 || vtSrc == VT_ERROR);
  4163. vt = vtSrc;
  4164. lVal = nSrc;
  4165. }
  4166. CComVariant(float fltSrc)
  4167. {
  4168. vt = VT_R4;
  4169. fltVal = fltSrc;
  4170. }
  4171. CComVariant(double dblSrc)
  4172. {
  4173. vt = VT_R8;
  4174. dblVal = dblSrc;
  4175. }
  4176. CComVariant(CY cySrc)
  4177. {
  4178. vt = VT_CY;
  4179. cyVal.Hi = cySrc.Hi;
  4180. cyVal.Lo = cySrc.Lo;
  4181. }
  4182. CComVariant(IDispatch* pSrc)
  4183. {
  4184. vt = VT_DISPATCH;
  4185. pdispVal = pSrc;
  4186. // Need to AddRef as VariantClear will Release
  4187. if (pdispVal != NULL)
  4188. pdispVal->AddRef();
  4189. }
  4190. CComVariant(IUnknown* pSrc)
  4191. {
  4192. vt = VT_UNKNOWN;
  4193. punkVal = pSrc;
  4194. // Need to AddRef as VariantClear will Release
  4195. if (punkVal != NULL)
  4196. punkVal->AddRef();
  4197. }
  4198. // Assignment Operators
  4199. public:
  4200. CComVariant& operator=(const CComVariant& varSrc)
  4201. {
  4202. InternalCopy(&varSrc);
  4203. return *this;
  4204. }
  4205. CComVariant& operator=(const VARIANT& varSrc)
  4206. {
  4207. InternalCopy(&varSrc);
  4208. return *this;
  4209. }
  4210. CComVariant& operator=(BSTR bstrSrc)
  4211. {
  4212. InternalClear();
  4213. vt = VT_BSTR;
  4214. bstrVal = ::SysAllocString(bstrSrc);
  4215. if (bstrVal == NULL && bstrSrc != NULL)
  4216. {
  4217. vt = VT_ERROR;
  4218. scode = E_OUTOFMEMORY;
  4219. }
  4220. return *this;
  4221. }
  4222. CComVariant& operator=(LPCOLESTR lpszSrc)
  4223. {
  4224. InternalClear();
  4225. vt = VT_BSTR;
  4226. bstrVal = ::SysAllocString(lpszSrc);
  4227. if (bstrVal == NULL && lpszSrc != NULL)
  4228. {
  4229. vt = VT_ERROR;
  4230. scode = E_OUTOFMEMORY;
  4231. }
  4232. return *this;
  4233. }
  4234. #ifndef OLE2ANSI
  4235. CComVariant& operator=(LPCSTR lpszSrc)
  4236. {
  4237. USES_CONVERSION;
  4238. InternalClear();
  4239. vt = VT_BSTR;
  4240. bstrVal = ::SysAllocString(A2COLE(lpszSrc));
  4241. if (bstrVal == NULL && lpszSrc != NULL)
  4242. {
  4243. vt = VT_ERROR;
  4244. scode = E_OUTOFMEMORY;
  4245. }
  4246. return *this;
  4247. }
  4248. #endif
  4249. CComVariant& operator=(bool bSrc)
  4250. {
  4251. if (vt != VT_BOOL)
  4252. {
  4253. InternalClear();
  4254. vt = VT_BOOL;
  4255. }
  4256. #pragma warning(disable: 4310) // cast truncates constant value
  4257. boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
  4258. #pragma warning(default: 4310) // cast truncates constant value
  4259. return *this;
  4260. }
  4261. CComVariant& operator=(int nSrc)
  4262. {
  4263. if (vt != VT_I4)
  4264. {
  4265. InternalClear();
  4266. vt = VT_I4;
  4267. }
  4268. lVal = nSrc;
  4269. return *this;
  4270. }
  4271. CComVariant& operator=(BYTE nSrc)
  4272. {
  4273. if (vt != VT_UI1)
  4274. {
  4275. InternalClear();
  4276. vt = VT_UI1;
  4277. }
  4278. bVal = nSrc;
  4279. return *this;
  4280. }
  4281. CComVariant& operator=(short nSrc)
  4282. {
  4283. if (vt != VT_I2)
  4284. {
  4285. InternalClear();
  4286. vt = VT_I2;
  4287. }
  4288. iVal = nSrc;
  4289. return *this;
  4290. }
  4291. CComVariant& operator=(long nSrc)
  4292. {
  4293. if (vt != VT_I4)
  4294. {
  4295. InternalClear();
  4296. vt = VT_I4;
  4297. }
  4298. lVal = nSrc;
  4299. return *this;
  4300. }
  4301. CComVariant& operator=(float fltSrc)
  4302. {
  4303. if (vt != VT_R4)
  4304. {
  4305. InternalClear();
  4306. vt = VT_R4;
  4307. }
  4308. fltVal = fltSrc;
  4309. return *this;
  4310. }
  4311. CComVariant& operator=(double dblSrc)
  4312. {
  4313. if (vt != VT_R8)
  4314. {
  4315. InternalClear();
  4316. vt = VT_R8;
  4317. }
  4318. dblVal = dblSrc;
  4319. return *this;
  4320. }
  4321. CComVariant& operator=(CY cySrc)
  4322. {
  4323. if (vt != VT_CY)
  4324. {
  4325. InternalClear();
  4326. vt = VT_CY;
  4327. }
  4328. cyVal.Hi = cySrc.Hi;
  4329. cyVal.Lo = cySrc.Lo;
  4330. return *this;
  4331. }
  4332. CComVariant& operator=(IDispatch* pSrc)
  4333. {
  4334. InternalClear();
  4335. vt = VT_DISPATCH;
  4336. pdispVal = pSrc;
  4337. // Need to AddRef as VariantClear will Release
  4338. if (pdispVal != NULL)
  4339. pdispVal->AddRef();
  4340. return *this;
  4341. }
  4342. CComVariant& operator=(IUnknown* pSrc)
  4343. {
  4344. InternalClear();
  4345. vt = VT_UNKNOWN;
  4346. punkVal = pSrc;
  4347. // Need to AddRef as VariantClear will Release
  4348. if (punkVal != NULL)
  4349. punkVal->AddRef();
  4350. return *this;
  4351. }
  4352. // Comparison Operators
  4353. public:
  4354. bool operator==(const VARIANT& varSrc) const
  4355. {
  4356. if (this == &varSrc)
  4357. return true;
  4358. // Variants not equal if types don't match
  4359. if (vt != varSrc.vt)
  4360. return false;
  4361. // Check type specific values
  4362. switch (vt)
  4363. {
  4364. case VT_EMPTY:
  4365. case VT_NULL:
  4366. return true;
  4367. case VT_BOOL:
  4368. return boolVal == varSrc.boolVal;
  4369. case VT_UI1:
  4370. return bVal == varSrc.bVal;
  4371. case VT_I2:
  4372. return iVal == varSrc.iVal;
  4373. case VT_I4:
  4374. return lVal == varSrc.lVal;
  4375. case VT_R4:
  4376. return fltVal == varSrc.fltVal;
  4377. case VT_R8:
  4378. return dblVal == varSrc.dblVal;
  4379. case VT_BSTR:
  4380. return (::SysStringByteLen(bstrVal) == ::SysStringByteLen(varSrc.bstrVal)) &&
  4381. (::memcmp(bstrVal, varSrc.bstrVal, ::SysStringByteLen(bstrVal)) == 0);
  4382. case VT_ERROR:
  4383. return scode == varSrc.scode;
  4384. case VT_DISPATCH:
  4385. return pdispVal == varSrc.pdispVal;
  4386. case VT_UNKNOWN:
  4387. return punkVal == varSrc.punkVal;
  4388. default:
  4389. ATLASSERT(false);
  4390. // fall through
  4391. }
  4392. return false;
  4393. }
  4394. bool operator!=(const VARIANT& varSrc) const {return !operator==(varSrc);}
  4395. WCE_DEL bool operator<(const VARIANT& varSrc) const {return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT)==VARCMP_LT;}
  4396. WCE_DEL bool operator>(const VARIANT& varSrc) const {return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT)==VARCMP_GT;}
  4397. // Operations
  4398. public:
  4399. HRESULT Clear() { return ::VariantClear(this); }
  4400. HRESULT Copy(const VARIANT* pSrc) { return ::VariantCopy(this, const_cast<VARIANT*>(pSrc)); }
  4401. HRESULT Attach(VARIANT* pSrc)
  4402. {
  4403. // Clear out the variant
  4404. HRESULT hr = Clear();
  4405. if (!FAILED(hr))
  4406. {
  4407. // Copy the contents and give control to CComVariant
  4408. memcpy(this, pSrc, sizeof(VARIANT));
  4409. pSrc->vt = VT_EMPTY;
  4410. hr = S_OK;
  4411. }
  4412. return hr;
  4413. }
  4414. HRESULT Detach(VARIANT* pDest)
  4415. {
  4416. // Clear out the variant
  4417. HRESULT hr = ::VariantClear(pDest);
  4418. if (!FAILED(hr))
  4419. {
  4420. // Copy the contents and remove control from CComVariant
  4421. memcpy(pDest, this, sizeof(VARIANT));
  4422. vt = VT_EMPTY;
  4423. hr = S_OK;
  4424. }
  4425. return hr;
  4426. }
  4427. HRESULT ChangeType(VARTYPE vtNew, const VARIANT* pSrc = NULL)
  4428. {
  4429. VARIANT* pVar = const_cast<VARIANT*>(pSrc);
  4430. // Convert in place if pSrc is NULL
  4431. if (pVar == NULL)
  4432. pVar = this;
  4433. // Do nothing if doing in place convert and vts not different
  4434. return ::VariantChangeType(this, pVar, 0, vtNew);
  4435. }
  4436. HRESULT WriteToStream(IStream* pStream);
  4437. HRESULT ReadFromStream(IStream* pStream);
  4438. // Implementation
  4439. public:
  4440. HRESULT InternalClear()
  4441. {
  4442. HRESULT hr = Clear();
  4443. ATLASSERT(SUCCEEDED(hr));
  4444. if (FAILED(hr))
  4445. {
  4446. vt = VT_ERROR;
  4447. scode = hr;
  4448. }
  4449. return hr;
  4450. }
  4451. void InternalCopy(const VARIANT* pSrc)
  4452. {
  4453. HRESULT hr = Copy(pSrc);
  4454. if (FAILED(hr))
  4455. {
  4456. vt = VT_ERROR;
  4457. scode = hr;
  4458. }
  4459. }
  4460. };
  4461. inline HRESULT CComVariant::WriteToStream(IStream* pStream)
  4462. {
  4463. HRESULT hr = pStream->Write(&vt, sizeof(VARTYPE), NULL);
  4464. if (FAILED(hr))
  4465. return hr;
  4466. int cbWrite = 0;
  4467. switch (vt)
  4468. {
  4469. case VT_UNKNOWN:
  4470. case VT_DISPATCH:
  4471. {
  4472. CComPtr<IPersistStream> spStream;
  4473. if (punkVal != NULL)
  4474. {
  4475. hr = punkVal->QueryInterface(IID_IPersistStream, (void**)&spStream);
  4476. if (FAILED(hr))
  4477. return hr;
  4478. }
  4479. if (spStream != NULL)
  4480. return WCE_FCTN(OleSaveToStream)(spStream, pStream);
  4481. else
  4482. return WriteClassStm(pStream, CLSID_NULL);
  4483. }
  4484. case VT_UI1:
  4485. case VT_I1:
  4486. cbWrite = sizeof(BYTE);
  4487. break;
  4488. case VT_I2:
  4489. case VT_UI2:
  4490. case VT_BOOL:
  4491. cbWrite = sizeof(short);
  4492. break;
  4493. case VT_I4:
  4494. case VT_UI4:
  4495. case VT_R4:
  4496. case VT_INT:
  4497. case VT_UINT:
  4498. case VT_ERROR:
  4499. cbWrite = sizeof(long);
  4500. break;
  4501. case VT_R8:
  4502. case VT_CY:
  4503. case VT_DATE:
  4504. cbWrite = sizeof(double);
  4505. break;
  4506. default:
  4507. break;
  4508. }
  4509. if (cbWrite != 0)
  4510. return pStream->Write((void*) &bVal, cbWrite, NULL);
  4511. CComBSTR bstrWrite;
  4512. CComVariant varBSTR;
  4513. if (vt != VT_BSTR)
  4514. {
  4515. hr = VariantChangeType(&varBSTR, this, VARIANT_NOVALUEPROP, VT_BSTR);
  4516. if (FAILED(hr))
  4517. return hr;
  4518. bstrWrite = varBSTR.bstrVal;
  4519. }
  4520. else
  4521. bstrWrite = bstrVal;
  4522. return bstrWrite.WriteToStream(pStream);
  4523. }
  4524. inline HRESULT CComVariant::ReadFromStream(IStream* pStream)
  4525. {
  4526. ATLASSERT(pStream != NULL);
  4527. HRESULT hr;
  4528. hr = VariantClear(this);
  4529. if (FAILED(hr))
  4530. return hr;
  4531. VARTYPE vtRead;
  4532. hr = pStream->Read(&vtRead, sizeof(VARTYPE), NULL);
  4533. if (hr == S_FALSE)
  4534. hr = E_FAIL;
  4535. if (FAILED(hr))
  4536. return hr;
  4537. vt = vtRead;
  4538. int cbRead = 0;
  4539. switch (vtRead)
  4540. {
  4541. case VT_UNKNOWN:
  4542. case VT_DISPATCH:
  4543. {
  4544. punkVal = NULL;
  4545. hr = WCE_FCTN(OleLoadFromStream)(pStream, (vtRead == VT_UNKNOWN) ? IID_IUnknown : IID_IDispatch, (void**)&punkVal);
  4546. if (hr == REGDB_E_CLASSNOTREG)
  4547. hr = S_OK;
  4548. return S_OK;
  4549. }
  4550. case VT_UI1:
  4551. case VT_I1:
  4552. cbRead = sizeof(BYTE);
  4553. break;
  4554. case VT_I2:
  4555. case VT_UI2:
  4556. case VT_BOOL:
  4557. cbRead = sizeof(short);
  4558. break;
  4559. case VT_I4:
  4560. case VT_UI4:
  4561. case VT_R4:
  4562. case VT_INT:
  4563. case VT_UINT:
  4564. case VT_ERROR:
  4565. cbRead = sizeof(long);
  4566. break;
  4567. case VT_R8:
  4568. case VT_CY:
  4569. case VT_DATE:
  4570. cbRead = sizeof(double);
  4571. break;
  4572. default:
  4573. break;
  4574. }
  4575. if (cbRead != 0)
  4576. {
  4577. hr = pStream->Read((void*) &bVal, cbRead, NULL);
  4578. if (hr == S_FALSE)
  4579. hr = E_FAIL;
  4580. return hr;
  4581. }
  4582. CComBSTR bstrRead;
  4583. hr = bstrRead.ReadFromStream(pStream);
  4584. if (FAILED(hr))
  4585. return hr;
  4586. vt = VT_BSTR;
  4587. bstrVal = bstrRead.Detach();
  4588. if (vtRead != VT_BSTR)
  4589. hr = ChangeType(vtRead);
  4590. return hr;
  4591. }
  4592. /////////////////////////////////////////////////////////////////////////////
  4593. // CRegKey
  4594. class CRegKey
  4595. {
  4596. public:
  4597. CRegKey();
  4598. ~CRegKey();
  4599. // Attributes
  4600. public:
  4601. operator HKEY() const;
  4602. HKEY m_hKey;
  4603. // Operations
  4604. public:
  4605. LONG SetValue(DWORD dwValue, LPCTSTR lpszValueName);
  4606. LONG QueryValue(DWORD& dwValue, LPCTSTR lpszValueName);
  4607. LONG QueryValue(LPTSTR szValue, LPCTSTR lpszValueName, DWORD* pdwCount);
  4608. LONG SetValue(LPCTSTR lpszValue, LPCTSTR lpszValueName = NULL);
  4609. LONG SetKeyValue(LPCTSTR lpszKeyName, LPCTSTR lpszValue, LPCTSTR lpszValueName = NULL);
  4610. static LONG WINAPI SetValue(HKEY hKeyParent, LPCTSTR lpszKeyName,
  4611. LPCTSTR lpszValue, LPCTSTR lpszValueName = NULL);
  4612. LONG Create(HKEY hKeyParent, LPCTSTR lpszKeyName,
  4613. LPTSTR lpszClass = REG_NONE, DWORD dwOptions = REG_OPTION_NON_VOLATILE,
  4614. REGSAM samDesired = KEY_ALL_ACCESS,
  4615. LPSECURITY_ATTRIBUTES lpSecAttr = NULL,
  4616. LPDWORD lpdwDisposition = NULL);
  4617. LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName,
  4618. REGSAM samDesired = KEY_ALL_ACCESS);
  4619. LONG Close();
  4620. HKEY Detach();
  4621. void Attach(HKEY hKey);
  4622. LONG DeleteSubKey(LPCTSTR lpszSubKey);
  4623. LONG RecurseDeleteKey(LPCTSTR lpszKey);
  4624. LONG DeleteValue(LPCTSTR lpszValue);
  4625. };
  4626. inline CRegKey::CRegKey()
  4627. {m_hKey = NULL;}
  4628. inline CRegKey::~CRegKey()
  4629. {Close();}
  4630. inline CRegKey::operator HKEY() const
  4631. {return m_hKey;}
  4632. inline HKEY CRegKey::Detach()
  4633. {
  4634. HKEY hKey = m_hKey;
  4635. m_hKey = NULL;
  4636. return hKey;
  4637. }
  4638. inline void CRegKey::Attach(HKEY hKey)
  4639. {
  4640. ATLASSERT(m_hKey == NULL);
  4641. m_hKey = hKey;
  4642. }
  4643. inline LONG CRegKey::DeleteSubKey(LPCTSTR lpszSubKey)
  4644. {
  4645. ATLASSERT(m_hKey != NULL);
  4646. return RegDeleteKey(m_hKey, lpszSubKey);
  4647. }
  4648. inline LONG CRegKey::DeleteValue(LPCTSTR lpszValue)
  4649. {
  4650. ATLASSERT(m_hKey != NULL);
  4651. return RegDeleteValue(m_hKey, (LPTSTR)lpszValue);
  4652. }
  4653. inline LONG CRegKey::Close()
  4654. {
  4655. LONG lRes = ERROR_SUCCESS;
  4656. if (m_hKey != NULL)
  4657. {
  4658. lRes = RegCloseKey(m_hKey);
  4659. m_hKey = NULL;
  4660. }
  4661. return lRes;
  4662. }
  4663. inline LONG CRegKey::Create(HKEY hKeyParent, LPCTSTR lpszKeyName,
  4664. LPTSTR lpszClass, DWORD dwOptions, REGSAM samDesired,
  4665. LPSECURITY_ATTRIBUTES lpSecAttr, LPDWORD lpdwDisposition)
  4666. {
  4667. ATLASSERT(hKeyParent != NULL);
  4668. DWORD dw;
  4669. HKEY hKey = NULL;
  4670. LONG lRes = RegCreateKeyEx(hKeyParent, lpszKeyName, 0,
  4671. lpszClass, dwOptions, samDesired, lpSecAttr, &hKey, &dw);
  4672. if (lpdwDisposition != NULL)
  4673. *lpdwDisposition = dw;
  4674. if (lRes == ERROR_SUCCESS)
  4675. {
  4676. lRes = Close();
  4677. m_hKey = hKey;
  4678. }
  4679. return lRes;
  4680. }
  4681. inline LONG CRegKey::Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired)
  4682. {
  4683. ATLASSERT(hKeyParent != NULL);
  4684. HKEY hKey = NULL;
  4685. LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyName, 0, samDesired, &hKey);
  4686. if (lRes == ERROR_SUCCESS)
  4687. {
  4688. lRes = Close();
  4689. ATLASSERT(lRes == ERROR_SUCCESS);
  4690. m_hKey = hKey;
  4691. }
  4692. return lRes;
  4693. }
  4694. inline LONG CRegKey::QueryValue(DWORD& dwValue, LPCTSTR lpszValueName)
  4695. {
  4696. DWORD dwType = NULL;
  4697. DWORD dwCount = sizeof(DWORD);
  4698. LONG lRes = RegQueryValueEx(m_hKey, (LPTSTR)lpszValueName, NULL, &dwType,
  4699. (LPBYTE)&dwValue, &dwCount);
  4700. ATLASSERT((lRes!=ERROR_SUCCESS) || (dwType == REG_DWORD));
  4701. ATLASSERT((lRes!=ERROR_SUCCESS) || (dwCount == sizeof(DWORD)));
  4702. return lRes;
  4703. }
  4704. inline LONG CRegKey::QueryValue(LPTSTR szValue, LPCTSTR lpszValueName, DWORD* pdwCount)
  4705. {
  4706. ATLASSERT(pdwCount != NULL);
  4707. DWORD dwType = NULL;
  4708. LONG lRes = RegQueryValueEx(m_hKey, (LPTSTR)lpszValueName, NULL, &dwType,
  4709. (LPBYTE)szValue, pdwCount);
  4710. ATLASSERT((lRes!=ERROR_SUCCESS) || (dwType == REG_SZ) ||
  4711. (dwType == REG_MULTI_SZ) || (dwType == REG_EXPAND_SZ));
  4712. return lRes;
  4713. }
  4714. inline LONG WINAPI CRegKey::SetValue(HKEY hKeyParent, LPCTSTR lpszKeyName, LPCTSTR lpszValue, LPCTSTR lpszValueName)
  4715. {
  4716. ATLASSERT(lpszValue != NULL);
  4717. CRegKey key;
  4718. LONG lRes = key.Create(hKeyParent, lpszKeyName);
  4719. if (lRes == ERROR_SUCCESS)
  4720. lRes = key.SetValue(lpszValue, lpszValueName);
  4721. return lRes;
  4722. }
  4723. inline LONG CRegKey::SetKeyValue(LPCTSTR lpszKeyName, LPCTSTR lpszValue, LPCTSTR lpszValueName)
  4724. {
  4725. ATLASSERT(lpszValue != NULL);
  4726. CRegKey key;
  4727. LONG lRes = key.Create(m_hKey, lpszKeyName);
  4728. if (lRes == ERROR_SUCCESS)
  4729. lRes = key.SetValue(lpszValue, lpszValueName);
  4730. return lRes;
  4731. }
  4732. inline LONG CRegKey::SetValue(DWORD dwValue, LPCTSTR lpszValueName)
  4733. {
  4734. ATLASSERT(m_hKey != NULL);
  4735. return RegSetValueEx(m_hKey, lpszValueName, NULL, REG_DWORD,
  4736. (BYTE * const)&dwValue, sizeof(DWORD));
  4737. }
  4738. inline LONG CRegKey::SetValue(LPCTSTR lpszValue, LPCTSTR lpszValueName)
  4739. {
  4740. ATLASSERT(lpszValue != NULL);
  4741. ATLASSERT(m_hKey != NULL);
  4742. return RegSetValueEx(m_hKey, lpszValueName, NULL, REG_SZ,
  4743. (BYTE * const)lpszValue, (lstrlen(lpszValue)+1)*sizeof(TCHAR));
  4744. }
  4745. inline LONG CRegKey::RecurseDeleteKey(LPCTSTR lpszKey)
  4746. {
  4747. CRegKey key;
  4748. LONG lRes = key.Open(m_hKey, lpszKey, KEY_READ | KEY_WRITE);
  4749. if (lRes != ERROR_SUCCESS)
  4750. return lRes;
  4751. FILETIME time;
  4752. DWORD dwSize = 256;
  4753. TCHAR szBuffer[256];
  4754. while (RegEnumKeyEx(key.m_hKey, 0, szBuffer, &dwSize, NULL, NULL, NULL,
  4755. &time)==ERROR_SUCCESS)
  4756. {
  4757. lRes = key.RecurseDeleteKey(szBuffer);
  4758. if (lRes != ERROR_SUCCESS)
  4759. return lRes;
  4760. dwSize = 256;
  4761. }
  4762. key.Close();
  4763. return DeleteSubKey(lpszKey);
  4764. }
  4765. inline HRESULT CComModule::RegisterProgID(LPCTSTR lpszCLSID, LPCTSTR lpszProgID, LPCTSTR lpszUserDesc)
  4766. {
  4767. CRegKey keyProgID;
  4768. LONG lRes = keyProgID.Create(HKEY_CLASSES_ROOT, lpszProgID, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ);
  4769. if (lRes == ERROR_SUCCESS)
  4770. {
  4771. keyProgID.SetValue(lpszUserDesc);
  4772. keyProgID.SetKeyValue(_T("CLSID"), lpszCLSID);
  4773. return S_OK;
  4774. }
  4775. return HRESULT_FROM_WIN32(lRes);
  4776. }
  4777. #ifdef _ATL_STATIC_REGISTRY
  4778. #include <statreg.h>
  4779. // Statically linking to Registry Ponent
  4780. inline HRESULT WINAPI CComModule::UpdateRegistryFromResourceS(UINT nResID, BOOL bRegister,
  4781. struct _ATL_REGMAP_ENTRY* pMapEntries)
  4782. {
  4783. USES_CONVERSION;
  4784. ATL::CRegObject ro;
  4785. TCHAR szModule[_MAX_PATH];
  4786. GetModuleFileName(_pModule->GetModuleInstance(), szModule, _MAX_PATH);
  4787. // Convert to short path to work around bug in NT4's CreateProcess
  4788. WCE_DEL TCHAR szModuleShort[_MAX_PATH];
  4789. WCE_DEL GetShortPathName(szModule, szModuleShort, _MAX_PATH);
  4790. LPOLESTR pszModule = T2OLE(WCE_IF(szModule, szModuleShort));
  4791. int nLen = ocslen(pszModule);
  4792. LPOLESTR pszModuleQuote = (LPOLESTR)alloca((nLen*2+1)*sizeof(OLECHAR));
  4793. ReplaceSingleQuote(pszModuleQuote, pszModule);
  4794. ro.AddReplacement(OLESTR("Module"), pszModuleQuote);
  4795. if (NULL != pMapEntries)
  4796. {
  4797. while (NULL != pMapEntries->szKey)
  4798. {
  4799. ATLASSERT(NULL != pMapEntries->szData);
  4800. ro.AddReplacement(pMapEntries->szKey, pMapEntries->szData);
  4801. pMapEntries++;
  4802. }
  4803. }
  4804. LPCOLESTR szType = OLESTR("REGISTRY");
  4805. return (bRegister) ? ro.ResourceRegister(pszModule, nResID, szType) :
  4806. ro.ResourceUnregister(pszModule, nResID, szType);
  4807. }
  4808. inline HRESULT WINAPI CComModule::UpdateRegistryFromResourceS(LPCTSTR lpszRes, BOOL bRegister,
  4809. struct _ATL_REGMAP_ENTRY* pMapEntries)
  4810. {
  4811. USES_CONVERSION;
  4812. ATL::CRegObject ro;
  4813. TCHAR szModule[_MAX_PATH];
  4814. GetModuleFileName(_pModule->GetModuleInstance(), szModule, _MAX_PATH);
  4815. // Convert to short path to work around bug in NT4's CreateProcess
  4816. WCE_DEL TCHAR szModuleShort[_MAX_PATH];
  4817. WCE_DEL GetShortPathName(szModule, szModuleShort, _MAX_PATH);
  4818. LPOLESTR pszModule = T2OLE(WCE_IF(szModule,szModuleShort));
  4819. int nLen = ocslen(pszModule);
  4820. LPOLESTR pszModuleQuote = (LPOLESTR)alloca((nLen*2+1)*sizeof(OLECHAR));
  4821. ReplaceSingleQuote(pszModuleQuote, pszModule);
  4822. ro.AddReplacement(OLESTR("Module"), pszModuleQuote);
  4823. if (NULL != pMapEntries)
  4824. {
  4825. while (NULL != pMapEntries->szKey)
  4826. {
  4827. ATLASSERT(NULL != pMapEntries->szData);
  4828. ro.AddReplacement(pMapEntries->szKey, pMapEntries->szData);
  4829. pMapEntries++;
  4830. }
  4831. }
  4832. LPCOLESTR szType = OLESTR("REGISTRY");
  4833. LPCOLESTR pszRes = T2COLE(lpszRes);
  4834. return (bRegister) ? ro.ResourceRegisterSz(pszModule, pszRes, szType) :
  4835. ro.ResourceUnregisterSz(pszModule, pszRes, szType);
  4836. }
  4837. #endif //_ATL_STATIC_REGISTRY
  4838. inline HRESULT WINAPI CComModule::UpdateRegistryClass(const CLSID& clsid, LPCTSTR lpszProgID,
  4839. LPCTSTR lpszVerIndProgID, UINT nDescID, DWORD dwFlags, BOOL bRegister)
  4840. {
  4841. if (bRegister)
  4842. {
  4843. return RegisterClassHelper(clsid, lpszProgID, lpszVerIndProgID, nDescID,
  4844. dwFlags);
  4845. }
  4846. else
  4847. return UnregisterClassHelper(clsid, lpszProgID, lpszVerIndProgID);
  4848. }
  4849. inline HRESULT WINAPI CComModule::RegisterClassHelper(const CLSID& clsid, LPCTSTR lpszProgID,
  4850. LPCTSTR lpszVerIndProgID, UINT nDescID, DWORD dwFlags)
  4851. {
  4852. static const TCHAR szProgID[] = _T("ProgID");
  4853. static const TCHAR szVIProgID[] = _T("VersionIndependentProgID");
  4854. static const TCHAR szLS32[] = _T("LocalServer32");
  4855. static const TCHAR szIPS32[] = _T("InprocServer32");
  4856. static const TCHAR szThreadingModel[] = _T("ThreadingModel");
  4857. static const TCHAR szAUTPRX32[] = _T("AUTPRX32.DLL");
  4858. static const TCHAR szApartment[] = _T("Apartment");
  4859. static const TCHAR szBoth[] = _T("both");
  4860. USES_CONVERSION;
  4861. HRESULT hRes = S_OK;
  4862. TCHAR szDesc[256];
  4863. LoadString(m_hInst, nDescID, szDesc, 256);
  4864. TCHAR szModule[_MAX_PATH];
  4865. GetModuleFileName(m_hInst, szModule, _MAX_PATH);
  4866. LPOLESTR lpOleStr;
  4867. StringFromCLSID(clsid, &lpOleStr);
  4868. LPTSTR lpsz = OLE2T(lpOleStr);
  4869. hRes = RegisterProgID(lpsz, lpszProgID, szDesc);
  4870. if (hRes == S_OK)
  4871. hRes = RegisterProgID(lpsz, lpszVerIndProgID, szDesc);
  4872. LONG lRes = ERROR_SUCCESS;
  4873. if (hRes == S_OK)
  4874. {
  4875. CRegKey key;
  4876. lRes = key.Open(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_READ);
  4877. if (lRes == ERROR_SUCCESS)
  4878. {
  4879. lRes = key.Create(key, lpsz, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ);
  4880. if (lRes == ERROR_SUCCESS)
  4881. {
  4882. key.SetValue(szDesc);
  4883. key.SetKeyValue(szProgID, lpszProgID);
  4884. key.SetKeyValue(szVIProgID, lpszVerIndProgID);
  4885. #if !defined(_WIN32_WCE)
  4886. // WinCE: No out-of-proc servers.
  4887. if ((m_hInst == NULL) || (m_hInst == GetModuleHandle(NULL))) // register as EXE
  4888. {
  4889. // Convert to short path to work around bug in NT4's CreateProcess
  4890. TCHAR szModuleShort[_MAX_PATH];
  4891. GetShortPathName(szModule, szModuleShort, _MAX_PATH);
  4892. key.SetKeyValue(szLS32, szModuleShort);
  4893. }
  4894. else
  4895. #endif // _WIN32_WCE
  4896. {
  4897. key.SetKeyValue(szIPS32, (dwFlags & AUTPRXFLAG) ? szAUTPRX32 : szModule);
  4898. LPCTSTR lpszModel = (dwFlags & THREADFLAGS_BOTH) ? szBoth :
  4899. (dwFlags & THREADFLAGS_APARTMENT) ? szApartment : NULL;
  4900. if (lpszModel != NULL)
  4901. key.SetKeyValue(szIPS32, lpszModel, szThreadingModel);
  4902. }
  4903. }
  4904. }
  4905. }
  4906. CoTaskMemFree(lpOleStr);
  4907. if (lRes != ERROR_SUCCESS)
  4908. hRes = HRESULT_FROM_WIN32(lRes);
  4909. return hRes;
  4910. }
  4911. inline HRESULT WINAPI CComModule::UnregisterClassHelper(const CLSID& clsid, LPCTSTR lpszProgID,
  4912. LPCTSTR lpszVerIndProgID)
  4913. {
  4914. USES_CONVERSION;
  4915. CRegKey key;
  4916. key.Attach(HKEY_CLASSES_ROOT);
  4917. if (lpszProgID != NULL && lstrcmpi(lpszProgID, _T("")))
  4918. key.RecurseDeleteKey(lpszProgID);
  4919. if (lpszVerIndProgID != NULL && lstrcmpi(lpszVerIndProgID, _T("")))
  4920. key.RecurseDeleteKey(lpszVerIndProgID);
  4921. LPOLESTR lpOleStr;
  4922. StringFromCLSID(clsid, &lpOleStr);
  4923. LPTSTR lpsz = OLE2T(lpOleStr);
  4924. if (key.Open(key, _T("CLSID"), KEY_READ) == ERROR_SUCCESS)
  4925. key.RecurseDeleteKey(lpsz);
  4926. CoTaskMemFree(lpOleStr);
  4927. return S_OK;
  4928. }
  4929. /////////////////////////////////////////////////////////////////////////////
  4930. // Large Block Allocation Helper - CVBufHelper & CVirtualBuffer
  4931. template <class T>
  4932. class CVBufHelper
  4933. {
  4934. public:
  4935. virtual T* operator()(T* pCurrent) {return pCurrent;}
  4936. };
  4937. template <class T>
  4938. class CVirtualBuffer
  4939. {
  4940. protected:
  4941. CVirtualBuffer() {}
  4942. T* m_pBase;
  4943. T* m_pCurrent;
  4944. T* m_pTop;
  4945. int m_nMaxElements;
  4946. public:
  4947. CVirtualBuffer(int nMaxElements)
  4948. {
  4949. m_nMaxElements = nMaxElements;
  4950. m_pBase = (T*) VirtualAlloc(NULL, sizeof(T) * nMaxElements,
  4951. MEM_RESERVE, PAGE_READWRITE);
  4952. m_pTop = m_pCurrent = m_pBase;
  4953. // Commit first page - chances are this is all that will be used
  4954. VirtualAlloc(m_pBase, sizeof(T), MEM_COMMIT, PAGE_READWRITE);
  4955. }
  4956. ~CVirtualBuffer()
  4957. {
  4958. VirtualFree(m_pBase, 0, MEM_RELEASE);
  4959. }
  4960. #if !defined(_WIN32_WCE)
  4961. int Except(LPEXCEPTION_POINTERS lpEP)
  4962. {
  4963. EXCEPTION_RECORD* pExcept = lpEP->ExceptionRecord;
  4964. if (pExcept->ExceptionCode != EXCEPTION_ACCESS_VIOLATION)
  4965. return EXCEPTION_CONTINUE_SEARCH;
  4966. BYTE* pAddress = (LPBYTE) pExcept->ExceptionInformation[1];
  4967. VirtualAlloc(pAddress, ((BYTE*)m_pTop - (BYTE*)m_pBase), MEM_COMMIT, PAGE_READWRITE);
  4968. return EXCEPTION_CONTINUE_EXECUTION;
  4969. }
  4970. #endif // _WIN32_WCE
  4971. void Seek(int nElement)
  4972. {
  4973. m_pCurrent = &m_pBase[nElement];
  4974. }
  4975. void SetAt(int nElement, const T& Element)
  4976. {
  4977. __try
  4978. {
  4979. T* p = &m_pBase[nElement]
  4980. *p = Element;
  4981. m_pTop = p > m_pTop ? p : m_pTop;
  4982. }
  4983. __except(Except(GetExceptionInformation()))
  4984. {
  4985. }
  4986. }
  4987. template <class Q>
  4988. void WriteBulk(Q& helper)
  4989. {
  4990. __try
  4991. {
  4992. m_pCurrent = helper(m_pBase);
  4993. m_pTop = m_pCurrent > m_pTop ? m_pCurrent : m_pTop;
  4994. }
  4995. __except(Except(GetExceptionInformation()))
  4996. {
  4997. }
  4998. }
  4999. void Write(const T& Element)
  5000. {
  5001. __try
  5002. {
  5003. *m_pCurrent = Element;
  5004. m_pCurrent++;
  5005. m_pTop = m_pCurrent > m_pTop ? m_pCurrent : m_pTop;
  5006. }
  5007. __except(Except(GetExceptionInformation()))
  5008. {
  5009. }
  5010. }
  5011. T& Read()
  5012. {
  5013. return *m_pCurrent;
  5014. }
  5015. operator BSTR()
  5016. {
  5017. BSTR bstrTemp;
  5018. __try
  5019. {
  5020. bstrTemp = SysAllocStringByteLen((char*) m_pBase,
  5021. (UINT) ((BYTE*)m_pTop - (BYTE*)m_pBase));
  5022. }
  5023. __except(Except(GetExceptionInformation()))
  5024. {
  5025. }
  5026. return bstrTemp;
  5027. }
  5028. const T& operator[](int nElement) const
  5029. {
  5030. return m_pBase[nElement];
  5031. }
  5032. operator T*()
  5033. {
  5034. return m_pBase;
  5035. }
  5036. };
  5037. typedef CVirtualBuffer<BYTE> CVirtualBytes;
  5038. inline HRESULT WINAPI AtlDumpIID(REFIID iid, LPCTSTR pszClassName, HRESULT hr)
  5039. {
  5040. if (atlTraceQI & ATL_TRACE_CATEGORY)
  5041. {
  5042. USES_CONVERSION;
  5043. CRegKey key;
  5044. TCHAR szName[100];
  5045. DWORD dwType,dw = sizeof(szName);
  5046. LPOLESTR pszGUID = NULL;
  5047. StringFromCLSID(iid, &pszGUID);
  5048. OutputDebugString(pszClassName);
  5049. OutputDebugString(_T(" - "));
  5050. // Attempt to find it in the interfaces section
  5051. key.Open(HKEY_CLASSES_ROOT, _T("Interface"), KEY_READ);
  5052. if (key.Open(key, OLE2T(pszGUID), KEY_READ) == S_OK)
  5053. {
  5054. *szName = 0;
  5055. RegQueryValueEx(key.m_hKey, (LPTSTR)NULL, NULL, &dwType, (LPBYTE)szName, &dw);
  5056. OutputDebugString(szName);
  5057. goto cleanup;
  5058. }
  5059. // Attempt to find it in the clsid section
  5060. key.Open(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_READ);
  5061. if (key.Open(key, OLE2T(pszGUID), KEY_READ) == S_OK)
  5062. {
  5063. *szName = 0;
  5064. RegQueryValueEx(key.m_hKey, (LPTSTR)NULL, NULL, &dwType, (LPBYTE)szName, &dw);
  5065. OutputDebugString(_T("(CLSID\?\?\?) "));
  5066. OutputDebugString(szName);
  5067. goto cleanup;
  5068. }
  5069. OutputDebugString(OLE2T(pszGUID));
  5070. cleanup:
  5071. if (hr != S_OK)
  5072. OutputDebugString(_T(" - failed"));
  5073. OutputDebugString(_T("\n"));
  5074. CoTaskMemFree(pszGUID);
  5075. }
  5076. return hr;
  5077. }
  5078. #pragma pack(pop)
  5079. // WM_FORWARDMSG - used to forward a message to another window for processing
  5080. // WPARAM - DWORD dwUserData - defined by user
  5081. // LPARAM - LPMSG pMsg - a pointer to the MSG structure
  5082. // return value - 0 if the message was not processed, nonzero if it was
  5083. #define WM_FORWARDMSG 0x037F
  5084. }; //namespace ATL
  5085. using namespace ATL;
  5086. //only suck in definition if static linking
  5087. #ifndef _ATL_DLL_IMPL
  5088. #ifndef _ATL_DLL
  5089. #define _ATLBASE_IMPL
  5090. #endif
  5091. #endif
  5092. #endif // __ATLBASE_H__
  5093. //All exports go here
  5094. #ifdef _ATLBASE_IMPL
  5095. #ifndef _ATL_DLL_IMPL
  5096. namespace ATL
  5097. {
  5098. #endif
  5099. /////////////////////////////////////////////////////////////////////////////
  5100. // statics
  5101. static UINT WINAPI AtlGetDirLen(LPCOLESTR lpszPathName)
  5102. {
  5103. ATLASSERT(lpszPathName != NULL);
  5104. // always capture the complete file name including extension (if present)
  5105. LPCOLESTR lpszTemp = lpszPathName;
  5106. for (LPCOLESTR lpsz = lpszPathName; *lpsz != NULL; )
  5107. {
  5108. LPCOLESTR lp = CharNextO(lpsz);
  5109. // remember last directory/drive separator
  5110. if (*lpsz == OLESTR('\\') || *lpsz == OLESTR('/') || *lpsz == OLESTR(':'))
  5111. lpszTemp = lp;
  5112. lpsz = lp;
  5113. }
  5114. return lpszTemp-lpszPathName;
  5115. }
  5116. /////////////////////////////////////////////////////////////////////////////
  5117. // QI support
  5118. ATLINLINE ATLAPI AtlInternalQueryInterface(void* pThis,
  5119. const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, void** ppvObject)
  5120. {
  5121. ATLASSERT(pThis != NULL);
  5122. // First entry in the com map should be a simple map entry
  5123. ATLASSERT(pEntries->pFunc == _ATL_SIMPLEMAPENTRY);
  5124. if (ppvObject == NULL)
  5125. return E_POINTER;
  5126. *ppvObject = NULL;
  5127. if (InlineIsEqualUnknown(iid)) // use first interface
  5128. {
  5129. IUnknown* pUnk = (IUnknown*)((int)pThis+pEntries->dw);
  5130. pUnk->AddRef();
  5131. *ppvObject = pUnk;
  5132. return S_OK;
  5133. }
  5134. while (pEntries->pFunc != NULL)
  5135. {
  5136. BOOL bBlind = (pEntries->piid == NULL);
  5137. if (bBlind || InlineIsEqualGUID(*(pEntries->piid), iid))
  5138. {
  5139. if (pEntries->pFunc == _ATL_SIMPLEMAPENTRY) //offset
  5140. {
  5141. ATLASSERT(!bBlind);
  5142. IUnknown* pUnk = (IUnknown*)((int)pThis+pEntries->dw);
  5143. pUnk->AddRef();
  5144. *ppvObject = pUnk;
  5145. return S_OK;
  5146. }
  5147. else //actual function call
  5148. {
  5149. HRESULT hRes = pEntries->pFunc(pThis,
  5150. iid, ppvObject, pEntries->dw);
  5151. if (hRes == S_OK || (!bBlind && FAILED(hRes)))
  5152. return hRes;
  5153. }
  5154. }
  5155. pEntries++;
  5156. }
  5157. return E_NOINTERFACE;
  5158. }
  5159. /////////////////////////////////////////////////////////////////////////////
  5160. // Smart Pointer helpers
  5161. ATLINLINE ATLAPI_(IUnknown*) AtlComPtrAssign(IUnknown** pp, IUnknown* lp)
  5162. {
  5163. if (lp != NULL)
  5164. lp->AddRef();
  5165. if (*pp)
  5166. (*pp)->Release();
  5167. *pp = lp;
  5168. return lp;
  5169. }
  5170. ATLINLINE ATLAPI_(IUnknown*) AtlComQIPtrAssign(IUnknown** pp, IUnknown* lp, REFIID riid)
  5171. {
  5172. IUnknown* pTemp = *pp;
  5173. *pp = NULL;
  5174. if (lp != NULL)
  5175. lp->QueryInterface(riid, (void**)pp);
  5176. if (pTemp)
  5177. pTemp->Release();
  5178. return *pp;
  5179. }
  5180. #if !defined(_WIN32_WCE)
  5181. /////////////////////////////////////////////////////////////////////////////
  5182. // Inproc Marshaling helpers
  5183. //This API should be called from the same thread that called
  5184. //AtlMarshalPtrInProc
  5185. ATLINLINE ATLAPI AtlFreeMarshalStream(IStream* pStream)
  5186. {
  5187. if (pStream != NULL)
  5188. {
  5189. LARGE_INTEGER l;
  5190. l.QuadPart = 0;
  5191. pStream->Seek(l, STREAM_SEEK_SET, NULL);
  5192. CoReleaseMarshalData(pStream);
  5193. pStream->Release();
  5194. }
  5195. return S_OK;
  5196. }
  5197. ATLINLINE ATLAPI AtlMarshalPtrInProc(IUnknown* pUnk, const IID& iid, IStream** ppStream)
  5198. {
  5199. HRESULT hRes = CreateStreamOnHGlobal(NULL, TRUE, ppStream);
  5200. if (SUCCEEDED(hRes))
  5201. {
  5202. hRes = CoMarshalInterface(*ppStream, iid,
  5203. pUnk, MSHCTX_INPROC, NULL, MSHLFLAGS_TABLESTRONG);
  5204. if (FAILED(hRes))
  5205. {
  5206. (*ppStream)->Release();
  5207. *ppStream = NULL;
  5208. }
  5209. }
  5210. return hRes;
  5211. }
  5212. ATLINLINE ATLAPI AtlUnmarshalPtr(IStream* pStream, const IID& iid, IUnknown** ppUnk)
  5213. {
  5214. *ppUnk = NULL;
  5215. HRESULT hRes = E_INVALIDARG;
  5216. if (pStream != NULL)
  5217. {
  5218. LARGE_INTEGER l;
  5219. l.QuadPart = 0;
  5220. pStream->Seek(l, STREAM_SEEK_SET, NULL);
  5221. hRes = CoUnmarshalInterface(pStream, iid, (void**)ppUnk);
  5222. }
  5223. return hRes;
  5224. }
  5225. ATLINLINE ATLAPI_(BOOL) AtlWaitWithMessageLoop(HANDLE hEvent)
  5226. {
  5227. DWORD dwRet;
  5228. MSG msg;
  5229. while(1)
  5230. {
  5231. dwRet = MsgWaitForMultipleObjects(1, &hEvent, FALSE, INFINITE, QS_ALLINPUT);
  5232. if (dwRet == WAIT_OBJECT_0)
  5233. return TRUE; // The event was signaled
  5234. if (dwRet != WAIT_OBJECT_0 + 1)
  5235. break; // Something else happened
  5236. // There is one or more window message available. Dispatch them
  5237. while(PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE))
  5238. {
  5239. TranslateMessage(&msg);
  5240. DispatchMessage(&msg);
  5241. if (WaitForSingleObject(hEvent, 0) == WAIT_OBJECT_0)
  5242. return TRUE; // Event is now signaled.
  5243. }
  5244. }
  5245. return FALSE;
  5246. }
  5247. #endif // _WIN32_WCE
  5248. /////////////////////////////////////////////////////////////////////////////
  5249. // Connection Point Helpers
  5250. ATLINLINE ATLAPI AtlAdvise(IUnknown* pUnkCP, IUnknown* pUnk, const IID& iid, LPDWORD pdw)
  5251. {
  5252. CComPtr<IConnectionPointContainer> pCPC;
  5253. CComPtr<IConnectionPoint> pCP;
  5254. HRESULT hRes = pUnkCP->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPC);
  5255. if (SUCCEEDED(hRes))
  5256. hRes = pCPC->FindConnectionPoint(iid, &pCP);
  5257. if (SUCCEEDED(hRes))
  5258. hRes = pCP->Advise(pUnk, pdw);
  5259. return hRes;
  5260. }
  5261. ATLINLINE ATLAPI AtlUnadvise(IUnknown* pUnkCP, const IID& iid, DWORD dw)
  5262. {
  5263. CComPtr<IConnectionPointContainer> pCPC;
  5264. CComPtr<IConnectionPoint> pCP;
  5265. HRESULT hRes = pUnkCP->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPC);
  5266. if (SUCCEEDED(hRes))
  5267. hRes = pCPC->FindConnectionPoint(iid, &pCP);
  5268. if (SUCCEEDED(hRes))
  5269. hRes = pCP->Unadvise(dw);
  5270. return hRes;
  5271. }
  5272. /////////////////////////////////////////////////////////////////////////////
  5273. // IDispatch Error handling
  5274. ATLINLINE ATLAPI AtlSetErrorInfo(const CLSID& clsid, LPCOLESTR lpszDesc, DWORD dwHelpID,
  5275. LPCOLESTR lpszHelpFile, const IID& iid, HRESULT hRes, HINSTANCE hInst)
  5276. {
  5277. USES_CONVERSION;
  5278. TCHAR szDesc[1024];
  5279. szDesc[0] = NULL;
  5280. // For a valid HRESULT the id should be in the range [0x0200, 0xffff]
  5281. if (HIWORD(lpszDesc) == 0) //id
  5282. {
  5283. UINT nID = LOWORD((DWORD)lpszDesc);
  5284. ATLASSERT((nID >= 0x0200 && nID <= 0xffff) || hRes != 0);
  5285. if (LoadString(hInst, nID, szDesc, 1024) == 0)
  5286. {
  5287. ATLASSERT(FALSE);
  5288. lstrcpy(szDesc, _T("Unknown Error"));
  5289. }
  5290. lpszDesc = T2OLE(szDesc);
  5291. if (hRes == 0)
  5292. hRes = MAKE_HRESULT(3, FACILITY_ITF, nID);
  5293. }
  5294. CComPtr<ICreateErrorInfo> pICEI;
  5295. if (SUCCEEDED(CreateErrorInfo(&pICEI)))
  5296. {
  5297. CComPtr<IErrorInfo> pErrorInfo;
  5298. pICEI->SetGUID(iid);
  5299. LPOLESTR lpsz;
  5300. WCE_FCTN(ProgIDFromCLSID)(clsid, &lpsz);
  5301. if (lpsz != NULL)
  5302. pICEI->SetSource(lpsz);
  5303. if (dwHelpID != 0 && lpszHelpFile != NULL)
  5304. {
  5305. pICEI->SetHelpContext(dwHelpID);
  5306. pICEI->SetHelpFile(const_cast<LPOLESTR>(lpszHelpFile));
  5307. }
  5308. CoTaskMemFree(lpsz);
  5309. pICEI->SetDescription((LPOLESTR)lpszDesc);
  5310. if (SUCCEEDED(pICEI->QueryInterface(IID_IErrorInfo, (void**)&pErrorInfo)))
  5311. SetErrorInfo(0, pErrorInfo);
  5312. }
  5313. return (hRes == 0) ? DISP_E_EXCEPTION : hRes;
  5314. }
  5315. /////////////////////////////////////////////////////////////////////////////
  5316. // Module
  5317. struct _ATL_MODULE20
  5318. {
  5319. // Attributes
  5320. public:
  5321. UINT cbSize;
  5322. HINSTANCE m_hInst;
  5323. HINSTANCE m_hInstResource;
  5324. HINSTANCE m_hInstTypeLib;
  5325. _ATL_OBJMAP_ENTRY* m_pObjMap;
  5326. LONG m_nLockCnt;
  5327. HANDLE m_hHeap;
  5328. CRITICAL_SECTION m_csTypeInfoHolder;
  5329. CRITICAL_SECTION m_csWindowCreate;
  5330. CRITICAL_SECTION m_csObjMap;
  5331. };
  5332. typedef _ATL_MODULE _ATL_MODULE30;
  5333. struct _ATL_OBJMAP_ENTRY20
  5334. {
  5335. const CLSID* pclsid;
  5336. HRESULT (WINAPI *pfnUpdateRegistry)(BOOL bRegister);
  5337. _ATL_CREATORFUNC* pfnGetClassObject;
  5338. _ATL_CREATORFUNC* pfnCreateInstance;
  5339. IUnknown* pCF;
  5340. DWORD dwRegister;
  5341. _ATL_DESCRIPTIONFUNC* pfnGetObjectDescription;
  5342. };
  5343. typedef _ATL_OBJMAP_ENTRY _ATL_OBJMAP_ENTRY30;
  5344. inline _ATL_OBJMAP_ENTRY* _NextObjectMapEntry(_ATL_MODULE* pM, _ATL_OBJMAP_ENTRY* pEntry)
  5345. {
  5346. if (pM->cbSize == sizeof(_ATL_MODULE20))
  5347. return (_ATL_OBJMAP_ENTRY*)(((BYTE*)pEntry) + sizeof(_ATL_OBJMAP_ENTRY20));
  5348. return pEntry+1;
  5349. }
  5350. //Although these functions are big, they are only used once in a module
  5351. //so we should make them inline.
  5352. ATLINLINE ATLAPI AtlModuleInit(_ATL_MODULE* pM, _ATL_OBJMAP_ENTRY* p, HINSTANCE h)
  5353. {
  5354. ATLASSERT(pM != NULL);
  5355. if (pM == NULL)
  5356. return E_INVALIDARG;
  5357. #ifdef _ATL_DLL_IMPL
  5358. if ((pM->cbSize != _nAtlModuleVer1Size) && (pM->cbSize != sizeof(_ATL_MODULE)))
  5359. return E_INVALIDARG;
  5360. #else
  5361. ATLASSERT(pM->cbSize == sizeof(_ATL_MODULE));
  5362. #endif
  5363. pM->m_pObjMap = p;
  5364. pM->m_hInst = pM->m_hInstTypeLib = pM->m_hInstResource = h;
  5365. pM->m_nLockCnt=0L;
  5366. pM->m_hHeap = NULL;
  5367. InitializeCriticalSection(&pM->m_csTypeInfoHolder);
  5368. InitializeCriticalSection(&pM->m_csWindowCreate);
  5369. InitializeCriticalSection(&pM->m_csObjMap);
  5370. #ifdef _ATL_DLL_IMPL
  5371. if (pM->cbSize > _nAtlModuleVer1Size)
  5372. #endif
  5373. {
  5374. pM->m_pCreateWndList = NULL;
  5375. pM->m_bDestroyHeap = true;
  5376. pM->m_dwHeaps = 0;
  5377. pM->m_nHeap = 0;
  5378. pM->m_phHeaps = NULL;
  5379. pM->m_pTermFuncs = NULL;
  5380. if (pM->m_pObjMap != NULL)
  5381. {
  5382. _ATL_OBJMAP_ENTRY* pEntry = pM->m_pObjMap;
  5383. while (pEntry->pclsid != NULL)
  5384. {
  5385. pEntry->pfnObjectMain(true); //initialize class resources
  5386. pEntry = _NextObjectMapEntry(pM, pEntry);
  5387. }
  5388. }
  5389. }
  5390. return S_OK;
  5391. }
  5392. #if !defined(_WIN32_WCE)
  5393. ATLINLINE ATLAPI AtlModuleRegisterClassObjects(_ATL_MODULE* pM, DWORD dwClsContext, DWORD dwFlags)
  5394. {
  5395. ATLASSERT(pM != NULL);
  5396. if (pM == NULL)
  5397. return E_INVALIDARG;
  5398. ATLASSERT(pM->m_pObjMap != NULL);
  5399. _ATL_OBJMAP_ENTRY* pEntry = pM->m_pObjMap;
  5400. HRESULT hRes = S_OK;
  5401. while (pEntry->pclsid != NULL && hRes == S_OK)
  5402. {
  5403. hRes = pEntry->RegisterClassObject(dwClsContext, dwFlags);
  5404. pEntry = _NextObjectMapEntry(pM, pEntry);
  5405. }
  5406. return hRes;
  5407. }
  5408. ATLINLINE ATLAPI AtlModuleRevokeClassObjects(_ATL_MODULE* pM)
  5409. {
  5410. ATLASSERT(pM != NULL);
  5411. if (pM == NULL)
  5412. return E_INVALIDARG;
  5413. ATLASSERT(pM->m_pObjMap != NULL);
  5414. _ATL_OBJMAP_ENTRY* pEntry = pM->m_pObjMap;
  5415. HRESULT hRes = S_OK;
  5416. while (pEntry->pclsid != NULL && hRes == S_OK)
  5417. {
  5418. hRes = pEntry->RevokeClassObject();
  5419. pEntry = _NextObjectMapEntry(pM, pEntry);
  5420. }
  5421. return hRes;
  5422. }
  5423. #endif // _WIN32_WCE
  5424. ATLINLINE ATLAPI AtlModuleGetClassObject(_ATL_MODULE* pM, REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  5425. {
  5426. ATLASSERT(pM != NULL);
  5427. if (pM == NULL)
  5428. return E_INVALIDARG;
  5429. ATLASSERT(pM->m_pObjMap != NULL);
  5430. _ATL_OBJMAP_ENTRY* pEntry = pM->m_pObjMap;
  5431. HRESULT hRes = S_OK;
  5432. if (ppv == NULL)
  5433. return E_POINTER;
  5434. *ppv = NULL;
  5435. while (pEntry->pclsid != NULL)
  5436. {
  5437. if ((pEntry->pfnGetClassObject != NULL) && InlineIsEqualGUID(rclsid, *pEntry->pclsid))
  5438. {
  5439. if (pEntry->pCF == NULL)
  5440. {
  5441. EnterCriticalSection(&pM->m_csObjMap);
  5442. if (pEntry->pCF == NULL)
  5443. hRes = pEntry->pfnGetClassObject(pEntry->pfnCreateInstance, IID_IUnknown, (LPVOID*)&pEntry->pCF);
  5444. LeaveCriticalSection(&pM->m_csObjMap);
  5445. }
  5446. if (pEntry->pCF != NULL)
  5447. hRes = pEntry->pCF->QueryInterface(riid, ppv);
  5448. break;
  5449. }
  5450. pEntry = _NextObjectMapEntry(pM, pEntry);
  5451. }
  5452. if (*ppv == NULL && hRes == S_OK)
  5453. hRes = CLASS_E_CLASSNOTAVAILABLE;
  5454. return hRes;
  5455. }
  5456. ATLINLINE ATLAPI AtlModuleTerm(_ATL_MODULE* pM)
  5457. {
  5458. ATLASSERT(pM != NULL);
  5459. if (pM == NULL)
  5460. return E_INVALIDARG;
  5461. ATLASSERT(pM->m_hInst != NULL);
  5462. if (pM->m_pObjMap != NULL)
  5463. {
  5464. _ATL_OBJMAP_ENTRY* pEntry = pM->m_pObjMap;
  5465. while (pEntry->pclsid != NULL)
  5466. {
  5467. if (pEntry->pCF != NULL)
  5468. pEntry->pCF->Release();
  5469. pEntry->pCF = NULL;
  5470. #ifdef _ATL_DLL_IMPL
  5471. if (pM->cbSize > _nAtlModuleVer1Size)
  5472. #endif
  5473. pEntry->pfnObjectMain(false); //cleanup class resources
  5474. pEntry = _NextObjectMapEntry(pM, pEntry);
  5475. }
  5476. }
  5477. DeleteCriticalSection(&pM->m_csTypeInfoHolder);
  5478. DeleteCriticalSection(&pM->m_csWindowCreate);
  5479. DeleteCriticalSection(&pM->m_csObjMap);
  5480. #ifdef _ATL_DLL_IMPL
  5481. if (pM->cbSize > _nAtlModuleVer1Size)
  5482. #endif
  5483. {
  5484. _ATL_TERMFUNC_ELEM* pElem = pM->m_pTermFuncs;
  5485. _ATL_TERMFUNC_ELEM* pNext = NULL;
  5486. while (pElem != NULL)
  5487. {
  5488. pElem->pFunc(pElem->dw);
  5489. pNext = pElem->pNext;
  5490. delete pElem;
  5491. pElem = pNext;
  5492. }
  5493. if (pM->m_hHeap != NULL && pM->m_bDestroyHeap)
  5494. {
  5495. #ifndef _ATL_NO_MP_HEAP
  5496. if (pM->m_phHeaps != NULL)
  5497. {
  5498. for (DWORD i=0; i<=pM->m_dwHeaps; i++)
  5499. HeapDestroy(pM->m_phHeaps[i]);
  5500. }
  5501. #endif
  5502. HeapDestroy(pM->m_hHeap);
  5503. }
  5504. }
  5505. return S_OK;
  5506. }
  5507. ATLINLINE ATLAPI AtlModuleAddTermFunc(_ATL_MODULE* pM, _ATL_TERMFUNC* pFunc, DWORD dw)
  5508. {
  5509. HRESULT hr = S_OK;
  5510. _ATL_TERMFUNC_ELEM* pNew = NULL;
  5511. ATLTRY(pNew = new _ATL_TERMFUNC_ELEM);
  5512. if (pNew == NULL)
  5513. hr = E_OUTOFMEMORY;
  5514. else
  5515. {
  5516. pNew->pFunc = pFunc;
  5517. pNew->dw = dw;
  5518. EnterCriticalSection(&pM->m_csStaticDataInit);
  5519. pNew->pNext = pM->m_pTermFuncs;
  5520. pM->m_pTermFuncs = pNew;
  5521. LeaveCriticalSection(&pM->m_csStaticDataInit);
  5522. }
  5523. return hr;
  5524. }
  5525. #if !defined(_WIN32_WCE)
  5526. ATLINLINE ATLAPI AtlRegisterClassCategoriesHelper( REFCLSID clsid,
  5527. const struct _ATL_CATMAP_ENTRY* pCatMap, BOOL bRegister )
  5528. {
  5529. CComPtr< ICatRegister > pCatRegister;
  5530. HRESULT hResult;
  5531. const struct _ATL_CATMAP_ENTRY* pEntry;
  5532. CATID catid;
  5533. if( pCatMap == NULL )
  5534. {
  5535. return( S_OK );
  5536. }
  5537. hResult = CoCreateInstance( CLSID_StdComponentCategoriesMgr, NULL,
  5538. CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pCatRegister );
  5539. if( FAILED( hResult ) )
  5540. {
  5541. // Since not all systems have the category manager installed, we'll allow
  5542. // the registration to succeed even though we didn't register our
  5543. // categories. If you really want to register categories on a system
  5544. // without the category manager, you can either manually add the
  5545. // appropriate entries to your registry script (.rgs), or you can
  5546. // redistribute comcat.dll.
  5547. return( S_OK );
  5548. }
  5549. hResult = S_OK;
  5550. pEntry = pCatMap;
  5551. while( pEntry->iType != _ATL_CATMAP_ENTRY_END )
  5552. {
  5553. catid = *pEntry->pcatid;
  5554. if( bRegister )
  5555. {
  5556. if( pEntry->iType == _ATL_CATMAP_ENTRY_IMPLEMENTED )
  5557. {
  5558. hResult = pCatRegister->RegisterClassImplCategories( clsid, 1,
  5559. &catid );
  5560. }
  5561. else
  5562. {
  5563. ATLASSERT( pEntry->iType == _ATL_CATMAP_ENTRY_REQUIRED );
  5564. hResult = pCatRegister->RegisterClassReqCategories( clsid, 1,
  5565. &catid );
  5566. }
  5567. if( FAILED( hResult ) )
  5568. {
  5569. return( hResult );
  5570. }
  5571. }
  5572. else
  5573. {
  5574. if( pEntry->iType == _ATL_CATMAP_ENTRY_IMPLEMENTED )
  5575. {
  5576. pCatRegister->UnRegisterClassImplCategories( clsid, 1, &catid );
  5577. }
  5578. else
  5579. {
  5580. ATLASSERT( pEntry->iType == _ATL_CATMAP_ENTRY_REQUIRED );
  5581. pCatRegister->UnRegisterClassReqCategories( clsid, 1, &catid );
  5582. }
  5583. }
  5584. pEntry++;
  5585. }
  5586. return( S_OK );
  5587. }
  5588. #endif // _WIN32_WCE
  5589. ATLINLINE ATLAPI AtlModuleRegisterServer(_ATL_MODULE* pM, BOOL bRegTypeLib, const CLSID* pCLSID)
  5590. {
  5591. ATLASSERT(pM != NULL);
  5592. if (pM == NULL)
  5593. return E_INVALIDARG;
  5594. ATLASSERT(pM->m_hInst != NULL);
  5595. ATLASSERT(pM->m_pObjMap != NULL);
  5596. _ATL_OBJMAP_ENTRY* pEntry = pM->m_pObjMap;
  5597. HRESULT hRes = S_OK;
  5598. for (;pEntry->pclsid != NULL; pEntry = _NextObjectMapEntry(pM, pEntry))
  5599. {
  5600. if (pCLSID == NULL)
  5601. {
  5602. if (pEntry->pfnGetObjectDescription != NULL &&
  5603. pEntry->pfnGetObjectDescription() != NULL)
  5604. continue;
  5605. }
  5606. else
  5607. {
  5608. if (!IsEqualGUID(*pCLSID, *pEntry->pclsid))
  5609. continue;
  5610. }
  5611. hRes = pEntry->pfnUpdateRegistry(TRUE);
  5612. if (FAILED(hRes))
  5613. break;
  5614. #if !defined(_WIN32_WCE)
  5615. if (pM->cbSize == sizeof(_ATL_MODULE))
  5616. {
  5617. hRes = AtlRegisterClassCategoriesHelper( *pEntry->pclsid,
  5618. pEntry->pfnGetCategoryMap(), TRUE );
  5619. if (FAILED(hRes))
  5620. break;
  5621. }
  5622. #endif // _WIN32_WCE
  5623. }
  5624. if (SUCCEEDED(hRes) && bRegTypeLib)
  5625. hRes = AtlModuleRegisterTypeLib(pM, 0);
  5626. return hRes;
  5627. }
  5628. ATLINLINE ATLAPI AtlModuleUnregisterServerEx(_ATL_MODULE* pM, BOOL bUnRegTypeLib, const CLSID* pCLSID)
  5629. {
  5630. ATLASSERT(pM != NULL);
  5631. if (pM == NULL)
  5632. return E_INVALIDARG;
  5633. ATLASSERT(pM->m_hInst != NULL);
  5634. ATLASSERT(pM->m_pObjMap != NULL);
  5635. _ATL_OBJMAP_ENTRY* pEntry = pM->m_pObjMap;
  5636. for (;pEntry->pclsid != NULL; pEntry = _NextObjectMapEntry(pM, pEntry))
  5637. {
  5638. if (pCLSID == NULL)
  5639. {
  5640. if (pEntry->pfnGetObjectDescription != NULL
  5641. && pEntry->pfnGetObjectDescription() != NULL)
  5642. continue;
  5643. }
  5644. else
  5645. {
  5646. if (!IsEqualGUID(*pCLSID, *pEntry->pclsid))
  5647. continue;
  5648. }
  5649. pEntry->pfnUpdateRegistry(FALSE); //unregister
  5650. #if !defined(_WIN32_WCE)
  5651. AtlRegisterClassCategoriesHelper( *pEntry->pclsid,
  5652. pEntry->pfnGetCategoryMap(), FALSE );
  5653. #endif // _WIN32_WCE
  5654. }
  5655. if (bUnRegTypeLib)
  5656. AtlModuleUnRegisterTypeLib(pM, 0);
  5657. return S_OK;
  5658. }
  5659. ATLINLINE ATLAPI AtlModuleUnregisterServer(_ATL_MODULE* pM, const CLSID* pCLSID)
  5660. {
  5661. return AtlModuleUnregisterServerEx(pM, FALSE, pCLSID);
  5662. }
  5663. ATLINLINE ATLAPI AtlModuleUpdateRegistryFromResourceD(_ATL_MODULE* pM, LPCOLESTR lpszRes,
  5664. BOOL bRegister, struct _ATL_REGMAP_ENTRY* pMapEntries, IRegistrar* pReg)
  5665. {
  5666. USES_CONVERSION;
  5667. ATLASSERT(pM != NULL);
  5668. HRESULT hRes = S_OK;
  5669. CComPtr<IRegistrar> p;
  5670. if (pReg != NULL)
  5671. p = pReg;
  5672. else
  5673. {
  5674. hRes = CoCreateInstance(CLSID_Registrar, NULL,
  5675. CLSCTX_INPROC_SERVER, IID_IRegistrar, (void**)&p);
  5676. }
  5677. if (SUCCEEDED(hRes))
  5678. {
  5679. TCHAR szModule[_MAX_PATH];
  5680. GetModuleFileName(pM->m_hInst, szModule, _MAX_PATH);
  5681. // Convert to short path to work around bug in NT4's CreateProcess
  5682. WCE_DEL TCHAR szModuleShort[_MAX_PATH];
  5683. WCE_DEL GetShortPathName(szModule, szModuleShort, _MAX_PATH);
  5684. LPOLESTR pszModule = T2OLE(WCE_IF(szModule,szModuleShort));
  5685. int nLen = ocslen(pszModule);
  5686. LPOLESTR pszModuleQuote = (LPOLESTR)alloca((nLen*2+1)*sizeof(OLECHAR));
  5687. CComModule::ReplaceSingleQuote(pszModuleQuote, pszModule);
  5688. p->AddReplacement(OLESTR("Module"), pszModuleQuote);
  5689. if (NULL != pMapEntries)
  5690. {
  5691. while (NULL != pMapEntries->szKey)
  5692. {
  5693. ATLASSERT(NULL != pMapEntries->szData);
  5694. p->AddReplacement((LPOLESTR)pMapEntries->szKey, (LPOLESTR)pMapEntries->szData);
  5695. pMapEntries++;
  5696. }
  5697. }
  5698. LPCOLESTR szType = OLESTR("REGISTRY");
  5699. if (HIWORD(lpszRes)==0)
  5700. {
  5701. if (bRegister)
  5702. hRes = p->ResourceRegister(pszModule, ((UINT)LOWORD((DWORD)lpszRes)), szType);
  5703. else
  5704. hRes = p->ResourceUnregister(pszModule, ((UINT)LOWORD((DWORD)lpszRes)), szType);
  5705. }
  5706. else
  5707. {
  5708. if (bRegister)
  5709. hRes = p->ResourceRegisterSz(pszModule, lpszRes, szType);
  5710. else
  5711. hRes = p->ResourceUnregisterSz(pszModule, lpszRes, szType);
  5712. }
  5713. }
  5714. return hRes;
  5715. }
  5716. /////////////////////////////////////////////////////////////////////////////
  5717. // TypeLib Support
  5718. ATLINLINE ATLAPI AtlModuleLoadTypeLib(_ATL_MODULE* pM, LPCOLESTR lpszIndex, BSTR* pbstrPath, ITypeLib** ppTypeLib)
  5719. {
  5720. *pbstrPath = NULL;
  5721. *ppTypeLib = NULL;
  5722. ATLASSERT(pM != NULL);
  5723. USES_CONVERSION;
  5724. ATLASSERT(pM->m_hInstTypeLib != NULL);
  5725. TCHAR szModule[_MAX_PATH+10];
  5726. GetModuleFileName(pM->m_hInstTypeLib, szModule, _MAX_PATH);
  5727. if (lpszIndex != NULL)
  5728. lstrcat(szModule, OLE2CT(lpszIndex));
  5729. LPOLESTR lpszModule = T2OLE(szModule);
  5730. HRESULT hr = LoadTypeLib(lpszModule, ppTypeLib);
  5731. if (!SUCCEEDED(hr))
  5732. {
  5733. // typelib not in module, try <module>.tlb instead
  5734. LPTSTR lpszExt = NULL;
  5735. LPTSTR lpsz;
  5736. for (lpsz = szModule; *lpsz != NULL; lpsz = CharNext(lpsz))
  5737. {
  5738. if (*lpsz == _T('.'))
  5739. lpszExt = lpsz;
  5740. }
  5741. if (lpszExt == NULL)
  5742. lpszExt = lpsz;
  5743. lstrcpy(lpszExt, _T(".tlb"));
  5744. lpszModule = T2OLE(szModule);
  5745. hr = LoadTypeLib(lpszModule, ppTypeLib);
  5746. }
  5747. if (SUCCEEDED(hr))
  5748. *pbstrPath = OLE2BSTR(lpszModule);
  5749. return hr;
  5750. }
  5751. ATLINLINE ATLAPI AtlModuleUnRegisterTypeLib(_ATL_MODULE* pM, LPCOLESTR lpszIndex)
  5752. {
  5753. typedef HRESULT (WINAPI *PFNRTL)(REFGUID, WORD, WORD, LCID, SYSKIND);
  5754. CComBSTR bstrPath;
  5755. CComPtr<ITypeLib> pTypeLib;
  5756. HRESULT hr = AtlModuleLoadTypeLib(pM, lpszIndex, &bstrPath, &pTypeLib);
  5757. if (SUCCEEDED(hr))
  5758. {
  5759. TLIBATTR* ptla;
  5760. HRESULT hr = pTypeLib->GetLibAttr(&ptla);
  5761. if (SUCCEEDED(hr))
  5762. {
  5763. HINSTANCE h = LoadLibrary(_T("oleaut32.dll"));
  5764. if (h != NULL)
  5765. {
  5766. PFNRTL pfn = (PFNRTL) GetProcAddress(h, WCE_IF(_T("UnRegisterTypeLib"),"UnRegisterTypeLib"));
  5767. if (pfn != NULL)
  5768. hr = pfn(ptla->guid, ptla->wMajorVerNum, ptla->wMinorVerNum, ptla->lcid, ptla->syskind);
  5769. FreeLibrary(h);
  5770. }
  5771. pTypeLib->ReleaseTLibAttr(ptla);
  5772. }
  5773. }
  5774. return hr;
  5775. }
  5776. ATLINLINE ATLAPI AtlModuleRegisterTypeLib(_ATL_MODULE* pM, LPCOLESTR lpszIndex)
  5777. {
  5778. CComBSTR bstrPath;
  5779. CComPtr<ITypeLib> pTypeLib;
  5780. HRESULT hr = AtlModuleLoadTypeLib(pM, lpszIndex, &bstrPath, &pTypeLib);
  5781. if (SUCCEEDED(hr))
  5782. {
  5783. OLECHAR szDir[_MAX_PATH];
  5784. ocscpy(szDir, bstrPath);
  5785. szDir[AtlGetDirLen(szDir)] = 0;
  5786. hr = ::RegisterTypeLib(pTypeLib, bstrPath, szDir);
  5787. }
  5788. return hr;
  5789. }
  5790. ATLINLINE ATLAPI_(DWORD) AtlGetVersion(void* /* pReserved */)
  5791. {
  5792. return _ATL_VER;
  5793. }
  5794. ATLINLINE ATLAPI_(void) AtlModuleAddCreateWndData(_ATL_MODULE* pM, _AtlCreateWndData* pData, void* pObject)
  5795. {
  5796. pData->m_pThis = pObject;
  5797. pData->m_dwThreadID = ::GetCurrentThreadId();
  5798. ::EnterCriticalSection(&pM->m_csWindowCreate);
  5799. pData->m_pNext = pM->m_pCreateWndList;
  5800. pM->m_pCreateWndList = pData;
  5801. ::LeaveCriticalSection(&pM->m_csWindowCreate);
  5802. }
  5803. ATLINLINE ATLAPI_(void*) AtlModuleExtractCreateWndData(_ATL_MODULE* pM)
  5804. {
  5805. void* pv = NULL;
  5806. ::EnterCriticalSection(&pM->m_csWindowCreate);
  5807. _AtlCreateWndData* pEntry = pM->m_pCreateWndList;
  5808. if(pEntry != NULL)
  5809. {
  5810. DWORD dwThreadID = ::GetCurrentThreadId();
  5811. _AtlCreateWndData* pPrev = NULL;
  5812. while(pEntry != NULL)
  5813. {
  5814. if(pEntry->m_dwThreadID == dwThreadID)
  5815. {
  5816. if(pPrev == NULL)
  5817. pM->m_pCreateWndList = pEntry->m_pNext;
  5818. else
  5819. pPrev->m_pNext = pEntry->m_pNext;
  5820. pv = pEntry->m_pThis;
  5821. break;
  5822. }
  5823. pPrev = pEntry;
  5824. pEntry = pEntry->m_pNext;
  5825. }
  5826. }
  5827. ::LeaveCriticalSection(&pM->m_csWindowCreate);
  5828. return pv;
  5829. }
  5830. #if !defined(_WIN32_WCE)
  5831. /////////////////////////////////////////////////////////////////////////////
  5832. // General DLL Version Helpers
  5833. inline HRESULT AtlGetDllVersion(HINSTANCE hInstDLL, DLLVERSIONINFO* pDllVersionInfo)
  5834. {
  5835. ATLASSERT(pDllVersionInfo != NULL);
  5836. if(::IsBadWritePtr(pDllVersionInfo, sizeof(DWORD)))
  5837. return E_INVALIDARG;
  5838. // We must get this function explicitly because some DLLs don't implement it.
  5839. DLLGETVERSIONPROC pfnDllGetVersion = (DLLGETVERSIONPROC)::GetProcAddress(hInstDLL, "DllGetVersion");
  5840. if(pfnDllGetVersion == NULL)
  5841. return E_NOTIMPL;
  5842. return (*pfnDllGetVersion)(pDllVersionInfo);
  5843. }
  5844. inline HRESULT AtlGetDllVersion(LPCTSTR lpstrDllName, DLLVERSIONINFO* pDllVersionInfo)
  5845. {
  5846. HINSTANCE hInstDLL = ::LoadLibrary(lpstrDllName);
  5847. if(hInstDLL == NULL)
  5848. return E_FAIL;
  5849. HRESULT hRet = AtlGetDllVersion(hInstDLL, pDllVersionInfo);
  5850. ::FreeLibrary(hInstDLL);
  5851. return hRet;
  5852. }
  5853. // Common Control Versions:
  5854. // Win95/WinNT 4.0 maj=4 min=00
  5855. // IE 3.x maj=4 min=70
  5856. // IE 4.0 maj=4 min=71
  5857. inline HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor)
  5858. {
  5859. ATLASSERT(pdwMajor != NULL && pdwMinor != NULL);
  5860. if(::IsBadWritePtr(pdwMajor, sizeof(DWORD)) || ::IsBadWritePtr(pdwMinor, sizeof(DWORD)))
  5861. return E_INVALIDARG;
  5862. DLLVERSIONINFO dvi;
  5863. ::ZeroMemory(&dvi, sizeof(dvi));
  5864. dvi.cbSize = sizeof(dvi);
  5865. HRESULT hRet = AtlGetDllVersion(_T("comctl32.dll"), &dvi);
  5866. if(SUCCEEDED(hRet))
  5867. {
  5868. *pdwMajor = dvi.dwMajorVersion;
  5869. *pdwMinor = dvi.dwMinorVersion;
  5870. }
  5871. else if(hRet == E_NOTIMPL)
  5872. {
  5873. // If DllGetVersion is not there, then the DLL is a version
  5874. // previous to the one shipped with IE 3.x
  5875. *pdwMajor = 4;
  5876. *pdwMinor = 0;
  5877. hRet = S_OK;
  5878. }
  5879. return hRet;
  5880. }
  5881. // Shell Versions:
  5882. // Win95/WinNT 4.0 maj=4 min=00
  5883. // IE 3.x, IE 4.0 without Web Integrated Desktop maj=4 min=00
  5884. // IE 4.0 with Web Integrated Desktop maj=4 min=71
  5885. // IE 4.01 with Web Integrated Desktop maj=4 min=72
  5886. inline HRESULT AtlGetShellVersion(LPDWORD pdwMajor, LPDWORD pdwMinor)
  5887. {
  5888. ATLASSERT(pdwMajor != NULL && pdwMinor != NULL);
  5889. if(::IsBadWritePtr(pdwMajor, sizeof(DWORD)) || ::IsBadWritePtr(pdwMinor, sizeof(DWORD)))
  5890. return E_INVALIDARG;
  5891. DLLVERSIONINFO dvi;
  5892. ::ZeroMemory(&dvi, sizeof(dvi));
  5893. dvi.cbSize = sizeof(dvi);
  5894. HRESULT hRet = AtlGetDllVersion(_T("shell32.dll"), &dvi);
  5895. if(SUCCEEDED(hRet))
  5896. {
  5897. *pdwMajor = dvi.dwMajorVersion;
  5898. *pdwMinor = dvi.dwMinorVersion;
  5899. }
  5900. else if(hRet == E_NOTIMPL)
  5901. {
  5902. // If DllGetVersion is not there, then the DLL is a version
  5903. // previous to the one shipped with IE 4.x
  5904. *pdwMajor = 4;
  5905. *pdwMinor = 0;
  5906. hRet = S_OK;
  5907. }
  5908. return hRet;
  5909. }
  5910. #endif // _WIN32_WCE
  5911. #ifndef _ATL_DLL_IMPL
  5912. }; //namespace ATL
  5913. #endif
  5914. //Prevent pulling in second time
  5915. #undef _ATLBASE_IMPL
  5916. #endif // _ATLBASE_IMPL
  5917. /////////////////////////////////////////////////////////////////////////////