ReactOS 0.4.16-dev-197-g92996da
atlbase.h
Go to the documentation of this file.
1/*
2 * ReactOS ATL
3 *
4 * Copyright 2009 Andrew Hill <ash77@reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#pragma once
22
23#include "atldef.h"
24#include "atlcore.h"
25#include "statreg.h"
26#include "atlcomcli.h"
27#include "atlalloc.h"
28#include "atlexcept.h"
29#include "atltrace.h"
30#include "comcat.h"
31#include "tchar.h"
32
33#ifdef _MSC_VER
34// It is common to use this in ATL constructors. They only store this for later use, so the usage is safe.
35#pragma warning(disable:4355)
36#endif
37
38#ifndef ATLTRY
39#define ATLTRY(x) x;
40#endif
41
42#ifdef _ATL_DISABLE_NO_VTABLE
43#define ATL_NO_VTABLE
44#else
45#define ATL_NO_VTABLE __declspec(novtable)
46#endif
47
48#ifndef ATL_DEPRECATED
49#define ATL_DEPRECATED __declspec(deprecated)
50#endif
51
52
53namespace ATL
54{
55
56class CAtlModule;
57class CComModule;
58class CAtlComModule;
59__declspec(selectany) CAtlModule *_pAtlModule = NULL;
60__declspec(selectany) CComModule *_pModule = NULL;
61
62template <bool isDll, typename T> struct CAtlValidateModuleConfiguration
63{
64#if !defined(_WINDLL) && !defined(_USRDLL)
65 static_assert(!isDll, "_WINDLL or _USRDLL must be defined when 'CAtlDllModuleT<T>' is used");
66#else
67 static_assert(isDll, "_WINDLL or _USRDLL must be defined when 'CAtlExeModuleT<T>' is used");
68#endif
69};
70
71
73{
74 int iType;
75 const GUID* pcatid;
76};
77
78#define _ATL_CATMAP_ENTRY_END 0
79#define _ATL_CATMAP_ENTRY_IMPLEMENTED 1
80#define _ATL_CATMAP_ENTRY_REQUIRED 2
81
82
83typedef HRESULT (WINAPI _ATL_CREATORFUNC)(void *pv, REFIID riid, LPVOID *ppv);
84typedef LPCTSTR (WINAPI _ATL_DESCRIPTIONFUNC)();
85typedef const struct _ATL_CATMAP_ENTRY * (_ATL_CATMAPFUNC)();
86
88{
89 const CLSID *pclsid;
90 HRESULT (WINAPI *pfnUpdateRegistry)(BOOL bRegister);
91 _ATL_CREATORFUNC *pfnGetClassObject;
92 _ATL_CREATORFUNC *pfnCreateInstance;
95 _ATL_DESCRIPTIONFUNC *pfnGetObjectDescription;
97 void (WINAPI *pfnObjectMain)(bool bStarting);
98
100 {
101 if (dwRegister == 0)
102 return S_OK;
104 }
105
107 {
108 IUnknown *p;
109 HRESULT hResult;
110
111 p = NULL;
112 if (pfnGetClassObject == NULL)
113 return S_OK;
114
115 hResult = pfnGetClassObject(reinterpret_cast<LPVOID *>(pfnCreateInstance), IID_IUnknown, reinterpret_cast<LPVOID *>(&p));
116 if (SUCCEEDED(hResult))
117 hResult = CoRegisterClassObject(*pclsid, p, dwClsContext, dwFlags, &dwRegister);
118
119 if (p != NULL)
120 p->Release();
121
122 return hResult;
123 }
124};
125
127
128typedef void (__stdcall _ATL_TERMFUNC)(DWORD_PTR dw);
129
131{
132 _ATL_TERMFUNC *pFunc;
135};
136
138{
143};
145
146typedef HRESULT (WINAPI _ATL_CREATORARGFUNC)(void *pv, REFIID riid, LPVOID *ppv, DWORD_PTR dw);
147
148#define _ATL_SIMPLEMAPENTRY ((ATL::_ATL_CREATORARGFUNC *)1)
149
151{
152 const IID *piid;
154 _ATL_CREATORARGFUNC *pFunc;
155};
156
158{
159 void *m_pThis;
162};
163
165{
171};
173
175{
179#ifdef NOTYET
180 CSimpleArray<ATOM> m_rgWindowClassAtoms;
181#endif
182};
184
185
186// Auto object map
187
188#if defined(_MSC_VER)
189#pragma section("ATL$__a", read, write)
190#pragma section("ATL$__z", read, write)
191#pragma section("ATL$__m", read, write)
192#define _ATLALLOC(x) __declspec(allocate(x))
193
194#if defined(_M_IX86)
195#define OBJECT_ENTRY_PRAGMA(class) __pragma(comment(linker, "/include:___pobjMap_" #class));
196#elif defined(_M_IA64) || defined(_M_AMD64) || (_M_ARM) || defined(_M_ARM64)
197#define OBJECT_ENTRY_PRAGMA(class) __pragma(comment(linker, "/include:__pobjMap_" #class));
198#else
199#error Your platform is not supported.
200#endif
201
202#elif defined(__GNUC__)
203
204// GCC completely ignores __attribute__((unused)) on the __pobjMap_ pointer, so we pass it to a function that is not allowed to be optimized....
205static int __attribute__((optimize("O0"), unused)) hack_for_gcc(const _ATL_OBJMAP_ENTRY * const *)
206{
207 return 1;
208}
209
210#define _ATLALLOC(x) __attribute__((section(x)))
211#define OBJECT_ENTRY_PRAGMA(class) static int __pobjMap_hack_##class = hack_for_gcc(&__pobjMap_##class);
212
213#else
214#error Your compiler is not supported.
215#endif
216
217
218extern "C"
219{
220 __declspec(selectany) _ATLALLOC("ATL$__a") _ATL_OBJMAP_ENTRY *__pobjMapEntryFirst = NULL;
221 __declspec(selectany) _ATLALLOC("ATL$__z") _ATL_OBJMAP_ENTRY *__pobjMapEntryLast = NULL;
222}
223
224
226{
227 LPCOLESTR szKey;
228 LPCOLESTR szData;
229};
230
233HRESULT WINAPI AtlInternalQueryInterface(void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject);
237
240
243
244
245template<class TLock>
247{
248private:
250 TLock &m_cs;
251public:
252 CComCritSecLock(TLock &cs, bool bInitialLock = true) : m_cs(cs)
253 {
254 HRESULT hResult;
255
256 m_bLocked = false;
257 if (bInitialLock)
258 {
259 hResult = Lock();
260 if (FAILED(hResult))
261 {
262 ATLASSERT(false);
263 }
264 }
265 }
266
268 {
269 if (m_bLocked)
270 Unlock();
271 }
272
274 {
275 HRESULT hResult;
276
278 hResult = m_cs.Lock();
279 if (FAILED(hResult))
280 return hResult;
281 m_bLocked = true;
282
283 return S_OK;
284 }
285
286 void Unlock()
287 {
288 HRESULT hResult;
289
291 hResult = m_cs.Unlock();
292 if (FAILED(hResult))
293 {
294 ATLASSERT(false);
295 }
296 m_bLocked = false;
297 }
298};
299
300
302{
303public:
305
306public:
309 {
310 }
311
314 {
315 Attach(handle.Detach());
316 }
317
320 {
321 }
322
324 {
325 if (m_handle)
326 {
327 Close();
328 }
329 }
330
332 {
333 if (this != &handle)
334 {
335 if (m_handle)
336 {
337 Close();
338 }
339 Attach(handle.Detach());
340 }
341
342 return *this;
343 }
344
345 operator HANDLE() const
346 {
347 return m_handle;
348 }
349
351 {
354 }
355
357 {
359 m_handle = NULL;
360 return handle;
361 }
362
363 void Close()
364 {
365 if (m_handle)
366 {
368 m_handle = NULL;
369 }
370 }
371};
372
373
375{
376 return (
377 ((unsigned long *)&rguid1)[0] == 0 &&
378 ((unsigned long *)&rguid1)[1] == 0 &&
379 ((unsigned long *)&rguid1)[2] == 0x000000C0 &&
380 ((unsigned long *)&rguid1)[3] == 0x46000000);
381}
382
384{
385public:
390
392 {
393 return InterlockedIncrement(p);
394 }
395
397 {
398 return InterlockedDecrement(p);
399 }
400};
401
403{
404public:
409
411 {
412 return InterlockedIncrement(p);
413 }
414
416 {
417 return InterlockedDecrement(p);
418 }
419};
420
422{
423public:
428
430 {
431 return ++*p;
432 }
433
435 {
436 return --*p;
437 }
438};
439
440#if defined(_ATL_FREE_THREADED)
441
444
445#elif defined(_ATL_APARTMENT_THREADED)
446
449
450#elif defined(_ATL_SINGLE_THREADED)
451
454
455#else
456#error No threading model
457#endif
458
460{
461public:
462 static GUID m_libid;
463
465 {
466 ATLASSERT(_pAtlModule == NULL);
467 _pAtlModule = this;
468 cbSize = sizeof(_ATL_MODULE);
469 m_nLockCnt = 0;
470 }
471
473 {
474 return m_nLockCnt;
475 }
476
477 virtual LONG Lock()
478 {
480 }
481
482 virtual LONG Unlock()
483 {
485 }
486
487 virtual HRESULT AddCommonRGSReplacements(IRegistrarBase* /*pRegistrar*/) = 0;
488
489 HRESULT WINAPI UpdateRegistryFromResource(LPCTSTR lpszRes, BOOL bRegister, struct _ATL_REGMAP_ENTRY *pMapEntries = NULL)
490 {
491 CRegObject registrar;
492 WCHAR modulePath[MAX_PATH];
493 HRESULT hResult;
494 PCWSTR lpwszRes;
495
496 hResult = CommonInitRegistrar(registrar, modulePath, sizeof(modulePath) / sizeof(modulePath[0]), pMapEntries);
497 if (FAILED(hResult))
498 return hResult;
499#ifdef UNICODE
500 lpwszRes = lpszRes;
501#else
502 /* FIXME: this is a bit of a hack, need to re-evaluate */
503 WCHAR resid[MAX_PATH];
504 MultiByteToWideChar(CP_ACP, 0, lpszRes, -1, resid, MAX_PATH);
505 lpwszRes = resid;
506#endif
507 if (bRegister != FALSE)
508 hResult = registrar.ResourceRegisterSz(modulePath, lpwszRes, L"REGISTRY");
509 else
510 hResult = registrar.ResourceUnregisterSz(modulePath, lpwszRes, L"REGISTRY");
511
512 return hResult;
513 }
514
515 HRESULT WINAPI UpdateRegistryFromResource(UINT nResID, BOOL bRegister, struct _ATL_REGMAP_ENTRY *pMapEntries = NULL)
516 {
517 CRegObject registrar;
518 WCHAR modulePath[MAX_PATH];
519 HRESULT hResult;
520
521 hResult = CommonInitRegistrar(registrar, modulePath, sizeof(modulePath) / sizeof(modulePath[0]), pMapEntries);
522 if (FAILED(hResult))
523 return hResult;
524
525 if (bRegister != FALSE)
526 hResult = registrar.ResourceRegister(modulePath, nResID, L"REGISTRY");
527 else
528 hResult = registrar.ResourceUnregister(modulePath, nResID, L"REGISTRY");
529
530 return hResult;
531 }
532
533private:
534 HRESULT CommonInitRegistrar(CRegObject &registrar, WCHAR *modulePath, DWORD modulePathCount, struct _ATL_REGMAP_ENTRY *pMapEntries)
535 {
537 DWORD dwFLen;
538 HRESULT hResult;
539
540 hInstance = _AtlBaseModule.GetModuleInstance();
541 dwFLen = GetModuleFileNameW(hInstance, modulePath, modulePathCount);
542 if (dwFLen == modulePathCount)
544 else if (dwFLen == 0)
546
547 if (pMapEntries != NULL)
548 {
549 while (pMapEntries->szKey != NULL)
550 {
551 ATLASSERT(pMapEntries->szData != NULL);
552 hResult = registrar.AddReplacement(pMapEntries->szKey, pMapEntries->szData);
553 if (FAILED(hResult))
554 return hResult;
555 pMapEntries++;
556 }
557 }
558
559 hResult = AddCommonRGSReplacements(&registrar);
560 if (FAILED(hResult))
561 return hResult;
562
563 hResult = registrar.AddReplacement(L"Module", modulePath);
564 if (FAILED(hResult))
565 return hResult;
566
567 hResult = registrar.AddReplacement(L"Module_Raw", modulePath);
568 if (FAILED(hResult))
569 return hResult;
570
571 return S_OK;
572 }
573};
574
575__declspec(selectany) GUID CAtlModule::m_libid = {0x0, 0x0, 0x0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0} };
576
577template <class T>
579{
580public:
581
582 HRESULT RegisterServer(BOOL bRegTypeLib = FALSE, const CLSID *pCLSID = NULL);
583 HRESULT UnregisterServer(BOOL bUnRegTypeLib, const CLSID *pCLSID = NULL);
584
585
587 {
588 return pRegistrar->AddReplacement(L"APPID", T::GetAppId());
589 }
590
591 static LPCOLESTR GetAppId()
592 {
593 return L"";
594 }
595};
596
598{
599public:
601 {
602 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)this, &m_hInstTypeLib);
603
604 m_ppAutoObjMapFirst = &__pobjMapEntryFirst + 1;
605 m_ppAutoObjMapLast = &__pobjMapEntryLast;
606 if (FAILED(m_csObjMap.Init()))
607 {
608 ATLASSERT(0);
610 return;
611 }
612 cbSize = sizeof(_ATL_COM_MODULE);
613 }
614
616 {
617 Term();
618 }
619
620 HRESULT RegisterServer(BOOL bRegTypeLib = FALSE, const CLSID *pCLSID = NULL)
621 {
622 return AtlComModuleRegisterServer(this, bRegTypeLib, pCLSID);
623 }
624
625 HRESULT UnregisterServer(BOOL bUnRegTypeLib, const CLSID *pCLSID = NULL)
626 {
627 return AtlComModuleUnregisterServer(this, bUnRegTypeLib, pCLSID);
628 }
629
630 void Term()
631 {
632 if (cbSize != 0)
633 {
634 for (_ATL_OBJMAP_ENTRY **iter = m_ppAutoObjMapFirst; iter < m_ppAutoObjMapLast; iter++)
635 {
636 _ATL_OBJMAP_ENTRY *ptr = *iter;
637 if (!ptr)
638 continue;
639
640 if (!ptr->pCF)
641 continue;
642
643 ptr->pCF->Release();
644 ptr->pCF = NULL;
645 }
647 cbSize = 0;
648 }
649 }
650
651 void ExecuteObjectMain(bool bStarting)
652 {
653 for (_ATL_OBJMAP_ENTRY **iter = m_ppAutoObjMapFirst; iter < m_ppAutoObjMapLast; iter++)
654 {
655 if (!*iter)
656 continue;
657
658 (*iter)->pfnObjectMain(bStarting);
659 }
660 }
661};
662
663__declspec(selectany) CAtlComModule _AtlComModule;
664
665
666template <class T>
668{
669 return _AtlComModule.RegisterServer(bRegTypeLib, pCLSID);
670}
671
672template <class T>
674{
675 return _AtlComModule.UnregisterServer(bUnRegTypeLib, pCLSID);
676}
677
678template <class T>
680 : public CAtlModuleT<T>
681 , private CAtlValidateModuleConfiguration<true, T>
682
683{
684public:
686 {
687 _AtlComModule.ExecuteObjectMain(true);
688 }
689
691 {
692 _AtlComModule.ExecuteObjectMain(false);
693 }
694
696 {
697 T *pThis;
698
699 pThis = static_cast<T *>(this);
700 if (pThis->GetLockCount() == 0)
701 return S_OK;
702 return S_FALSE;
703 }
704
706 {
707 T *pThis;
708
709 pThis = static_cast<T *>(this);
710 return pThis->GetClassObject(rclsid, riid, ppv);
711 }
712
714 {
715 T *pThis;
716 HRESULT hResult;
717
718 pThis = static_cast<T *>(this);
719 hResult = pThis->RegisterServer(bRegTypeLib);
720 return hResult;
721 }
722
724 {
725 T *pThis;
726 HRESULT hResult;
727
728 pThis = static_cast<T *>(this);
729 hResult = pThis->UnregisterServer(bUnRegTypeLib);
730 return hResult;
731 }
732
734 {
735 return AtlComModuleGetClassObject(&_AtlComModule, rclsid, riid, ppv);
736 }
737};
738
739
740template <class T>
742 : public CAtlModuleT<T>
743 , private CAtlValidateModuleConfiguration<false, T>
744{
745public:
747 //DWORD m_dwTimeOut;
748 //DWORD m_dwPause;
749 //bool m_bDelayShutdown;
750
753 {
754 _AtlComModule.ExecuteObjectMain(true);
755 }
756
758 {
759 _AtlComModule.ExecuteObjectMain(false);
760 }
761
762 int WinMain(int nShowCmd)
763 {
764 HRESULT hr = T::InitializeCom();
765 if (FAILED(hr))
766 return hr;
767
768 T* pThis = static_cast<T*>(this);
769
770 LPCTSTR lpCommandLine = GetCommandLine();
771 if (pThis->ParseCommandLine(lpCommandLine, &hr))
772 {
773 hr = pThis->Run(nShowCmd);
774 }
775
776 T::UninitializeCom();
777 return hr;
778 }
779
780
781 HRESULT Run(int nShowCmd = SW_HIDE)
782 {
783 HRESULT hr = S_OK;
784
785 T* pThis = static_cast<T*>(this);
786 hr = pThis->PreMessageLoop(nShowCmd);
787
788 if (hr == S_OK)
789 {
790 pThis->RunMessageLoop();
791 hr = pThis->PostMessageLoop();
792 }
793
794 return hr;
795 }
796
798 {
799 return CoAddRefServerProcess();
800 }
801
803 {
805 if (lRet == 0)
806 {
808 }
809 return lRet;
810 }
811
812 bool ParseCommandLine(LPCTSTR lpCmdLine, HRESULT* pnRetCode)
813 {
814 // unimplemented!
815 return true;
816 }
817
819 {
820 T* pThis = static_cast<T*>(this);
821 return pThis->RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE);
822 }
823
825 {
826 MSG msg;
827 while (GetMessage(&msg, 0, 0, 0) > 0)
828 {
831 }
832 }
833
835 {
836 T* pThis = static_cast<T*>(this);
837 return pThis->RevokeClassObjects();
838 }
839
841 {
842 return AtlComModuleRegisterClassObjects(&_AtlComModule, dwClsContext, dwFlags);
843 }
844
846 {
847 return AtlComModuleRevokeClassObjects(&_AtlComModule);
848 }
849
851 {
852#if defined(_ATL_FREE_THREADED)
853 constexpr COINIT coInit = COINIT_MULTITHREADED;
854#else
855 constexpr COINIT coInit = COINIT_APARTMENTTHREADED;
856#endif
857 return ::CoInitializeEx(NULL, coInit);
858 }
859
860 static void UninitializeCom()
861 {
863 }
864
865};
866
867
868
869class CComModule : public CAtlModuleT<CComModule>
870{
871public:
873public:
875 {
876 ATLASSERT(_pModule == NULL);
877 _pModule = this;
878 _pModule->m_pObjMap = NULL;
879 }
880
882 {
883 _pModule = NULL;
884 }
885
886 HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE /* h */, const GUID *plibid)
887 {
888 _ATL_OBJMAP_ENTRY *objectMapEntry;
889
890 if (plibid != NULL)
891 m_libid = *plibid;
892
893 if (p != reinterpret_cast<_ATL_OBJMAP_ENTRY *>(-1))
894 {
895 m_pObjMap = p;
896 if (p != NULL)
897 {
898 objectMapEntry = p;
899 while (objectMapEntry->pclsid != NULL)
900 {
901 objectMapEntry->pfnObjectMain(true);
902 objectMapEntry++;
903 }
904 }
905 }
906
907 for (_ATL_OBJMAP_ENTRY **iter = _AtlComModule.m_ppAutoObjMapFirst; iter < _AtlComModule.m_ppAutoObjMapLast; iter++)
908 {
909 if (*iter != NULL)
910 (*iter)->pfnObjectMain(true);
911 }
912
913 return S_OK;
914 }
915
916 void Term()
917 {
918 _ATL_OBJMAP_ENTRY *objectMapEntry;
919
920 if (m_pObjMap != NULL)
921 {
922 objectMapEntry = m_pObjMap;
923 while (objectMapEntry->pclsid != NULL)
924 {
925 if (objectMapEntry->pCF != NULL)
926 objectMapEntry->pCF->Release();
927 objectMapEntry->pCF = NULL;
928 objectMapEntry->pfnObjectMain(false);
929 objectMapEntry++;
930 }
931 }
932
933 for (_ATL_OBJMAP_ENTRY **iter = _AtlComModule.m_ppAutoObjMapFirst; iter < _AtlComModule.m_ppAutoObjMapLast; iter++)
934 {
935 if (*iter != NULL)
936 (*iter)->pfnObjectMain(false);
937 }
938
939 }
940
942 {
943 _ATL_OBJMAP_ENTRY *objectMapEntry;
944 HRESULT hResult;
945
946 ATLASSERT(ppv != NULL);
947 if (ppv == NULL)
948 return E_POINTER;
949 *ppv = NULL;
950 hResult = S_OK;
951 if (m_pObjMap != NULL)
952 {
953 objectMapEntry = m_pObjMap;
954 while (objectMapEntry->pclsid != NULL)
955 {
956 if (objectMapEntry->pfnGetClassObject != NULL && InlineIsEqualGUID(rclsid, *objectMapEntry->pclsid) != FALSE)
957 {
958 if (objectMapEntry->pCF == NULL)
959 {
961
962 if (objectMapEntry->pCF == NULL)
963 hResult = objectMapEntry->pfnGetClassObject(reinterpret_cast<void *>(objectMapEntry->pfnCreateInstance), IID_IUnknown, reinterpret_cast<LPVOID *>(&objectMapEntry->pCF));
964 }
965 if (objectMapEntry->pCF != NULL)
966 hResult = objectMapEntry->pCF->QueryInterface(riid, ppv);
967 break;
968 }
969 objectMapEntry++;
970 }
971 }
972 if (hResult == S_OK && *ppv == NULL)
973 {
974 hResult = AtlComModuleGetClassObject(&_AtlComModule, rclsid, riid, ppv);
975 }
976 return hResult;
977 }
978
979 HRESULT RegisterServer(BOOL bRegTypeLib = FALSE, const CLSID *pCLSID = NULL)
980 {
981 _ATL_OBJMAP_ENTRY *objectMapEntry;
982 HRESULT hResult;
983
984 hResult = S_OK;
985 objectMapEntry = m_pObjMap;
986 if (objectMapEntry != NULL)
987 {
988 while (objectMapEntry->pclsid != NULL)
989 {
990 if (pCLSID == NULL || IsEqualGUID(*pCLSID, *objectMapEntry->pclsid) != FALSE)
991 {
992 hResult = objectMapEntry->pfnUpdateRegistry(TRUE);
993 if (FAILED(hResult))
994 break;
995 }
996 objectMapEntry++;
997 }
998 }
999 if (SUCCEEDED(hResult))
1000 hResult = CAtlModuleT<CComModule>::RegisterServer(bRegTypeLib, pCLSID);
1001 return hResult;
1002 }
1003
1004 HRESULT UnregisterServer(BOOL bUnRegTypeLib, const CLSID *pCLSID = NULL)
1005 {
1006 _ATL_OBJMAP_ENTRY *objectMapEntry;
1007 HRESULT hResult;
1008
1009 hResult = S_OK;
1010 objectMapEntry = m_pObjMap;
1011 if (objectMapEntry != NULL)
1012 {
1013 while (objectMapEntry->pclsid != NULL)
1014 {
1015 if (pCLSID == NULL || IsEqualGUID(*pCLSID, *objectMapEntry->pclsid) != FALSE)
1016 {
1017 hResult = objectMapEntry->pfnUpdateRegistry(FALSE); //unregister
1018 if (FAILED(hResult))
1019 break;
1020 }
1021 objectMapEntry++;
1022 }
1023 }
1024 if (SUCCEEDED(hResult))
1025 hResult = CAtlModuleT<CComModule>::UnregisterServer(bUnRegTypeLib, pCLSID);
1026
1027 return hResult;
1028 }
1029
1031 {
1032 if (GetLockCount() == 0)
1033 return S_OK;
1034 return S_FALSE;
1035 }
1036
1038 {
1039 return GetClassObject(rclsid, riid, ppv);
1040 }
1041
1043 {
1044 return RegisterServer(bRegTypeLib);
1045 }
1046
1048 {
1049 return UnregisterServer(bUnRegTypeLib);
1050 }
1051
1052};
1053
1055{
1056public:
1058 {
1059 HRESULT hResult;
1060
1061 hResult = AtlWinModuleInit(this);
1062 if (FAILED(hResult))
1063 {
1065 ATLASSERT(0);
1066 }
1067 }
1068
1070 {
1071 Term();
1072 }
1073
1074 void Term()
1075 {
1076 AtlWinModuleTerm(this, _AtlBaseModule.GetModuleInstance());
1077 }
1078
1080 {
1082 }
1083
1085 {
1087 }
1088};
1089
1090__declspec(selectany) CAtlWinModule _AtlWinModule;
1091
1092
1094{
1095public:
1096 static void* Allocate(_In_ size_t size)
1097 {
1098 return ::CoTaskMemAlloc(size);
1099 }
1100
1101 static void* Reallocate(_In_opt_ void* ptr, _In_ size_t size)
1102 {
1103 return ::CoTaskMemRealloc(ptr, size);
1104 }
1105
1106 static void Free(_In_opt_ void* ptr)
1107 {
1109 }
1110};
1111
1113{
1114public:
1116#if 0
1117 // FIXME & TODO:
1118 CAtlTransactionManager* m_pTM;
1119#endif
1120
1121public:
1122
1123 CRegKey() noexcept
1124 : m_hKey(NULL)
1125 {
1126 }
1127
1129 : m_hKey(key.Detach())
1130 {
1131 }
1132
1133 explicit CRegKey(HKEY hKey) noexcept
1134 : m_hKey(hKey)
1135 {
1136 }
1137
1138#if 0
1139 // FIXME & TODO:
1140 CRegKey(CAtlTransactionManager* pTM) noexcept
1141 {
1142 ...
1143 }
1144#endif
1145
1146 ~CRegKey() noexcept
1147 {
1148 Close();
1149 }
1150
1151 void Attach(HKEY hKey) noexcept
1152 {
1153 m_hKey = hKey;
1154 }
1155
1156 LONG Close() noexcept
1157 {
1158 if (m_hKey)
1159 {
1160 HKEY hKey = Detach();
1161 return ::RegCloseKey(hKey);
1162 }
1163 return ERROR_SUCCESS;
1164 }
1165
1166 HKEY Detach() noexcept
1167 {
1168 HKEY hKey = m_hKey;
1169 m_hKey = NULL;
1170 return hKey;
1171 }
1172
1173 LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName,
1174 REGSAM samDesired = KEY_READ | KEY_WRITE) noexcept
1175 {
1176 ATLASSERT(hKeyParent);
1177 ATLASSERT(lpszKeyName);
1178
1179 HKEY hKey = NULL;
1180 LONG lRes = ::RegOpenKeyEx(hKeyParent, lpszKeyName, 0, samDesired, &hKey);
1181 if (lRes == ERROR_SUCCESS)
1182 {
1183 Close();
1184 m_hKey = hKey;
1185 }
1186 return lRes;
1187 }
1188
1189 LONG Create(HKEY hKeyParent, LPCTSTR lpszKeyName,
1190 LPTSTR lpszClass = REG_NONE,
1192 REGSAM samDesired = KEY_READ | KEY_WRITE,
1193 LPSECURITY_ATTRIBUTES lpSecAttr = NULL,
1194 LPDWORD lpdwDisposition = NULL) noexcept
1195 {
1196 ATLASSERT(hKeyParent);
1197 ATLASSERT(lpszKeyName);
1198
1199 HKEY hKey = NULL;
1200 LONG lRes = ::RegCreateKeyEx(hKeyParent, lpszKeyName, 0, lpszClass,
1201 dwOptions, samDesired, lpSecAttr, &hKey,
1202 lpdwDisposition);
1203 if (lRes == ERROR_SUCCESS)
1204 {
1205 Close();
1206 m_hKey = hKey;
1207 }
1208 return lRes;
1209 }
1210
1211 LONG QueryValue(LPCTSTR pszValueName, DWORD* pdwType, void* pData, ULONG* pnBytes) noexcept
1212 {
1214 return ::RegQueryValueEx(m_hKey, pszValueName, NULL, pdwType, (LPBYTE)pData, pnBytes);
1215 }
1216
1217 LONG QueryDWORDValue(LPCTSTR pszValueName, DWORD& dwValue) noexcept
1218 {
1219 ULONG size = sizeof(DWORD);
1220 DWORD type = 0;
1221 LONG lRet = QueryValue(pszValueName, &type, &dwValue, &size);
1222
1223 if (lRet == ERROR_SUCCESS && type != REG_DWORD)
1224 lRet = ERROR_INVALID_DATA;
1225
1226 return lRet;
1227 }
1228
1229 LONG QueryBinaryValue(LPCTSTR pszValueName, void* pValue, ULONG* pnBytes) noexcept
1230 {
1231 DWORD type = 0;
1232 LONG lRet = QueryValue(pszValueName, &type, pValue, pnBytes);
1233
1234 if (lRet == ERROR_SUCCESS && type != REG_BINARY)
1235 lRet = ERROR_INVALID_DATA;
1236
1237 return lRet;
1238 }
1239
1240 LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG* pnChars) noexcept
1241 {
1242 ULONG size = (*pnChars) * sizeof(TCHAR);
1243 DWORD type = 0;
1244 LONG lRet = QueryValue(pszValueName, &type, pszValue, &size);
1245
1246 if (lRet == ERROR_SUCCESS && type != REG_SZ && type != REG_EXPAND_SZ)
1247 lRet = ERROR_INVALID_DATA;
1248
1249 *pnChars = size / sizeof(TCHAR);
1250 return lRet;
1251 }
1252
1253 LONG QueryGUIDValue(LPCTSTR pszValueName, GUID& guidValue) noexcept
1254 {
1255 OLECHAR buf[40] = {0};
1256 ULONG nChars = 39;
1257 LONG lRet;
1258
1259#ifdef UNICODE
1260 lRet = QueryStringValue(pszValueName, buf, &nChars);
1261#else
1262 CHAR bufA[40] = {0};
1263 lRet = QueryStringValue(pszValueName, bufA, &nChars);
1264 if (lRet != ERROR_SUCCESS)
1265 return lRet;
1266 if (!::MultiByteToWideChar(CP_THREAD_ACP, 0, bufA, -1, buf, 39))
1267 lRet = ERROR_INVALID_DATA;
1268#endif
1269 if (lRet != ERROR_SUCCESS)
1270 return lRet;
1271
1272 if (!SUCCEEDED(::CLSIDFromString(buf, &guidValue)))
1273 return ERROR_INVALID_DATA;
1274
1275 return lRet;
1276 }
1277
1278 LONG QueryQWORDValue(LPCTSTR pszValueName, ULONGLONG& qwValue) noexcept
1279 {
1280 ULONG size = sizeof(ULONGLONG);
1281 DWORD type = 0;
1282 LONG lRet = QueryValue(pszValueName, &type, &qwValue, &size);
1283
1284 if (lRet == ERROR_SUCCESS && type != REG_QWORD)
1285 lRet = ERROR_INVALID_DATA;
1286
1287 return lRet;
1288 }
1289
1291 ULONG* pnChars) noexcept
1292 {
1293 ULONG size = (*pnChars) * sizeof(TCHAR);
1294 DWORD type;
1295 LONG lRet = QueryValue(pszValueName, &type, pszValue, &size);
1296
1297 if (lRet == ERROR_SUCCESS && type != REG_MULTI_SZ)
1298 lRet = ERROR_INVALID_DATA;
1299
1300 *pnChars = size / sizeof(TCHAR);
1301 return lRet;
1302 }
1303
1304 LONG SetValue(LPCTSTR pszValueName, DWORD dwType, const void* pValue, ULONG nBytes) noexcept
1305 {
1307 return ::RegSetValueEx(m_hKey, pszValueName, 0, dwType, (const BYTE*)pValue, nBytes);
1308 }
1309
1310 LONG SetDWORDValue(LPCTSTR pszValueName, DWORD dwValue) noexcept
1311 {
1312 return SetValue(pszValueName, REG_DWORD, &dwValue, sizeof(DWORD));
1313 }
1314
1315 LONG SetStringValue(LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType = REG_SZ) noexcept
1316 {
1317 SIZE_T length;
1318 switch (dwType)
1319 {
1320 case REG_SZ:
1321 case REG_EXPAND_SZ:
1322 length = (_tcslen(pszValue) + 1) * sizeof(TCHAR);
1323 return SetValue(pszValueName, dwType, pszValue, length);
1324 case REG_MULTI_SZ:
1325 return SetMultiStringValue(pszValueName, pszValue);
1326 default:
1327 return ERROR_INVALID_DATA;
1328 }
1329 }
1330
1331 LONG SetGUIDValue(LPCTSTR pszValueName, REFGUID guidValue) noexcept
1332 {
1333 OLECHAR buf[40] = {0};
1334 ::StringFromGUID2(guidValue, buf, 39);
1335#ifdef UNICODE
1336 return SetStringValue(pszValueName, buf);
1337#else
1338 CHAR bufA[40] = {0};
1339 ::WideCharToMultiByte(CP_THREAD_ACP, 0, buf, -1, bufA, 40, NULL, NULL);
1340 return SetStringValue(pszValueName, bufA);
1341#endif
1342 }
1343
1344 LONG SetBinaryValue(LPCTSTR pszValueName, const void* pValue, ULONG nBytes) noexcept
1345 {
1346 return SetValue(pszValueName, REG_BINARY, pValue, nBytes);
1347 }
1348
1349 LONG SetMultiStringValue(LPCTSTR pszValueName, LPCTSTR pszValue) noexcept
1350 {
1352 return SetValue(pszValueName, REG_MULTI_SZ, pszValue, dwSize);
1353 }
1354
1355 LONG SetQWORDValue(LPCTSTR pszValueName, ULONGLONG qwValue) noexcept
1356 {
1357 ULONG dwSize = sizeof(ULONGLONG);
1358 return SetValue(pszValueName, REG_QWORD, &qwValue, dwSize);
1359 }
1360
1361 LONG NotifyChangeKeyValue(BOOL bWatchSubtree, DWORD dwNotifyFilter,
1362 HANDLE hEvent, BOOL bAsync = TRUE) noexcept
1363 {
1365 LONG ret = ::RegNotifyChangeKeyValue(m_hKey, bWatchSubtree,
1366 dwNotifyFilter, hEvent, bAsync);
1367 return ret;
1368 }
1369
1370 LONG Flush() noexcept
1371 {
1374 return ret;
1375 }
1376
1377 static LONG WINAPI SetValue(HKEY hKeyParent, LPCTSTR lpszKeyName,
1378 LPCTSTR lpszValue, LPCTSTR lpszValueName = NULL)
1379 {
1380 CRegKey key;
1381 LONG lRet = key.Create(hKeyParent, lpszKeyName);
1382 if (lRet == ERROR_SUCCESS)
1383 {
1384 lRet = key.SetStringValue(lpszValueName, lpszValue);
1385 }
1386 return lRet;
1387 }
1388
1389 LONG SetKeyValue(LPCTSTR lpszKeyName, LPCTSTR lpszValue,
1390 LPCTSTR lpszValueName = NULL) noexcept
1391 {
1392 CRegKey key;
1393 LONG lRet = key.Create(m_hKey, lpszKeyName);
1394 if (lRet == ERROR_SUCCESS)
1395 {
1396 lRet = key.SetStringValue(lpszValueName, lpszValue);
1397 }
1398 return lRet;
1399 }
1400
1401 LONG DeleteValue(LPCTSTR lpszValue) noexcept
1402 {
1404 return ::RegDeleteValue(m_hKey, lpszValue);
1405 }
1406
1407 LONG DeleteSubKey(LPCTSTR lpszSubKey) noexcept
1408 {
1410 ATLASSERT(lpszSubKey);
1411 return ::RegDeleteKey(m_hKey, lpszSubKey);
1412 }
1413
1415 {
1417 ATLASSERT(lpszKey);
1418 return CRegKey::_DoDeleteKeyTree(m_hKey, lpszKey);
1419 }
1420
1421 LONG EnumKey(DWORD iIndex, LPTSTR pszName, LPDWORD pnNameLength,
1422 FILETIME* pftLastWriteTime = NULL) noexcept
1423 {
1425 LONG ret = ::RegEnumKeyEx(m_hKey, iIndex, pszName, pnNameLength, NULL,
1426 NULL, NULL, pftLastWriteTime);
1427 return ret;
1428 }
1429
1431 LPDWORD pnBytes) noexcept
1432 {
1434 LONG ret = ::RegGetKeySecurity(m_hKey, si, psd, pnBytes);
1435 return ret;
1436 }
1437
1439 PSECURITY_DESCRIPTOR psd) noexcept
1440 {
1442 LONG ret = ::RegSetKeySecurity(m_hKey, si, psd);
1443 return ret;
1444 }
1445
1446 operator HKEY() const noexcept
1447 {
1448 return m_hKey;
1449 }
1450
1452 {
1453 if (m_hKey != key.m_hKey)
1454 {
1455 Close();
1456 Attach(key.Detach());
1457 }
1458 return *this;
1459 }
1460
1461protected:
1462 // get the total size of a multistring
1464 {
1465 size_t count = 0;
1466 do
1467 {
1468 size_t len = _tcslen(pszz);
1469 count += len + 1;
1470 pszz += len + 1;
1471 } while (*pszz != TEXT('\0'));
1472 ++count;
1473 ATLASSERT(count * sizeof(TCHAR) <= ULONG_MAX);
1474 return (ULONG)count * sizeof(TCHAR);
1475 }
1476
1477 // delete key recursively
1478 static LONG _DoDeleteKeyTree(HKEY hParentKey, LPCTSTR lpszKey)
1479 {
1480 ATLASSERT(hParentKey);
1481 ATLASSERT(lpszKey);
1482
1483 // open the key
1484 CRegKey key;
1485 LONG ret = key.Open(hParentKey, lpszKey);
1486 if (ret != ERROR_SUCCESS)
1487 {
1488 return ret; // failure
1489 }
1490
1491 // get the longest length of subkey names
1492 DWORD NameMax;
1493 ret = ::RegQueryInfoKey(key, NULL, NULL, NULL, NULL, &NameMax, NULL,
1494 NULL, NULL, NULL, NULL, NULL);
1495 if (ret != ERROR_SUCCESS)
1496 {
1497 return ret; // failure
1498 }
1499 ++NameMax; // for NUL
1500
1501 // allocate the string buffer for names if necessary
1502 TCHAR szNameBuf[MAX_PATH], *pszName;
1503 if (NameMax > MAX_PATH)
1504 {
1505 pszName = (TCHAR *)malloc(NameMax * sizeof(TCHAR));
1506 ATLASSERT(pszName);
1507 if (pszName == NULL)
1508 {
1509 return ERROR_OUTOFMEMORY; // failure
1510 }
1511 }
1512 else
1513 {
1514 NameMax = MAX_PATH;
1515 pszName = szNameBuf;
1516 }
1517
1518 // enumerate every subkey and delete
1519 for (;;)
1520 {
1521 DWORD Count = NameMax;
1522 ret = key.EnumKey(0, pszName, &Count);
1523 if (ret != ERROR_SUCCESS)
1524 {
1525 if (ret == ERROR_NO_MORE_ITEMS)
1527 break;
1528 }
1529
1530 ret = CRegKey::_DoDeleteKeyTree(key, pszName);
1531 if (ret != ERROR_SUCCESS)
1532 break;
1533 }
1534
1535 // close key
1536 key.Close();
1537
1538 // delete the subkey
1539 if (ret == ERROR_SUCCESS)
1540 ret = ::RegDeleteKey(hParentKey, lpszKey);
1541
1542 // delete the buffer if any
1543 if (pszName != szNameBuf)
1544 free(pszName);
1545
1546 return ret;
1547 }
1548};
1549
1550template<class T>
1551class CComHeapPtr : public CHeapPtr<T, CComAllocator>
1552{
1553public:
1555 {
1556 }
1557
1558 explicit CComHeapPtr(T *lp) :
1560 {
1561 }
1562};
1563
1564
1565inline HRESULT __stdcall AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID &iid, LPDWORD pdw)
1566{
1568 CComPtr<IConnectionPoint> connectionPoint;
1569 HRESULT hResult;
1570
1571 if (pUnkCP == NULL)
1572 return E_INVALIDARG;
1573 hResult = pUnkCP->QueryInterface(IID_IConnectionPointContainer, (void **)&container);
1574 if (FAILED(hResult))
1575 return hResult;
1576 hResult = container->FindConnectionPoint(iid, &connectionPoint);
1577 if (FAILED(hResult))
1578 return hResult;
1579 return connectionPoint->Advise(pUnk, pdw);
1580}
1581
1582inline HRESULT __stdcall AtlUnadvise(IUnknown *pUnkCP, const IID &iid, DWORD dw)
1583{
1585 CComPtr<IConnectionPoint> connectionPoint;
1586 HRESULT hResult;
1587
1588 if (pUnkCP == NULL)
1589 return E_INVALIDARG;
1590 hResult = pUnkCP->QueryInterface(IID_IConnectionPointContainer, (void **)&container);
1591 if (FAILED(hResult))
1592 return hResult;
1593 hResult = container->FindConnectionPoint(iid, &connectionPoint);
1594 if (FAILED(hResult))
1595 return hResult;
1596 return connectionPoint->Unadvise(dw);
1597}
1598
1599inline HRESULT __stdcall AtlInternalQueryInterface(void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
1600{
1601 int i;
1602 IUnknown *resultInterface;
1603 HRESULT hResult;
1604
1605 ATLASSERT(pThis != NULL && pEntries != NULL);
1606 if (pThis == NULL || pEntries == NULL)
1607 return E_INVALIDARG;
1608
1609 if (ppvObject == NULL)
1610 return E_POINTER;
1611
1612 if (InlineIsEqualUnknown(iid))
1613 {
1614 resultInterface = reinterpret_cast<IUnknown *>(reinterpret_cast<char *>(pThis) + pEntries[0].dw);
1615 *ppvObject = resultInterface;
1616 resultInterface->AddRef();
1617 return S_OK;
1618 }
1619
1620 i = 0;
1621 while (pEntries[i].pFunc != 0)
1622 {
1623 if (pEntries[i].piid == NULL || InlineIsEqualGUID(iid, *pEntries[i].piid))
1624 {
1625 if (pEntries[i].pFunc == reinterpret_cast<_ATL_CREATORARGFUNC *>(1))
1626 {
1627 ATLASSERT(pEntries[i].piid != NULL);
1628 resultInterface = reinterpret_cast<IUnknown *>(reinterpret_cast<char *>(pThis) + pEntries[i].dw);
1629 *ppvObject = resultInterface;
1630 resultInterface->AddRef();
1631 return S_OK;
1632 }
1633 else
1634 {
1635 hResult = pEntries[i].pFunc(pThis, iid, ppvObject, 0);
1636 if (hResult == S_OK)
1637 return hResult;
1638 if (FAILED(hResult) && pEntries[i].piid != NULL)
1639 break;
1640 }
1641 }
1642 i++;
1643 }
1644 *ppvObject = NULL;
1645 return E_NOINTERFACE;
1646}
1647
1649{
1650 if (pWinModule == NULL)
1651 return E_INVALIDARG;
1652 pWinModule->m_pCreateWndList = NULL;
1653 return pWinModule->m_csWindowCreate.Init();
1654}
1655
1657{
1658 if (pWinModule == NULL)
1659 return E_INVALIDARG;
1660 pWinModule->m_csWindowCreate.Term();
1661 return S_OK;
1662}
1663
1665{
1667
1668 ATLASSERT(pWinModule != NULL);
1670
1671 pData->m_pThis = pObject;
1672 pData->m_dwThreadID = ::GetCurrentThreadId();
1673 pData->m_pNext = pWinModule->m_pCreateWndList;
1674 pWinModule->m_pCreateWndList = pData;
1675}
1676
1678{
1680 void *result;
1681 _AtlCreateWndData *currentEntry;
1682 _AtlCreateWndData **previousLink;
1683 DWORD threadID;
1684
1685 ATLASSERT(pWinModule != NULL);
1686
1687 result = NULL;
1688 threadID = GetCurrentThreadId();
1689 currentEntry = pWinModule->m_pCreateWndList;
1690 previousLink = &pWinModule->m_pCreateWndList;
1691 while (currentEntry != NULL)
1692 {
1693 if (currentEntry->m_dwThreadID == threadID)
1694 {
1695 *previousLink = currentEntry->m_pNext;
1696 result = currentEntry->m_pThis;
1697 break;
1698 }
1699 previousLink = &currentEntry->m_pNext;
1700 currentEntry = currentEntry->m_pNext;
1701 }
1702 return result;
1703}
1704
1705// Adapted from dll/win32/atl/atl.c
1706inline HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex,
1707 BSTR *pbstrPath, ITypeLib **ppTypeLib)
1708{
1709 size_t index_len = lpszIndex ? wcslen(lpszIndex) : 0;
1711 path.Allocate(MAX_PATH + index_len + wcslen(L".tlb"));
1712
1713 if (!path)
1714 return E_OUTOFMEMORY;
1715
1716 size_t path_len = GetModuleFileNameW(inst, path, MAX_PATH);
1717 if (!path_len)
1719
1720 if (index_len)
1721 wcscat(path, lpszIndex);
1722
1724 HRESULT hResult = LoadTypeLib(path, &typelib);
1725 if (FAILED(hResult))
1726 {
1727 WCHAR *ptr;
1728 for (ptr = path+path_len-1; ptr > path && *ptr != '\\' && *ptr != '.'; ptr--)
1729 ;
1730 if (*ptr != '.')
1731 ptr = (WCHAR*)path + path_len;
1732 wcscpy(ptr, L".tlb");
1733
1734 hResult = LoadTypeLib(path, &typelib);
1735 }
1736
1737 if (SUCCEEDED(hResult))
1738 {
1739 *pbstrPath = SysAllocString(path);
1740 if (!*pbstrPath)
1741 {
1742 typelib.Release();
1743 hResult = E_OUTOFMEMORY;
1744 }
1745 }
1746
1747 if (FAILED(hResult))
1748 return hResult;
1749
1750 *ppTypeLib = typelib.Detach();
1751 return S_OK;
1752}
1753
1754// Adapted from dll/win32/atl/atl.c
1756{
1757 CComBSTR path;
1759 HRESULT hResult = AtlLoadTypeLib(inst, index, &path, &typelib);
1760 if (FAILED(hResult))
1761 return hResult;
1762
1763 return RegisterTypeLib(typelib, path, NULL); /* FIXME: pass help directory */
1764}
1765
1766// Adapted from dll/win32/atl/atl.c
1768{
1769 if (!catmap)
1770 return S_OK;
1771
1773
1774 HRESULT hResult = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&catreg);
1775 if (FAILED(hResult))
1776 return hResult;
1777
1778 for (const _ATL_CATMAP_ENTRY *iter = catmap; iter->iType != _ATL_CATMAP_ENTRY_END; iter++)
1779 {
1780 CATID catid = *iter->pcatid;
1781
1782 if (iter->iType == _ATL_CATMAP_ENTRY_IMPLEMENTED)
1783 {
1784 if (reg)
1786 else
1788 }
1789 else
1790 {
1791 if (reg)
1793 else
1795 }
1796 if (FAILED(hResult))
1797 return hResult;
1798 }
1799
1800 if (!reg)
1801 {
1802 WCHAR reg_path[256] = L"CLSID\\";
1803
1804 StringFromGUID2(clsid, reg_path + wcslen(reg_path), 64);
1805 wcscat(reg_path, L"\\");
1806 WCHAR* ptr = reg_path + wcslen(reg_path);
1807
1808 wcscpy(ptr, L"Implemented Categories");
1810
1811 wcscpy(ptr, L"Required Categories");
1813 }
1814
1815 return hResult;
1816}
1817
1818
1819// Adapted from dll/win32/atl80/atl80.c
1821{
1822 HRESULT hResult = S_OK;
1823
1824 for (_ATL_OBJMAP_ENTRY ** iter = mod->m_ppAutoObjMapFirst; iter < mod->m_ppAutoObjMapLast; iter++)
1825 {
1826 if (!*iter)
1827 continue;
1828 _ATL_OBJMAP_ENTRY* entry = *iter;
1829 if (clsid && !IsEqualCLSID(*entry->pclsid, *clsid))
1830 continue;
1831
1832 hResult = entry->pfnUpdateRegistry(TRUE);
1833 if (FAILED(hResult))
1834 return hResult;
1835
1836 const _ATL_CATMAP_ENTRY *catmap = entry->pfnGetCategoryMap();
1837 if (catmap)
1838 {
1839 hResult = AtlRegisterClassCategoriesHelper(*entry->pclsid, catmap, TRUE);
1840 if (FAILED(hResult))
1841 return hResult;
1842 }
1843 }
1844
1845 if (bRegTypeLib)
1846 {
1847 hResult = AtlRegisterTypeLib(mod->m_hInstTypeLib, NULL);
1848 }
1849
1850 return hResult;
1851}
1852
1853// Adapted from dll/win32/atl/atl.c
1855{
1856 HRESULT hResult = S_OK;
1857
1858 for (_ATL_OBJMAP_ENTRY **iter = mod->m_ppAutoObjMapFirst; iter < mod->m_ppAutoObjMapLast; iter++)
1859 {
1860 if (!*iter)
1861 continue;
1862 _ATL_OBJMAP_ENTRY* entry = *iter;
1863 if (clsid && !IsEqualCLSID(*entry->pclsid, *clsid))
1864 continue;
1865
1866 const _ATL_CATMAP_ENTRY *catmap = entry->pfnGetCategoryMap();
1867 if (catmap)
1868 {
1869 hResult = AtlRegisterClassCategoriesHelper(*entry->pclsid, catmap, FALSE);
1870 if (FAILED(hResult))
1871 return hResult;
1872 }
1873
1874 hResult = entry->pfnUpdateRegistry(FALSE);
1875 if (FAILED(hResult))
1876 return hResult;
1877 }
1878
1879 if (bUnRegTypeLib)
1880 {
1882 TLIBATTR *attr;
1883 CComBSTR path;
1884
1885 hResult = AtlLoadTypeLib(mod->m_hInstTypeLib, NULL, &path, &typelib);
1886 if (FAILED(hResult))
1887 return hResult;
1888
1889 hResult = typelib->GetLibAttr(&attr);
1890 if (SUCCEEDED(hResult))
1891 {
1892 hResult = UnRegisterTypeLib(attr->guid, attr->wMajorVerNum, attr->wMinorVerNum, attr->lcid, attr->syskind);
1893 typelib->ReleaseTLibAttr(attr);
1894 }
1895 }
1896
1897 return hResult;
1898}
1899
1900
1901// Adapted from dll/win32/atl/atl.c
1903{
1904 _ATL_OBJMAP_ENTRY **iter;
1905 IUnknown* unk = NULL;
1906 HRESULT hr;
1907
1908 if (!module)
1909 return E_INVALIDARG;
1910
1911 for (iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++)
1912 {
1913 _ATL_OBJMAP_ENTRY *ptr = *iter;
1914 if (!ptr)
1915 continue;
1916
1917 if (!ptr->pfnGetClassObject)
1918 continue;
1919
1920 hr = ptr->pfnGetClassObject((void*)ptr->pfnCreateInstance, IID_IUnknown, (void**)&unk);
1921 if (FAILED(hr))
1922 return hr;
1923
1924 hr = CoRegisterClassObject(*ptr->pclsid, unk, context, flags, &ptr->dwRegister);
1925 unk->Release();
1926 if (FAILED(hr))
1927 return hr;
1928 }
1929
1930 return S_OK;
1931}
1932
1933
1934// Adapted from dll/win32/atl/atl.c
1936{
1937 _ATL_OBJMAP_ENTRY **iter;
1938 HRESULT hr;
1939
1940 if (!module)
1941 return E_INVALIDARG;
1942
1943 for (iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++)
1944 {
1945 _ATL_OBJMAP_ENTRY *ptr = *iter;
1946 if (!ptr)
1947 continue;
1948
1949 hr = CoRevokeClassObject(ptr->dwRegister);
1950 if (FAILED(hr))
1951 return hr;
1952 }
1953
1954 return S_OK;
1955}
1956
1957// Adapted from dll/win32/atl/atl.c
1958inline HRESULT WINAPI
1960{
1961 if (!pm)
1962 return E_INVALIDARG;
1963
1964 for (_ATL_OBJMAP_ENTRY **iter = pm->m_ppAutoObjMapFirst; iter < pm->m_ppAutoObjMapLast; iter++)
1965 {
1966 _ATL_OBJMAP_ENTRY *ptr = *iter;
1967 if (!ptr)
1968 continue;
1969
1970 if (IsEqualCLSID(*ptr->pclsid, rclsid) && ptr->pfnGetClassObject)
1971 {
1973
1974 if (!ptr->pCF)
1975 {
1977 if (!ptr->pCF)
1978 {
1979 hr = ptr->pfnGetClassObject((void *)ptr->pfnCreateInstance, IID_IUnknown, (void **)&ptr->pCF);
1980 }
1981 }
1982 if (ptr->pCF)
1983 hr = ptr->pCF->QueryInterface(riid, ppv);
1984 return hr;
1985 }
1986 }
1987
1989}
1990
1991
1992}; // namespace ATL
1993
1994#ifndef _ATL_NO_AUTOMATIC_NAMESPACE
1995using namespace ATL;
1996#endif
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:66
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define msg(x)
Definition: auth_time.c:54
const GUID IID_IUnknown
HANDLE HKEY
Definition: registry.h:26
HINSTANCE hInstance
Definition: charmap.c:19
static bool m_bInitFailed
Definition: atlcore.h:193
HRESULT UnregisterServer(BOOL bUnRegTypeLib, const CLSID *pCLSID=NULL)
Definition: atlbase.h:625
void ExecuteObjectMain(bool bStarting)
Definition: atlbase.h:651
HRESULT RegisterServer(BOOL bRegTypeLib=FALSE, const CLSID *pCLSID=NULL)
Definition: atlbase.h:620
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:705
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:723
HRESULT GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:733
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:713
HRESULT DllCanUnloadNow()
Definition: atlbase.h:695
HRESULT Run(int nShowCmd=SW_HIDE)
Definition: atlbase.h:781
HRESULT PreMessageLoop(int nShowCmd)
Definition: atlbase.h:818
DWORD m_dwMainThreadID
Definition: atlbase.h:746
int WinMain(int nShowCmd)
Definition: atlbase.h:762
HRESULT PostMessageLoop()
Definition: atlbase.h:834
void RunMessageLoop()
Definition: atlbase.h:824
HRESULT RevokeClassObjects()
Definition: atlbase.h:845
HRESULT RegisterClassObjects(DWORD dwClsContext, DWORD dwFlags)
Definition: atlbase.h:840
static HRESULT InitializeCom()
Definition: atlbase.h:850
static void UninitializeCom()
Definition: atlbase.h:860
bool ParseCommandLine(LPCTSTR lpCmdLine, HRESULT *pnRetCode)
Definition: atlbase.h:812
HRESULT UnregisterServer(BOOL bUnRegTypeLib, const CLSID *pCLSID=NULL)
Definition: atlbase.h:673
virtual HRESULT AddCommonRGSReplacements(IRegistrarBase *pRegistrar)
Definition: atlbase.h:586
static LPCOLESTR GetAppId()
Definition: atlbase.h:591
HRESULT RegisterServer(BOOL bRegTypeLib=FALSE, const CLSID *pCLSID=NULL)
Definition: atlbase.h:667
virtual LONG Unlock()
Definition: atlbase.h:482
static GUID m_libid
Definition: atlbase.h:462
HRESULT WINAPI UpdateRegistryFromResource(UINT nResID, BOOL bRegister, struct _ATL_REGMAP_ENTRY *pMapEntries=NULL)
Definition: atlbase.h:515
HRESULT WINAPI UpdateRegistryFromResource(LPCTSTR lpszRes, BOOL bRegister, struct _ATL_REGMAP_ENTRY *pMapEntries=NULL)
Definition: atlbase.h:489
virtual LONG GetLockCount()
Definition: atlbase.h:472
virtual HRESULT AddCommonRGSReplacements(IRegistrarBase *)=0
virtual LONG Lock()
Definition: atlbase.h:477
HRESULT CommonInitRegistrar(CRegObject &registrar, WCHAR *modulePath, DWORD modulePathCount, struct _ATL_REGMAP_ENTRY *pMapEntries)
Definition: atlbase.h:534
void AddCreateWndData(_AtlCreateWndData *pData, void *pObject)
Definition: atlbase.h:1079
void * ExtractCreateWndData()
Definition: atlbase.h:1084
static void * Allocate(_In_ size_t size)
Definition: atlbase.h:1096
static void * Reallocate(_In_opt_ void *ptr, _In_ size_t size)
Definition: atlbase.h:1101
static void Free(_In_opt_ void *ptr)
Definition: atlbase.h:1106
CComCritSecLock(TLock &cs, bool bInitialLock=true)
Definition: atlbase.h:252
HRESULT Lock()
Definition: atlbase.h:273
CComHeapPtr(T *lp)
Definition: atlbase.h:1558
void Term()
Definition: atlbase.h:916
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:1037
HRESULT RegisterServer(BOOL bRegTypeLib=FALSE, const CLSID *pCLSID=NULL)
Definition: atlbase.h:979
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:1047
HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE, const GUID *plibid)
Definition: atlbase.h:886
HRESULT DllCanUnloadNow()
Definition: atlbase.h:1030
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:1042
_ATL_OBJMAP_ENTRY * m_pObjMap
Definition: atlbase.h:872
HRESULT UnregisterServer(BOOL bUnRegTypeLib, const CLSID *pCLSID=NULL)
Definition: atlbase.h:1004
HRESULT GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:941
CComFakeCriticalSection AutoCriticalSection
Definition: atlbase.h:386
CComMultiThreadModelNoCS ThreadModelNoCS
Definition: atlbase.h:388
static ULONG WINAPI Increment(LPLONG p)
Definition: atlbase.h:391
static ULONG WINAPI Decrement(LPLONG p)
Definition: atlbase.h:396
CComFakeCriticalSection CriticalSection
Definition: atlbase.h:387
CComFakeCriticalSection AutoDeleteCriticalSection
Definition: atlbase.h:389
static ULONG WINAPI Decrement(LPLONG p)
Definition: atlbase.h:415
static ULONG WINAPI Increment(LPLONG p)
Definition: atlbase.h:410
CComCriticalSection CriticalSection
Definition: atlbase.h:406
CComAutoDeleteCriticalSection AutoDeleteCriticalSection
Definition: atlbase.h:408
CComMultiThreadModelNoCS ThreadModelNoCS
Definition: atlbase.h:407
CComAutoCriticalSection AutoCriticalSection
Definition: atlbase.h:405
CComSingleThreadModel ThreadModelNoCS
Definition: atlbase.h:426
CComFakeCriticalSection CriticalSection
Definition: atlbase.h:425
static ULONG WINAPI Decrement(LPLONG p)
Definition: atlbase.h:434
static ULONG WINAPI Increment(LPLONG p)
Definition: atlbase.h:429
CComFakeCriticalSection AutoCriticalSection
Definition: atlbase.h:424
CComFakeCriticalSection AutoDeleteCriticalSection
Definition: atlbase.h:427
HANDLE Detach()
Definition: atlbase.h:356
CHandle & operator=(_Inout_ CHandle &handle)
Definition: atlbase.h:331
CHandle(_Inout_ CHandle &handle)
Definition: atlbase.h:312
HANDLE m_handle
Definition: atlbase.h:304
void Close()
Definition: atlbase.h:363
CHandle(_In_ HANDLE handle)
Definition: atlbase.h:318
void Attach(_In_ HANDLE handle)
Definition: atlbase.h:350
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE) noexcept
Definition: atlbase.h:1173
LONG SetQWORDValue(LPCTSTR pszValueName, ULONGLONG qwValue) noexcept
Definition: atlbase.h:1355
static LONG _DoDeleteKeyTree(HKEY hParentKey, LPCTSTR lpszKey)
Definition: atlbase.h:1478
LONG SetStringValue(LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType=REG_SZ) noexcept
Definition: atlbase.h:1315
LONG SetKeySecurity(SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR psd) noexcept
Definition: atlbase.h:1438
LONG QueryValue(LPCTSTR pszValueName, DWORD *pdwType, void *pData, ULONG *pnBytes) noexcept
Definition: atlbase.h:1211
LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars) noexcept
Definition: atlbase.h:1240
CRegKey(HKEY hKey) noexcept
Definition: atlbase.h:1133
HKEY m_hKey
Definition: atlbase.h:1115
LONG SetDWORDValue(LPCTSTR pszValueName, DWORD dwValue) noexcept
Definition: atlbase.h:1310
static LONG WINAPI SetValue(HKEY hKeyParent, LPCTSTR lpszKeyName, LPCTSTR lpszValue, LPCTSTR lpszValueName=NULL)
Definition: atlbase.h:1377
LONG Create(HKEY hKeyParent, LPCTSTR lpszKeyName, LPTSTR lpszClass=REG_NONE, DWORD dwOptions=REG_OPTION_NON_VOLATILE, REGSAM samDesired=KEY_READ|KEY_WRITE, LPSECURITY_ATTRIBUTES lpSecAttr=NULL, LPDWORD lpdwDisposition=NULL) noexcept
Definition: atlbase.h:1189
LONG Flush() noexcept
Definition: atlbase.h:1370
LONG QueryMultiStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars) noexcept
Definition: atlbase.h:1290
LONG QueryDWORDValue(LPCTSTR pszValueName, DWORD &dwValue) noexcept
Definition: atlbase.h:1217
HKEY Detach() noexcept
Definition: atlbase.h:1166
static ULONG _GetMultiStringSize(LPCTSTR pszz)
Definition: atlbase.h:1463
LONG DeleteSubKey(LPCTSTR lpszSubKey) noexcept
Definition: atlbase.h:1407
LONG SetMultiStringValue(LPCTSTR pszValueName, LPCTSTR pszValue) noexcept
Definition: atlbase.h:1349
LONG SetBinaryValue(LPCTSTR pszValueName, const void *pValue, ULONG nBytes) noexcept
Definition: atlbase.h:1344
CRegKey(CRegKey &key) noexcept
Definition: atlbase.h:1128
LONG QueryGUIDValue(LPCTSTR pszValueName, GUID &guidValue) noexcept
Definition: atlbase.h:1253
LONG SetKeyValue(LPCTSTR lpszKeyName, LPCTSTR lpszValue, LPCTSTR lpszValueName=NULL) noexcept
Definition: atlbase.h:1389
LONG NotifyChangeKeyValue(BOOL bWatchSubtree, DWORD dwNotifyFilter, HANDLE hEvent, BOOL bAsync=TRUE) noexcept
Definition: atlbase.h:1361
LONG QueryQWORDValue(LPCTSTR pszValueName, ULONGLONG &qwValue) noexcept
Definition: atlbase.h:1278
CRegKey & operator=(CRegKey &key) noexcept
Definition: atlbase.h:1451
~CRegKey() noexcept
Definition: atlbase.h:1146
CRegKey() noexcept
Definition: atlbase.h:1123
LONG Close() noexcept
Definition: atlbase.h:1156
LONG EnumKey(DWORD iIndex, LPTSTR pszName, LPDWORD pnNameLength, FILETIME *pftLastWriteTime=NULL) noexcept
Definition: atlbase.h:1421
LONG QueryBinaryValue(LPCTSTR pszValueName, void *pValue, ULONG *pnBytes) noexcept
Definition: atlbase.h:1229
LONG GetKeySecurity(SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR psd, LPDWORD pnBytes) noexcept
Definition: atlbase.h:1430
LONG RecurseDeleteKey(LPCTSTR lpszKey) noexcept
Definition: atlbase.h:1414
LONG SetGUIDValue(LPCTSTR pszValueName, REFGUID guidValue) noexcept
Definition: atlbase.h:1331
LONG DeleteValue(LPCTSTR lpszValue) noexcept
Definition: atlbase.h:1401
LONG SetValue(LPCTSTR pszValueName, DWORD dwType, const void *pValue, ULONG nBytes) noexcept
Definition: atlbase.h:1304
void Attach(HKEY hKey) noexcept
Definition: atlbase.h:1151
HRESULT STDMETHODCALLTYPE ResourceUnregisterSz(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
Definition: statreg.h:145
HRESULT STDMETHODCALLTYPE ResourceRegisterSz(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
Definition: statreg.h:140
HRESULT STDMETHODCALLTYPE ResourceUnregister(LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
Definition: statreg.h:175
HRESULT STDMETHODCALLTYPE AddReplacement(LPCOLESTR key, LPCOLESTR item)
Definition: statreg.h:87
HRESULT STDMETHODCALLTYPE ResourceRegister(LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
Definition: statreg.h:170
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2951
LONG WINAPI RegGetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, LPDWORD lpcbSecurityDescriptor)
Definition: reg.c:2987
LONG WINAPI RegSetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor)
Definition: reg.c:4759
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
LONG WINAPI RegNotifyChangeKeyValue(HKEY hKey, BOOL bWatchSubtree, DWORD dwNotifyFilter, HANDLE hEvent, BOOL fAsynchronous)
Definition: reg.c:3152
static ICatRegister * catreg
Definition: atl.c:40
#define CloseHandle
Definition: compat.h:739
#define CP_ACP
Definition: compat.h:109
WCHAR OLECHAR
Definition: compat.h:2292
OLECHAR * BSTR
Definition: compat.h:2293
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:866
HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid, LPUNKNOWN pUnk, DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister)
Definition: compobj.c:2897
ULONG WINAPI CoAddRefServerProcess(void)
Definition: compobj.c:4162
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI DECLSPEC_HOTPATCH CoRevokeClassObject(DWORD dwRegister)
Definition: compobj.c:1086
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
ULONG WINAPI CoReleaseServerProcess(void)
Definition: compobj.c:4193
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
HRESULT WINAPI RegisterTypeLib(ITypeLib *ptlib, const WCHAR *szFullPath, const WCHAR *szHelpDir)
Definition: typelib.c:656
HRESULT WINAPI UnRegisterTypeLib(REFGUID libid, WORD wVerMajor, WORD wVerMinor, LCID lcid, SYSKIND syskind)
Definition: typelib.c:882
HRESULT WINAPI LoadTypeLib(const OLECHAR *szFile, ITypeLib **pptLib)
Definition: typelib.c:458
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
FxObject * pObject
PWCHAR pValue
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static int reg
Definition: i386-dis.c:1290
#define cs
Definition: i386-dis.c:442
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define ULONG_MAX
Definition: limits.h:44
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define _ATL_CATMAP_ENTRY_END
Definition: atlbase.h:253
#define _ATL_CATMAP_ENTRY_IMPLEMENTED
Definition: atlbase.h:254
HRESULT RegisterClassReqCategories([in] REFCLSID rclsid, [in] ULONG cCategories, [in, size_is(cCategories)] CATID rgcatid[])
HRESULT RegisterClassImplCategories([in] REFCLSID rclsid, [in] ULONG cCategories, [in, size_is(cCategories)] CATID rgcatid[])
HRESULT UnRegisterClassImplCategories([in] REFCLSID rclsid, [in] ULONG cCategories, [in, size_is(cCategories)] CATID rgcatid[])
HRESULT UnRegisterClassReqCategories([in] REFCLSID rclsid, [in] ULONG cCategories, [in, size_is(cCategories)] CATID rgcatid[])
HRESULT AddReplacement([in] LPCOLESTR Key, [in] LPCOLESTR item)
ULONG AddRef()
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
nsresult QueryInterface(nsIIDRef riid, void **result)
nsrefcnt Release()
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
uint32_t entry
Definition: isohybrid.c:63
#define TEXT(s)
Definition: k32.h:26
#define REG_SZ
Definition: layer.c:22
#define T
Definition: mbstring.h:31
static LPMONITOREX pm
Definition: localmon.c:45
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static PVOID ptr
Definition: dispmode.c:27
static DWORD path_len
Definition: batch.c:31
@ SetValue
Definition: shader.c:1968
static HANDLE hEvent
Definition: comm.c:54
WORD unused[29]
Definition: crypt.c:1155
DWORD SECURITY_INFORMATION
Definition: ms-dtyp.idl:311
#define _Inout_
Definition: ms_sal.h:378
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
REFCLSID clsid
Definition: msctf.c:82
GUID catid
Definition: msctf.idl:647
Definition: rosdlgs.h:6
__declspec(selectany) CAtlModule *_pAtlModule
Definition: atlbase.h:575
_ATL_COM_MODULE70 _ATL_COM_MODULE
Definition: atlbase.h:172
_ATL_MODULE70 _ATL_MODULE
Definition: atlbase.h:144
HRESULT WINAPI AtlComModuleGetClassObject(_ATL_COM_MODULE *pComModule, REFCLSID rclsid, REFIID riid, LPVOID *ppv)
HRESULT __stdcall AtlUnadvise(IUnknown *pUnkCP, const IID &iid, DWORD dw)
Definition: atlbase.h:1582
HRESULT __stdcall AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID &iid, LPDWORD pdw)
Definition: atlbase.h:1565
HRESULT WINAPI AtlRegisterTypeLib(HINSTANCE inst, const WCHAR *index)
Definition: atlbase.h:1755
void WINAPI AtlWinModuleAddCreateWndData(_ATL_WIN_MODULE *pWinModule, _AtlCreateWndData *pData, void *pObject)
Definition: atlbase.h:1664
_ATL_OBJMAP_ENTRY30 _ATL_OBJMAP_ENTRY
Definition: atlbase.h:126
HRESULT WINAPI AtlInternalQueryInterface(void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
Definition: atlbase.h:1599
HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD context, DWORD flags)
Definition: atlbase.h:1902
HRESULT WINAPI AtlComModuleRegisterServer(_ATL_COM_MODULE *mod, BOOL bRegTypeLib, const CLSID *clsid)
Definition: atlbase.h:1820
CComMultiThreadModel CComGlobalsThreadModel
Definition: atlbase.h:443
HRESULT WINAPI AtlWinModuleInit(_ATL_WIN_MODULE *pWinModule)
Definition: atlbase.h:1648
void *WINAPI AtlWinModuleExtractCreateWndData(_ATL_WIN_MODULE *pWinModule)
Definition: atlbase.h:1677
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:146
_ATL_WIN_MODULE70 _ATL_WIN_MODULE
Definition: atlbase.h:183
HRESULT WINAPI AtlComModuleUnregisterServer(_ATL_COM_MODULE *mod, BOOL bRegTypeLib, const CLSID *clsid)
Definition: atlbase.h:1854
const struct _ATL_CATMAP_ENTRY *() _ATL_CATMAPFUNC()
Definition: atlbase.h:85
CComMultiThreadModel CComObjectThreadModel
Definition: atlbase.h:442
HRESULT WINAPI AtlComModuleRevokeClassObjects(_ATL_COM_MODULE *module)
Definition: atlbase.h:1935
HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex, BSTR *pbstrPath, ITypeLib **ppTypeLib)
Definition: atlbase.h:1706
REFIID LPVOID * ppv
Definition: atlbase.h:83
HRESULT WINAPI AtlWinModuleTerm(_ATL_WIN_MODULE *pWinModule, HINSTANCE hInst)
Definition: atlbase.h:1656
HRESULT WINAPI AtlRegisterClassCategoriesHelper(REFCLSID clsid, const _ATL_CATMAP_ENTRY *catmap, BOOL reg)
Definition: atlbase.h:1767
REFIID riid
Definition: atlbase.h:83
BOOL WINAPI InlineIsEqualUnknown(REFGUID rguid1)
Definition: atlbase.h:374
unsigned int UINT
Definition: ndis.h:50
int Count
Definition: noreturn.cpp:7
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_READ
Definition: nt_native.h:1023
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define KEY_WRITE
Definition: nt_native.h:1031
#define DWORD
Definition: nt_native.h:44
#define REG_NONE
Definition: nt_native.h:1492
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define L(x)
Definition: ntvdm.h:50
@ REGCLS_MULTIPLEUSE
Definition: objbase.h:393
enum tagCOINIT COINIT
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
@ COINIT_MULTITHREADED
Definition: objbase.h:279
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
const GUID IID_IConnectionPointContainer
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define InlineIsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:142
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
#define REG_QWORD
Definition: sdbapi.c:597
#define REG_DWORD
Definition: sdbapi.c:596
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
HRESULT hr
Definition: shlfolder.c:183
DWORD dwOptions
Definition: solitaire.cpp:25
Definition: atlbase.h:73
const GUID * pcatid
Definition: atlbase.h:75
int iType
Definition: atlbase.h:74
HINSTANCE m_hInstTypeLib
Definition: atlbase.h:167
_ATL_OBJMAP_ENTRY ** m_ppAutoObjMapLast
Definition: atlbase.h:169
_ATL_OBJMAP_ENTRY ** m_ppAutoObjMapFirst
Definition: atlbase.h:168
CComCriticalSection m_csObjMap
Definition: atlbase.h:170
Definition: atlbase.h:151
const IID * piid
Definition: atlbase.h:152
DWORD_PTR dw
Definition: atlbase.h:153
_ATL_CREATORARGFUNC * pFunc
Definition: atlbase.h:154
CComCriticalSection m_csStaticDataInitAndTypeInfo
Definition: atlbase.h:142
_ATL_TERMFUNC_ELEM * m_pTermFuncs
Definition: atlbase.h:141
_ATL_CREATORFUNC * pfnGetClassObject
Definition: atlbase.h:91
HRESULT WINAPI RegisterClassObject(DWORD dwClsContext, DWORD dwFlags)
Definition: atlbase.h:106
_ATL_DESCRIPTIONFUNC * pfnGetObjectDescription
Definition: atlbase.h:95
_ATL_CATMAPFUNC * pfnGetCategoryMap
Definition: atlbase.h:96
HRESULT(WINAPI *pfnUpdateRegistry)(BOOL bRegister)
_ATL_CREATORFUNC * pfnCreateInstance
Definition: atlbase.h:92
const CLSID * pclsid
Definition: atlbase.h:89
void(WINAPI *pfnObjectMain)(bool bStarting)
HRESULT WINAPI RevokeClassObject()
Definition: atlbase.h:99
Definition: atlbase.h:226
LPCOLESTR szData
Definition: atlbase.h:228
LPCOLESTR szKey
Definition: atlbase.h:227
_ATL_TERMFUNC * pFunc
Definition: atlbase.h:132
_ATL_TERMFUNC_ELEM * pNext
Definition: atlbase.h:134
CComCriticalSection m_csWindowCreate
Definition: atlbase.h:177
_AtlCreateWndData * m_pCreateWndList
Definition: atlbase.h:178
_AtlCreateWndData * m_pNext
Definition: atlbase.h:161
Definition: scsiwmi.h:51
Definition: cookie.c:202
Definition: http.c:7252
Definition: copy.c:22
rwlock_t lock
Definition: tcpcore.h:0
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t DWORD_PTR
Definition: typedefs.h:65
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t * LPLONG
Definition: typedefs.h:58
PVOID HANDLE
Definition: typedefs.h:73
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t * LPDWORD
Definition: typedefs.h:59
#define __stdcall
Definition: typedefs.h:25
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define GetCommandLine
Definition: winbase.h:3823
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define E_POINTER
Definition: winerror.h:2365
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define CP_THREAD_ACP
Definition: winnls.h:233
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegCreateKeyEx
Definition: winreg.h:501
ACCESS_MASK REGSAM
Definition: winreg.h:69
#define RegDeleteKey
Definition: winreg.h:502
#define RegEnumKeyEx
Definition: winreg.h:510
#define RegQueryInfoKey
Definition: winreg.h:521
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define SW_HIDE
Definition: winuser.h:771
#define WM_QUIT
Definition: winuser.h:1626
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define PostThreadMessage
Definition: winuser.h:5845
#define GetMessage
Definition: winuser.h:5802
#define DispatchMessage
Definition: winuser.h:5777
char TCHAR
Definition: xmlstorage.h:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
CHAR * LPTSTR
Definition: xmlstorage.h:192
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define _tcslen
Definition: xmlstorage.h:198
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193
#define const
Definition: zconf.h:233