ReactOS 0.4.17-dev-804-g023d8af
atl.c
Go to the documentation of this file.
1/*
2 * Copyright 2012 Stefan Leichter
3 * Copyright 2012 Jacek Caban for CodeWeavers
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#define COBJMACROS
21
22#include "atlbase.h"
23#include "atlcom.h"
24
25#include "wine/debug.h"
26
27#ifdef __REACTOS__
28#include <wingdi.h>
29#endif
30
32
33#define ATLVer1Size FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer)
34
35typedef unsigned char cpp_bool;
36
38
39/***********************************************************************
40 * AtlAdvise [atl100.@]
41 */
42HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, DWORD *pdw)
43{
47
48 TRACE("%p %p %p %p\n", pUnkCP, pUnk, iid, pdw);
49
50 if(!pUnkCP)
51 return E_INVALIDARG;
52
53 hres = IUnknown_QueryInterface(pUnkCP, &IID_IConnectionPointContainer, (void**)&container);
54 if(FAILED(hres))
55 return hres;
56
57 hres = IConnectionPointContainer_FindConnectionPoint(container, iid, &cp);
58 IConnectionPointContainer_Release(container);
59 if(FAILED(hres))
60 return hres;
61
62 hres = IConnectionPoint_Advise(cp, pUnk, pdw);
63 IConnectionPoint_Release(cp);
64 return hres;
65}
66
67/***********************************************************************
68 * AtlUnadvise [atl100.@]
69 */
71{
75
76 TRACE("%p %p %ld\n", pUnkCP, iid, dw);
77
78 if(!pUnkCP)
79 return E_INVALIDARG;
80
81 hres = IUnknown_QueryInterface(pUnkCP, &IID_IConnectionPointContainer, (void**)&container);
82 if(FAILED(hres))
83 return hres;
84
85 hres = IConnectionPointContainer_FindConnectionPoint(container, iid, &cp);
86 IConnectionPointContainer_Release(container);
87 if(FAILED(hres))
88 return hres;
89
90 hres = IConnectionPoint_Unadvise(cp, dw);
91 IConnectionPoint_Release(cp);
92 return hres;
93}
94
95/***********************************************************************
96 * AtlFreeMarshalStream [atl100.@]
97 */
99{
100 FIXME("%p\n", stm);
101 return S_OK;
102}
103
104/***********************************************************************
105 * AtlMarshalPtrInProc [atl100.@]
106 */
108{
109 FIXME("%p %p %p\n", pUnk, iid, pstm);
110 return E_FAIL;
111}
112
113/***********************************************************************
114 * AtlUnmarshalPtr [atl100.@]
115 */
117{
118 FIXME("%p %p %p\n", stm, iid, ppUnk);
119 return E_FAIL;
120}
121
122/***********************************************************************
123 * AtlCreateTargetDC [atl100.@]
124 */
125HDC WINAPI AtlCreateTargetDC( HDC hdc, DVTARGETDEVICE *dv )
126{
127 const WCHAR *driver = NULL, *device = NULL, *port = NULL;
129
130 TRACE( "(%p, %p)\n", hdc, dv );
131
132 if (dv)
133 {
134 if (dv->tdDriverNameOffset) driver = (WCHAR *)((char *)dv + dv->tdDriverNameOffset);
135 if (dv->tdDeviceNameOffset) device = (WCHAR *)((char *)dv + dv->tdDeviceNameOffset);
136 if (dv->tdPortNameOffset) port = (WCHAR *)((char *)dv + dv->tdPortNameOffset);
137 if (dv->tdExtDevmodeOffset) devmode = (DEVMODEW *)((char *)dv + dv->tdExtDevmodeOffset);
138 }
139 else
140 {
141 if (hdc) return hdc;
142 driver = L"display";
143 }
144 return CreateDCW( driver, device, port, devmode );
145}
146
147/***********************************************************************
148 * AtlHiMetricToPixel [atl100.@]
149 */
150void WINAPI AtlHiMetricToPixel(const SIZEL* lpHiMetric, SIZEL* lpPix)
151{
152 HDC dc = GetDC(NULL);
153 lpPix->cx = lpHiMetric->cx * GetDeviceCaps( dc, LOGPIXELSX ) / 100;
154 lpPix->cy = lpHiMetric->cy * GetDeviceCaps( dc, LOGPIXELSY ) / 100;
155 ReleaseDC( NULL, dc );
156}
157
158/***********************************************************************
159 * AtlPixelToHiMetric [atl100.@]
160 */
161void WINAPI AtlPixelToHiMetric(const SIZEL* lpPix, SIZEL* lpHiMetric)
162{
163 HDC dc = GetDC(NULL);
164 lpHiMetric->cx = 100 * lpPix->cx / GetDeviceCaps( dc, LOGPIXELSX );
165 lpHiMetric->cy = 100 * lpPix->cy / GetDeviceCaps( dc, LOGPIXELSY );
166 ReleaseDC( NULL, dc );
167}
168
169/***********************************************************************
170 * AtlComPtrAssign [atl100.@]
171 */
173{
174 TRACE("(%p %p)\n", pp, p);
175
176 if (p) IUnknown_AddRef(p);
177 if (*pp) IUnknown_Release(*pp);
178 *pp = p;
179 return p;
180}
181
182/***********************************************************************
183 * AtlComQIPtrAssign [atl100.@]
184 */
186{
187 IUnknown *new_p = NULL;
188
189 TRACE("(%p %p %s)\n", pp, p, debugstr_guid(riid));
190
191 if (p) IUnknown_QueryInterface(p, riid, (void **)&new_p);
192 if (*pp) IUnknown_Release(*pp);
193 *pp = new_p;
194 return new_p;
195}
196
197/***********************************************************************
198 * AtlInternalQueryInterface [atl100.@]
199 */
200HRESULT WINAPI AtlInternalQueryInterface(void* this, const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, void** ppvObject)
201{
202 int i = 0;
204 TRACE("(%p, %p, %s, %p)\n",this, pEntries, debugstr_guid(iid), ppvObject);
205
206 if (IsEqualGUID(iid,&IID_IUnknown))
207 {
208 TRACE("Returning IUnknown\n");
209 *ppvObject = ((LPSTR)this+pEntries[0].dw);
210 IUnknown_AddRef((IUnknown*)*ppvObject);
211 return S_OK;
212 }
213
214 while (pEntries[i].pFunc != 0)
215 {
216 TRACE("Trying entry %i (%s %Ix %p)\n",i,debugstr_guid(pEntries[i].piid),
217 pEntries[i].dw, pEntries[i].pFunc);
218
219 if (!pEntries[i].piid || IsEqualGUID(iid,pEntries[i].piid))
220 {
221 TRACE("MATCH\n");
222 if (pEntries[i].pFunc == (_ATL_CREATORARGFUNC*)1)
223 {
224 TRACE("Offset\n");
225 *ppvObject = ((LPSTR)this+pEntries[i].dw);
226 IUnknown_AddRef((IUnknown*)*ppvObject);
227 return S_OK;
228 }
229 else
230 {
231 TRACE("Function\n");
232 rc = pEntries[i].pFunc(this, iid, ppvObject, pEntries[i].dw);
233 if(rc==S_OK || pEntries[i].piid)
234 return rc;
235 }
236 }
237 i++;
238 }
239 TRACE("Done returning (0x%lx)\n",rc);
240 return rc;
241}
242
243/***********************************************************************
244 * AtlIPersistStreamInit_Load [atl100.@]
245 */
247 void *pThis, IUnknown *pUnk)
248{
249 FIXME("(%p, %p, %p, %p)\n", pStm, pMap, pThis, pUnk);
250
251 return S_OK;
252}
253
254/***********************************************************************
255 * AtlIPersistStreamInit_Save [atl100.@]
256 */
258 ATL_PROPMAP_ENTRY *pMap, void *pThis,
259 IUnknown *pUnk)
260{
261 FIXME("(%p, %d, %p, %p, %p)\n", pStm, fClearDirty, pMap, pThis, pUnk);
262
263 return S_OK;
264}
265
266/***********************************************************************
267 * AtlIPersistPropertyBag_Load [atl100.@]
268 */
269HRESULT WINAPI AtlIPersistPropertyBag_Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog,
270 ATL_PROPMAP_ENTRY *pMap, void *pThis,
271 IUnknown *pUnk)
272{
273 FIXME("(%p, %p, %p, %p, %p)\n", pPropBag, pErrorLog, pMap, pThis, pUnk);
274
275 return S_OK;
276}
277
278/***********************************************************************
279 * AtlIPersistPropertyBag_Save [atl100.@]
280 */
281HRESULT WINAPI AtlIPersistPropertyBag_Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty,
282 BOOL fSaveAll, ATL_PROPMAP_ENTRY *pMap,
283 void *pThis, IUnknown *pUnk)
284{
285 FIXME("(%p, %d, %d, %p, %p, %p)\n", pPropBag, fClearDirty, fSaveAll, pMap, pThis, pUnk);
286
287 return S_OK;
288}
289
290/***********************************************************************
291 * AtlModuleAddTermFunc [atl100.@]
292 */
294{
295 _ATL_TERMFUNC_ELEM *termfunc_elem;
296
297 TRACE("version %04x (%p %p %Id)\n", _ATL_VER, pM, pFunc, dw);
298
299 if (_ATL_VER > _ATL_VER_30 || pM->cbSize > ATLVer1Size) {
300 termfunc_elem = malloc(sizeof(*termfunc_elem));
301 termfunc_elem->pFunc = pFunc;
302 termfunc_elem->dw = dw;
303 termfunc_elem->pNext = pM->m_pTermFuncs;
304
305 pM->m_pTermFuncs = termfunc_elem;
306 }
307
308 return S_OK;
309}
310
311#if _ATL_VER > _ATL_VER_30
312
313/***********************************************************************
314 * AtlCallTermFunc [atl100.@]
315 */
317{
318 _ATL_TERMFUNC_ELEM *iter = pM->m_pTermFuncs, *tmp;
319
320 TRACE("(%p)\n", pM);
321
322 while(iter) {
323 iter->pFunc(iter->dw);
324 tmp = iter;
325 iter = iter->pNext;
326 free(tmp);
327 }
328
329 pM->m_pTermFuncs = NULL;
330}
331
332#endif
333
334/***********************************************************************
335 * AtlLoadTypeLib [atl100.56]
336 */
337HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex,
338 BSTR *pbstrPath, ITypeLib **ppTypeLib)
339{
340 size_t path_len, index_len;
342 WCHAR *path;
344
345 TRACE("(%p %s %p %p)\n", inst, debugstr_w(lpszIndex), pbstrPath, ppTypeLib);
346
347 index_len = lpszIndex ? lstrlenW(lpszIndex) : 0;
348 path = malloc((MAX_PATH+index_len)*sizeof(WCHAR) + sizeof(L".tlb"));
349 if(!path)
350 return E_OUTOFMEMORY;
351
353 if(!path_len) {
354 free(path);
356 }
357
358 if(index_len)
359 memcpy(path+path_len, lpszIndex, (index_len+1)*sizeof(WCHAR));
360
362 if(FAILED(hres)) {
363 WCHAR *ptr;
364
365 for(ptr = path+path_len-1; ptr > path && *ptr != '\\' && *ptr != '.'; ptr--);
366 if(*ptr != '.')
367 ptr = path+path_len;
368 lstrcpyW(ptr, L".tlb");
370 }
371
372 if(SUCCEEDED(hres)) {
373 *pbstrPath = SysAllocString(path);
374 if(!*pbstrPath) {
375 ITypeLib_Release(typelib);
377 }
378 }
379
380 free(path);
381 if(FAILED(hres))
382 return hres;
383
384 *ppTypeLib = typelib;
385 return S_OK;
386}
387
388#if _ATL_VER <= _ATL_VER_80
389
390/***********************************************************************
391 * AtlRegisterTypeLib [atl80.19]
392 */
394{
396 BSTR path;
398
399 TRACE("(%p %s)\n", inst, debugstr_w(index));
400
401 hres = AtlLoadTypeLib(inst, index, &path, &typelib);
402 if(FAILED(hres))
403 return hres;
404
405 hres = RegisterTypeLib(typelib, path, NULL); /* FIXME: pass help directory */
406 ITypeLib_Release(typelib);
408 return hres;
409}
410
411#endif
412
413#if _ATL_VER > _ATL_VER_30
414
415/***********************************************************************
416 * AtlWinModuleInit [atl100.65]
417 */
419{
420 TRACE("(%p)\n", winmod);
421
422 if(winmod->cbSize != sizeof(*winmod))
423 return E_INVALIDARG;
424
426 winmod->m_pCreateWndList = NULL;
427 return S_OK;
428}
429
430/***********************************************************************
431 * AtlWinModuleAddCreateWndData [atl100.43]
432 */
434{
435 TRACE("(%p, %p, %p)\n", pM, pData, pvObject);
436
437 pData->m_pThis = pvObject;
438 pData->m_dwThreadID = GetCurrentThreadId();
439
441 pData->m_pNext = pM->m_pCreateWndList;
444}
445
446/***********************************************************************
447 * AtlWinModuleExtractCreateWndData [atl100.44]
448 */
450{
451 _AtlCreateWndData *iter, *prev = NULL;
453
454 TRACE("(%p)\n", winmod);
455
457
459
460 for(iter = winmod->m_pCreateWndList; iter && iter->m_dwThreadID != thread_id; iter = iter->m_pNext)
461 prev = iter;
462 if(iter) {
463 if(prev)
464 prev->m_pNext = iter->m_pNext;
465 else
466 winmod->m_pCreateWndList = iter->m_pNext;
467 }
468
470
471 return iter ? iter->m_pThis : NULL;
472}
473
474/***********************************************************************
475 * AtlComModuleGetClassObject [atl100.15]
476 */
477#if _ATL_VER < _ATL_VER_110
479{
480 _ATL_OBJMAP_ENTRY **iter;
482
483 TRACE("(%p %s %s %p)\n", pm, debugstr_guid(rclsid), debugstr_guid(riid), ppv);
484
485 if(!pm)
486 return E_INVALIDARG;
487
488 for(iter = pm->m_ppAutoObjMapFirst; iter < pm->m_ppAutoObjMapLast; iter++) {
489 if(*iter && IsEqualCLSID((*iter)->pclsid, rclsid) && (*iter)->pfnGetClassObject) {
490 if(!(*iter)->pCF)
491 hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&(*iter)->pCF);
492 if((*iter)->pCF)
493 hres = IUnknown_QueryInterface((*iter)->pCF, riid, ppv);
494 TRACE("returning %p (%08lx)\n", *ppv, hres);
495 return hres;
496 }
497 }
498
499 WARN("Class %s not found\n", debugstr_guid(rclsid));
501}
502#else
504{
507
508 TRACE("(%p %s %s %p)\n", pm, debugstr_guid(rclsid), debugstr_guid(riid), ppv);
509
510 if(!pm)
511 return E_INVALIDARG;
512
513 for(iter = pm->m_ppAutoObjMapFirst; iter < pm->m_ppAutoObjMapLast; iter++) {
514 if(*iter && IsEqualCLSID((*iter)->pclsid, rclsid) && (*iter)->pfnGetClassObject) {
515 if(!(*iter)->pCache->pCF)
516 hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&(*iter)->pCache->pCF);
517 if((*iter)->pCache->pCF)
518 hres = IUnknown_QueryInterface((*iter)->pCache->pCF, riid, ppv);
519 TRACE("returning %p (%08lx)\n", *ppv, hres);
520 return hres;
521 }
522 }
523
524 WARN("Class %s not found\n", debugstr_guid(rclsid));
526}
527#endif
528
529/***********************************************************************
530 * AtlComModuleRegisterClassObjects [atl100.17]
531 */
532#if _ATL_VER < _ATL_VER_110
534{
535 _ATL_OBJMAP_ENTRY **iter;
536 IUnknown *unk;
538
539 TRACE("(%p %lx %lx)\n", module, context, flags);
540
541 if(!module)
542 return E_INVALIDARG;
543
544 for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
545 if(!(*iter) || !(*iter)->pfnGetClassObject)
546 continue;
547
548 hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&unk);
549 if(FAILED(hres))
550 return hres;
551
552 hres = CoRegisterClassObject((*iter)->pclsid, unk, context, flags, &(*iter)->dwRegister);
553 IUnknown_Release(unk);
554 if(FAILED(hres))
555 return hres;
556 }
557
558 return S_OK;
559}
560#else
562{
564 IUnknown *unk;
566
567 TRACE("(%p %lx %lx)\n", module, context, flags);
568
569 if(!module)
570 return E_INVALIDARG;
571
572 for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
573 if(!(*iter) || !(*iter)->pfnGetClassObject)
574 continue;
575
576 hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&unk);
577 if(FAILED(hres))
578 return hres;
579
580 hres = CoRegisterClassObject((*iter)->pclsid, unk, context, flags, &(*iter)->pCache->dwRegister);
581 IUnknown_Release(unk);
582 if(FAILED(hres))
583 return hres;
584 }
585
586 return S_OK;
587}
588#endif
589
590/***********************************************************************
591 * AtlComModuleRevokeClassObjects [atl100.20]
592 */
593#if _ATL_VER < _ATL_VER_110
595{
596 _ATL_OBJMAP_ENTRY **iter;
598
599 TRACE("(%p)\n", module);
600
601 if(!module)
602 return E_INVALIDARG;
603
604 for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
605 if(!(*iter))
606 continue;
607
608 hres = CoRevokeClassObject((*iter)->dwRegister);
609 if(FAILED(hres))
610 return hres;
611 }
612
613 return S_OK;
614}
615#else
617{
620
621 TRACE("(%p)\n", module);
622
623 if(!module)
624 return E_INVALIDARG;
625
626 for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
627 if(!(*iter))
628 continue;
629
630 hres = CoRevokeClassObject((*iter)->pCache->dwRegister);
631 if(FAILED(hres))
632 return hres;
633 }
634
635 return S_OK;
636}
637#endif
638
639/***********************************************************************
640 * AtlComModuleUnregisterServer [atl100.22]
641 */
642#if _ATL_VER < _ATL_VER_110
644{
645 const struct _ATL_CATMAP_ENTRY *catmap;
646 _ATL_OBJMAP_ENTRY **iter;
648
649 TRACE("(%p %x %s)\n", mod, bRegTypeLib, debugstr_guid(clsid));
650
651 for(iter = mod->m_ppAutoObjMapFirst; iter < mod->m_ppAutoObjMapLast; iter++) {
652 if(!*iter || (clsid && !IsEqualCLSID((*iter)->pclsid, clsid)))
653 continue;
654
655 TRACE("Unregistering clsid %s\n", debugstr_guid((*iter)->pclsid));
656
657 catmap = (*iter)->pfnGetCategoryMap();
658 if(catmap) {
659 hres = AtlRegisterClassCategoriesHelper((*iter)->pclsid, catmap, FALSE);
660 if(FAILED(hres))
661 return hres;
662 }
663
664 hres = (*iter)->pfnUpdateRegistry(FALSE);
665 if(FAILED(hres))
666 return hres;
667 }
668
669 if(bRegTypeLib) {
671 TLIBATTR *attr;
672 BSTR path;
673
674 hres = AtlLoadTypeLib(mod->m_hInstTypeLib, NULL, &path, &typelib);
675 if(FAILED(hres))
676 return hres;
677
679 hres = ITypeLib_GetLibAttr(typelib, &attr);
680 if(SUCCEEDED(hres)) {
681 hres = UnRegisterTypeLib(&attr->guid, attr->wMajorVerNum, attr->wMinorVerNum, attr->lcid, attr->syskind);
682 ITypeLib_ReleaseTLibAttr(typelib, attr);
683 }
684 ITypeLib_Release(typelib);
685 if(FAILED(hres))
686 return hres;
687 }
688
689 return S_OK;
690}
691#else
693{
694 const struct _ATL_CATMAP_ENTRY *catmap;
697
698 TRACE("(%p %x %s)\n", mod, bRegTypeLib, debugstr_guid(clsid));
699
700 for(iter = mod->m_ppAutoObjMapFirst; iter < mod->m_ppAutoObjMapLast; iter++) {
701 if(!*iter || (clsid && !IsEqualCLSID((*iter)->pclsid, clsid)))
702 continue;
703
704 TRACE("Unregistering clsid %s\n", debugstr_guid((*iter)->pclsid));
705
706 catmap = (*iter)->pfnGetCategoryMap();
707 if(catmap) {
708 hres = AtlRegisterClassCategoriesHelper((*iter)->pclsid, catmap, FALSE);
709 if(FAILED(hres))
710 return hres;
711 }
712
713 hres = (*iter)->pfnUpdateRegistry(FALSE);
714 if(FAILED(hres))
715 return hres;
716 }
717
718 if(bRegTypeLib) {
720 TLIBATTR *attr;
721 BSTR path;
722
723 hres = AtlLoadTypeLib(mod->m_hInstTypeLib, NULL, &path, &typelib);
724 if(FAILED(hres))
725 return hres;
726
728 hres = ITypeLib_GetLibAttr(typelib, &attr);
729 if(SUCCEEDED(hres)) {
730 hres = UnRegisterTypeLib(&attr->guid, attr->wMajorVerNum, attr->wMinorVerNum, attr->lcid, attr->syskind);
731 ITypeLib_ReleaseTLibAttr(typelib, attr);
732 }
733 ITypeLib_Release(typelib);
734 if(FAILED(hres))
735 return hres;
736 }
737
738 return S_OK;
739}
740#endif
741
742#endif
743
744/***********************************************************************
745 * AtlRegisterClassCategoriesHelper [atl100.49]
746 */
748{
749 const struct _ATL_CATMAP_ENTRY *iter;
751
752 TRACE("(%s %p %x)\n", debugstr_guid(clsid), catmap, reg);
753
754 if(!catmap)
755 return S_OK;
756
757 if(!catreg) {
758 ICatRegister *new_catreg;
759
760 hres = CoCreateInstance(&CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER,
761 &IID_ICatRegister, (void**)&new_catreg);
762 if(FAILED(hres))
763 return hres;
764
765 if(InterlockedCompareExchangePointer((void**)&catreg, new_catreg, NULL))
766 ICatRegister_Release(new_catreg);
767 }
768
769 for(iter = catmap; iter->iType != _ATL_CATMAP_ENTRY_END; iter++) {
770 CATID catid = *iter->pcatid; /* For stupid lack of const in ICatRegister declaration. */
771
773 if(reg)
774 hres = ICatRegister_RegisterClassImplCategories(catreg, clsid, 1, &catid);
775 else
776 hres = ICatRegister_UnRegisterClassImplCategories(catreg, clsid, 1, &catid);
777 }else {
778 if(reg)
779 hres = ICatRegister_RegisterClassReqCategories(catreg, clsid, 1, &catid);
780 else
781 hres = ICatRegister_UnRegisterClassReqCategories(catreg, clsid, 1, &catid);
782 }
783 if(FAILED(hres))
784 return hres;
785 }
786
787 if(!reg) {
788 WCHAR reg_path[256] = L"CLSID\\", *ptr = reg_path+6;
789
790 ptr += StringFromGUID2(clsid, ptr, 64)-1;
791 *ptr++ = '\\';
792
793 lstrcpyW(ptr, L"Implemented Categories");
795
796 lstrcpyW(ptr, L"Required Categories");
798 }
799
800 return S_OK;
801}
802
803/***********************************************************************
804 * AtlWaitWithMessageLoop [atl100.24]
805 */
807{
808 MSG msg;
809 DWORD res;
810
811 TRACE("(%p)\n", handle);
812
813 while(1) {
815 switch(res) {
816 case WAIT_OBJECT_0:
817 return TRUE;
818 case WAIT_OBJECT_0+1:
819 if(GetMessageW(&msg, NULL, 0, 0) < 0)
820 return FALSE;
821
824 break;
825 default:
826 return FALSE;
827 }
828 }
829}
830
832{
833 ITypeInfo *typeinfo, *src_typeinfo = NULL;
834 TYPEATTR *attr;
835 int type_flags;
836 unsigned i;
838
839 hres = ITypeLib_GetTypeInfoOfGuid(typelib, clsid, &typeinfo);
840 if(FAILED(hres))
841 return hres;
842
843 hres = ITypeInfo_GetTypeAttr(typeinfo, &attr);
844 if(FAILED(hres)) {
845 ITypeInfo_Release(typeinfo);
846 return hres;
847 }
848
849 for(i=0; i < attr->cImplTypes; i++) {
850 hres = ITypeInfo_GetImplTypeFlags(typeinfo, i, &type_flags);
851 if(SUCCEEDED(hres) && type_flags == (IMPLTYPEFLAG_FSOURCE|IMPLTYPEFLAG_FDEFAULT)) {
852 HREFTYPE ref;
853
854 hres = ITypeInfo_GetRefTypeOfImplType(typeinfo, i, &ref);
855 if(SUCCEEDED(hres))
856 hres = ITypeInfo_GetRefTypeInfo(typeinfo, ref, &src_typeinfo);
857 break;
858 }
859 }
860
861 ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
862 ITypeInfo_Release(typeinfo);
863 if(FAILED(hres))
864 return hres;
865
866 if(!src_typeinfo) {
867 *iid = IID_NULL;
868 return S_OK;
869 }
870
871 hres = ITypeInfo_GetTypeAttr(src_typeinfo, &attr);
872 if(SUCCEEDED(hres)) {
873 *iid = attr->guid;
874 ITypeInfo_ReleaseTypeAttr(src_typeinfo, attr);
875 }
876 ITypeInfo_Release(src_typeinfo);
877 return hres;
878}
879
880/***********************************************************************
881 * AtlGetObjectSourceInterface [atl100.54]
882 */
883HRESULT WINAPI AtlGetObjectSourceInterface(IUnknown *unk, GUID *libid, IID *iid, unsigned short *major, unsigned short *minor)
884{
888 IPersist *persist;
889 IDispatch *disp;
891
892 TRACE("(%p %p %p %p %p)\n", unk, libid, iid, major, minor);
893
894 hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&disp);
895 if(FAILED(hres))
896 return hres;
897
898 hres = IDispatch_GetTypeInfo(disp, 0, 0, &typeinfo);
899 IDispatch_Release(disp);
900 if(FAILED(hres))
901 return hres;
902
903 hres = ITypeInfo_GetContainingTypeLib(typeinfo, &typelib, 0);
904 ITypeInfo_Release(typeinfo);
905 if(SUCCEEDED(hres)) {
906 TLIBATTR *attr;
907
908 hres = ITypeLib_GetLibAttr(typelib, &attr);
909 if(SUCCEEDED(hres)) {
910 *libid = attr->guid;
911 *major = attr->wMajorVerNum;
912 *minor = attr->wMinorVerNum;
913 ITypeLib_ReleaseTLibAttr(typelib, attr);
914 }else {
915 ITypeLib_Release(typelib);
916 }
917 }
918 if(FAILED(hres))
919 return hres;
920
921 hres = IUnknown_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&classinfo);
922 if(SUCCEEDED(hres)) {
923 hres = IProvideClassInfo2_GetGUID(classinfo, GUIDKIND_DEFAULT_SOURCE_DISP_IID, iid);
924 IProvideClassInfo2_Release(classinfo);
925 ITypeLib_Release(typelib);
926 return hres;
927 }
928
929 hres = IUnknown_QueryInterface(unk, &IID_IPersist, (void**)&persist);
930 if(SUCCEEDED(hres)) {
931 CLSID clsid;
932
933 hres = IPersist_GetClassID(persist, &clsid);
934 if(SUCCEEDED(hres))
936 IPersist_Release(persist);
937 }
938
939 return hres;
940}
941
942#if _ATL_VER >= _ATL_VER90
943
944/***********************************************************************
945 * AtlSetPerUserRegistration [atl100.67]
946 */
948{
949 FIXME("stub: bEnable: %d\n", bEnable);
950 return E_NOTIMPL;
951}
952
953/***********************************************************************
954 * AtlGetPerUserRegistration [atl100.68]
955 */
957{
958 FIXME("stub: returning false\n");
959 *pbEnabled = 0;
960 return S_OK;
961}
962
963#endif
964
965/***********************************************************************
966 * AtlGetVersion [atl100.@]
967 */
969{
970 TRACE("version %04x (%p)\n", _ATL_VER, pReserved);
971 return _ATL_VER;
972}
973
975{
976 TRACE("(0x%p, %ld, %p)\n", hinstDLL, fdwReason, lpvReserved);
977
978 switch(fdwReason) {
981 break;
983 if (lpvReserved) break;
984 if(catreg)
985 ICatRegister_Release(catreg);
986 }
987
988 return TRUE;
989}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:68
DEVMODEW devmode
static DWORD const fdwReason
#define msg(x)
Definition: auth_time.c:54
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
HDC dc
Definition: cylfrac.c:34
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
IUnknown *WINAPI AtlComQIPtrAssign(IUnknown **pp, IUnknown *p, REFIID riid)
Definition: atl.c:185
HRESULT WINAPI AtlModuleAddTermFunc(_ATL_MODULE *pM, _ATL_TERMFUNC *pFunc, DWORD_PTR dw)
Definition: atl.c:293
static ICatRegister * catreg
Definition: atl.c:37
HRESULT WINAPI AtlSetPerUserRegistration(cpp_bool bEnable)
Definition: atl.c:947
HRESULT WINAPI AtlIPersistStreamInit_Save(LPSTREAM pStm, BOOL fClearDirty, ATL_PROPMAP_ENTRY *pMap, void *pThis, IUnknown *pUnk)
Definition: atl.c:257
HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, DWORD *pdw)
Definition: atl.c:42
HRESULT WINAPI AtlIPersistPropertyBag_Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty, BOOL fSaveAll, ATL_PROPMAP_ENTRY *pMap, void *pThis, IUnknown *pUnk)
Definition: atl.c:281
HRESULT WINAPI AtlIPersistStreamInit_Load(LPSTREAM pStm, ATL_PROPMAP_ENTRY *pMap, void *pThis, IUnknown *pUnk)
Definition: atl.c:246
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: atl.c:974
HRESULT WINAPI AtlUnadvise(IUnknown *pUnkCP, const IID *iid, DWORD dw)
Definition: atl.c:70
DWORD WINAPI AtlGetVersion(void *pReserved)
Definition: atl.c:968
HRESULT WINAPI AtlGetObjectSourceInterface(IUnknown *unk, GUID *libid, IID *iid, unsigned short *major, unsigned short *minor)
Definition: atl.c:883
HRESULT WINAPI AtlFreeMarshalStream(IStream *stm)
Definition: atl.c:98
unsigned char cpp_bool
Definition: atl.c:35
HRESULT WINAPI AtlRegisterClassCategoriesHelper(REFCLSID clsid, const struct _ATL_CATMAP_ENTRY *catmap, BOOL reg)
Definition: atl.c:747
static HRESULT get_default_source(ITypeLib *typelib, const CLSID *clsid, IID *iid)
Definition: atl.c:831
HRESULT WINAPI AtlIPersistPropertyBag_Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog, ATL_PROPMAP_ENTRY *pMap, void *pThis, IUnknown *pUnk)
Definition: atl.c:269
HRESULT WINAPI AtlMarshalPtrInProc(IUnknown *pUnk, const IID *iid, IStream **pstm)
Definition: atl.c:107
IUnknown *WINAPI AtlComPtrAssign(IUnknown **pp, IUnknown *p)
Definition: atl.c:172
HDC WINAPI AtlCreateTargetDC(HDC hdc, DVTARGETDEVICE *dv)
Definition: atl.c:125
HRESULT WINAPI AtlUnmarshalPtr(IStream *stm, const IID *iid, IUnknown **ppUnk)
Definition: atl.c:116
HRESULT WINAPI AtlGetPerUserRegistration(cpp_bool *pbEnabled)
Definition: atl.c:956
HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex, BSTR *pbstrPath, ITypeLib **ppTypeLib)
Definition: atl.c:337
void WINAPI AtlHiMetricToPixel(const SIZEL *lpHiMetric, SIZEL *lpPix)
Definition: atl.c:150
HRESULT WINAPI AtlRegisterTypeLib(HINSTANCE inst, const WCHAR *index)
Definition: atl.c:393
BOOL WINAPI AtlWaitWithMessageLoop(HANDLE handle)
Definition: atl.c:806
HRESULT WINAPI AtlInternalQueryInterface(void *this, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
Definition: atl.c:200
void WINAPI AtlPixelToHiMetric(const SIZEL *lpPix, SIZEL *lpHiMetric)
Definition: atl.c:161
#define ATLVer1Size
Definition: atl.c:33
HRESULT WINAPI DECLSPEC_HOTPATCH CoRevokeClassObject(DWORD cookie)
Definition: combase.c:3107
INT WINAPI StringFromGUID2(REFGUID guid, LPOLESTR str, INT cmax)
Definition: combase.c:1525
HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid, IUnknown *object, DWORD clscontext, DWORD flags, DWORD *cookie)
Definition: combase.c:2970
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
OLECHAR * BSTR
Definition: compat.h:2293
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HRESULT WINAPI RegisterTypeLib(ITypeLib *ptlib, const WCHAR *szFullPath, const WCHAR *szHelpDir)
Definition: typelib.c:612
HRESULT WINAPI UnRegisterTypeLib(REFGUID libid, WORD wVerMajor, WORD wVerMinor, LCID lcid, SYSKIND syskind)
Definition: typelib.c:848
HRESULT WINAPI LoadTypeLib(const OLECHAR *szFile, ITypeLib **pptLib)
Definition: typelib.c:434
USHORT port
Definition: uri.c:210
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
#define L(x)
Definition: resources.c:13
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLuint index
Definition: glext.h:6031
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
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 _ATL_VER_30
Definition: atlbase.h:28
HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *, DWORD, DWORD)
REFIID riid
Definition: atlbase.h:39
HRESULT WINAPI AtlWinModuleInit(_ATL_WIN_MODULE *)
#define _ATL_VER
Definition: atlbase.h:36
void WINAPI AtlWinModuleAddCreateWndData(_ATL_WIN_MODULE *, _AtlCreateWndData *, void *)
HRESULT WINAPI AtlComModuleRevokeClassObjects(_ATL_COM_MODULE *)
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define _ATL_CATMAP_ENTRY_END
Definition: atlbase.h:253
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
void *WINAPI AtlWinModuleExtractCreateWndData(_ATL_WIN_MODULE *)
HRESULT WINAPI AtlComModuleUnregisterServer(_ATL_COM_MODULE *, BOOL, const CLSID *)
void WINAPI AtlCallTermFunc(_ATL_MODULE *)
HRESULT WINAPI AtlComModuleGetClassObject(_ATL_COM_MODULE *, REFCLSID, REFIID, void **)
#define _ATL_CATMAP_ENTRY_IMPLEMENTED
Definition: atlbase.h:254
#define InterlockedCompareExchangePointer
Definition: interlocked.h:144
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
static IN DWORD IN LPVOID lpvReserved
static LPMONITOREX pm
Definition: localmon.c:45
POINT cp
Definition: magnifier.c:59
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
HDC hdc
Definition: main.c:9
static DWORD path_len
Definition: batch.c:31
static HDC
Definition: imagelist.c:88
HRESULT hres
Definition: protocol.c:465
static DWORD thread_id
Definition: protocol.c:164
struct @1851::@1852 driver
const CLSID * clsid
Definition: msctf.cpp:50
GUID catid
Definition: msctf.idl:629
_Out_ PVOID pReserved
Definition: netsh.h:77
interface IStream * LPSTREAM
Definition: objfwd.h:10
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:240
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:273
const GUID IID_IConnectionPointContainer
const GUID IID_IProvideClassInfo2
const GUID IID_IDispatch
short WCHAR
Definition: pedump.c:58
const GUID IID_IPersist
Definition: proxy.cpp:14
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define IID_NULL
Definition: guiddef.h:98
#define REFCLSID
Definition: guiddef.h:117
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
#define minor(rdev)
Definition: propsheet.cpp:929
#define major(rdev)
Definition: propsheet.cpp:928
#define TRACE(s)
Definition: solgame.cpp:4
Definition: atlcom.h:27
Definition: atlbase.h:248
const CATID * pcatid
Definition: atlbase.h:250
int iType
Definition: atlbase.h:249
Definition: atlbase.h:235
_ATL_CREATORARGFUNC * pFunc
Definition: atlbase.h:238
UINT cbSize
Definition: atlbase.h:192
_ATL_TERMFUNC_ELEM * m_pTermFuncs
Definition: atlbase.h:194
struct _ATL_TERMFUNC_ELEM_TAG * pNext
Definition: atlbase.h:119
_ATL_TERMFUNC * pFunc
Definition: atlbase.h:117
CComCriticalSection m_csWindowCreate
Definition: atlbase.h:201
_AtlCreateWndData * m_pCreateWndList
Definition: atlbase.h:202
struct _AtlCreateWndData_TAG * m_pNext
Definition: atlbase.h:126
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
Definition: cookie.c:202
Definition: http.c:7252
Definition: devices.h:37
Definition: send.c:48
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:687
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint32_t DWORD_PTR
Definition: typedefs.h:65
char * LPSTR
Definition: typedefs.h:51
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define WAIT_OBJECT_0
Definition: winbase.h:383
_In_ BOOL bEnable
Definition: winddi.h:3426
#define WINAPI
Definition: msvc.h:6
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:3772
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719
#define LOGPIXELSX
Definition: wingdi.h:718
HDC WINAPI CreateDCW(_In_opt_ LPCWSTR pszDriver, _In_opt_ LPCWSTR pszDevice, _In_opt_ LPCWSTR psz, _In_opt_ const DEVMODEW *pdmInit)
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define QS_ALLINPUT
Definition: winuser.h:914
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
HDC WINAPI GetDC(_In_opt_ HWND)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)