ReactOS 0.4.16-dev-2320-ge1853c6
apartment.c
Go to the documentation of this file.
1/*
2 * Copyright 1995 Martin von Loewis
3 * Copyright 1998 Justin Bradford
4 * Copyright 1999 Francis Beaudet
5 * Copyright 1999 Sylvain St-Germain
6 * Copyright 2002 Marcus Meissner
7 * Copyright 2004 Mike Hearn
8 * Copyright 2005-2006 Robert Shearman (for CodeWeavers)
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 *
24 */
25
26#include <stdarg.h>
27#include <assert.h>
28
29#define COBJMACROS
30#include "windef.h"
31#include "winbase.h"
32#include "servprov.h"
33
34#include "combase_private.h"
35
36#include "wine/debug.h"
37#include "wine/list.h"
38
40
42{
48};
49
50static struct apartment *mta;
51static struct apartment *main_sta; /* the first STA */
52static struct list apts = LIST_INIT(apts);
53
56{
57 0, 0, &apt_cs,
59 0, 0, { (DWORD_PTR)(__FILE__ ": apt_cs") }
60};
61static CRITICAL_SECTION apt_cs = { &apt_cs_debug, -1, 0, 0, 0, 0 };
62
63static struct list dlls = LIST_INIT(dlls);
64
67{
68 0, 0, &dlls_cs,
70 0, 0, { (DWORD_PTR)(__FILE__ ": dlls_cs") }
71};
72static CRITICAL_SECTION dlls_cs = { &dlls_cs_debug, -1, 0, 0, 0, 0 };
73
76
77struct opendll
78{
84 struct list entry;
85};
86
88{
89 struct list entry;
90 struct opendll *dll;
93};
94
96{
97 struct opendll *ptr, *ret = NULL;
98
101 {
102 if (!wcsicmp(library_name, ptr->library_name) &&
103 (InterlockedIncrement(&ptr->refs) != 1) /* entry is being destroyed if == 1 */)
104 {
105 ret = ptr;
106 break;
107 }
108 }
110
111 return ret;
112}
113
114/* caller must ensure that library_name is not already in the open dll list */
116{
117 struct opendll *entry;
118 int len;
119 HRESULT hr = S_OK;
123
124 TRACE("%s\n", debugstr_w(library_name));
125
127 if (*ret) return S_OK;
128
129 /* Load outside of dlls lock to avoid dependency on the loader lock */
131 if (!hLibrary)
132 {
133 ERR("couldn't load in-process dll %s\n", debugstr_w(library_name));
134 /* failure: DLL could not be loaded */
135 return E_ACCESSDENIED; /* FIXME: or should this be CO_E_DLLNOTFOUND? */
136 }
137
138 /* DllCanUnloadNow is optional */
139 DllCanUnloadNow = (void *)GetProcAddress(hLibrary, "DllCanUnloadNow");
140 DllGetClassObject = (void *)GetProcAddress(hLibrary, "DllGetClassObject");
142 {
143 /* failure: the dll did not export DllGetClassObject */
144 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(library_name));
146 return CO_E_DLLNOTFOUND;
147 }
148
150
152 if (*ret)
153 {
154 /* another caller to this function already added the dll while we
155 * weren't in the critical section */
157 }
158 else
159 {
161 entry = malloc(sizeof(*entry));
162 if (entry)
163 entry->library_name = malloc((len + 1) * sizeof(WCHAR));
164 if (entry && entry->library_name)
165 {
166 memcpy(entry->library_name, library_name, (len + 1)*sizeof(WCHAR));
167 entry->library = hLibrary;
168 entry->refs = 1;
169 entry->DllCanUnloadNow = DllCanUnloadNow;
170 entry->DllGetClassObject = DllGetClassObject;
171 list_add_tail(&dlls, &entry->entry);
172 *ret = entry;
173 }
174 else
175 {
176 free(entry);
179 }
180 }
181
183
184 return hr;
185}
186
187/* pass FALSE for free_entry to release a reference without destroying the
188 * entry if it reaches zero or TRUE otherwise */
189static void apartment_release_dll(struct opendll *entry, BOOL free_entry)
190{
191 if (!InterlockedDecrement(&entry->refs) && free_entry)
192 {
194 list_remove(&entry->entry);
196
197 TRACE("freeing %p\n", entry->library);
198 FreeLibrary(entry->library);
199
200 free(entry->library_name);
201 free(entry);
202 }
203}
204
205/* frees memory associated with active dll list */
206static void apartment_release_dlls(void)
207{
208 struct opendll *entry, *cursor2;
210 LIST_FOR_EACH_ENTRY_SAFE(entry, cursor2, &dlls, struct opendll, entry)
211 {
212 list_remove(&entry->entry);
213 free(entry->library_name);
214 free(entry);
215 }
218}
219
220/*
221 * This is a marshallable object exposing registered local servers.
222 * IServiceProvider is used only because it happens meet requirements
223 * and already has proxy/stub code. If more functionality is needed,
224 * a custom interface may be used instead.
225 */
227{
230 struct apartment *apt;
232};
233
235{
237}
238
240{
242
243 TRACE("%p, %s, %p\n", iface, debugstr_guid(riid), obj);
244
246 IsEqualGUID(riid, &IID_IServiceProvider))
247 {
249 }
250 else
251 {
252 *obj = NULL;
253 return E_NOINTERFACE;
254 }
255
256 IUnknown_AddRef((IUnknown *)*obj);
257 return S_OK;
258}
259
261{
264
265 TRACE("%p, refcount %ld\n", iface, refcount);
266
267 return refcount;
268}
269
271{
274
275 TRACE("%p, refcount %ld\n", iface, refcount);
276
277 if (!refcount)
278 {
281 }
282
283 return refcount;
284}
285
287{
289 struct apartment *apt = com_get_current_apt();
290 HRESULT hr = E_FAIL;
291 IUnknown *unk;
292
293 TRACE("%p, %s, %s, %p\n", iface, debugstr_guid(guid), debugstr_guid(riid), obj);
294
295 if (!local_server->apt)
296 return E_UNEXPECTED;
297
298 if ((unk = com_get_registered_class_object(apt, guid, CLSCTX_LOCAL_SERVER)))
299 {
300 hr = IUnknown_QueryInterface(unk, riid, obj);
301 IUnknown_Release(unk);
302 }
303
304 return hr;
305}
306
307static const IServiceProviderVtbl local_server_vtbl =
308{
313};
314
316{
317 HRESULT hr = S_OK;
318
320
321 if (!apt->local_server)
322 {
323 struct local_server *obj;
324
325 obj = malloc(sizeof(*obj));
326 if (obj)
327 {
328 obj->IServiceProvider_iface.lpVtbl = &local_server_vtbl;
329 obj->refcount = 1;
330 obj->apt = apt;
331
332 hr = CreateStreamOnHGlobal(0, TRUE, &obj->marshal_stream);
333 if (SUCCEEDED(hr))
334 {
335 hr = CoMarshalInterface(obj->marshal_stream, &IID_IServiceProvider, (IUnknown *)&obj->IServiceProvider_iface,
336 MSHCTX_LOCAL, NULL, MSHLFLAGS_TABLESTRONG);
337 if (FAILED(hr))
338 IStream_Release(obj->marshal_stream);
339 }
340
341 if (SUCCEEDED(hr))
342 apt->local_server = obj;
343 else
344 free(obj);
345 }
346 else
348 }
349
350 if (SUCCEEDED(hr))
351 hr = IStream_Clone(apt->local_server->marshal_stream, ret);
352
354
355 if (FAILED(hr))
356 ERR("Failed: %#lx\n", hr);
357
358 return hr;
359}
360
361/* Creates new apartment for given model */
363{
364 struct apartment *apt;
365
366 TRACE("creating new apartment, model %ld\n", model);
367
368 apt = calloc(1, sizeof(*apt));
369 apt->tid = GetCurrentThreadId();
370
371 list_init(&apt->proxies);
372 list_init(&apt->stubmgrs);
373 list_init(&apt->loaded_dlls);
375 apt->ipidc = 0;
376 apt->refs = 1;
377 apt->remunk_exported = FALSE;
378 apt->oidc = 1;
380 apt->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": apartment");
381
383
384 if (apt->multi_threaded)
385 {
386 /* FIXME: should be randomly generated by in an RPC call to rpcss */
387 apt->oxid = ((OXID)GetCurrentProcessId() << 32) | 0xcafe;
388 }
389 else
390 {
391 /* FIXME: should be randomly generated by in an RPC call to rpcss */
392 apt->oxid = ((OXID)GetCurrentProcessId() << 32) | GetCurrentThreadId();
393 }
394
395 TRACE("Created apartment on OXID %s\n", wine_dbgstr_longlong(apt->oxid));
396
397 list_add_head(&apts, &apt->entry);
398
399 return apt;
400}
401
402/* Frees unused libraries loaded into apartment */
404{
406
409 {
410 if (entry->dll->DllCanUnloadNow && (entry->dll->DllCanUnloadNow() == S_OK))
411 {
412 DWORD real_delay = delay;
413
414 if (real_delay == INFINITE)
415 {
416 /* DLLs that return multi-threaded objects aren't unloaded
417 * straight away to cope for programs that have races between
418 * last object destruction and threads in the DLLs that haven't
419 * finished, despite DllCanUnloadNow returning S_OK */
420 if (entry->multi_threaded)
421 real_delay = 10 * 60 * 1000; /* 10 minutes */
422 else
423 real_delay = 0;
424 }
425
426 if (!real_delay || (entry->unload_time && ((int)(GetTickCount() - entry->unload_time) > 0)))
427 {
428 list_remove(&entry->entry);
430 free(entry);
431 }
432 else
433 {
434 entry->unload_time = GetTickCount() + real_delay;
435 if (!entry->unload_time) entry->unload_time = 1;
436 }
437 }
438 else if (entry->unload_time)
439 entry->unload_time = 0;
440 }
442}
443
445{
446 DWORD refcount;
447
449
450 refcount = InterlockedDecrement(&apt->refs);
451 TRACE("%s: after = %ld\n", wine_dbgstr_longlong(apt->oxid), refcount);
452
453 if (apt->being_destroyed)
454 {
456 return;
457 }
458
459 /* destruction stuff that needs to happen under global */
460 if (!refcount)
461 {
462 apt->being_destroyed = TRUE;
463 if (apt == mta) mta = NULL;
464 else if (apt == main_sta) main_sta = NULL;
465 list_remove(&apt->entry);
466 }
467
469
470 if (!refcount)
471 {
472 struct list *cursor, *cursor2;
473
474 TRACE("destroying apartment %p, oxid %s\n", apt, wine_dbgstr_longlong(apt->oxid));
475
476 if (apt->local_server)
477 {
478 struct local_server *local_server = apt->local_server;
480
481 memset(&zero, 0, sizeof(zero));
482 IStream_Seek(local_server->marshal_stream, zero, STREAM_SEEK_SET, NULL);
484 IStream_Release(local_server->marshal_stream);
486
487 apt->local_server = NULL;
489 IServiceProvider_Release(&local_server->IServiceProvider_iface);
490 }
491
492 /* Release the references to the registered class objects */
494
495 /* no locking is needed for this apartment, because no other thread
496 * can access it at this point */
497
499
500 if (apt->win) DestroyWindow(apt->win);
501 if (apt->host_apt_tid) PostThreadMessageW(apt->host_apt_tid, WM_QUIT, 0, 0);
502
503 LIST_FOR_EACH_SAFE(cursor, cursor2, &apt->stubmgrs)
504 {
505 struct stub_manager *stubmgr = LIST_ENTRY(cursor, struct stub_manager, entry);
506 /* release the implicit reference given by the fact that the
507 * stub has external references (it must do since it is in the
508 * stub manager list in the apartment and all non-apartment users
509 * must have a ref on the apartment and so it cannot be destroyed).
510 */
512 }
513
514 /* if this assert fires, then another thread took a reference to a
515 * stub manager without taking a reference to the containing
516 * apartment, which it must do. */
517 assert(list_empty(&apt->stubmgrs));
518
519 if (apt->filter) IMessageFilter_Release(apt->filter);
520
521 /* free as many unused libraries as possible... */
523
524 /* ... and free the memory for the apartment loaded dll entry and
525 * release the dll list reference without freeing the library for the
526 * rest */
527 while ((cursor = list_head(&apt->loaded_dlls)))
528 {
533 }
534
535 apt->cs.DebugInfo->Spare[0] = 0;
537
538 free(apt);
539 }
540}
541
543{
544 DWORD refs = InterlockedIncrement(&apt->refs);
545 TRACE("%s: before = %ld\n", wine_dbgstr_longlong(apt->oxid), refs - 1);
546 return refs;
547}
548
549/* Gets existing apartment or creates a new one and enters it */
551{
552 struct apartment *apt = com_get_current_apt();
553 struct tlsdata *data;
554
555 if (!apt)
556 {
558
559 if (model & COINIT_APARTMENTTHREADED)
560 {
562
563 apt = apartment_construct(model);
564 if (!main_sta)
565 {
566 main_sta = apt;
567 apt->main = TRUE;
568 TRACE("Created main-threaded apartment with OXID %s\n", wine_dbgstr_longlong(apt->oxid));
569 }
570
572 if (model & COINIT_DISABLE_OLE1DDE)
574
576
577 if (apt->main)
579 }
580 else
581 {
583
584 /* The multi-threaded apartment (MTA) contains zero or more threads interacting
585 * with free threaded (ie thread safe) COM objects. There is only ever one MTA
586 * in a process */
587 if (mta)
588 {
589 TRACE("entering the multithreaded apartment %s\n", wine_dbgstr_longlong(mta->oxid));
591 }
592 else
593 mta = apartment_construct(model);
594
596
597 apt = mta;
598
600 }
601 data->apt = apt;
602 }
603
604 return apt;
605}
606
608{
609 struct apartment *apt;
610
612
613 if ((apt = mta))
614 apartment_addref(apt);
615
617
618 return apt;
619}
620
621/* Return the current apartment if it exists, or, failing that, the MTA. Caller
622 * must free the returned apartment in either case. */
624{
625 struct apartment *apt = com_get_current_apt();
626 if (apt)
627 {
628 apartment_addref(apt);
629 return apt;
630 }
631 return apartment_get_mta();
632}
633
634/* The given OXID must be local to this process */
636{
637 struct apartment *result = NULL, *apt;
638
641 {
642 if (apt->oxid == oxid)
643 {
644 result = apt;
646 break;
647 }
648 }
650
651 return result;
652}
653
654/* gets the apartment which has a given creator thread ID. The caller must
655 * release the reference from the apartment as soon as the apartment pointer
656 * is no longer required. */
658{
659 struct apartment *result = NULL, *apt;
660
663 {
664 if (apt != mta && apt->tid == tid)
665 {
666 result = apt;
668 break;
669 }
670 }
671
672 if (!result && mta && mta->tid == tid)
673 {
674 result = mta;
676 }
677
679
680 return result;
681}
682
683/* gets the main apartment if it exists. The caller must
684 * release the reference from the apartment as soon as the apartment pointer
685 * is no longer required. */
686static struct apartment *apartment_findmain(void)
687{
688 struct apartment *result;
689
691
694
696
697 return result;
698}
699
701{
703 CLSID clsid; /* clsid of object to marshal */
704 IID iid; /* interface to marshal */
705 HANDLE event; /* event signalling when ready for multi-threaded case */
706 HRESULT hr; /* result for multi-threaded case */
707 IStream *stream; /* stream that the object will be marshaled into */
708 BOOL apartment_threaded; /* is the component purely apartment-threaded? */
709};
710
711/* Returns expanded dll path from the registry or activation context. */
713{
714 DWORD ret;
715
716 if (regdata->origin == CLASS_REG_REGISTRY)
717 {
718 DWORD keytype;
720 DWORD dwLength = dstlen * sizeof(WCHAR);
721
722 if ((ret = RegQueryValueExW(regdata->u.hkey, NULL, NULL, &keytype, (BYTE*)src, &dwLength)) == ERROR_SUCCESS)
723 {
724 if (keytype == REG_EXPAND_SZ)
725 {
727 }
728 else
729 {
730 const WCHAR *quote_start;
731 quote_start = wcschr(src, '\"');
732 if (quote_start)
733 {
734 const WCHAR *quote_end = wcschr(quote_start + 1, '\"');
735 if (quote_end)
736 {
737 memmove(src, quote_start + 1, (quote_end - quote_start - 1) * sizeof(WCHAR));
738 src[quote_end - quote_start - 1] = '\0';
739 }
740 }
742 }
743 }
744 return !ret;
745 }
746 else
747 {
749
750 *dst = 0;
751 ActivateActCtx(regdata->u.actctx.hactctx, &cookie);
752 ret = SearchPathW(NULL, regdata->u.actctx.module_name, L".dll", dstlen, dst, NULL);
754 return *dst != 0;
755 }
756}
757
758/* gets the specified class object by loading the appropriate DLL, if
759 * necessary and calls the DllGetClassObject function for the DLL */
761 BOOL apartment_threaded,
762 REFCLSID rclsid, REFIID riid, void **ppv)
763{
764 HRESULT hr = S_OK;
765 BOOL found = FALSE;
767
768 if (!wcsicmp(dllpath, L"ole32.dll"))
769 {
770 HRESULT (WINAPI *p_ole32_DllGetClassObject)(REFCLSID clsid, REFIID riid, void **obj);
771
772 p_ole32_DllGetClassObject = (void *)GetProcAddress(GetModuleHandleW(L"ole32.dll"), "DllGetClassObject");
773
774 /* we don't need to control the lifetime of this dll, so use the local
775 * implementation of DllGetClassObject directly */
776 TRACE("calling ole32!DllGetClassObject\n");
777 hr = p_ole32_DllGetClassObject(rclsid, riid, ppv);
778
779 if (hr != S_OK)
780 ERR("DllGetClassObject returned error %#lx for dll %s\n", hr, debugstr_w(dllpath));
781
782 return hr;
783 }
784
786
788 if (!wcsicmp(dllpath, apartment_loaded_dll->dll->library_name))
789 {
790 TRACE("found %s already loaded\n", debugstr_w(dllpath));
791 found = TRUE;
792 break;
793 }
794
795 if (!found)
796 {
800 if (SUCCEEDED(hr))
801 {
805 if (FAILED(hr))
807 }
808 if (SUCCEEDED(hr))
809 {
810 TRACE("added new loaded dll %s\n", debugstr_w(dllpath));
812 }
813 }
814
816
817 if (SUCCEEDED(hr))
818 {
819 /* one component being multi-threaded overrides any number of
820 * apartment-threaded components */
821 if (!apartment_threaded)
823
824 TRACE("calling DllGetClassObject %p\n", apartment_loaded_dll->dll->DllGetClassObject);
825 /* OK: get the ClassObject */
826 hr = apartment_loaded_dll->dll->DllGetClassObject(rclsid, riid, ppv);
827
828 if (hr != S_OK)
829 ERR("DllGetClassObject returned error %#lx for dll %s\n", hr, debugstr_w(dllpath));
830 }
831
832 return hr;
833}
834
835static HRESULT apartment_hostobject(struct apartment *apt,
836 const struct host_object_params *params);
837
839{
843};
844
845/* thread for hosting an object to allow an object to appear to be created in
846 * an apartment with an incompatible threading model */
848{
849 struct host_thread_params *params = p;
850 MSG msg;
851 HRESULT hr;
852 struct apartment *apt;
853
854 TRACE("\n");
855
856 hr = CoInitializeEx(NULL, params->threading_model);
857 if (FAILED(hr)) return hr;
858
859 apt = com_get_current_apt();
860 if (params->threading_model == COINIT_APARTMENTTHREADED)
861 {
863 params->apartment_hwnd = apartment_getwindow(apt);
864 }
865 else
866 params->apartment_hwnd = NULL;
867
868 /* force the message queue to be created before signaling parent thread */
870
871 SetEvent(params->ready_event);
872 params = NULL; /* can't touch params after here as it may be invalid */
873
874 while (GetMessageW(&msg, NULL, 0, 0))
875 {
876 if (!msg.hwnd && (msg.message == DM_HOSTOBJECT))
877 {
878 struct host_object_params *obj_params = (struct host_object_params *)msg.lParam;
879 obj_params->hr = apartment_hostobject(apt, obj_params);
880 SetEvent(obj_params->event);
881 }
882 else
883 {
886 }
887 }
888
889 TRACE("exiting\n");
890
892
893 return S_OK;
894}
895
896/* finds or creates a host apartment, creates the object inside it and returns
897 * a proxy to it so that the object can be used in the apartment of the
898 * caller of this function */
899static HRESULT apartment_hostobject_in_hostapt(struct apartment *apt, BOOL multi_threaded,
900 BOOL main_apartment, const struct class_reg_data *regdata, REFCLSID rclsid, REFIID riid, void **ppv)
901{
903 HWND apartment_hwnd = NULL;
904 DWORD apartment_tid = 0;
905 HRESULT hr;
906
907 if (!multi_threaded && main_apartment)
908 {
909 struct apartment *host_apt = apartment_findmain();
910 if (host_apt)
911 {
912 apartment_hwnd = apartment_getwindow(host_apt);
913 apartment_release(host_apt);
914 }
915 }
916
917 if (!apartment_hwnd)
918 {
920
921 if (!apt->host_apt_tid)
922 {
923 struct host_thread_params thread_params;
924 HANDLE handles[2];
925 DWORD wait_value;
926
927 thread_params.threading_model = multi_threaded ? COINIT_MULTITHREADED : COINIT_APARTMENTTHREADED;
928 handles[0] = thread_params.ready_event = CreateEventW(NULL, FALSE, FALSE, NULL);
929 thread_params.apartment_hwnd = NULL;
930 handles[1] = CreateThread(NULL, 0, apartment_hostobject_thread, &thread_params, 0, &apt->host_apt_tid);
931 if (!handles[1])
932 {
935 return E_OUTOFMEMORY;
936 }
937 wait_value = WaitForMultipleObjects(2, handles, FALSE, INFINITE);
940 if (wait_value == WAIT_OBJECT_0)
941 apt->host_apt_hwnd = thread_params.apartment_hwnd;
942 else
943 {
945 return E_OUTOFMEMORY;
946 }
947 }
948
949 if (multi_threaded || !main_apartment)
950 {
952 apartment_tid = apt->host_apt_tid;
953 }
954
956 }
957
958 /* another thread may have become the main apartment in the time it took
959 * us to create the thread for the host apartment */
960 if (!apartment_hwnd && !multi_threaded && main_apartment)
961 {
962 struct apartment *host_apt = apartment_findmain();
963 if (host_apt)
964 {
965 apartment_hwnd = apartment_getwindow(host_apt);
966 apartment_release(host_apt);
967 }
968 }
969
970 params.regdata = *regdata;
971 params.clsid = *rclsid;
972 params.iid = *riid;
974 if (FAILED(hr))
975 return hr;
976 params.apartment_threaded = !multi_threaded;
977 if (multi_threaded)
978 {
979 params.hr = S_OK;
981 if (!PostThreadMessageW(apartment_tid, DM_HOSTOBJECT, 0, (LPARAM)&params))
983 else
984 {
986 hr = params.hr;
987 }
988 CloseHandle(params.event);
989 }
990 else
991 {
992 if (!apartment_hwnd)
993 {
994 ERR("host apartment didn't create window\n");
996 }
997 else
998 hr = SendMessageW(apartment_hwnd, DM_HOSTOBJECT, 0, (LPARAM)&params);
999 }
1000 if (SUCCEEDED(hr))
1002 IStream_Release(params.stream);
1003 return hr;
1004}
1005
1007{
1008 if (data->origin == CLASS_REG_REGISTRY)
1009 {
1010 WCHAR threading_model[10 /* lstrlenW(L"apartment")+1 */];
1011 DWORD dwLength = sizeof(threading_model);
1012 DWORD keytype;
1013 DWORD ret;
1014
1015 ret = RegQueryValueExW(data->u.hkey, L"ThreadingModel", NULL, &keytype, (BYTE*)threading_model, &dwLength);
1016 if ((ret != ERROR_SUCCESS) || (keytype != REG_SZ))
1017 threading_model[0] = '\0';
1018
1019 if (!wcsicmp(threading_model, L"Apartment")) return ThreadingModel_Apartment;
1020 if (!wcsicmp(threading_model, L"Free")) return ThreadingModel_Free;
1021 if (!wcsicmp(threading_model, L"Both")) return ThreadingModel_Both;
1022
1023 /* there's not specific handling for this case */
1024 if (threading_model[0]) return ThreadingModel_Neutral;
1025 return ThreadingModel_No;
1026 }
1027 else
1028 return data->u.actctx.threading_model;
1029}
1030
1032 REFCLSID rclsid, REFIID riid, DWORD class_context, void **ppv)
1033{
1035 BOOL apartment_threaded;
1036
1037 if (!(class_context & CLSCTX_PS_DLL))
1038 {
1039 enum comclass_threadingmodel model = get_threading_model(regdata);
1040
1041 if (model == ThreadingModel_Apartment)
1042 {
1043 apartment_threaded = TRUE;
1044 if (apt->multi_threaded)
1045 return apartment_hostobject_in_hostapt(apt, FALSE, FALSE, regdata, rclsid, riid, ppv);
1046 }
1047 else if (model == ThreadingModel_Free)
1048 {
1049 apartment_threaded = FALSE;
1050 if (!apt->multi_threaded)
1051 return apartment_hostobject_in_hostapt(apt, TRUE, FALSE, regdata, rclsid, riid, ppv);
1052 }
1053 /* everything except "Apartment", "Free" and "Both" */
1054 else if (model != ThreadingModel_Both)
1055 {
1056 apartment_threaded = TRUE;
1057 /* everything else is main-threaded */
1058 if (model != ThreadingModel_No)
1059 FIXME("unrecognised threading model %d for object %s, should be main-threaded?\n", model, debugstr_guid(rclsid));
1060
1061 if (apt->multi_threaded || !apt->main)
1062 return apartment_hostobject_in_hostapt(apt, FALSE, TRUE, regdata, rclsid, riid, ppv);
1063 }
1064 else
1065 apartment_threaded = FALSE;
1066 }
1067 else
1068 apartment_threaded = !apt->multi_threaded;
1069
1071 {
1072 /* failure: CLSID is not found in registry */
1073 WARN("class %s not registered inproc\n", debugstr_guid(rclsid));
1074 return REGDB_E_CLASSNOTREG;
1075 }
1076
1077 return apartment_getclassobject(apt, dllpath, apartment_threaded, rclsid, riid, ppv);
1078}
1079
1081{
1082 static const LARGE_INTEGER llZero;
1085 HRESULT hr;
1086
1087 TRACE("clsid %s, iid %s\n", debugstr_guid(&params->clsid), debugstr_guid(&params->iid));
1088
1090 {
1091 /* failure: CLSID is not found in registry */
1092 WARN("class %s not registered inproc\n", debugstr_guid(&params->clsid));
1093 return REGDB_E_CLASSNOTREG;
1094 }
1095
1096 hr = apartment_getclassobject(apt, dllpath, params->apartment_threaded, &params->clsid, &params->iid, (void **)&object);
1097 if (FAILED(hr))
1098 return hr;
1099
1100 hr = CoMarshalInterface(params->stream, &params->iid, object, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
1101 if (FAILED(hr))
1102 IUnknown_Release(object);
1103 IStream_Seek(params->stream, llZero, STREAM_SEEK_SET, NULL);
1104
1105 return hr;
1106}
1107
1108struct dispatch_params;
1109
1111{
1112 switch (msg)
1113 {
1114 case DM_EXECUTERPC:
1116 return 0;
1117 case DM_HOSTOBJECT:
1119 default:
1120 return DefWindowProcW(hWnd, msg, wParam, lParam);
1121 }
1122}
1123
1124static BOOL apartment_is_model(const struct apartment *apt, DWORD model)
1125{
1126 return (apt->multi_threaded == !(model & COINIT_APARTMENTTHREADED));
1127}
1128
1130{
1131 HRESULT hr = S_OK;
1132
1133 if (!data->apt)
1134 {
1135 if (!apartment_get_or_create(model))
1136 return E_OUTOFMEMORY;
1137 }
1138 else if (!apartment_is_model(data->apt, model))
1139 {
1140 WARN("Attempt to change threading model of this apartment from %s to %s\n",
1141 data->apt->multi_threaded ? "multi-threaded" : "apartment threaded",
1142 model & COINIT_APARTMENTTHREADED ? "apartment threaded" : "multi-threaded" );
1143 return RPC_E_CHANGED_MODE;
1144 }
1145 else
1146 hr = S_FALSE;
1147
1148 data->inits++;
1149
1150 return hr;
1151}
1152
1154{
1155 if (!--data->inits)
1156 {
1157 if (data->ole_inits)
1158 WARN( "Uninitializing apartment while Ole is still initialized\n" );
1159 apartment_release(data->apt);
1160 if (data->implicit_mta_cookie)
1161 {
1162 apartment_decrement_mta_usage(data->implicit_mta_cookie);
1163 data->implicit_mta_cookie = NULL;
1164 }
1165 data->apt = NULL;
1167 }
1168}
1169
1171{
1172 struct list entry;
1173};
1174
1176{
1177 struct mta_cookie *mta_cookie;
1178
1179 *cookie = NULL;
1180
1181 if (!(mta_cookie = malloc(sizeof(*mta_cookie))))
1182 return E_OUTOFMEMORY;
1183
1185
1186 if (mta)
1188 else
1190 list_add_head(&mta->usage_cookies, &mta_cookie->entry);
1191
1193
1194 *cookie = (CO_MTA_USAGE_COOKIE)mta_cookie;
1195
1196 return S_OK;
1197}
1198
1199void apartment_decrement_mta_usage(CO_MTA_USAGE_COOKIE cookie)
1200{
1201 struct mta_cookie *mta_cookie = (struct mta_cookie *)cookie;
1202
1204
1205 if (mta)
1206 {
1207 struct mta_cookie *cur;
1208
1209 LIST_FOR_EACH_ENTRY(cur, &mta->usage_cookies, struct mta_cookie, entry)
1210 {
1211 if (mta_cookie == cur)
1212 {
1213 list_remove(&cur->entry);
1214 free(cur);
1216 break;
1217 }
1218 }
1219 }
1220
1222}
1223
1224static const WCHAR aptwinclassW[] = L"OleMainThreadWndClass";
1226
1227static BOOL WINAPI register_class( INIT_ONCE *once, void *param, void **context )
1228{
1229 WNDCLASSW wclass;
1230
1231 /* Dispatching to the correct thread in an apartment is done through
1232 * window messages rather than RPC transports. When an interface is
1233 * marshalled into another apartment in the same process, a window of the
1234 * following class is created. The *caller* of CoMarshalInterface (i.e., the
1235 * application) is responsible for pumping the message loop in that thread.
1236 * The WM_USER messages which point to the RPCs are then dispatched to
1237 * apartment_wndproc by the user's code from the apartment in which the
1238 * interface was unmarshalled.
1239 */
1240 memset(&wclass, 0, sizeof(wclass));
1242 wclass.hInstance = hProxyDll;
1243 wclass.lpszClassName = aptwinclassW;
1244 apt_win_class = RegisterClassW(&wclass);
1245 return TRUE;
1246}
1247
1248/* create a window for the apartment or return the current one if one has
1249 * already been created */
1251{
1252 static INIT_ONCE class_init_once = INIT_ONCE_STATIC_INIT;
1253
1254 if (apt->multi_threaded)
1255 return S_OK;
1256
1257 if (!apt->win)
1258 {
1259 HWND hwnd;
1260
1261 InitOnceExecuteOnce( &class_init_once, register_class, NULL, NULL );
1262
1264 if (!hwnd)
1265 {
1266 ERR("CreateWindow failed with error %ld\n", GetLastError());
1268 }
1269 if (InterlockedCompareExchangePointer((void **)&apt->win, hwnd, NULL))
1270 /* someone beat us to it */
1272 }
1273
1274 return S_OK;
1275}
1276
1277/* retrieves the window for the main- or apartment-threaded apartment */
1279{
1280 assert(!apt->multi_threaded);
1281 return apt->win;
1282}
1283
1285{
1286 return apt->oxid;
1287}
1288
1290{
1291 if (apt_win_class)
1295}
1296
1298{
1299 struct apartment *apt;
1300 struct tlsdata *data;
1301 HRESULT hr;
1302
1303 if (FAILED(hr = com_get_tlsdata(&data)))
1304 return hr;
1305 if ((apt = data->apt) && (data->implicit_mta_cookie || apt->multi_threaded))
1306 return S_OK;
1307
1309 if (apt || mta)
1310 hr = apartment_increment_mta_usage(&data->implicit_mta_cookie);
1311 else
1314
1315 if (FAILED(hr))
1316 {
1317 ERR("Failed, hr %#lx.\n", hr);
1318 return hr;
1319 }
1320 return S_OK;
1321}
#define CO_E_NOTINITIALIZED
static BOOL get_object_dll_path(const struct class_reg_data *regdata, WCHAR *dst, DWORD dstlen)
Definition: apartment.c:712
static void apartment_release_dlls(void)
Definition: apartment.c:206
HRESULT(WINAPI * DllCanUnloadNowFunc)(void)
Definition: apartment.c:75
static struct apartment * apartment_get_or_create(DWORD model)
Definition: apartment.c:550
static CRITICAL_SECTION_DEBUG dlls_cs_debug
Definition: apartment.c:66
HRESULT apartment_createwindowifneeded(struct apartment *apt)
Definition: apartment.c:1250
static struct apartment * mta
Definition: apartment.c:50
static ATOM apt_win_class
Definition: apartment.c:1225
static HRESULT apartment_getclassobject(struct apartment *apt, LPCWSTR dllpath, BOOL apartment_threaded, REFCLSID rclsid, REFIID riid, void **ppv)
Definition: apartment.c:760
static LRESULT CALLBACK apartment_wndproc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: apartment.c:1110
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
static CRITICAL_SECTION_DEBUG apt_cs_debug
Definition: apartment.c:55
struct apartment * apartment_get_mta(void)
Definition: apartment.c:607
HRESULT enter_apartment(struct tlsdata *data, DWORD model)
Definition: apartment.c:1129
static BOOL apartment_is_model(const struct apartment *apt, DWORD model)
Definition: apartment.c:1124
static DWORD apartment_addref(struct apartment *apt)
Definition: apartment.c:542
static const IServiceProviderVtbl local_server_vtbl
Definition: apartment.c:307
HRESULT apartment_increment_mta_usage(CO_MTA_USAGE_COOKIE *cookie)
Definition: apartment.c:1175
static struct apartment * apartment_findmain(void)
Definition: apartment.c:686
static struct list dlls
Definition: apartment.c:63
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
static HRESULT WINAPI local_server_QueryInterface(IServiceProvider *iface, REFIID riid, void **obj)
Definition: apartment.c:239
static const WCHAR aptwinclassW[]
Definition: apartment.c:1224
static CRITICAL_SECTION dlls_cs
Definition: apartment.c:65
void leave_apartment(struct tlsdata *data)
Definition: apartment.c:1153
void apartment_release(struct apartment *apt)
Definition: apartment.c:444
static CRITICAL_SECTION apt_cs
Definition: apartment.c:54
HRESULT ensure_mta(void)
Definition: apartment.c:1297
void apartment_decrement_mta_usage(CO_MTA_USAGE_COOKIE cookie)
Definition: apartment.c:1199
HRESULT(WINAPI * DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, void **obj)
Definition: apartment.c:74
static HRESULT WINAPI local_server_QueryService(IServiceProvider *iface, REFGUID guid, REFIID riid, void **obj)
Definition: apartment.c:286
HWND apartment_getwindow(const struct apartment *apt)
Definition: apartment.c:1278
static struct apartment * main_sta
Definition: apartment.c:51
static HRESULT apartment_hostobject(struct apartment *apt, const struct host_object_params *params)
Definition: apartment.c:1080
OXID apartment_getoxid(const struct apartment *apt)
Definition: apartment.c:1284
struct apartment * apartment_findfromtid(DWORD tid)
Definition: apartment.c:657
static ULONG WINAPI local_server_Release(IServiceProvider *iface)
Definition: apartment.c:270
static DWORD CALLBACK apartment_hostobject_thread(void *p)
Definition: apartment.c:847
struct apartment * apartment_findfromoxid(OXID oxid)
Definition: apartment.c:635
static struct apartment * apartment_construct(DWORD model)
Definition: apartment.c:362
struct apartment * apartment_get_current_or_mta(void)
Definition: apartment.c:623
static HRESULT apartment_add_dll(const WCHAR *library_name, struct opendll **ret)
Definition: apartment.c:115
static struct list apts
Definition: apartment.c:52
static ULONG WINAPI local_server_AddRef(IServiceProvider *iface)
Definition: apartment.c:260
static void apartment_release_dll(struct opendll *entry, BOOL free_entry)
Definition: apartment.c:189
comclass_threadingmodel
Definition: apartment.c:42
@ ThreadingModel_No
Definition: apartment.c:45
@ ThreadingModel_Both
Definition: apartment.c:46
@ ThreadingModel_Neutral
Definition: apartment.c:47
@ ThreadingModel_Free
Definition: apartment.c:44
@ ThreadingModel_Apartment
Definition: apartment.c:43
static struct local_server * impl_from_IServiceProvider(IServiceProvider *iface)
Definition: apartment.c:234
static enum comclass_threadingmodel get_threading_model(const struct class_reg_data *data)
Definition: apartment.c:1006
static struct opendll * apartment_get_dll(const WCHAR *library_name)
Definition: apartment.c:95
static HRESULT apartment_hostobject_in_hostapt(struct apartment *apt, BOOL multi_threaded, BOOL main_apartment, const struct class_reg_data *regdata, REFCLSID rclsid, REFIID riid, void **ppv)
Definition: apartment.c:899
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static int list_empty(struct list_entry *head)
Definition: list.h:58
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
Definition: list.h:37
void rpc_execute_call(struct dispatch_params *params)
Definition: rpc.c:1874
@ CLASS_REG_REGISTRY
HRESULT apartment_disconnectproxies(struct apartment *apt)
Definition: marshal.c:1992
@ OLETLS_DISABLE_OLE1DDE
@ OLETLS_APARTMENTTHREADED
@ OLETLS_MULTITHREADED
#define DM_EXECUTERPC
ULONG stub_manager_int_release(struct stub_manager *stub_manager)
Definition: stubmanager.c:309
#define DM_HOSTOBJECT
static struct apartment * com_get_current_apt(void)
static HRESULT com_get_tlsdata(struct tlsdata **data)
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
HMODULE hLibrary
Definition: odbccp32.c:12
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define ERROR_SUCCESS
Definition: deptool.c:10
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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
IUnknown * com_get_registered_class_object(const struct apartment *apt, REFCLSID rclsid, DWORD clscontext)
Definition: combase.c:144
void apartment_revoke_all_classes(const struct apartment *apt)
Definition: combase.c:3089
HINSTANCE hProxyDll
Definition: combase.c:40
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(void *reserved, DWORD model)
Definition: combase.c:2803
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL delete_on_release, IStream **stream)
HRESULT WINAPI CoMarshalInterface(IStream *stream, REFIID riid, IUnknown *unk, DWORD dest_context, void *pvDestContext, DWORD mshlFlags)
Definition: marshal.c:483
HRESULT WINAPI CoReleaseMarshalData(IStream *stream)
Definition: marshal.c:673
HRESULT WINAPI CoUnmarshalInterface(IStream *stream, REFIID riid, void **ppv)
Definition: marshal.c:793
#define CloseHandle
Definition: compat.h:739
#define wcschr
Definition: compat.h:17
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
#define wcsicmp
Definition: compat.h:15
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
static DWORD DWORD * dwLength
Definition: fusion.c:86
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:520
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
Definition: path.c:1298
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
BOOL WINAPI InitOnceExecuteOnce(_Inout_ PINIT_ONCE InitOnce, _In_ __callback PINIT_ONCE_FN InitFn, _Inout_opt_ PVOID Parameter, _Outptr_opt_result_maybenull_ LPVOID *Context)
Definition: InitOnce.c:12
BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount, IN DWORD flags)
Definition: sync.c:107
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
GUID guid
Definition: version.c:147
#define assert(_expr)
Definition: assert.h:32
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxCollectionEntry * cur
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum src
Definition: glext.h:6340
GLenum const GLfloat * params
Definition: glext.h:5645
GLenum GLenum dst
Definition: glext.h:6340
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
const char cursor[]
Definition: icontest.c:13
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
static TfClientId tid
#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
uint32_t entry
Definition: isohybrid.c:63
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
#define REG_SZ
Definition: layer.c:22
WCHAR dllpath[MAX_PATH]
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static PVOID ptr
Definition: dispmode.c:27
static ATOM register_class(void)
Definition: atl_ax.c:49
static DWORD dstlen
Definition: directory.c:51
UINT64 OXID
Definition: marshal.c:86
static const LARGE_INTEGER llZero
Definition: moniker.c:1425
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *ppvOut)
Definition: msctf.cpp:566
const CLSID * clsid
Definition: msctf.cpp:50
HRESULT WINAPI DllCanUnloadNow(void)
Definition: msctf.cpp:558
unsigned int UINT
Definition: ndis.h:50
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
enum tagCOINIT COINIT
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:279
@ COINIT_DISABLE_OLE1DDE
Definition: objbase.h:281
@ COINIT_MULTITHREADED
Definition: objbase.h:280
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
static unsigned __int64 next
Definition: rand_nt.c:6
#define calloc
Definition: rosglue.h:14
#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 LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:192
#define memset(x, y, z)
Definition: compat.h:39
int zero
Definition: sehframes.cpp:29
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
Definition: scsiwmi.h:51
PRTL_CRITICAL_SECTION_DEBUG DebugInfo
Definition: rtltypes.h:1450
LPCWSTR lpszClassName
Definition: winuser.h:3287
HINSTANCE hInstance
Definition: winuser.h:3282
WNDPROC lpfnWndProc
Definition: winuser.h:3279
struct opendll * dll
Definition: apartment.c:90
struct list entry
Definition: apartment.c:89
struct list proxies
struct list entry
struct list loaded_dlls
BOOL being_destroyed
CRITICAL_SECTION cs
struct local_server * local_server
struct list usage_cookies
DWORD host_apt_tid
BOOL remunk_exported
struct list stubmgrs
HWND host_apt_hwnd
BOOL multi_threaded
union class_reg_data::@323 u
enum class_reg_data_origin origin
struct class_reg_data::@323::@324 actctx
Definition: http.c:7252
Definition: cookie.c:34
struct class_reg_data regdata
Definition: apartment.c:702
IStream * stream
Definition: apartment.c:707
COINIT threading_model
Definition: apartment.c:840
Definition: list.h:15
IServiceProvider IServiceProvider_iface
Definition: apartment.c:228
LONG refcount
Definition: apartment.c:229
struct apartment * apt
Definition: apartment.c:230
IStream * marshal_stream
Definition: apartment.c:231
LONG refs
Definition: apartment.c:79
DllGetClassObjectFunc DllGetClassObject
Definition: apartment.c:82
DllCanUnloadNowFunc DllCanUnloadNow
Definition: apartment.c:83
LPWSTR library_name
Definition: apartment.c:80
HANDLE library
Definition: apartment.c:81
struct list entry
Definition: apartment.c:84
struct apartment * apt
struct apartment * apt
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:669
#define LIST_INIT(head)
Definition: queue.h:197
#define LIST_ENTRY(type)
Definition: queue.h:175
#define DWORD_PTR
Definition: treelist.c:76
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
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
static EFI_HANDLE * handles
Definition: uefidisk.c:118
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1156
#define LOAD_WITH_ALTERED_SEARCH_PATH
Definition: winbase.h:340
#define MAKEINTATOM(i)
Definition: winbase.h:1220
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
RTL_RUN_ONCE INIT_ONCE
Definition: winbase.h:3680
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define INIT_ONCE_STATIC_INIT
Definition: winbase.h:591
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:3801
#define S_FALSE
Definition: winerror.h:3451
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define E_NOINTERFACE
Definition: winerror.h:3479
#define E_ACCESSDENIED
Definition: winerror.h:4116
#define E_UNEXPECTED
Definition: winerror.h:3528
#define CO_E_DLLNOTFOUND
Definition: winerror.h:3924
#define RPC_E_CHANGED_MODE
Definition: winerror.h:3554
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO
Definition: winnt_old.h:1152
#define HWND_MESSAGE
Definition: winuser.h:1221
#define WM_QUIT
Definition: winuser.h:1651
BOOL WINAPI TranslateMessage(_In_ const MSG *)
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI PostThreadMessageW(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4418
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define WM_USER
Definition: winuser.h:1923
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define PM_NOREMOVE
Definition: winuser.h:1206
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned char BYTE
Definition: xxhash.c:193