ReactOS 0.4.16-dev-2320-ge1853c6
combase.c
Go to the documentation of this file.
1/*
2 * Copyright 2005 Juan Lang
3 * Copyright 2005-2006 Robert Shearman (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#include "ntstatus.h"
22#define WIN32_NO_STATUS
23#define USE_COM_CONTEXT_DEF
24#include "objbase.h"
25#include "ctxtcall.h"
26#include "oleauto.h"
27#include "dde.h"
28#include "winternl.h"
29
30#include "combase_private.h"
31
32#include "wine/debug.h"
33
34#ifndef RTL_CONSTANT_STRING
35#define RTL_CONSTANT_STRING(s) { sizeof(s)-sizeof((s)[0]), sizeof(s), s }
36#endif
37
39
41
43
44/* Ole32 exports */
45extern void WINAPI DestroyRunningObjectTable(void);
47
48/*
49 * Number of times CoInitialize is called. It is decreased every time CoUninitialize is called. When it hits 0, the COM libraries are freed
50 */
52
54
56{
75};
76
78{
87};
88
90{
94};
95
97{
98 struct list entry;
100 unsigned int id;
101};
102
104{
105 struct list entry;
108};
109
111
114{
115 0, 0, &cs_registered_ps,
117 0, 0, { (DWORD_PTR)(__FILE__ ": cs_registered_psclsid_list") }
118};
119static CRITICAL_SECTION cs_registered_ps = { &psclsid_cs_debug, -1, 0, 0, 0, 0 };
120
121struct registered_class
122{
123 struct list entry;
129 unsigned int cookie;
130 unsigned int rpcss_cookie;
131};
132
134
137{
140 0, 0, { (DWORD_PTR)(__FILE__ ": registered_classes_cs") }
141};
143
145{
146 struct registered_class *cur;
147 IUnknown *object = NULL;
148
150
152 {
153 if ((apt->oxid == cur->apartment_id) &&
154 (clscontext & cur->clscontext) &&
155 IsEqualGUID(&cur->clsid, rclsid))
156 {
157 object = cur->object;
158 IUnknown_AddRef(cur->object);
159 break;
160 }
161 }
162
164
165 return object;
166}
167
168static struct init_spy *get_spy_entry(struct tlsdata *tlsdata, unsigned int id)
169{
170 struct init_spy *spy;
171
173 {
174 if (id == spy->id && spy->spy)
175 return spy;
176 }
177
178 return NULL;
179}
180
182{
183 NTSTATUS status = NtCreateKey((HANDLE *)retkey, access, attr, 0, NULL, 0, NULL);
184
186 {
187 HANDLE subkey;
188 WCHAR *buffer = attr->ObjectName->Buffer;
189 DWORD pos = 0, i = 0, len = attr->ObjectName->Length / sizeof(WCHAR);
191 OBJECT_ATTRIBUTES attr2 = *attr;
192
193 while (i < len && buffer[i] != '\\') i++;
194 if (i == len) return status;
195
196 attr2.ObjectName = &str;
197
198 while (i < len)
199 {
200 str.Buffer = buffer + pos;
201 str.Length = (i - pos) * sizeof(WCHAR);
202 status = NtCreateKey(&subkey, access, &attr2, 0, NULL, 0, NULL);
203 if (attr2.RootDirectory != attr->RootDirectory) NtClose(attr2.RootDirectory);
204 if (status) return status;
205 attr2.RootDirectory = subkey;
206 while (i < len && buffer[i] == '\\') i++;
207 pos = i;
208 while (i < len && buffer[i] != '\\') i++;
209 }
210 str.Buffer = buffer + pos;
211 str.Length = (i - pos) * sizeof(WCHAR);
212 status = NtCreateKey((HANDLE *)retkey, access, &attr2, 0, NULL, 0, NULL);
213 if (attr2.RootDirectory != attr->RootDirectory) NtClose(attr2.RootDirectory);
214 }
215 return status;
216}
217
219
221{
222 HKEY hkey, ret = 0;
224 UNICODE_STRING name = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\Classes");
225
226 attr.Length = sizeof(attr);
227 attr.RootDirectory = 0;
228 attr.ObjectName = &name;
229#ifdef __REACTOS__
230 attr.Attributes = OBJ_CASE_INSENSITIVE;
231#else
232 attr.Attributes = 0;
233#endif
234 attr.SecurityDescriptor = NULL;
235 attr.SecurityQualityOfService = NULL;
236
237 if (create_key( &hkey, access, &attr )) return 0;
238 TRACE( "%s -> %p\n", debugstr_w(attr.ObjectName->Buffer), hkey );
239
240 if (!(access & KEY_WOW64_64KEY))
241 {
242 if (!(ret = InterlockedCompareExchangePointer( (void **)&classes_root_hkey, hkey, 0 )))
243 ret = hkey;
244 else
245 NtClose( hkey ); /* somebody beat us to it */
246 }
247 else
248 ret = hkey;
249 return ret;
250}
251
253
255{
258
259 if (!(hkey = get_classes_root_hkey(hkey, access)))
261
262 attr.Length = sizeof(attr);
263 attr.RootDirectory = hkey;
264 attr.ObjectName = &nameW;
265#ifdef __REACTOS__
266 attr.Attributes = OBJ_CASE_INSENSITIVE;
267#else
268 attr.Attributes = 0;
269#endif
270 attr.SecurityDescriptor = NULL;
271 attr.SecurityQualityOfService = NULL;
273
274 return RtlNtStatusToDosError(create_key(retkey, access, &attr));
275}
276
278{
279 HKEY ret = hkey;
280 const BOOL is_win64 = sizeof(void*) > sizeof(int);
281 const BOOL force_wow32 = is_win64 && (access & KEY_WOW64_32KEY);
282
283 if (hkey == HKEY_CLASSES_ROOT &&
286 if (force_wow32 && ret && ret == classes_root_hkey)
287 {
288 access &= ~KEY_WOW64_32KEY;
289 if (create_classes_key(classes_root_hkey, L"Wow6432Node", access, &hkey))
290 return 0;
291 ret = hkey;
292 }
293
294 return ret;
295}
296
297static LSTATUS open_classes_key(HKEY hkey, const WCHAR *name, REGSAM access, HKEY *retkey)
298{
301
302 if (!(hkey = get_classes_root_hkey(hkey, access)))
304
305 attr.Length = sizeof(attr);
306 attr.RootDirectory = hkey;
307 attr.ObjectName = &nameW;
308#ifdef __REACTOS__
309 attr.Attributes = OBJ_CASE_INSENSITIVE;
310#else
311 attr.Attributes = 0;
312#endif
313 attr.SecurityDescriptor = NULL;
314 attr.SecurityQualityOfService = NULL;
316
317 return RtlNtStatusToDosError(NtOpenKey((HANDLE *)retkey, access, &attr));
318}
319
321{
322 static const WCHAR clsidW[] = L"CLSID\\";
324 LONG res;
325 HKEY key;
326
330
332 return REGDB_E_CLASSNOTREG;
333 else if (res != ERROR_SUCCESS)
334 return REGDB_E_READREGDB;
335
336 if (!keyname)
337 {
338 *subkey = key;
339 return S_OK;
340 }
341
342 res = open_classes_key(key, keyname, access, subkey);
345 return REGDB_E_KEYMISSING;
346 else if (res != ERROR_SUCCESS)
347 return REGDB_E_READREGDB;
348
349 return S_OK;
350}
351
352/* open HKCR\\AppId\\{string form of appid clsid} key */
354{
355 static const WCHAR appidkeyW[] = L"AppId\\";
356 DWORD res;
358 WCHAR keyname[ARRAY_SIZE(appidkeyW) + CHARS_IN_GUID];
359 DWORD size;
360 HKEY hkey;
361 DWORD type;
362 HRESULT hr;
363
364 /* read the AppID value under the class's key */
366 if (FAILED(hr))
367 return hr;
368
369 size = sizeof(buf);
370 res = RegQueryValueExW(hkey, L"AppId", NULL, &type, (LPBYTE)buf, &size);
371 RegCloseKey(hkey);
373 return REGDB_E_KEYMISSING;
374 else if (res != ERROR_SUCCESS || type!=REG_SZ)
375 return REGDB_E_READREGDB;
376
377 lstrcpyW(keyname, appidkeyW);
378 lstrcatW(keyname, buf);
379 res = open_classes_key(HKEY_CLASSES_ROOT, keyname, access, subkey);
381 return REGDB_E_KEYMISSING;
382 else if (res != ERROR_SUCCESS)
383 return REGDB_E_READREGDB;
384
385 return S_OK;
386}
387
388/***********************************************************************
389 * InternalIsProcessInitialized (combase.@)
390 */
392{
393 struct apartment *apt;
394
395 if (!(apt = apartment_get_current_or_mta()))
396 return FALSE;
398
399 return TRUE;
400}
401
402/***********************************************************************
403 * InternalTlsAllocData (combase.@)
404 */
406{
407 if (!(*data = calloc(1, sizeof(**data))))
408 return E_OUTOFMEMORY;
409
410 list_init(&(*data)->spies);
411 NtCurrentTeb()->ReservedForOle = *data;
412
413 return S_OK;
414}
415
416static void com_cleanup_tlsdata(void)
417{
418 struct tlsdata *tlsdata = NtCurrentTeb()->ReservedForOle;
419 struct init_spy *cursor, *cursor2;
420
421 if (!tlsdata)
422 return;
423
424 if (tlsdata->apt)
428
429 if (tlsdata->errorinfo)
430 IErrorInfo_Release(tlsdata->errorinfo);
431 if (tlsdata->state)
432 IUnknown_Release(tlsdata->state);
433
435 {
436 list_remove(&cursor->entry);
437 if (cursor->spy)
438 IInitializeSpy_Release(cursor->spy);
439 free(cursor);
440 }
441
443 IObjContext_Release(tlsdata->context_token);
444
445 free(tlsdata);
446 NtCurrentTeb()->ReservedForOle = NULL;
447}
448
450{
453};
454
456{
458}
459
461{
462 TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), ppv);
463
464 if (IsEqualGUID(&IID_IGlobalOptions, riid) || IsEqualGUID(&IID_IUnknown, riid))
465 {
466 *ppv = iface;
467 }
468 else
469 {
470 *ppv = NULL;
471 return E_NOINTERFACE;
472 }
473
474 IUnknown_AddRef((IUnknown *)*ppv);
475 return S_OK;
476}
477
479{
482
483 TRACE("%p, refcount %ld.\n", iface, refcount);
484
485 return refcount;
486}
487
489{
492
493 TRACE("%p, refcount %ld.\n", iface, refcount);
494
495 if (!refcount)
496 free(options);
497
498 return refcount;
499}
500
502{
503 FIXME("%p, %u, %Ix.\n", iface, property, value);
504
505 return S_OK;
506}
507
509{
510 TRACE("%p, %u, %p.\n", iface, property, value);
511
512 if (property < COMGLB_EXCEPTION_HANDLING || property > COMGLB_PROPERTIES_RESERVED3)
513 return E_INVALIDARG;
514
516
517 return S_OK;
518}
519
520static const IGlobalOptionsVtbl global_options_vtbl =
521{
527};
528
530{
531 TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), ppv);
532
534 {
535 *ppv = iface;
536 return S_OK;
537 }
538
539 *ppv = NULL;
540 return E_NOINTERFACE;
541}
542
544{
545 return 2;
546}
547
549{
550 return 1;
551}
552
554{
555 TRACE("%d\n", fLock);
556
557 return S_OK;
558}
559
561{
562 struct global_options *object;
563 HRESULT hr;
564
565 TRACE("%p, %s, %p.\n", outer, debugstr_guid(riid), ppv);
566
567 if (outer)
568 return E_INVALIDARG;
569
570 if (!(object = malloc(sizeof(*object))))
571 return E_OUTOFMEMORY;
572 object->IGlobalOptions_iface.lpVtbl = &global_options_vtbl;
573 object->refcount = 1;
574
575 hr = IGlobalOptions_QueryInterface(&object->IGlobalOptions_iface, riid, ppv);
576 IGlobalOptions_Release(&object->IGlobalOptions_iface);
577 return hr;
578}
579
580static const IClassFactoryVtbl global_options_factory_vtbl =
581{
587};
588
590
592{
593 if (IsEqualCLSID(rclsid, &CLSID_GlobalOptions))
594 return IClassFactory_QueryInterface(&global_options_factory, riid, obj);
595 return E_UNEXPECTED;
596}
597
598/***********************************************************************
599 * FreePropVariantArray (combase.@)
600 */
602{
603 ULONG i;
604
605 TRACE("%lu, %p.\n", count, rgvars);
606
607 if (!rgvars)
608 return E_INVALIDARG;
609
610 for (i = 0; i < count; ++i)
611 PropVariantClear(&rgvars[i]);
612
613 return S_OK;
614}
615
617{
618 switch (vt)
619 {
620 case VT_EMPTY:
621 case VT_NULL:
622 case VT_I1:
623 case VT_I2:
624 case VT_I4:
625 case VT_I8:
626 case VT_R4:
627 case VT_R8:
628 case VT_CY:
629 case VT_DATE:
630 case VT_BSTR:
631 case VT_ERROR:
632 case VT_BOOL:
633 case VT_DECIMAL:
634 case VT_UI1:
635 case VT_UI2:
636 case VT_UI4:
637 case VT_UI8:
638 case VT_INT:
639 case VT_UINT:
640 case VT_LPSTR:
641 case VT_LPWSTR:
642 case VT_FILETIME:
643 case VT_BLOB:
644 case VT_DISPATCH:
645 case VT_UNKNOWN:
646 case VT_STREAM:
647 case VT_STORAGE:
649 case VT_STORED_OBJECT:
650 case VT_BLOB_OBJECT:
651 case VT_CF:
652 case VT_CLSID:
653 case VT_I1|VT_VECTOR:
654 case VT_I2|VT_VECTOR:
655 case VT_I4|VT_VECTOR:
656 case VT_I8|VT_VECTOR:
657 case VT_R4|VT_VECTOR:
658 case VT_R8|VT_VECTOR:
659 case VT_CY|VT_VECTOR:
660 case VT_DATE|VT_VECTOR:
661 case VT_BSTR|VT_VECTOR:
662 case VT_ERROR|VT_VECTOR:
663 case VT_BOOL|VT_VECTOR:
665 case VT_UI1|VT_VECTOR:
666 case VT_UI2|VT_VECTOR:
667 case VT_UI4|VT_VECTOR:
668 case VT_UI8|VT_VECTOR:
669 case VT_LPSTR|VT_VECTOR:
670 case VT_LPWSTR|VT_VECTOR:
672 case VT_CF|VT_VECTOR:
673 case VT_CLSID|VT_VECTOR:
674 case VT_ARRAY|VT_I1:
675 case VT_ARRAY|VT_UI1:
676 case VT_ARRAY|VT_I2:
677 case VT_ARRAY|VT_UI2:
678 case VT_ARRAY|VT_I4:
679 case VT_ARRAY|VT_UI4:
680 case VT_ARRAY|VT_INT:
681 case VT_ARRAY|VT_UINT:
682 case VT_ARRAY|VT_R4:
683 case VT_ARRAY|VT_R8:
684 case VT_ARRAY|VT_CY:
685 case VT_ARRAY|VT_DATE:
686 case VT_ARRAY|VT_BSTR:
687 case VT_ARRAY|VT_BOOL:
688 case VT_ARRAY|VT_DECIMAL:
690 case VT_ARRAY|VT_UNKNOWN:
691 case VT_ARRAY|VT_ERROR:
692 case VT_ARRAY|VT_VARIANT:
693 return S_OK;
694 }
695 WARN("Bad type %d\n", vt);
697}
698
699static void propvar_free_cf_array(ULONG count, CLIPDATA *data)
700{
701 ULONG i;
702 for (i = 0; i < count; ++i)
703 CoTaskMemFree(data[i].pClipData);
704}
705
706/***********************************************************************
707 * PropVariantClear (combase.@)
708 */
710{
711 HRESULT hr;
712
713 TRACE("%p.\n", pvar);
714
715 if (!pvar)
716 return S_OK;
717
718 hr = propvar_validatetype(pvar->vt);
719 if (FAILED(hr))
720 {
721 memset(pvar, 0, sizeof(*pvar));
722 return hr;
723 }
724
725 switch (pvar->vt)
726 {
727 case VT_EMPTY:
728 case VT_NULL:
729 case VT_I1:
730 case VT_I2:
731 case VT_I4:
732 case VT_I8:
733 case VT_R4:
734 case VT_R8:
735 case VT_CY:
736 case VT_DATE:
737 case VT_ERROR:
738 case VT_BOOL:
739 case VT_DECIMAL:
740 case VT_UI1:
741 case VT_UI2:
742 case VT_UI4:
743 case VT_UI8:
744 case VT_INT:
745 case VT_UINT:
746 case VT_FILETIME:
747 break;
748 case VT_DISPATCH:
749 case VT_UNKNOWN:
750 case VT_STREAM:
752 case VT_STORAGE:
753 case VT_STORED_OBJECT:
754 if (pvar->pStream)
755 IStream_Release(pvar->pStream);
756 break;
757 case VT_CLSID:
758 case VT_LPSTR:
759 case VT_LPWSTR:
760 /* pick an arbitrary typed pointer - we don't care about the type
761 * as we are just freeing it */
762 CoTaskMemFree(pvar->puuid);
763 break;
764 case VT_BLOB:
765 case VT_BLOB_OBJECT:
766 CoTaskMemFree(pvar->blob.pBlobData);
767 break;
768 case VT_BSTR:
769 SysFreeString(pvar->bstrVal);
770 break;
771 case VT_CF:
772 if (pvar->pclipdata)
773 {
774 propvar_free_cf_array(1, pvar->pclipdata);
775 CoTaskMemFree(pvar->pclipdata);
776 }
777 break;
778 default:
779 if (pvar->vt & VT_VECTOR)
780 {
781 ULONG i;
782
783 switch (pvar->vt & ~VT_VECTOR)
784 {
785 case VT_VARIANT:
786 FreePropVariantArray(pvar->capropvar.cElems, pvar->capropvar.pElems);
787 break;
788 case VT_CF:
789 propvar_free_cf_array(pvar->caclipdata.cElems, pvar->caclipdata.pElems);
790 break;
791 case VT_BSTR:
792 for (i = 0; i < pvar->cabstr.cElems; i++)
793 SysFreeString(pvar->cabstr.pElems[i]);
794 break;
795 case VT_LPSTR:
796 for (i = 0; i < pvar->calpstr.cElems; i++)
797 CoTaskMemFree(pvar->calpstr.pElems[i]);
798 break;
799 case VT_LPWSTR:
800 for (i = 0; i < pvar->calpwstr.cElems; i++)
801 CoTaskMemFree(pvar->calpwstr.pElems[i]);
802 break;
803 }
804 if (pvar->vt & ~VT_VECTOR)
805 {
806 /* pick an arbitrary VT_VECTOR structure - they all have the same
807 * memory layout */
808 CoTaskMemFree(pvar->capropvar.pElems);
809 }
810 }
811 else if (pvar->vt & VT_ARRAY)
812 hr = SafeArrayDestroy(pvar->parray);
813 else
814 {
815 WARN("Invalid/unsupported type %d\n", pvar->vt);
817 }
818 }
819
820 memset(pvar, 0, sizeof(*pvar));
821 return hr;
822}
823
824/***********************************************************************
825 * PropVariantCopy (combase.@)
826 */
827HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, const PROPVARIANT *pvarSrc)
828{
829 ULONG len;
830 HRESULT hr;
831
832 TRACE("%p, %p vt %04x.\n", pvarDest, pvarSrc, pvarSrc->vt);
833
834 hr = propvar_validatetype(pvarSrc->vt);
835 if (FAILED(hr))
836 return DISP_E_BADVARTYPE;
837
838 /* this will deal with most cases */
839 *pvarDest = *pvarSrc;
840
841 switch (pvarSrc->vt)
842 {
843 case VT_EMPTY:
844 case VT_NULL:
845 case VT_I1:
846 case VT_UI1:
847 case VT_I2:
848 case VT_UI2:
849 case VT_BOOL:
850 case VT_DECIMAL:
851 case VT_I4:
852 case VT_UI4:
853 case VT_R4:
854 case VT_ERROR:
855 case VT_I8:
856 case VT_UI8:
857 case VT_INT:
858 case VT_UINT:
859 case VT_R8:
860 case VT_CY:
861 case VT_DATE:
862 case VT_FILETIME:
863 break;
864 case VT_DISPATCH:
865 case VT_UNKNOWN:
866 case VT_STREAM:
868 case VT_STORAGE:
869 case VT_STORED_OBJECT:
870 if (pvarDest->pStream)
871 IStream_AddRef(pvarDest->pStream);
872 break;
873 case VT_CLSID:
874 pvarDest->puuid = CoTaskMemAlloc(sizeof(CLSID));
875 *pvarDest->puuid = *pvarSrc->puuid;
876 break;
877 case VT_LPSTR:
878 if (pvarSrc->pszVal)
879 {
880 len = strlen(pvarSrc->pszVal);
881 pvarDest->pszVal = CoTaskMemAlloc((len+1)*sizeof(CHAR));
882 CopyMemory(pvarDest->pszVal, pvarSrc->pszVal, (len+1)*sizeof(CHAR));
883 }
884 break;
885 case VT_LPWSTR:
886 if (pvarSrc->pwszVal)
887 {
888 len = lstrlenW(pvarSrc->pwszVal);
889 pvarDest->pwszVal = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
890 CopyMemory(pvarDest->pwszVal, pvarSrc->pwszVal, (len+1)*sizeof(WCHAR));
891 }
892 break;
893 case VT_BLOB:
894 case VT_BLOB_OBJECT:
895 if (pvarSrc->blob.pBlobData)
896 {
897 len = pvarSrc->blob.cbSize;
898 pvarDest->blob.pBlobData = CoTaskMemAlloc(len);
899 CopyMemory(pvarDest->blob.pBlobData, pvarSrc->blob.pBlobData, len);
900 }
901 break;
902 case VT_BSTR:
903 pvarDest->bstrVal = SysAllocString(pvarSrc->bstrVal);
904 break;
905 case VT_CF:
906 if (pvarSrc->pclipdata)
907 {
908 len = pvarSrc->pclipdata->cbSize - sizeof(pvarSrc->pclipdata->ulClipFmt);
909 pvarDest->pclipdata = CoTaskMemAlloc(sizeof (CLIPDATA));
910 pvarDest->pclipdata->cbSize = pvarSrc->pclipdata->cbSize;
911 pvarDest->pclipdata->ulClipFmt = pvarSrc->pclipdata->ulClipFmt;
912 pvarDest->pclipdata->pClipData = CoTaskMemAlloc(len);
913 CopyMemory(pvarDest->pclipdata->pClipData, pvarSrc->pclipdata->pClipData, len);
914 }
915 break;
916 default:
917 if (pvarSrc->vt & VT_VECTOR)
918 {
919 int elemSize;
920 ULONG i;
921
922 switch (pvarSrc->vt & ~VT_VECTOR)
923 {
924 case VT_I1: elemSize = sizeof(pvarSrc->cVal); break;
925 case VT_UI1: elemSize = sizeof(pvarSrc->bVal); break;
926 case VT_I2: elemSize = sizeof(pvarSrc->iVal); break;
927 case VT_UI2: elemSize = sizeof(pvarSrc->uiVal); break;
928 case VT_BOOL: elemSize = sizeof(pvarSrc->boolVal); break;
929 case VT_I4: elemSize = sizeof(pvarSrc->lVal); break;
930 case VT_UI4: elemSize = sizeof(pvarSrc->ulVal); break;
931 case VT_R4: elemSize = sizeof(pvarSrc->fltVal); break;
932 case VT_R8: elemSize = sizeof(pvarSrc->dblVal); break;
933 case VT_ERROR: elemSize = sizeof(pvarSrc->scode); break;
934 case VT_I8: elemSize = sizeof(pvarSrc->hVal); break;
935 case VT_UI8: elemSize = sizeof(pvarSrc->uhVal); break;
936 case VT_CY: elemSize = sizeof(pvarSrc->cyVal); break;
937 case VT_DATE: elemSize = sizeof(pvarSrc->date); break;
938 case VT_FILETIME: elemSize = sizeof(pvarSrc->filetime); break;
939 case VT_CLSID: elemSize = sizeof(*pvarSrc->puuid); break;
940 case VT_CF: elemSize = sizeof(*pvarSrc->pclipdata); break;
941 case VT_BSTR: elemSize = sizeof(pvarSrc->bstrVal); break;
942 case VT_LPSTR: elemSize = sizeof(pvarSrc->pszVal); break;
943 case VT_LPWSTR: elemSize = sizeof(pvarSrc->pwszVal); break;
944 case VT_VARIANT: elemSize = sizeof(*pvarSrc->pvarVal); break;
945
946 default:
947 FIXME("Invalid element type: %ul\n", pvarSrc->vt & ~VT_VECTOR);
948 return E_INVALIDARG;
949 }
950 len = pvarSrc->capropvar.cElems;
951 pvarDest->capropvar.pElems = len ? CoTaskMemAlloc(len * elemSize) : NULL;
952 if (pvarSrc->vt == (VT_VECTOR | VT_VARIANT))
953 {
954 for (i = 0; i < len; i++)
955 PropVariantCopy(&pvarDest->capropvar.pElems[i], &pvarSrc->capropvar.pElems[i]);
956 }
957 else if (pvarSrc->vt == (VT_VECTOR | VT_CF))
958 {
959 FIXME("Copy clipformats\n");
960 }
961 else if (pvarSrc->vt == (VT_VECTOR | VT_BSTR))
962 {
963 for (i = 0; i < len; i++)
964 pvarDest->cabstr.pElems[i] = SysAllocString(pvarSrc->cabstr.pElems[i]);
965 }
966 else if (pvarSrc->vt == (VT_VECTOR | VT_LPSTR))
967 {
968 size_t strLen;
969 for (i = 0; i < len; i++)
970 {
971 strLen = lstrlenA(pvarSrc->calpstr.pElems[i]) + 1;
972 pvarDest->calpstr.pElems[i] = CoTaskMemAlloc(strLen);
973 memcpy(pvarDest->calpstr.pElems[i],
974 pvarSrc->calpstr.pElems[i], strLen);
975 }
976 }
977 else if (pvarSrc->vt == (VT_VECTOR | VT_LPWSTR))
978 {
979 size_t strLen;
980 for (i = 0; i < len; i++)
981 {
982 strLen = (lstrlenW(pvarSrc->calpwstr.pElems[i]) + 1) *
983 sizeof(WCHAR);
984 pvarDest->calpstr.pElems[i] = CoTaskMemAlloc(strLen);
985 memcpy(pvarDest->calpstr.pElems[i],
986 pvarSrc->calpstr.pElems[i], strLen);
987 }
988 }
989 else
990 CopyMemory(pvarDest->capropvar.pElems, pvarSrc->capropvar.pElems, len * elemSize);
991 }
992 else if (pvarSrc->vt & VT_ARRAY)
993 {
994 pvarDest->uhVal.QuadPart = 0;
995 return SafeArrayCopy(pvarSrc->parray, &pvarDest->parray);
996 }
997 else
998 WARN("Invalid/unsupported type %d\n", pvarSrc->vt);
999 }
1000
1001 return S_OK;
1002}
1003
1004/***********************************************************************
1005 * CoFileTimeNow (combase.@)
1006 */
1008{
1010 return S_OK;
1011}
1012
1013/******************************************************************************
1014 * CoCreateGuid (combase.@)
1015 */
1017{
1019
1020 if (!guid) return E_INVALIDARG;
1021
1023 if (status == RPC_S_OK || status == RPC_S_UUID_LOCAL_ONLY) return S_OK;
1024 return HRESULT_FROM_WIN32(status);
1025}
1026
1027/******************************************************************************
1028 * CoQueryProxyBlanket (combase.@)
1029 */
1031 DWORD *authz_service, OLECHAR **servername, DWORD *authn_level,
1032 DWORD *imp_level, void **auth_info, DWORD *capabilities)
1033{
1035 HRESULT hr;
1036
1037 TRACE("%p, %p, %p, %p, %p, %p, %p, %p.\n", proxy, authn_service, authz_service, servername, authn_level, imp_level,
1038 auth_info, capabilities);
1039
1040 hr = IUnknown_QueryInterface(proxy, &IID_IClientSecurity, (void **)&client_security);
1041 if (SUCCEEDED(hr))
1042 {
1043 hr = IClientSecurity_QueryBlanket(client_security, proxy, authn_service, authz_service, servername,
1044 authn_level, imp_level, auth_info, capabilities);
1045 IClientSecurity_Release(client_security);
1046 }
1047
1048 if (FAILED(hr)) ERR("-- failed with %#lx.\n", hr);
1049 return hr;
1050}
1051
1052/******************************************************************************
1053 * CoSetProxyBlanket (combase.@)
1054 */
1056 OLECHAR *servername, DWORD authn_level, DWORD imp_level, void *auth_info, DWORD capabilities)
1057{
1059 HRESULT hr;
1060
1061 TRACE("%p, %lu, %lu, %p, %lu, %lu, %p, %#lx.\n", proxy, authn_service, authz_service, servername,
1062 authn_level, imp_level, auth_info, capabilities);
1063
1064 hr = IUnknown_QueryInterface(proxy, &IID_IClientSecurity, (void **)&client_security);
1065 if (SUCCEEDED(hr))
1066 {
1067 hr = IClientSecurity_SetBlanket(client_security, proxy, authn_service, authz_service, servername, authn_level,
1068 imp_level, auth_info, capabilities);
1069 IClientSecurity_Release(client_security);
1070 }
1071
1072 if (FAILED(hr)) ERR("-- failed with %#lx.\n", hr);
1073 return hr;
1074}
1075
1076/***********************************************************************
1077 * CoCopyProxy (combase.@)
1078 */
1080{
1082 HRESULT hr;
1083
1084 TRACE("%p, %p.\n", proxy, proxy_copy);
1085
1086 hr = IUnknown_QueryInterface(proxy, &IID_IClientSecurity, (void **)&client_security);
1087 if (SUCCEEDED(hr))
1088 {
1089 hr = IClientSecurity_CopyProxy(client_security, proxy, proxy_copy);
1090 IClientSecurity_Release(client_security);
1091 }
1092
1093 if (FAILED(hr)) ERR("-- failed with %#lx.\n", hr);
1094 return hr;
1095}
1096
1097/***********************************************************************
1098 * CoQueryClientBlanket (combase.@)
1099 */
1100HRESULT WINAPI CoQueryClientBlanket(DWORD *authn_service, DWORD *authz_service, OLECHAR **servername,
1101 DWORD *authn_level, DWORD *imp_level, RPC_AUTHZ_HANDLE *privs, DWORD *capabilities)
1102{
1103 IServerSecurity *server_security;
1104 HRESULT hr;
1105
1106 TRACE("%p, %p, %p, %p, %p, %p, %p.\n", authn_service, authz_service, servername, authn_level, imp_level,
1107 privs, capabilities);
1108
1109 hr = CoGetCallContext(&IID_IServerSecurity, (void **)&server_security);
1110 if (SUCCEEDED(hr))
1111 {
1112 hr = IServerSecurity_QueryBlanket(server_security, authn_service, authz_service, servername, authn_level,
1113 imp_level, privs, capabilities);
1114 IServerSecurity_Release(server_security);
1115 }
1116
1117 return hr;
1118}
1119
1120/***********************************************************************
1121 * CoImpersonateClient (combase.@)
1122 */
1124{
1125 IServerSecurity *server_security;
1126 HRESULT hr;
1127
1128 TRACE("\n");
1129
1130 hr = CoGetCallContext(&IID_IServerSecurity, (void **)&server_security);
1131 if (SUCCEEDED(hr))
1132 {
1133 hr = IServerSecurity_ImpersonateClient(server_security);
1134 IServerSecurity_Release(server_security);
1135 }
1136
1137 return hr;
1138}
1139
1140/***********************************************************************
1141 * CoRevertToSelf (combase.@)
1142 */
1144{
1145 IServerSecurity *server_security;
1146 HRESULT hr;
1147
1148 TRACE("\n");
1149
1150 hr = CoGetCallContext(&IID_IServerSecurity, (void **)&server_security);
1151 if (SUCCEEDED(hr))
1152 {
1153 hr = IServerSecurity_RevertToSelf(server_security);
1154 IServerSecurity_Release(server_security);
1155 }
1156
1157 return hr;
1158}
1159
1160/***********************************************************************
1161 * CoInitializeSecurity (combase.@)
1162 */
1164 SOLE_AUTHENTICATION_SERVICE *asAuthSvc, void *reserved1, DWORD authn_level,
1165 DWORD imp_level, void *reserved2, DWORD capabilities, void *reserved3)
1166{
1167 FIXME("%p, %ld, %p, %p, %ld, %ld, %p, %ld, %p stub\n", sd, cAuthSvc, asAuthSvc, reserved1, authn_level,
1168 imp_level, reserved2, capabilities, reserved3);
1169
1170 return S_OK;
1171}
1172
1173/***********************************************************************
1174 * CoGetObjectContext (combase.@)
1175 */
1177{
1179 HRESULT hr;
1180
1181 TRACE("%s, %p.\n", debugstr_guid(riid), ppv);
1182
1183 *ppv = NULL;
1185 if (FAILED(hr))
1186 return hr;
1187
1188 return IObjContext_QueryInterface(context, riid, ppv);
1189}
1190
1191/***********************************************************************
1192 * CoGetDefaultContext (combase.@)
1193 */
1195{
1196 FIXME("%d, %s, %p stub\n", type, debugstr_guid(riid), obj);
1197
1198 return E_NOINTERFACE;
1199}
1200
1201/***********************************************************************
1202 * CoGetCallState (combase.@)
1203 */
1205{
1206 FIXME("%d, %p.\n", arg1, arg2);
1207
1208 return E_NOTIMPL;
1209}
1210
1211/***********************************************************************
1212 * CoGetActivationState (combase.@)
1213 */
1215{
1216 FIXME("%s, %lx, %p.\n", debugstr_guid(&guid), arg2, arg3);
1217
1218 return E_NOTIMPL;
1219}
1220
1221/******************************************************************************
1222 * CoGetTreatAsClass (combase.@)
1223 */
1225{
1226 WCHAR buffW[CHARS_IN_GUID];
1227 LONG len = sizeof(buffW);
1228 HRESULT hr = S_OK;
1229 HKEY hkey = NULL;
1230
1231 TRACE("%s, %p.\n", debugstr_guid(clsidOld), clsidNew);
1232
1233 if (!clsidOld || !clsidNew)
1234 return E_INVALIDARG;
1235
1236 *clsidNew = *clsidOld;
1237
1238 hr = open_key_for_clsid(clsidOld, L"TreatAs", KEY_READ, &hkey);
1239 if (FAILED(hr))
1240 {
1241 hr = S_FALSE;
1242 goto done;
1243 }
1244
1245 if (RegQueryValueW(hkey, NULL, buffW, &len))
1246 {
1247 hr = S_FALSE;
1248 goto done;
1249 }
1250
1251 hr = CLSIDFromString(buffW, clsidNew);
1252 if (FAILED(hr))
1253 ERR("Failed to get CLSID from string %s, hr %#lx.\n", debugstr_w(buffW), hr);
1254done:
1255 if (hkey) RegCloseKey(hkey);
1256 return hr;
1257}
1258
1259/******************************************************************************
1260 * ProgIDFromCLSID (combase.@)
1261 */
1263{
1264 ACTCTX_SECTION_KEYED_DATA data;
1265 LONG progidlen = 0;
1266 HKEY hkey;
1267 REGSAM opposite = (sizeof(void *) > sizeof(int)) ? KEY_WOW64_32KEY : KEY_WOW64_64KEY;
1268 BOOL is_wow64;
1269 HRESULT hr;
1270
1271 if (!progid)
1272 return E_INVALIDARG;
1273
1274 *progid = NULL;
1275
1276 data.cbSize = sizeof(data);
1277 if (FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
1278 clsid, &data))
1279 {
1280 struct comclassredirect_data *comclass = (struct comclassredirect_data *)data.lpData;
1281 if (comclass->progid_len)
1282 {
1283 WCHAR *ptrW;
1284
1285 *progid = CoTaskMemAlloc(comclass->progid_len + sizeof(WCHAR));
1286 if (!*progid) return E_OUTOFMEMORY;
1287
1288 ptrW = (WCHAR *)((BYTE *)comclass + comclass->progid_offset);
1289 memcpy(*progid, ptrW, comclass->progid_len + sizeof(WCHAR));
1290 return S_OK;
1291 }
1292 else
1293 return REGDB_E_CLASSNOTREG;
1294 }
1295
1296 hr = open_key_for_clsid(clsid, L"ProgID", KEY_READ, &hkey);
1297 if (FAILED(hr) && (opposite == KEY_WOW64_32KEY || (IsWow64Process(GetCurrentProcess(), &is_wow64) && is_wow64)))
1298 {
1299 hr = open_key_for_clsid(clsid, L"ProgID", opposite | KEY_READ, &hkey);
1300 if (FAILED(hr))
1301 return hr;
1302 }
1303
1304 if (RegQueryValueW(hkey, NULL, NULL, &progidlen))
1306
1307 if (hr == S_OK)
1308 {
1309 *progid = CoTaskMemAlloc(progidlen * sizeof(WCHAR));
1310 if (*progid)
1311 {
1312 if (RegQueryValueW(hkey, NULL, *progid, &progidlen))
1313 {
1316 *progid = NULL;
1317 }
1318 }
1319 else
1320 hr = E_OUTOFMEMORY;
1321 }
1322
1323 RegCloseKey(hkey);
1324 return hr;
1325}
1326
1327static inline BOOL is_valid_hex(WCHAR c)
1328{
1329 if (!(((c >= '0') && (c <= '9')) ||
1330 ((c >= 'a') && (c <= 'f')) ||
1331 ((c >= 'A') && (c <= 'F'))))
1332 return FALSE;
1333 return TRUE;
1334}
1335
1336static const BYTE guid_conv_table[256] =
1337{
1338 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */
1339 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */
1340 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */
1341 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 0x30 */
1342 0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 */
1343 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */
1344 0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf /* 0x60 */
1345};
1346
1348{
1349 int i;
1350
1351 if (!s || s[0] != '{')
1352 {
1353 memset(id, 0, sizeof(*id));
1354 if (!s) return TRUE;
1355 return FALSE;
1356 }
1357
1358 TRACE("%s -> %p\n", debugstr_w(s), id);
1359
1360 /* In form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
1361
1362 id->Data1 = 0;
1363 for (i = 1; i < 9; ++i)
1364 {
1365 if (!is_valid_hex(s[i])) return FALSE;
1366 id->Data1 = (id->Data1 << 4) | guid_conv_table[s[i]];
1367 }
1368 if (s[9] != '-') return FALSE;
1369
1370 id->Data2 = 0;
1371 for (i = 10; i < 14; ++i)
1372 {
1373 if (!is_valid_hex(s[i])) return FALSE;
1374 id->Data2 = (id->Data2 << 4) | guid_conv_table[s[i]];
1375 }
1376 if (s[14] != '-') return FALSE;
1377
1378 id->Data3 = 0;
1379 for (i = 15; i < 19; ++i)
1380 {
1381 if (!is_valid_hex(s[i])) return FALSE;
1382 id->Data3 = (id->Data3 << 4) | guid_conv_table[s[i]];
1383 }
1384 if (s[19] != '-') return FALSE;
1385
1386 for (i = 20; i < 37; i += 2)
1387 {
1388 if (i == 24)
1389 {
1390 if (s[i] != '-') return FALSE;
1391 i++;
1392 }
1393 if (!is_valid_hex(s[i]) || !is_valid_hex(s[i + 1])) return FALSE;
1394 id->Data4[(i - 20) / 2] = guid_conv_table[s[i]] << 4 | guid_conv_table[s[i + 1]];
1395 }
1396
1397 if (s[37] == '}' && s[38] == '\0')
1398 return TRUE;
1399
1400 return FALSE;
1401}
1402
1404{
1405 WCHAR buf2[CHARS_IN_GUID];
1406 LONG buf2len = sizeof(buf2);
1407 HKEY xhkey;
1408 WCHAR *buf;
1409
1410 memset(clsid, 0, sizeof(*clsid));
1411 buf = malloc((lstrlenW(progid) + 8) * sizeof(WCHAR));
1412 if (!buf) return E_OUTOFMEMORY;
1413
1415 lstrcatW(buf, L"\\CLSID");
1417 {
1418 free(buf);
1419 WARN("couldn't open key for ProgID %s\n", debugstr_w(progid));
1420 return CO_E_CLASSSTRING;
1421 }
1422 free(buf);
1423
1424 if (RegQueryValueW(xhkey, NULL, buf2, &buf2len))
1425 {
1426 RegCloseKey(xhkey);
1427 WARN("couldn't query clsid value for ProgID %s\n", debugstr_w(progid));
1428 return CO_E_CLASSSTRING;
1429 }
1430 RegCloseKey(xhkey);
1431 return guid_from_string(buf2, clsid) ? S_OK : CO_E_CLASSSTRING;
1432}
1433
1434/******************************************************************************
1435 * CLSIDFromProgID (combase.@)
1436 */
1438{
1439 ACTCTX_SECTION_KEYED_DATA data;
1440
1441 if (!progid || !clsid)
1442 return E_INVALIDARG;
1443
1444 data.cbSize = sizeof(data);
1445 if (FindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION,
1446 progid, &data))
1447 {
1448 struct progidredirect_data *progiddata = (struct progidredirect_data *)data.lpData;
1449 CLSID *alias = (CLSID *)((BYTE *)data.lpSectionBase + progiddata->clsid_offset);
1450 *clsid = *alias;
1451 return S_OK;
1452 }
1453
1455}
1456
1457/******************************************************************************
1458 * CLSIDFromProgIDEx (combase.@)
1459 */
1461{
1462 FIXME("%s, %p: semi-stub\n", debugstr_w(progid), clsid);
1463
1464 return CLSIDFromProgID(progid, clsid);
1465}
1466
1467/******************************************************************************
1468 * CLSIDFromString (combase.@)
1469 */
1471{
1472 CLSID tmp_id;
1473 HRESULT hr;
1474
1475 if (!clsid)
1476 return E_INVALIDARG;
1477
1479 return S_OK;
1480
1481 /* It appears a ProgID is also valid */
1482 hr = clsid_from_string_reg(str, &tmp_id);
1483 if (SUCCEEDED(hr))
1484 *clsid = tmp_id;
1485
1486 return hr;
1487}
1488
1489/******************************************************************************
1490 * IIDFromString (combase.@)
1491 */
1493{
1494 TRACE("%s, %p\n", debugstr_w(str), iid);
1495
1496 if (!str)
1497 {
1498 memset(iid, 0, sizeof(*iid));
1499 return S_OK;
1500 }
1501
1502 /* length mismatch is a special case */
1503 if (lstrlenW(str) + 1 != CHARS_IN_GUID)
1504 return E_INVALIDARG;
1505
1506 if (str[0] != '{')
1507 return CO_E_IIDSTRING;
1508
1509 return guid_from_string(str, iid) ? S_OK : CO_E_IIDSTRING;
1510}
1511
1512/******************************************************************************
1513 * StringFromCLSID (combase.@)
1514 */
1516{
1517 if (!(*str = CoTaskMemAlloc(CHARS_IN_GUID * sizeof(WCHAR)))) return E_OUTOFMEMORY;
1519 return S_OK;
1520}
1521
1522/******************************************************************************
1523 * StringFromGUID2 (combase.@)
1524 */
1526{
1527 if (!guid || cmax < CHARS_IN_GUID) return 0;
1528 swprintf(str, CHARS_IN_GUID, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", guid->Data1,
1529 guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
1530 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
1531 return CHARS_IN_GUID;
1532}
1533
1534static void init_multi_qi(DWORD count, MULTI_QI *mqi, HRESULT hr)
1535{
1536 ULONG i;
1537
1538 for (i = 0; i < count; i++)
1539 {
1540 mqi[i].pItf = NULL;
1541 mqi[i].hr = hr;
1542 }
1543}
1544
1545static HRESULT return_multi_qi(IUnknown *unk, DWORD count, MULTI_QI *mqi, BOOL include_unk)
1546{
1547 ULONG index = 0, fetched = 0;
1548
1549 if (include_unk)
1550 {
1551 mqi[0].hr = S_OK;
1552 mqi[0].pItf = unk;
1553 index = fetched = 1;
1554 }
1555
1556 for (; index < count; index++)
1557 {
1558 mqi[index].hr = IUnknown_QueryInterface(unk, mqi[index].pIID, (void **)&mqi[index].pItf);
1559 if (mqi[index].hr == S_OK)
1560 fetched++;
1561 }
1562
1563 if (!include_unk)
1564 IUnknown_Release(unk);
1565
1566 if (fetched == 0)
1567 return E_NOINTERFACE;
1568
1569 return fetched == count ? S_OK : CO_S_NOTALLINTERFACES;
1570}
1571
1572/***********************************************************************
1573 * CoGetInstanceFromFile (combase.@)
1574 */
1576 IUnknown *outer, DWORD cls_context, DWORD grfmode, OLECHAR *filename, DWORD count,
1577 MULTI_QI *results)
1578{
1579 IPersistFile *pf = NULL;
1580 IUnknown *obj = NULL;
1581 CLSID clsid;
1582 HRESULT hr;
1583
1584 if (!count || !results)
1585 return E_INVALIDARG;
1586
1587 if (server_info)
1588 FIXME("() non-NULL server_info not supported\n");
1589
1591
1592 if (!rclsid)
1593 {
1595 if (FAILED(hr))
1596 {
1597 ERR("Failed to get CLSID from a file.\n");
1598 return hr;
1599 }
1600
1601 rclsid = &clsid;
1602 }
1603
1604 hr = CoCreateInstance(rclsid, outer, cls_context, &IID_IUnknown, (void **)&obj);
1605 if (hr != S_OK)
1606 {
1608 return hr;
1609 }
1610
1611 /* Init from file */
1612 hr = IUnknown_QueryInterface(obj, &IID_IPersistFile, (void **)&pf);
1613 if (FAILED(hr))
1614 {
1616 IUnknown_Release(obj);
1617 return hr;
1618 }
1619
1620 hr = IPersistFile_Load(pf, filename, grfmode);
1621 IPersistFile_Release(pf);
1622 if (SUCCEEDED(hr))
1624 else
1625 {
1627 IUnknown_Release(obj);
1628 return hr;
1629 }
1630}
1631
1632/***********************************************************************
1633 * CoGetInstanceFromIStorage (combase.@)
1634 */
1636 IUnknown *outer, DWORD cls_context, IStorage *storage, DWORD count, MULTI_QI *results)
1637{
1638 IPersistStorage *ps = NULL;
1639 IUnknown *obj = NULL;
1640 STATSTG stat;
1641 HRESULT hr;
1642
1643 if (!count || !results || !storage)
1644 return E_INVALIDARG;
1645
1646 if (server_info)
1647 FIXME("() non-NULL server_info not supported\n");
1648
1650
1651 if (!rclsid)
1652 {
1653 memset(&stat.clsid, 0, sizeof(stat.clsid));
1654 hr = IStorage_Stat(storage, &stat, STATFLAG_NONAME);
1655 if (FAILED(hr))
1656 {
1657 ERR("Failed to get CLSID from a storage.\n");
1658 return hr;
1659 }
1660
1661 rclsid = &stat.clsid;
1662 }
1663
1664 hr = CoCreateInstance(rclsid, outer, cls_context, &IID_IUnknown, (void **)&obj);
1665 if (hr != S_OK)
1666 return hr;
1667
1668 /* Init from IStorage */
1669 hr = IUnknown_QueryInterface(obj, &IID_IPersistStorage, (void **)&ps);
1670 if (FAILED(hr))
1671 ERR("failed to get IPersistStorage\n");
1672
1673 if (ps)
1674 {
1675 IPersistStorage_Load(ps, storage);
1676 IPersistStorage_Release(ps);
1677 }
1678
1680}
1681
1682/***********************************************************************
1683 * CoCreateInstance (combase.@)
1684 */
1686 REFIID riid, void **obj)
1687{
1688 MULTI_QI multi_qi = { .pIID = riid };
1689 HRESULT hr;
1690
1691 TRACE("%s, %p, %#lx, %s, %p.\n", debugstr_guid(rclsid), outer, cls_context, debugstr_guid(riid), obj);
1692
1693 if (!obj)
1694 return E_POINTER;
1695
1696 hr = CoCreateInstanceEx(rclsid, outer, cls_context, NULL, 1, &multi_qi);
1697 *obj = multi_qi.pItf;
1698 return hr;
1699}
1700
1701/***********************************************************************
1702 * CoCreateInstanceFromApp (combase.@)
1703 */
1705 void *server_info, ULONG count, MULTI_QI *results)
1706{
1707 TRACE("%s, %p, %#lx, %p, %lu, %p\n", debugstr_guid(rclsid), outer, cls_context, server_info,
1708 count, results);
1709
1710 return CoCreateInstanceEx(rclsid, outer, cls_context | CLSCTX_APPCONTAINER, server_info,
1711 count, results);
1712}
1713
1716{
1717 struct class_reg_data clsreg = { 0 };
1719 IUnknown *registered_obj;
1720 struct apartment *apt;
1721
1722 if (!obj)
1723 return E_INVALIDARG;
1724
1725 *obj = NULL;
1726
1727 if (!(apt = apartment_get_current_or_mta()))
1728 {
1729 ERR("apartment not initialised\n");
1730 return CO_E_NOTINITIALIZED;
1731 }
1732
1733 if (server_info)
1734 FIXME("server_info name %s, authinfo %p\n", debugstr_w(server_info->pwszName), server_info->pAuthInfo);
1735
1736 if (clscontext & CLSCTX_INPROC_SERVER)
1737 {
1740 (!(clscontext & CLSCTX_APPCONTAINER) && IsEqualCLSID(rclsid, &CLSID_ManualResetEvent)) ||
1742 {
1743 apartment_release(apt);
1744
1745 if (IsEqualCLSID(rclsid, &CLSID_GlobalOptions))
1746 return get_builtin_class_factory(rclsid, riid, obj);
1747 else
1748 return Ole32DllGetClassObject(rclsid, riid, obj);
1749 }
1750 }
1751
1752 if (clscontext & CLSCTX_INPROC)
1753 {
1754 ACTCTX_SECTION_KEYED_DATA data;
1755
1756 data.cbSize = sizeof(data);
1757 /* search activation context first */
1758 if (FindActCtxSectionGuid(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
1759 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, rclsid, &data))
1760 {
1761 struct comclassredirect_data *comclass = (struct comclassredirect_data *)data.lpData;
1762
1763 clsreg.u.actctx.module_name = (WCHAR *)((BYTE *)data.lpSectionBase + comclass->name_offset);
1764 clsreg.u.actctx.hactctx = data.hActCtx;
1765 clsreg.u.actctx.threading_model = comclass->model;
1766 clsreg.origin = CLASS_REG_ACTCTX;
1767
1768 hr = apartment_get_inproc_class_object(apt, &clsreg, &comclass->clsid, riid, clscontext, obj);
1769 ReleaseActCtx(data.hActCtx);
1770 apartment_release(apt);
1771 return hr;
1772 }
1773 }
1774
1775 /*
1776 * First, try and see if we can't match the class ID with one of the
1777 * registered classes.
1778 */
1779 if (!(clscontext & CLSCTX_APPCONTAINER) && (registered_obj = com_get_registered_class_object(apt, rclsid, clscontext)))
1780 {
1781 hr = IUnknown_QueryInterface(registered_obj, riid, obj);
1782 IUnknown_Release(registered_obj);
1783 apartment_release(apt);
1784 return hr;
1785 }
1786
1787 /* First try in-process server */
1788 if (clscontext & CLSCTX_INPROC_SERVER)
1789 {
1790 HKEY hkey;
1791
1792 hr = open_key_for_clsid(rclsid, L"InprocServer32", KEY_READ, &hkey);
1793 if (FAILED(hr))
1794 {
1795 if (hr == REGDB_E_CLASSNOTREG)
1796 ERR("class %s not registered\n", debugstr_guid(rclsid));
1797 else if (hr == REGDB_E_KEYMISSING)
1798 {
1799 WARN("class %s not registered as in-proc server\n", debugstr_guid(rclsid));
1801 }
1802 }
1803
1804 if (SUCCEEDED(hr))
1805 {
1806 clsreg.u.hkey = hkey;
1807 clsreg.origin = CLASS_REG_REGISTRY;
1808
1809 hr = apartment_get_inproc_class_object(apt, &clsreg, rclsid, riid, clscontext, obj);
1810 RegCloseKey(hkey);
1811 }
1812
1813 /* return if we got a class, otherwise fall through to one of the
1814 * other types */
1815 if (SUCCEEDED(hr))
1816 {
1817 apartment_release(apt);
1818 return hr;
1819 }
1820 }
1821
1822 /* Next try in-process handler */
1823 if (clscontext & CLSCTX_INPROC_HANDLER)
1824 {
1825 HKEY hkey;
1826
1827 hr = open_key_for_clsid(rclsid, L"InprocHandler32", KEY_READ, &hkey);
1828 if (FAILED(hr))
1829 {
1830 if (hr == REGDB_E_CLASSNOTREG)
1831 ERR("class %s not registered\n", debugstr_guid(rclsid));
1832 else if (hr == REGDB_E_KEYMISSING)
1833 {
1834 WARN("class %s not registered in-proc handler\n", debugstr_guid(rclsid));
1836 }
1837 }
1838
1839 if (SUCCEEDED(hr))
1840 {
1841 clsreg.u.hkey = hkey;
1842 clsreg.origin = CLASS_REG_REGISTRY;
1843
1844 hr = apartment_get_inproc_class_object(apt, &clsreg, rclsid, riid, clscontext, obj);
1845 RegCloseKey(hkey);
1846 }
1847
1848 /* return if we got a class, otherwise fall through to one of the
1849 * other types */
1850 if (SUCCEEDED(hr))
1851 {
1852 apartment_release(apt);
1853 return hr;
1854 }
1855 }
1856 apartment_release(apt);
1857
1858 /* Next try out of process */
1859 if (clscontext & CLSCTX_LOCAL_SERVER)
1860 {
1862 if (SUCCEEDED(hr))
1863 return hr;
1864 }
1865
1866 /* Finally try remote: this requires networked DCOM (a lot of work) */
1867 if (clscontext & CLSCTX_REMOTE_SERVER)
1868 {
1869 FIXME ("CLSCTX_REMOTE_SERVER not supported\n");
1871 }
1872
1873 if (FAILED(hr))
1874 ERR("no class object %s could be created for context %#lx\n", debugstr_guid(rclsid), clscontext);
1875
1876 return hr;
1877}
1878
1879/***********************************************************************
1880 * CoCreateInstanceEx (combase.@)
1881 */
1884{
1886 IUnknown *unk = NULL;
1887 CLSID clsid;
1888 HRESULT hr;
1889
1890 TRACE("%s, %p, %#lx, %p, %lu, %p\n", debugstr_guid(rclsid), outer, cls_context, server_info, count, results);
1891
1892 if (!count || !results)
1893 return E_INVALIDARG;
1894
1895 if (server_info)
1896 FIXME("Server info is not supported.\n");
1897
1899
1900 clsid = *rclsid;
1901 if (!(cls_context & CLSCTX_APPCONTAINER))
1902 CoGetTreatAsClass(rclsid, &clsid);
1903
1904 if (FAILED(hr = com_get_class_object(&clsid, cls_context, NULL, &IID_IClassFactory, (void **)&factory)))
1905 return hr;
1906
1907 hr = IClassFactory_CreateInstance(factory, outer, results[0].pIID, (void **)&unk);
1908 IClassFactory_Release(factory);
1909 if (FAILED(hr))
1910 {
1911 if (hr == CLASS_E_NOAGGREGATION && outer)
1912 FIXME("Class %s does not support aggregation\n", debugstr_guid(&clsid));
1913 else
1914 FIXME("no instance created for interface %s of class %s, hr %#lx.\n",
1916 return hr;
1917 }
1918
1919 return return_multi_qi(unk, count, results, TRUE);
1920}
1921
1922/***********************************************************************
1923 * CoGetClassObject (combase.@)
1924 */
1927{
1928 TRACE("%s, %#lx, %s\n", debugstr_guid(rclsid), clscontext, debugstr_guid(riid));
1929
1931}
1932
1933/***********************************************************************
1934 * CoFreeUnusedLibraries (combase.@)
1935 */
1937{
1939}
1940
1941/***********************************************************************
1942 * CoGetCallContext (combase.@)
1943 */
1945{
1946 struct tlsdata *tlsdata;
1947 HRESULT hr;
1948
1949 TRACE("%s, %p\n", debugstr_guid(riid), obj);
1950
1952 return hr;
1953
1954 if (!tlsdata->call_state)
1955 return RPC_E_CALL_COMPLETE;
1956
1957 return IUnknown_QueryInterface(tlsdata->call_state, riid, obj);
1958}
1959
1960/***********************************************************************
1961 * CoSwitchCallContext (combase.@)
1962 */
1964{
1965 struct tlsdata *tlsdata;
1966 HRESULT hr;
1967
1968 TRACE("%p, %p\n", context, old_context);
1969
1971 return hr;
1972
1973 /* Reference counts are not touched. */
1974 *old_context = tlsdata->call_state;
1976
1977 return S_OK;
1978}
1979
1980/******************************************************************************
1981 * CoRegisterInitializeSpy (combase.@)
1982 */
1984{
1985 struct tlsdata *tlsdata;
1986 struct init_spy *entry;
1987 unsigned int id;
1988 HRESULT hr;
1989
1990 TRACE("%p, %p\n", spy, cookie);
1991
1992 if (!spy || !cookie)
1993 return E_INVALIDARG;
1994
1996 return hr;
1997
1998 hr = IInitializeSpy_QueryInterface(spy, &IID_IInitializeSpy, (void **)&spy);
1999 if (FAILED(hr))
2000 return hr;
2001
2002 entry = malloc(sizeof(*entry));
2003 if (!entry)
2004 {
2005 IInitializeSpy_Release(spy);
2006 return E_OUTOFMEMORY;
2007 }
2008
2009 entry->spy = spy;
2010
2011 id = 0;
2012 while (get_spy_entry(tlsdata, id) != NULL)
2013 {
2014 id++;
2015 }
2016
2017 entry->id = id;
2018 list_add_head(&tlsdata->spies, &entry->entry);
2019
2020 cookie->u.HighPart = GetCurrentThreadId();
2021 cookie->u.LowPart = entry->id;
2022
2023 return S_OK;
2024}
2025
2026/******************************************************************************
2027 * CoRevokeInitializeSpy (combase.@)
2028 */
2030{
2031 struct tlsdata *tlsdata;
2032 struct init_spy *spy;
2033 HRESULT hr;
2034
2035 TRACE("%s\n", wine_dbgstr_longlong(cookie.QuadPart));
2036
2037 if (cookie.u.HighPart != GetCurrentThreadId())
2038 return E_INVALIDARG;
2039
2041 return hr;
2042
2043 if (!(spy = get_spy_entry(tlsdata, cookie.u.LowPart))) return E_INVALIDARG;
2044
2045 IInitializeSpy_Release(spy->spy);
2046 spy->spy = NULL;
2047 if (!tlsdata->spies_lock)
2048 {
2049 list_remove(&spy->entry);
2050 free(spy);
2051 }
2052 return S_OK;
2053}
2054
2056{
2057 /* First try to retrieve messages for incoming COM calls to the apartment window */
2058 return (apt->win && PeekMessageW(msg, apt->win, 0, 0, PM_REMOVE | PM_NOYIELD)) ||
2059 /* Next retrieve other messages necessary for the app to remain responsive */
2061 PeekMessageW(msg, NULL, 0, 0, PM_QS_PAINT | PM_QS_SENDMESSAGE | PM_REMOVE | PM_NOYIELD);
2062}
2063
2064/***********************************************************************
2065 * CoWaitForMultipleHandles (combase.@)
2066 */
2068 DWORD *index)
2069{
2070 BOOL check_apc = !!(flags & COWAIT_ALERTABLE), message_loop;
2071 struct { BOOL post; UINT code; } quit = { .post = FALSE };
2072 DWORD start_time, wait_flags = 0;
2073 struct tlsdata *tlsdata;
2074 struct apartment *apt;
2075 HRESULT hr;
2076
2077 TRACE("%#lx, %#lx, %lu, %p, %p\n", flags, timeout, handle_count, handles, index);
2078
2079 if (!index)
2080 return E_INVALIDARG;
2081
2082 *index = 0;
2083
2084 if (!handles)
2085 return E_INVALIDARG;
2086
2087 if (!handle_count)
2088 return RPC_E_NO_SYNC;
2089
2091 return hr;
2092
2093 apt = com_get_current_apt();
2094 message_loop = apt && !apt->multi_threaded;
2095
2096 if (flags & COWAIT_WAITALL)
2097 wait_flags |= MWMO_WAITALL;
2098 if (flags & COWAIT_ALERTABLE)
2099 wait_flags |= MWMO_ALERTABLE;
2100
2101 start_time = GetTickCount();
2102
2103 while (TRUE)
2104 {
2106
2107 if (now - start_time > timeout)
2108 {
2110 break;
2111 }
2112
2113 if (message_loop)
2114 {
2115 TRACE("waiting for rpc completion or window message\n");
2116
2117 res = WAIT_TIMEOUT;
2118
2119 if (check_apc)
2120 {
2121 res = WaitForMultipleObjectsEx(handle_count, handles, !!(flags & COWAIT_WAITALL), 0, TRUE);
2122 check_apc = FALSE;
2123 }
2124
2125 if (res == WAIT_TIMEOUT)
2126 res = MsgWaitForMultipleObjectsEx(handle_count, handles,
2127 timeout == INFINITE ? INFINITE : start_time + timeout - now,
2128 QS_SENDMESSAGE | QS_ALLPOSTMESSAGE | QS_PAINT, wait_flags);
2129
2130 if (res == WAIT_OBJECT_0 + handle_count) /* messages available */
2131 {
2132 int msg_count = 0;
2133 MSG msg;
2134
2135 /* call message filter */
2136
2137 if (apt->filter)
2138 {
2139 PENDINGTYPE pendingtype = tlsdata->pending_call_count_server ? PENDINGTYPE_NESTED : PENDINGTYPE_TOPLEVEL;
2140 DWORD be_handled = IMessageFilter_MessagePending(apt->filter, 0 /* FIXME */, now - start_time, pendingtype);
2141
2142 TRACE("IMessageFilter_MessagePending returned %ld\n", be_handled);
2143
2144 switch (be_handled)
2145 {
2146 case PENDINGMSG_CANCELCALL:
2147 WARN("call canceled\n");
2149 break;
2150 case PENDINGMSG_WAITNOPROCESS:
2151 case PENDINGMSG_WAITDEFPROCESS:
2152 default:
2153 /* FIXME: MSDN is very vague about the difference
2154 * between WAITNOPROCESS and WAITDEFPROCESS - there
2155 * appears to be none, so it is possibly a left-over
2156 * from the 16-bit world. */
2157 break;
2158 }
2159 }
2160
2161 if (!apt->win)
2162 {
2163 /* If window is NULL on apartment, peek at messages so that it will not trigger
2164 * MsgWaitForMultipleObjects next time. */
2165 PeekMessageW(NULL, NULL, 0, 0, PM_QS_POSTMESSAGE | PM_NOREMOVE | PM_NOYIELD);
2166 }
2167
2168 /* Some apps (e.g. Visio 2010) don't handle WM_PAINT properly and loop forever,
2169 * so after processing 100 messages we go back to checking the wait handles */
2170 while (msg_count++ < 100 && com_peek_message(apt, &msg))
2171 {
2172 if (msg.message == WM_QUIT)
2173 {
2174 TRACE("Received WM_QUIT message\n");
2175 quit.post = TRUE;
2176 quit.code = msg.wParam;
2177 }
2178 else
2179 {
2180 TRACE("Received message whilst waiting for RPC: 0x%04x\n", msg.message);
2183 }
2184 }
2185 continue;
2186 }
2187 }
2188 else
2189 {
2190 TRACE("Waiting for rpc completion\n");
2191
2193 (timeout == INFINITE) ? INFINITE : start_time + timeout - now, !!(flags & COWAIT_ALERTABLE));
2194 }
2195
2196 switch (res)
2197 {
2198 case WAIT_TIMEOUT:
2200 break;
2201 case WAIT_FAILED:
2203 break;
2204 default:
2205 *index = res;
2206 break;
2207 }
2208 break;
2209 }
2210 if (quit.post) PostQuitMessage(quit.code);
2211
2212 TRACE("-- %#lx\n", hr);
2213
2214 return hr;
2215}
2216
2217/******************************************************************************
2218 * CoRegisterMessageFilter (combase.@)
2219 */
2221{
2222 IMessageFilter *old_filter;
2223 struct apartment *apt;
2224
2225 TRACE("%p, %p\n", filter, ret_filter);
2226
2227 apt = com_get_current_apt();
2228
2229 /* Can't set a message filter in a multi-threaded apartment */
2230 if (!apt || apt->multi_threaded)
2231 {
2232 WARN("Can't set message filter in MTA or uninitialized apt\n");
2233 return CO_E_NOT_SUPPORTED;
2234 }
2235
2236 if (filter)
2237 IMessageFilter_AddRef(filter);
2238
2239 EnterCriticalSection(&apt->cs);
2240
2241 old_filter = apt->filter;
2242 apt->filter = filter;
2243
2244 LeaveCriticalSection(&apt->cs);
2245
2246 if (ret_filter)
2247 *ret_filter = old_filter;
2248 else if (old_filter)
2249 IMessageFilter_Release(old_filter);
2250
2251 return S_OK;
2252}
2253
2255{
2256 struct registered_ps *cur, *cur2;
2257
2259
2261 {
2262 list_remove(&cur->entry);
2263 free(cur);
2264 }
2265
2267}
2268
2270{
2272 HKEY hkey;
2273 DWORD len;
2274
2275 access |= KEY_READ;
2276
2278 return REGDB_E_IIDNOTREG;
2279
2280 len = sizeof(value);
2281 if (ERROR_SUCCESS != RegQueryValueExW(hkey, NULL, NULL, NULL, (BYTE *)value, &len))
2282 return REGDB_E_IIDNOTREG;
2283 RegCloseKey(hkey);
2284
2285 if (CLSIDFromString(value, pclsid) != NOERROR)
2286 return REGDB_E_IIDNOTREG;
2287
2288 return S_OK;
2289}
2290
2291/*****************************************************************************
2292 * CoGetPSClsid (combase.@)
2293 */
2295{
2296 static const WCHAR interfaceW[] = L"Interface\\";
2297 static const WCHAR psW[] = L"\\ProxyStubClsid32";
2298 WCHAR path[ARRAY_SIZE(interfaceW) - 1 + CHARS_IN_GUID - 1 + ARRAY_SIZE(psW)];
2299 ACTCTX_SECTION_KEYED_DATA data;
2300 struct registered_ps *cur;
2301 REGSAM opposite = (sizeof(void*) > sizeof(int)) ? KEY_WOW64_32KEY : KEY_WOW64_64KEY;
2302 BOOL is_wow64;
2303 HRESULT hr;
2304
2305 TRACE("%s, %p\n", debugstr_guid(riid), pclsid);
2306
2308 {
2309 ERR("apartment not initialised\n");
2310 return CO_E_NOTINITIALIZED;
2311 }
2312
2313 if (!pclsid)
2314 return E_INVALIDARG;
2315
2317
2319 {
2320 if (IsEqualIID(&cur->iid, riid))
2321 {
2322 *pclsid = cur->clsid;
2324 return S_OK;
2325 }
2326 }
2327
2329
2330 data.cbSize = sizeof(data);
2331 if (FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION,
2332 riid, &data))
2333 {
2334 struct ifacepsredirect_data *ifaceps = (struct ifacepsredirect_data *)data.lpData;
2335 *pclsid = ifaceps->iid;
2336 return S_OK;
2337 }
2338
2339 /* Interface\\{string form of riid}\\ProxyStubClsid32 */
2340 lstrcpyW(path, interfaceW);
2341 StringFromGUID2(riid, path + ARRAY_SIZE(interfaceW) - 1, CHARS_IN_GUID);
2342 lstrcpyW(path + ARRAY_SIZE(interfaceW) - 1 + CHARS_IN_GUID - 1, psW);
2343
2345 if (FAILED(hr) && (opposite == KEY_WOW64_32KEY || (IsWow64Process(GetCurrentProcess(), &is_wow64) && is_wow64)))
2346 hr = get_ps_clsid_from_registry(path, opposite | KEY_READ, pclsid);
2347
2348 if (hr == S_OK)
2349 TRACE("() Returning CLSID %s\n", debugstr_guid(pclsid));
2350 else
2351 WARN("No PSFactoryBuffer object is registered for IID %s\n", debugstr_guid(riid));
2352
2353 return hr;
2354}
2355
2356/*****************************************************************************
2357 * CoRegisterPSClsid (combase.@)
2358 */
2360{
2361 struct registered_ps *cur;
2362
2363 TRACE("%s, %s\n", debugstr_guid(riid), debugstr_guid(rclsid));
2364
2366 {
2367 ERR("apartment not initialised\n");
2368 return CO_E_NOTINITIALIZED;
2369 }
2370
2372
2374 {
2375 if (IsEqualIID(&cur->iid, riid))
2376 {
2377 cur->clsid = *rclsid;
2379 return S_OK;
2380 }
2381 }
2382
2383 cur = malloc(sizeof(*cur));
2384 if (!cur)
2385 {
2387 return E_OUTOFMEMORY;
2388 }
2389
2390 cur->iid = *riid;
2391 cur->clsid = *rclsid;
2393
2395
2396 return S_OK;
2397}
2398
2400{
2405};
2406
2408{
2410}
2411
2413{
2415}
2416
2418{
2419 return CONTAINING_RECORD(iface, struct thread_context, IObjContext_iface);
2420}
2421
2423{
2425
2426 *obj = NULL;
2427
2428 if (IsEqualIID(riid, &IID_IComThreadingInfo) ||
2430 {
2431 *obj = &context->IComThreadingInfo_iface;
2432 }
2433 else if (IsEqualIID(riid, &IID_IContextCallback))
2434 {
2435 *obj = &context->IContextCallback_iface;
2436 }
2437 else if (IsEqualIID(riid, &IID_IObjContext))
2438 {
2439 *obj = &context->IObjContext_iface;
2440 }
2441
2442 if (*obj)
2443 {
2444 IUnknown_AddRef((IUnknown *)*obj);
2445 return S_OK;
2446 }
2447
2448 FIXME("interface not implemented %s\n", debugstr_guid(riid));
2449 return E_NOINTERFACE;
2450}
2451
2453{
2455 return InterlockedIncrement(&context->refcount);
2456}
2457
2459{
2461
2462 /* Context instance is initially created with CoGetContextToken() with refcount set to 0,
2463 releasing context while refcount is at 0 destroys it. */
2464 if (!context->refcount)
2465 {
2466 free(context);
2467 return 0;
2468 }
2469
2470 return InterlockedDecrement(&context->refcount);
2471}
2472
2474{
2476
2477 TRACE("%p\n", apttype);
2478
2479 return CoGetApartmentType(apttype, &qualifier);
2480}
2481
2483{
2485 APTTYPE apttype;
2486 HRESULT hr;
2487
2488 hr = CoGetApartmentType(&apttype, &qualifier);
2489 if (FAILED(hr))
2490 return hr;
2491
2492 TRACE("%p\n", thdtype);
2493
2494 switch (apttype)
2495 {
2496 case APTTYPE_STA:
2497 case APTTYPE_MAINSTA:
2498 *thdtype = THDTYPE_PROCESSMESSAGES;
2499 break;
2500 default:
2501 *thdtype = THDTYPE_BLOCKMESSAGES;
2502 break;
2503 }
2504 return S_OK;
2505}
2506
2508{
2509 TRACE("%p\n", logical_thread_id);
2510
2511 return CoGetCurrentLogicalThreadId(logical_thread_id);
2512}
2513
2515{
2516 FIXME("%s stub\n", debugstr_guid(logical_thread_id));
2517
2518 return E_NOTIMPL;
2519}
2520
2521static const IComThreadingInfoVtbl thread_context_info_vtbl =
2522{
2530};
2531
2533{
2535 return IComThreadingInfo_QueryInterface(&context->IComThreadingInfo_iface, riid, obj);
2536}
2537
2539{
2541 return IComThreadingInfo_AddRef(&context->IComThreadingInfo_iface);
2542}
2543
2545{
2547 return IComThreadingInfo_Release(&context->IComThreadingInfo_iface);
2548}
2549
2551 PFNCONTEXTCALL callback, ComCallData *param, REFIID riid, int method, IUnknown *punk)
2552{
2553 FIXME("%p, %p, %p, %s, %d, %p\n", iface, callback, param, debugstr_guid(riid), method, punk);
2554
2555 return E_NOTIMPL;
2556}
2557
2558static const IContextCallbackVtbl thread_context_callback_vtbl =
2559{
2564};
2565
2567{
2569 return IComThreadingInfo_QueryInterface(&context->IComThreadingInfo_iface, riid, obj);
2570}
2571
2573{
2575 return IComThreadingInfo_AddRef(&context->IComThreadingInfo_iface);
2576}
2577
2579{
2581 return IComThreadingInfo_Release(&context->IComThreadingInfo_iface);
2582}
2583
2585{
2586 FIXME("%p, %s, %lx, %p\n", iface, debugstr_guid(propid), flags, punk);
2587
2588 return E_NOTIMPL;
2589}
2590
2592{
2593 FIXME("%p, %s\n", iface, debugstr_guid(propid));
2594
2595 return E_NOTIMPL;
2596}
2597
2599{
2600 FIXME("%p, %s, %p, %p\n", iface, debugstr_guid(propid), flags, punk);
2601
2602 return E_NOTIMPL;
2603}
2604
2606{
2607 FIXME("%p, %p\n", iface, props);
2608
2609 return E_NOTIMPL;
2610}
2611
2613{
2614 FIXME("%p\n", iface);
2615}
2616
2618{
2619 FIXME("%p\n", iface);
2620}
2621
2623{
2624 FIXME("%p\n", iface);
2625}
2626
2628{
2629 FIXME("%p\n", iface);
2630}
2631
2633{
2634 FIXME("%p\n", iface);
2635}
2636
2638{
2639 FIXME("%p\n", iface);
2640}
2641
2643{
2644 FIXME("%p\n", iface);
2645}
2646
2647static const IObjContextVtbl thread_object_context_vtbl =
2648{
2663};
2664
2665/***********************************************************************
2666 * CoGetContextToken (combase.@)
2667 */
2669{
2670 struct tlsdata *tlsdata;
2671 HRESULT hr;
2672
2673 TRACE("%p\n", token);
2674
2676 {
2677 ERR("apartment not initialised\n");
2678 return CO_E_NOTINITIALIZED;
2679 }
2680
2682 return hr;
2683
2684 if (!token)
2685 return E_POINTER;
2686
2687 if (!tlsdata->context_token)
2688 {
2689 struct thread_context *context;
2690
2691 context = calloc(1, sizeof(*context));
2692 if (!context)
2693 return E_OUTOFMEMORY;
2694
2695 context->IComThreadingInfo_iface.lpVtbl = &thread_context_info_vtbl;
2696 context->IContextCallback_iface.lpVtbl = &thread_context_callback_vtbl;
2697 context->IObjContext_iface.lpVtbl = &thread_object_context_vtbl;
2698 /* Context token does not take a reference, it's always zero until the
2699 interface is explicitly requested with CoGetObjectContext(). */
2700 context->refcount = 0;
2701
2702 tlsdata->context_token = &context->IObjContext_iface;
2703 }
2704
2706 TRACE("context_token %p\n", tlsdata->context_token);
2707
2708 return S_OK;
2709}
2710
2711/***********************************************************************
2712 * CoGetCurrentLogicalThreadId (combase.@)
2713 */
2715{
2716 struct tlsdata *tlsdata;
2717 HRESULT hr;
2718
2719 if (!id)
2720 return E_INVALIDARG;
2721
2723 return hr;
2724
2726 {
2729 }
2730
2731 *id = tlsdata->causality_id;
2732
2733 return S_OK;
2734}
2735
2736/******************************************************************************
2737 * CoGetCurrentProcess (combase.@)
2738 */
2740{
2741 struct tlsdata *tlsdata;
2742
2744 return 0;
2745
2746 if (!tlsdata->thread_seqid)
2748
2749 return tlsdata->thread_seqid;
2750}
2751
2752/***********************************************************************
2753 * CoFreeUnusedLibrariesEx (combase.@)
2754 */
2756{
2757 struct apartment *apt = com_get_current_apt();
2758 if (!apt)
2759 {
2760 ERR("apartment not initialised\n");
2761 return;
2762 }
2763
2764 apartment_freeunusedlibraries(apt, unload_delay);
2765}
2766
2767/*
2768 * When locked, don't modify list (unless we add a new head), so that it's
2769 * safe to iterate it. Freeing of list entries is delayed and done on unlock.
2770 */
2771static inline void lock_init_spies(struct tlsdata *tlsdata)
2772{
2774}
2775
2777{
2778 struct init_spy *spy, *next;
2779
2780 if (--tlsdata->spies_lock) return;
2781
2783 {
2784 if (spy->spy) continue;
2785 list_remove(&spy->entry);
2786 free(spy);
2787 }
2788}
2789
2790/******************************************************************************
2791 * CoInitializeWOW (combase.@)
2792 */
2794{
2795 FIXME("%#lx, %#lx\n", arg1, arg2);
2796
2797 return S_OK;
2798}
2799
2800/******************************************************************************
2801 * CoInitializeEx (combase.@)
2802 */
2804{
2805 struct tlsdata *tlsdata;
2806 struct init_spy *cursor;
2807 HRESULT hr;
2808
2809 TRACE("%p, %#lx\n", reserved, model);
2810
2811 if (reserved)
2812 WARN("Unexpected reserved argument %p\n", reserved);
2813
2815 return hr;
2816
2818 TRACE("Initializing the COM libraries\n");
2819
2822 {
2823 if (cursor->spy) IInitializeSpy_PreInitialize(cursor->spy, model, tlsdata->inits);
2824 }
2826
2827 hr = enter_apartment(tlsdata, model);
2828
2831 {
2832 if (cursor->spy) hr = IInitializeSpy_PostInitialize(cursor->spy, hr, model, tlsdata->inits);
2833 }
2835
2836 return hr;
2837}
2838
2839/***********************************************************************
2840 * CoUninitialize (combase.@)
2841 */
2843{
2844 struct tlsdata *tlsdata;
2845 struct init_spy *cursor, *next;
2846 LONG lockcount;
2847
2848 TRACE("\n");
2849
2851 return;
2852
2855 {
2856 if (cursor->spy) IInitializeSpy_PreUninitialize(cursor->spy, tlsdata->inits);
2857 }
2859
2860 /* sanity check */
2861 if (!tlsdata->inits)
2862 {
2863 ERR("Mismatched CoUninitialize\n");
2864
2867 {
2868 if (cursor->spy) IInitializeSpy_PostUninitialize(cursor->spy, tlsdata->inits);
2869 }
2871
2872 return;
2873 }
2874
2876
2877 /*
2878 * Decrease the reference count.
2879 * If we are back to 0 locks on the COM library, make sure we free
2880 * all the associated data structures.
2881 */
2882 lockcount = InterlockedExchangeAdd(&com_lockcount, -1);
2883 if (lockcount == 1)
2884 {
2885 TRACE("Releasing the COM libraries\n");
2886
2889 }
2890 else if (lockcount < 1)
2891 {
2892 ERR("Unbalanced lock count %ld\n", lockcount);
2894 }
2895
2898 {
2899 if (cursor->spy) IInitializeSpy_PostUninitialize(cursor->spy, tlsdata->inits);
2900 }
2902}
2903
2904/***********************************************************************
2905 * CoIncrementMTAUsage (combase.@)
2906 */
2908{
2909 TRACE("%p\n", cookie);
2910
2912}
2913
2914/***********************************************************************
2915 * CoDecrementMTAUsage (combase.@)
2916 */
2918{
2919 TRACE("%p\n", cookie);
2920
2922 return S_OK;
2923}
2924
2925/***********************************************************************
2926 * CoGetApartmentType (combase.@)
2927 */
2929{
2930 struct tlsdata *tlsdata;
2931 struct apartment *apt;
2932 HRESULT hr;
2933
2934 TRACE("%p, %p\n", type, qualifier);
2935
2936 if (!type || !qualifier)
2937 return E_INVALIDARG;
2938
2940 return hr;
2941
2942 if (!tlsdata->apt)
2943 *type = APTTYPE_CURRENT;
2944 else if (tlsdata->apt->multi_threaded)
2945 *type = APTTYPE_MTA;
2946 else if (tlsdata->apt->main)
2948 else
2949 *type = APTTYPE_STA;
2950
2952
2953 if (!tlsdata->apt && (apt = apartment_get_mta()))
2954 {
2955 apartment_release(apt);
2956 *type = APTTYPE_MTA;
2958 return S_OK;
2959 }
2960
2961 return tlsdata->apt ? S_OK : CO_E_NOTINITIALIZED;
2962}
2963
2964/******************************************************************************
2965 * CoRegisterClassObject (combase.@)
2966 * BUGS
2967 * MSDN claims that multiple interface registrations are legal, but we
2968 * can't do that with our current implementation.
2969 */
2972{
2973 static LONG next_cookie;
2974
2975 struct registered_class *newclass;
2976 IUnknown *found_object;
2977 struct apartment *apt;
2978 HRESULT hr = S_OK;
2979
2980 TRACE("%s, %p, %#lx, %#lx, %p\n", debugstr_guid(rclsid), object, clscontext, flags, cookie);
2981
2982 if (!cookie || !object)
2983 return E_INVALIDARG;
2984
2985 if (!(apt = apartment_get_current_or_mta()))
2986 {
2987 ERR("COM was not initialized\n");
2988 return CO_E_NOTINITIALIZED;
2989 }
2990
2991 *cookie = 0;
2992
2993 /* REGCLS_MULTIPLEUSE implies registering as inproc server. This is what
2994 * differentiates the flag from REGCLS_MULTI_SEPARATE. */
2996 clscontext |= CLSCTX_INPROC_SERVER;
2997
2998 /*
2999 * First, check if the class is already registered.
3000 * If it is, this should cause an error.
3001 */
3002 if ((found_object = com_get_registered_class_object(apt, rclsid, clscontext)))
3003 {
3005 {
3006 if (clscontext & CLSCTX_LOCAL_SERVER)
3007 hr = CoLockObjectExternal(found_object, TRUE, FALSE);
3008 IUnknown_Release(found_object);
3009 apartment_release(apt);
3010 return hr;
3011 }
3012
3013 IUnknown_Release(found_object);
3014 ERR("object already registered for class %s\n", debugstr_guid(rclsid));
3015 apartment_release(apt);
3016 return CO_E_OBJISREG;
3017 }
3018
3019 newclass = calloc(1, sizeof(*newclass));
3020 if (!newclass)
3021 {
3022 apartment_release(apt);
3023 return E_OUTOFMEMORY;
3024 }
3025
3026 newclass->clsid = *rclsid;
3027 newclass->apartment_id = apt->oxid;
3028 newclass->clscontext = clscontext;
3029 newclass->flags = flags;
3030
3031 if (!(newclass->cookie = InterlockedIncrement(&next_cookie)))
3032 newclass->cookie = InterlockedIncrement(&next_cookie);
3033
3034 newclass->object = object;
3035 IUnknown_AddRef(newclass->object);
3036
3040
3041 *cookie = newclass->cookie;
3042
3043 if (clscontext & CLSCTX_LOCAL_SERVER)
3044 {
3045 IStream *marshal_stream;
3046
3047 hr = apartment_get_local_server_stream(apt, &marshal_stream);
3048 if(FAILED(hr))
3049 {
3050 apartment_release(apt);
3051 return hr;
3052 }
3053
3054 hr = rpc_register_local_server(&newclass->clsid, marshal_stream, flags, &newclass->rpcss_cookie);
3055 IStream_Release(marshal_stream);
3056 }
3057
3058 apartment_release(apt);
3059 return S_OK;
3060}
3061
3063{
3064 list_remove(&entry->entry);
3065
3066 if (entry->clscontext & CLSCTX_LOCAL_SERVER)
3067 rpc_revoke_local_server(entry->rpcss_cookie);
3068
3069 IUnknown_Release(entry->object);
3070 free(entry);
3071}
3072
3073/* Cleans up rpcss registry */
3075{
3076 struct registered_class *cur, *cur2;
3077
3079
3081 {
3082 if (cur->clscontext & CLSCTX_LOCAL_SERVER)
3084 }
3085
3087}
3088
3090{
3091 struct registered_class *cur, *cur2;
3092
3094
3096 {
3097 if (cur->apartment_id == apt->oxid)
3099 }
3100
3102}
3103
3104/***********************************************************************
3105 * CoRevokeClassObject (combase.@)
3106 */
3108{
3110 struct registered_class *cur;
3111 struct apartment *apt;
3112
3113 TRACE("%#lx\n", cookie);
3114
3115 if (!(apt = apartment_get_current_or_mta()))
3116 {
3117 ERR("COM was not initialized\n");
3118 return CO_E_NOTINITIALIZED;
3119 }
3120
3122
3124 {
3125 if (cur->cookie != cookie)
3126 continue;
3127
3128 if (cur->apartment_id == apt->oxid)
3129 {
3131 hr = S_OK;
3132 }
3133 else
3134 {
3135 ERR("called from wrong apartment, should be called from %s\n", wine_dbgstr_longlong(cur->apartment_id));
3137 }
3138
3139 break;
3140 }
3141
3143 apartment_release(apt);
3144
3145 return hr;
3146}
3147
3148/***********************************************************************
3149 * CoAddRefServerProcess (combase.@)
3150 */
3152{
3153 ULONG refs;
3154
3155 TRACE("\n");
3156
3160
3161 TRACE("refs before: %ld\n", refs - 1);
3162
3163 return refs;
3164}
3165
3166/***********************************************************************
3167 * CoReleaseServerProcess [OLE32.@]
3168 */
3170{
3171 ULONG refs;
3172
3173 TRACE("\n");
3174
3176
3178 /* FIXME: suspend objects */
3179
3181
3182 TRACE("refs after: %ld\n", refs);
3183
3184 return refs;
3185}
3186
3187/******************************************************************************
3188 * CoDisconnectObject (combase.@)
3189 */
3191{
3192 struct stub_manager *manager;
3193 struct apartment *apt;
3194 IMarshal *marshal;
3195 HRESULT hr;
3196
3197 TRACE("%p, %#lx\n", object, reserved);
3198
3199 if (!object)
3200 return E_INVALIDARG;
3201
3202 hr = IUnknown_QueryInterface(object, &IID_IMarshal, (void **)&marshal);
3203 if (hr == S_OK)
3204 {
3205 hr = IMarshal_DisconnectObject(marshal, reserved);
3206 IMarshal_Release(marshal);
3207 return hr;
3208 }
3209
3210 if (!(apt = apartment_get_current_or_mta()))
3211 {
3212 ERR("apartment not initialised\n");
3213 return CO_E_NOTINITIALIZED;
3214 }
3215
3216 manager = get_stub_manager_from_object(apt, object, FALSE);
3217 if (manager)
3218 {
3219 stub_manager_disconnect(manager);
3220 /* Release stub manager twice, to remove the apartment reference. */
3221 stub_manager_int_release(manager);
3222 stub_manager_int_release(manager);
3223 }
3224
3225 /* Note: native is pretty broken here because it just silently
3226 * fails, without returning an appropriate error code if the object was
3227 * not found, making apps think that the object was disconnected, when
3228 * it actually wasn't */
3229
3230 apartment_release(apt);
3231 return S_OK;
3232}
3233
3234/******************************************************************************
3235 * CoLockObjectExternal (combase.@)
3236 */
3238{
3239 struct stub_manager *stubmgr;
3240 struct apartment *apt;
3241
3242 TRACE("%p, %d, %d\n", object, lock, last_unlock_releases);
3243
3244 if (!(apt = apartment_get_current_or_mta()))
3245 {
3246 ERR("apartment not initialised\n");
3247 return CO_E_NOTINITIALIZED;
3248 }
3249
3250 stubmgr = get_stub_manager_from_object(apt, object, lock);
3251 if (!stubmgr)
3252 {
3253 WARN("stub object not found %p\n", object);
3254 /* Note: native is pretty broken here because it just silently
3255 * fails, without returning an appropriate error code, making apps
3256 * think that the object was disconnected, when it actually wasn't */
3257 apartment_release(apt);
3258 return S_OK;
3259 }
3260
3261 if (lock)
3262 stub_manager_ext_addref(stubmgr, 1, FALSE);
3263 else
3264 stub_manager_ext_release(stubmgr, 1, FALSE, last_unlock_releases);
3265
3266 stub_manager_int_release(stubmgr);
3267 apartment_release(apt);
3268 return S_OK;
3269}
3270
3271/***********************************************************************
3272 * CoRegisterChannelHook (combase.@)
3273 */
3275{
3276 TRACE("%s, %p\n", debugstr_guid(guidExtension), channel_hook);
3277
3278 return rpc_register_channel_hook(guidExtension, channel_hook);
3279}
3280
3281/***********************************************************************
3282 * CoDisableCallCancellation (combase.@)
3283 */
3285{
3286 struct tlsdata *tlsdata;
3287 HRESULT hr;
3288
3289 TRACE("%p\n", reserved);
3290
3292 return hr;
3293
3294 if (!tlsdata->cancelcount)
3295 return CO_E_CANCEL_DISABLED;
3296
3298
3299 return S_OK;
3300}
3301
3302/***********************************************************************
3303 * CoEnableCallCancellation (combase.@)
3304 */
3306{
3307 struct tlsdata *tlsdata;
3308 HRESULT hr;
3309
3310 TRACE("%p\n", reserved);
3311
3313 return hr;
3314
3316
3317 return S_OK;
3318}
3319
3320/***********************************************************************
3321 * CoGetCallerTID (combase.@)
3322 */
3324{
3325 FIXME("stub!\n");
3326 return E_NOTIMPL;
3327}
3328
3329/***********************************************************************
3330 * CoIsHandlerConnected (combase.@)
3331 */
3333{
3334 FIXME("%p\n", object);
3335
3336 return TRUE;
3337}
3338
3339/***********************************************************************
3340 * CoSuspendClassObjects (combase.@)
3341 */
3343{
3344 FIXME("\n");
3345
3346 return S_OK;
3347}
3348
3349/***********************************************************************
3350 * CoResumeClassObjects (combase.@)
3351 */
3353{
3354 FIXME("stub\n");
3355
3356 return S_OK;
3357}
3358
3359/***********************************************************************
3360 * CoRegisterSurrogate (combase.@)
3361 */
3363{
3364 FIXME("%p stub\n", surrogate);
3365
3366 return E_NOTIMPL;
3367}
3368
3369/***********************************************************************
3370 * CoRegisterSurrogateEx (combase.@)
3371 */
3373{
3374 FIXME("%s, %p stub\n", debugstr_guid(guid), reserved);
3375
3376 return E_NOTIMPL;
3377}
3378
3379/***********************************************************************
3380 * DllMain (combase.@)
3381 */
3383{
3384 TRACE("%p, %#lx, %p\n", hinstDLL, reason, reserved);
3385
3386 switch (reason)
3387 {
3388 case DLL_PROCESS_ATTACH:
3389 hProxyDll = hinstDLL;
3390 break;
3391 case DLL_PROCESS_DETACH:
3393 if (reserved) break;
3397 break;
3398 case DLL_THREAD_DETACH:
3400 break;
3401 }
3402
3403 return TRUE;
3404}
3405
3407{
3408 TRACE("%s, %s, %p.\n", debugstr_guid(rclsid), debugstr_guid(riid), obj);
3409
3410 *obj = NULL;
3411
3412 if (IsEqualCLSID(rclsid, &CLSID_GlobalOptions))
3413 return IClassFactory_QueryInterface(&global_options_factory, riid, obj);
3414
3416}
#define CO_E_NOTINITIALIZED
static struct _test_info results[8]
Definition: SetCursorPos.c:31
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:240
#define stat
Definition: acwin.h:99
HRESULT apartment_get_inproc_class_object(struct apartment *apt, const struct class_reg_data *regdata, REFCLSID rclsid, REFIID riid, DWORD class_context, void **ppv)
Definition: apartment.c:1031
void apartment_global_cleanup(void)
Definition: apartment.c:1289
struct apartment * apartment_get_mta(void)
Definition: apartment.c:607
HRESULT enter_apartment(struct tlsdata *data, DWORD model)
Definition: apartment.c:1129
HRESULT apartment_increment_mta_usage(CO_MTA_USAGE_COOKIE *cookie)
Definition: apartment.c:1175
HRESULT apartment_get_local_server_stream(struct apartment *apt, IStream **ret)
Definition: apartment.c:315
void apartment_freeunusedlibraries(struct apartment *apt, DWORD delay)
Definition: apartment.c:403
void leave_apartment(struct tlsdata *data)
Definition: apartment.c:1153
void apartment_release(struct apartment *apt)
Definition: apartment.c:444
void apartment_decrement_mta_usage(CO_MTA_USAGE_COOKIE cookie)
Definition: apartment.c:1199
struct apartment * apartment_get_current_or_mta(void)
Definition: apartment.c:623
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define msg(x)
Definition: auth_time.c:54
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const WCHAR * alias
Definition: main.c:67
LONG NTSTATUS
Definition: precomp.h:26
static const WCHAR nameW[]
Definition: main.c:49
#define index(s, c)
Definition: various.h:29
void quit(int argc, const char *argv[])
Definition: cmds.c:1606
#define ARRAY_SIZE(A)
Definition: main.h:20
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
static void list_init(struct list_entry *head)
Definition: list.h:51
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define RegCloseKey(hKey)
Definition: registry.h:49
const CLSID CLSID_GlobalOptions
const CLSID CLSID_ManualResetEvent
const CLSID CLSID_InProcFreeMarshaler
const CLSID CLSID_StdGlobalInterfaceTable
Definition: list.h:37
@ CLASS_REG_REGISTRY
@ CLASS_REG_ACTCTX
HRESULT rpc_revoke_local_server(unsigned int cookie)
Definition: rpc.c:375
ULONG stub_manager_ext_release(struct stub_manager *m, ULONG refs, BOOL tableweak, BOOL last_unlock_releases)
Definition: stubmanager.c:437
struct stub_manager * get_stub_manager_from_object(struct apartment *apt, IUnknown *object, BOOL alloc)
Definition: stubmanager.c:335
HRESULT rpc_register_local_server(REFCLSID clsid, IStream *stream, DWORD flags, unsigned int *cookie)
Definition: rpc.c:701
@ OLETLS_UUIDINITIALIZED
ULONG stub_manager_int_release(struct stub_manager *stub_manager)
Definition: stubmanager.c:309
#define CHARS_IN_GUID
void stub_manager_disconnect(struct stub_manager *m)
Definition: stubmanager.c:242
HRESULT rpc_register_channel_hook(REFGUID rguid, IChannelHook *hook)
Definition: rpc.c:971
HRESULT rpcss_get_next_seqid(DWORD *id)
Definition: rpc.c:308
static struct apartment * com_get_current_apt(void)
HRESULT rpc_get_local_class_object(REFCLSID rclsid, REFIID riid, void **obj)
Definition: rpc.c:629
void rpc_unregister_channel_hooks(void)
Definition: rpc.c:990
static HRESULT com_get_tlsdata(struct tlsdata **data)
ULONG stub_manager_ext_addref(struct stub_manager *m, ULONG refs, BOOL tableweak)
Definition: stubmanager.c:406
#define WM_DDE_FIRST
Definition: dde.h:47
#define WM_DDE_LAST
Definition: dde.h:46
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR clsidW[]
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LSTATUS WINAPI RegQueryValueW(HKEY hkey, LPCWSTR name, LPWSTR data, LPLONG count)
Definition: reg.c:4241
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
static void com_cleanup_tlsdata(void)
Definition: combase.c:416
static struct thread_context * impl_from_IComThreadingInfo(IComThreadingInfo *iface)
Definition: combase.c:2407
HRESULT WINAPI CoInitializeWOW(DWORD arg1, DWORD arg2)
Definition: combase.c:2793
HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, CLSID *clsid)
Definition: combase.c:1437
HRESULT WINAPI CoGetPSClsid(REFIID riid, CLSID *pclsid)
Definition: combase.c:2294
static HRESULT WINAPI global_options_Set(IGlobalOptions *iface, GLOBALOPT_PROPERTIES property, ULONG_PTR value)
Definition: combase.c:501
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **obj)
Definition: combase.c:3406
DWORD WINAPI CoGetCurrentProcess(void)
Definition: combase.c:2739
static LSTATUS create_classes_key(HKEY hkey, const WCHAR *name, REGSAM access, HKEY *retkey)
Definition: combase.c:254
HRESULT WINAPI InternalTlsAllocData(struct tlsdata **data)
Definition: combase.c:405
static BOOL is_valid_hex(WCHAR c)
Definition: combase.c:1327
ULONG WINAPI CoAddRefServerProcess(void)
Definition: combase.c:3151
static IClassFactory global_options_factory
Definition: combase.c:589
HRESULT WINAPI CoGetTreatAsClass(REFCLSID clsidOld, CLSID *clsidNew)
Definition: combase.c:1224
static HRESULT get_builtin_class_factory(REFCLSID rclsid, REFIID riid, void **obj)
Definition: combase.c:591
static void com_revoke_local_servers(void)
Definition: combase.c:3074
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
Definition: combase.c:709
HRESULT WINAPI Ole32DllGetClassObject(REFCLSID rclsid, REFIID riid, void **obj)
Definition: oleproxy.c:229
HRESULT WINAPI CoIncrementMTAUsage(CO_MTA_USAGE_COOKIE *cookie)
Definition: combase.c:2907
static void WINAPI thread_object_context_Reserved6(IObjContext *iface)
Definition: combase.c:2637
HRESULT WINAPI CoGetInstanceFromIStorage(COSERVERINFO *server_info, CLSID *rclsid, IUnknown *outer, DWORD cls_context, IStorage *storage, DWORD count, MULTI_QI *results)
Definition: combase.c:1635
static HRESULT WINAPI class_factory_LockServer(IClassFactory *iface, BOOL fLock)
Definition: combase.c:553
static void init_multi_qi(DWORD count, MULTI_QI *mqi, HRESULT hr)
Definition: combase.c:1534
HRESULT WINAPI CoRegisterMessageFilter(IMessageFilter *filter, IMessageFilter **ret_filter)
Definition: combase.c:2220
HRESULT WINAPI CoGetDefaultContext(APTTYPE type, REFIID riid, void **obj)
Definition: combase.c:1194
static HRESULT WINAPI global_options_Query(IGlobalOptions *iface, GLOBALOPT_PROPERTIES property, ULONG_PTR *value)
Definition: combase.c:508
HRESULT WINAPI CoRegisterSurrogate(ISurrogate *surrogate)
Definition: combase.c:3362
static HRESULT propvar_validatetype(VARTYPE vt)
Definition: combase.c:616
IUnknown * com_get_registered_class_object(const struct apartment *apt, REFCLSID rclsid, DWORD clscontext)
Definition: combase.c:144
HRESULT open_appidkey_from_clsid(REFCLSID clsid, REGSAM access, HKEY *subkey)
Definition: combase.c:353
static HRESULT WINAPI thread_context_info_GetCurrentApartmentType(IComThreadingInfo *iface, APTTYPE *apttype)
Definition: combase.c:2473
static const IClassFactoryVtbl global_options_factory_vtbl
Definition: combase.c:580
static struct list registered_proxystubs
Definition: combase.c:110
static HRESULT WINAPI thread_object_context_QueryInterface(IObjContext *iface, REFIID riid, void **obj)
Definition: combase.c:2566
HRESULT WINAPI CoQueryClientBlanket(DWORD *authn_service, DWORD *authz_service, OLECHAR **servername, DWORD *authn_level, DWORD *imp_level, RPC_AUTHZ_HANDLE *privs, DWORD *capabilities)
Definition: combase.c:1100
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
static ULONG WINAPI thread_object_context_AddRef(IObjContext *iface)
Definition: combase.c:2572
HRESULT WINAPI IIDFromString(LPCOLESTR str, IID *iid)
Definition: combase.c:1492
void WINAPI DECLSPEC_HOTPATCH CoFreeUnusedLibrariesEx(DWORD unload_delay, DWORD reserved)
Definition: combase.c:2755
static HKEY classes_root_hkey
Definition: combase.c:218
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstanceEx(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, COSERVERINFO *server_info, ULONG count, MULTI_QI *results)
Definition: combase.c:1882
static HRESULT return_multi_qi(IUnknown *unk, DWORD count, MULTI_QI *mqi, BOOL include_unk)
Definition: combase.c:1545
static HRESULT WINAPI thread_context_info_QueryInterface(IComThreadingInfo *iface, REFIID riid, void **obj)
Definition: combase.c:2422
HRESULT WINAPI CoRegisterInitializeSpy(IInitializeSpy *spy, ULARGE_INTEGER *cookie)
Definition: combase.c:1983
static HRESULT get_ps_clsid_from_registry(const WCHAR *path, REGSAM access, CLSID *pclsid)
Definition: combase.c:2269
static void WINAPI thread_object_context_Reserved4(IObjContext *iface)
Definition: combase.c:2627
BOOL WINAPI CoIsHandlerConnected(IUnknown *object)
Definition: combase.c:3332
HRESULT WINAPI CoGetCallerTID(DWORD *tid)
Definition: combase.c:3323
void WINAPI DestroyRunningObjectTable(void)
Definition: moniker.c:748
HRESULT WINAPI CLSIDFromProgIDEx(LPCOLESTR progid, CLSID *clsid)
Definition: combase.c:1460
static void WINAPI thread_object_context_Reserved3(IObjContext *iface)
Definition: combase.c:2622
static void WINAPI thread_object_context_Reserved5(IObjContext *iface)
Definition: combase.c:2632
HRESULT WINAPI CoDisableCallCancellation(void *reserved)
Definition: combase.c:3284
static CRITICAL_SECTION_DEBUG registered_classes_cs_debug
Definition: combase.c:136
HRESULT WINAPI StringFromCLSID(REFCLSID clsid, LPOLESTR *str)
Definition: combase.c:1515
HRESULT WINAPI DECLSPEC_HOTPATCH CoRevokeClassObject(DWORD cookie)
Definition: combase.c:3107
HRESULT WINAPI CoSetProxyBlanket(IUnknown *proxy, DWORD authn_service, DWORD authz_service, OLECHAR *servername, DWORD authn_level, DWORD imp_level, void *auth_info, DWORD capabilities)
Definition: combase.c:1055
HRESULT WINAPI CoGetContextToken(ULONG_PTR *token)
Definition: combase.c:2668
void apartment_revoke_all_classes(const struct apartment *apt)
Definition: combase.c:3089
static ULONG WINAPI thread_object_context_Release(IObjContext *iface)
Definition: combase.c:2578
HRESULT WINAPI CoEnableCallCancellation(void *reserved)
Definition: combase.c:3305
HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, const PROPVARIANT *pvarSrc)
Definition: combase.c:827
static void WINAPI thread_object_context_Reserved7(IObjContext *iface)
Definition: combase.c:2642
HRESULT WINAPI CoInitializeSecurity(PSECURITY_DESCRIPTOR sd, LONG cAuthSvc, SOLE_AUTHENTICATION_SERVICE *asAuthSvc, void *reserved1, DWORD authn_level, DWORD imp_level, void *reserved2, DWORD capabilities, void *reserved3)
Definition: combase.c:1163
static struct thread_context * impl_from_IContextCallback(IContextCallback *iface)
Definition: combase.c:2412
static HRESULT WINAPI thread_context_info_SetCurrentLogicalThreadId(IComThreadingInfo *iface, REFGUID logical_thread_id)
Definition: combase.c:2514
HRESULT WINAPI DECLSPEC_HOTPATCH ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *progid)
Definition: combase.c:1262
static HRESULT WINAPI thread_object_context_GetProperty(IObjContext *iface, REFGUID propid, CPFLAGS *flags, IUnknown **punk)
Definition: combase.c:2598
static HKEY get_classes_root_hkey(HKEY hkey, REGSAM access)
Definition: combase.c:277
static struct init_spy * get_spy_entry(struct tlsdata *tlsdata, unsigned int id)
Definition: combase.c:168
static BOOL com_peek_message(struct apartment *apt, MSG *msg)
Definition: combase.c:2055
static CRITICAL_SECTION cs_registered_ps
Definition: combase.c:112
INT WINAPI StringFromGUID2(REFGUID guid, LPOLESTR str, INT cmax)
Definition: combase.c:1525
static HRESULT WINAPI thread_object_context_SetProperty(IObjContext *iface, REFGUID propid, CPFLAGS flags, IUnknown *punk)
Definition: combase.c:2584
static HKEY create_classes_root_hkey(DWORD access)
Definition: combase.c:220
static NTSTATUS create_key(HKEY *retkey, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr)
Definition: combase.c:181
static struct thread_context * impl_from_IObjContext(IObjContext *iface)
Definition: combase.c:2417
static ULONG WINAPI class_factory_Release(IClassFactory *iface)
Definition: combase.c:548
void WINAPI DECLSPEC_HOTPATCH CoFreeUnusedLibraries(void)
Definition: combase.c:1936
HRESULT WINAPI CoGetCallState(int arg1, ULONG *arg2)
Definition: combase.c:1204
static HRESULT WINAPI thread_object_context_RemoveProperty(IObjContext *iface, REFGUID propid)
Definition: combase.c:2591
HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD clscontext, COSERVERINFO *server_info, REFIID riid, void **obj)
Definition: combase.c:1925
static const IObjContextVtbl thread_object_context_vtbl
Definition: combase.c:2647
HRESULT WINAPI CoDisconnectObject(IUnknown *object, DWORD reserved)
Definition: combase.c:3190
HRESULT WINAPI CoGetObjectContext(REFIID riid, void **ppv)
Definition: combase.c:1176
static HRESULT WINAPI thread_context_callback_ContextCallback(IContextCallback *iface, PFNCONTEXTCALL callback, ComCallData *param, REFIID riid, int method, IUnknown *punk)
Definition: combase.c:2550
HRESULT WINAPI CoGetCallContext(REFIID riid, void **obj)
Definition: combase.c:1944
static ULONG WINAPI thread_context_info_Release(IComThreadingInfo *iface)
Definition: combase.c:2458
HRESULT WINAPI CoSwitchCallContext(IUnknown *context, IUnknown **old_context)
Definition: combase.c:1963
HINSTANCE hProxyDll
Definition: combase.c:40
HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier)
Definition: combase.c:2928
static const IComThreadingInfoVtbl thread_context_info_vtbl
Definition: combase.c:2521
static LONG com_server_process_refcount
Definition: combase.c:53
HRESULT WINAPI CoCreateInstanceFromApp(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, void *server_info, ULONG count, MULTI_QI *results)
Definition: combase.c:1704
static void propvar_free_cf_array(ULONG count, CLIPDATA *data)
Definition: combase.c:699
static void unlock_init_spies(struct tlsdata *tlsdata)
Definition: combase.c:2776
static void com_revoke_all_ps_clsids(void)
Definition: combase.c:2254
static ULONG WINAPI thread_context_callback_Release(IContextCallback *iface)
Definition: combase.c:2544
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
Definition: combase.c:3382
static ULONG WINAPI global_options_Release(IGlobalOptions *iface)
Definition: combase.c:488
static CRITICAL_SECTION_DEBUG psclsid_cs_debug
Definition: combase.c:113
static HRESULT WINAPI thread_context_info_GetCurrentThreadType(IComThreadingInfo *iface, THDTYPE *thdtype)
Definition: combase.c:2482
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(void *reserved, DWORD model)
Definition: combase.c:2803
HRESULT WINAPI CoSuspendClassObjects(void)
Definition: combase.c:3342
static const IContextCallbackVtbl thread_context_callback_vtbl
Definition: combase.c:2558
static HRESULT WINAPI thread_context_callback_QueryInterface(IContextCallback *iface, REFIID riid, void **obj)
Definition: combase.c:2532
HRESULT WINAPI CoRegisterPSClsid(REFIID riid, REFCLSID rclsid)
Definition: combase.c:2359
HRESULT WINAPI CoCreateGuid(GUID *guid)
Definition: combase.c:1016
HRESULT WINAPI CoResumeClassObjects(void)
Definition: combase.c:3352
static ULONG WINAPI thread_context_info_AddRef(IComThreadingInfo *iface)
Definition: combase.c:2452
static ULONG WINAPI global_options_AddRef(IGlobalOptions *iface)
Definition: combase.c:478
HRESULT WINAPI CoImpersonateClient(void)
Definition: combase.c:1123
HRESULT WINAPI CoCopyProxy(IUnknown *proxy, IUnknown **proxy_copy)
Definition: combase.c:1079
static HRESULT WINAPI thread_object_context_EnumContextProps(IObjContext *iface, IEnumContextProps **props)
Definition: combase.c:2605
static struct global_options * impl_from_IGlobalOptions(IGlobalOptions *iface)
Definition: combase.c:455
static HRESULT com_get_class_object(REFCLSID rclsid, DWORD clscontext, COSERVERINFO *server_info, REFIID riid, void **obj)
Definition: combase.c:1714
HRESULT WINAPI CoGetActivationState(GUID guid, DWORD arg2, DWORD *arg3)
Definition: combase.c:1214
static void com_revoke_class_object(struct registered_class *entry)
Definition: combase.c:3062
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
static void lock_init_spies(struct tlsdata *tlsdata)
Definition: combase.c:2771
HRESULT WINAPI CoRegisterSurrogateEx(REFGUID guid, void *reserved)
Definition: combase.c:3372
static HRESULT WINAPI global_options_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: combase.c:560
HRESULT WINAPI DECLSPEC_HOTPATCH CoGetInstanceFromFile(COSERVERINFO *server_info, CLSID *rclsid, IUnknown *outer, DWORD cls_context, DWORD grfmode, OLECHAR *filename, DWORD count, MULTI_QI *results)
Definition: combase.c:1575
HRESULT WINAPI CoRegisterChannelHook(REFGUID guidExtension, IChannelHook *channel_hook)
Definition: combase.c:3274
HRESULT WINAPI CoRevertToSelf(void)
Definition: combase.c:1143
ULONG WINAPI CoReleaseServerProcess(void)
Definition: combase.c:3169
static BOOL guid_from_string(LPCWSTR s, GUID *id)
Definition: combase.c:1347
HRESULT WINAPI CoQueryProxyBlanket(IUnknown *proxy, DWORD *authn_service, DWORD *authz_service, OLECHAR **servername, DWORD *authn_level, DWORD *imp_level, void **auth_info, DWORD *capabilities)
Definition: combase.c:1030
HRESULT open_key_for_clsid(REFCLSID clsid, const WCHAR *keyname, REGSAM access, HKEY *subkey)
Definition: combase.c:320
static LSTATUS open_classes_key(HKEY hkey, const WCHAR *name, REGSAM access, HKEY *retkey)
Definition: combase.c:297
static HRESULT WINAPI global_options_QueryInterface(IGlobalOptions *iface, REFIID riid, void **ppv)
Definition: combase.c:460
HRESULT WINAPI CoRevokeInitializeSpy(ULARGE_INTEGER cookie)
Definition: combase.c:2029
HRESULT WINAPI CoLockObjectExternal(IUnknown *object, BOOL lock, BOOL last_unlock_releases)
Definition: combase.c:3237
BOOL WINAPI InternalIsProcessInitialized(void)
Definition: combase.c:391
static const BYTE guid_conv_table[256]
Definition: combase.c:1336
HRESULT WINAPI CoFileTimeNow(FILETIME *filetime)
Definition: combase.c:1007
static CRITICAL_SECTION registered_classes_cs
Definition: combase.c:135
static ULONG WINAPI thread_context_callback_AddRef(IContextCallback *iface)
Definition: combase.c:2538
HRESULT WINAPI CLSIDFromString(LPCOLESTR str, LPCLSID clsid)
Definition: combase.c:1470
static HRESULT clsid_from_string_reg(LPCOLESTR progid, CLSID *clsid)
Definition: combase.c:1403
static void WINAPI thread_object_context_Reserved1(IObjContext *iface)
Definition: combase.c:2612
static struct list registered_classes
Definition: combase.c:133
static ULONG WINAPI class_factory_AddRef(IClassFactory *iface)
Definition: combase.c:543
static void WINAPI thread_object_context_Reserved2(IObjContext *iface)
Definition: combase.c:2617
static LONG com_lockcount
Definition: combase.c:51
static HRESULT WINAPI thread_context_info_GetCurrentLogicalThreadId(IComThreadingInfo *iface, GUID *logical_thread_id)
Definition: combase.c:2507
static const IGlobalOptionsVtbl global_options_vtbl
Definition: combase.c:520
HRESULT WINAPI CoGetCurrentLogicalThreadId(GUID *id)
Definition: combase.c:2714
HRESULT WINAPI CoDecrementMTAUsage(CO_MTA_USAGE_COOKIE cookie)
Definition: combase.c:2917
HRESULT WINAPI CoWaitForMultipleHandles(DWORD flags, DWORD timeout, ULONG handle_count, HANDLE *handles, DWORD *index)
Definition: combase.c:2067
HRESULT WINAPI FreePropVariantArray(ULONG count, PROPVARIANT *rgvars)
Definition: combase.c:601
static HRESULT WINAPI class_factory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
Definition: combase.c:529
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
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
#define DLL_THREAD_DETACH
Definition: compat.h:133
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
WCHAR OLECHAR
Definition: compat.h:2292
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define GetCurrentProcess()
Definition: compat.h:759
#define IsWow64Process
Definition: compat.h:760
unsigned short VARTYPE
Definition: compat.h:2254
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define lstrcpyW
Definition: compat.h:749
@ VT_BLOB
Definition: compat.h:2330
@ VT_UI8
Definition: compat.h:2315
@ VT_BLOB_OBJECT
Definition: compat.h:2335
@ VT_BSTR
Definition: compat.h:2303
@ VT_INT
Definition: compat.h:2316
@ VT_LPSTR
Definition: compat.h:2324
@ VT_R4
Definition: compat.h:2299
@ VT_NULL
Definition: compat.h:2296
@ VT_UNKNOWN
Definition: compat.h:2308
@ VT_UI2
Definition: compat.h:2312
@ VT_DECIMAL
Definition: compat.h:2309
@ VT_ERROR
Definition: compat.h:2305
@ VT_CLSID
Definition: compat.h:2337
@ VT_STREAM
Definition: compat.h:2331
@ VT_ARRAY
Definition: compat.h:2341
@ VT_STORED_OBJECT
Definition: compat.h:2334
@ VT_LPWSTR
Definition: compat.h:2325
@ VT_R8
Definition: compat.h:2300
@ VT_CY
Definition: compat.h:2301
@ VT_VARIANT
Definition: compat.h:2307
@ VT_I8
Definition: compat.h:2314
@ VT_I1
Definition: compat.h:2310
@ VT_I4
Definition: compat.h:2298
@ VT_CF
Definition: compat.h:2336
@ VT_STORAGE
Definition: compat.h:2332
@ VT_FILETIME
Definition: compat.h:2329
@ VT_DATE
Definition: compat.h:2302
@ VT_BOOL
Definition: compat.h:2306
@ VT_STREAMED_OBJECT
Definition: compat.h:2333
@ VT_I2
Definition: compat.h:2297
@ VT_UI4
Definition: compat.h:2313
@ VT_UINT
Definition: compat.h:2317
@ VT_EMPTY
Definition: compat.h:2295
@ VT_VECTOR
Definition: compat.h:2340
@ VT_DISPATCH
Definition: compat.h:2304
@ VT_UI1
Definition: compat.h:2311
#define lstrlenW
Definition: compat.h:750
VOID WINAPI ReleaseActCtx(IN HANDLE hActCtx)
Definition: actctx.c:208
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI FindActCtxSectionStringW(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, LPCWSTR lpSearchStr, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:238
BOOL WINAPI FindActCtxSectionGuid(DWORD dwFlags, const GUID *lpExtGuid, ULONG ulId, const GUID *lpSearchGuid, PACTCTX_SECTION_KEYED_DATA pInfo)
Definition: actctx.c:265
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
GUID guid
Definition: version.c:147
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:91
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
HRESULT WINAPI GetClassFile(LPCOLESTR filePathName, CLSID *pclsid)
Definition: moniker.c:921
HRESULT WINAPI SafeArrayCopy(SAFEARRAY *psa, SAFEARRAY **ppsaOut)
Definition: safearray.c:1379
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1347
#define swprintf
Definition: precomp.h:40
method
Definition: dragdrop.c:54
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
r reserved
Definition: btrfs.c:3006
#define INFINITE
Definition: serial.h:102
#define ULONG_PTR
Definition: config.h:101
#define progid(str)
Definition: exdisp.idl:31
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
time_t now
Definition: finger.c:65
uint8_t reserved2[12]
Definition: fsck.fat.h:23
uint8_t reserved3
Definition: fsck.fat.h:26
int proxy
Definition: main.c:67
FxCollectionEntry * cur
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLuint GLuint GLuint GLuint arg1
Definition: glext.h:9513
const GLubyte * c
Definition: glext.h:8905
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg3
Definition: glext.h:9515
GLuint index
Definition: glext.h:6031
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: glext.h:9514
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
GLbitfield flags
Definition: glext.h:7161
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
GLuint id
Definition: glext.h:5910
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
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 token
Definition: glfuncs.h:210
const char cursor[]
Definition: icontest.c:13
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
static TfClientId tid
#define InterlockedExchangeAdd
Definition: interlocked.h:196
#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
const char * filename
Definition: ioapi.h:137
#define NtCurrentTeb
uint32_t entry
Definition: isohybrid.c:63
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
BOOL is_wow64
Definition: main.c:38
static const BOOL is_win64
Definition: kernelbase.h:49
#define GUID_NULL
Definition: ks.h:106
#define REG_SZ
Definition: layer.c:22
if(dx< 0)
Definition: linetemp.h:194
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
#define CopyMemory
Definition: minwinbase.h:29
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static IPrintDialogCallback callback
Definition: printdlg.c:326
static const WCHAR sd[]
Definition: suminfo.c:286
static APTTYPEQUALIFIER * qualifier
Definition: compobj.c:77
static IUnknown DWORD clscontext
Definition: compobj.c:82
static IUnknown * outer
Definition: compobj.c:82
UINT64 OXID
Definition: marshal.c:86
static BSTR *static LPOLESTR
Definition: varformat.c:44
const CLSID * clsid
Definition: msctf.cpp:50
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define KEY_READ
Definition: nt_native.h:1026
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
@ REGCLS_MULTIPLEUSE
Definition: objbase.h:396
@ COWAIT_ALERTABLE
Definition: objbase.h:714
@ COWAIT_WAITALL
Definition: objbase.h:713
enum APTTYPE_MAINSTA
enum _THDTYPE THDTYPE
enum APTTYPE_MTA
@ APTTYPEQUALIFIER_IMPLICIT_MTA
@ APTTYPEQUALIFIER_NONE
enum APTTYPE_STA
DWORD CPFLAGS
enum _APTTYPEQUALIFIER APTTYPEQUALIFIER
@ THDTYPE_PROCESSMESSAGES
@ THDTYPE_BLOCKMESSAGES
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
const GUID IID_IPersistStorage
const GUID IID_IPersistFile
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
_In_opt_ IUnknown * punk
Definition: shlwapi.h:158
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static unsigned __int64 next
Definition: rand_nt.c:6
#define calloc
Definition: rosglue.h:14
const WCHAR * str
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:330
long RPC_STATUS
Definition: rpc.h:48
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
Definition: scsiwmi.h:51
HANDLE RootDirectory
Definition: umtypes.h:186
PUNICODE_STRING ObjectName
Definition: umtypes.h:187
CRITICAL_SECTION cs
IMessageFilter * filter
BOOL multi_threaded
Definition: cookie.c:202
union class_reg_data::@323 u
enum class_reg_data_origin origin
struct class_reg_data::@323::@324 actctx
Definition: inflate.c:139
DWORD miscstatuscontent
Definition: combase.c:71
DWORD miscstatusdocprint
Definition: combase.c:74
DWORD miscstatusthumbnail
Definition: combase.c:72
Definition: http.c:7252
Definition: cookie.c:34
Definition: main.c:439
LONG refcount
Definition: combase.c:452
IGlobalOptions IGlobalOptions_iface
Definition: combase.c:451
unsigned int id
Definition: combase.c:100
struct list entry
Definition: combase.c:98
IInitializeSpy * spy
Definition: combase.c:99
Definition: copy.c:22
Definition: name.c:39
ULONG clsid_offset
Definition: combase.c:93
struct list entry
Definition: rpcss_main.c:48
PMInterfacePointer object
Definition: rpcss_main.c:51
unsigned int cookie
Definition: rpcss_main.c:50
OXID apartment_id
Definition: combase.c:125
IUnknown * object
Definition: combase.c:126
unsigned int rpcss_cookie
Definition: combase.c:130
DWORD clscontext
Definition: combase.c:127
struct list entry
Definition: combase.c:105
CLSID clsid
Definition: combase.c:107
Definition: stat.h:66
Definition: ps.c:97
IComThreadingInfo IComThreadingInfo_iface
Definition: combase.c:2401
IObjContext IObjContext_iface
Definition: combase.c:2403
IContextCallback IContextCallback_iface
Definition: combase.c:2402
Definition: dhcpd.h:248
DWORD inits
DWORD flags
IUnknown * call_state
DWORD thread_seqid
CO_MTA_USAGE_COOKIE implicit_mta_cookie
IUnknown * state
IObjContext * context_token
struct apartment * apt
LONG pending_call_count_server
DWORD spies_lock
struct list spies
IErrorInfo * errorinfo
DWORD cancelcount
GUID causality_id
DWORD WINAPI WaitForMultipleObjectsEx(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:169
#define LIST_INIT(head)
Definition: queue.h:197
rwlock_t lock
Definition: tcpcore.h:0
#define DWORD_PTR
Definition: treelist.c:76
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
static EFI_HANDLE * handles
Definition: uefidisk.c:118
Definition: pdh_main.c:96
static const WCHAR props[]
Definition: wbemdisp.c:288
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)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define WAIT_FAILED
Definition: winbase.h:390
#define WINAPI
Definition: msvc.h:6
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:3801
#define S_FALSE
Definition: winerror.h:3451
#define CO_E_IIDSTRING
Definition: winerror.h:3920
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define CO_E_CANCEL_DISABLED
Definition: winerror.h:3611
#define RPC_E_WRONG_THREAD
Definition: winerror.h:3562
#define E_NOINTERFACE
Definition: winerror.h:3479
#define DISP_E_BADVARTYPE
Definition: winerror.h:3620
#define REGDB_E_READREGDB
Definition: winerror.h:3797
#define REGDB_E_IIDNOTREG
Definition: winerror.h:3802
#define RPC_E_CALL_CANCELED
Definition: winerror.h:3531
#define NOERROR
Definition: winerror.h:3448
#define RPC_S_CALLPENDING
Definition: winerror.h:3569
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771
#define RPC_E_CALL_COMPLETE
Definition: winerror.h:3571
#define E_UNEXPECTED
Definition: winerror.h:3528
#define STG_E_INVALIDPARAMETER
Definition: winerror.h:3675
#define RPC_E_NO_SYNC
Definition: winerror.h:3580
#define RPC_S_UUID_LOCAL_ONLY
Definition: winerror.h:1488
#define CO_S_NOTALLINTERFACES
Definition: winerror.h:4211
#define E_POINTER
Definition: winerror.h:3480
#define CO_E_OBJISREG
Definition: winerror.h:3928
#define CO_E_NOT_SUPPORTED
Definition: winerror.h:3510
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:3772
#define REGDB_E_KEYMISSING
Definition: winerror.h:3799
#define CO_E_CLASSSTRING
Definition: winerror.h:3919
ACCESS_MASK REGSAM
Definition: winreg.h:76
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define QS_SENDMESSAGE
Definition: winuser.h:891
#define WM_QUIT
Definition: winuser.h:1651
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define MWMO_ALERTABLE
Definition: winuser.h:920
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define QS_ALLPOSTMESSAGE
Definition: winuser.h:893
DWORD WINAPI MsgWaitForMultipleObjectsEx(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask, _In_ DWORD dwFlags)
#define PM_NOYIELD
Definition: winuser.h:1208
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1207
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define QS_PAINT
Definition: winuser.h:890
#define MWMO_WAITALL
Definition: winuser.h:919
#define PM_NOREMOVE
Definition: winuser.h:1206
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193