45#define NONAMELESSUNION
48#define WIN32_NO_STATUS
54#define USE_COM_CONTEXT_DEF
85 0, 0, { (
DWORD_PTR)(__FILE__
": csApartment") }
179 0, 0, { (
DWORD_PTR)(__FILE__
": cs_registered_psclsid_list") }
233 0, 0, { (
DWORD_PTR)(__FILE__
": csRegisteredClassList") }
241 case DVASPECT_CONTENT:
243 case DVASPECT_THUMBNAIL:
247 case DVASPECT_DOCPRINT:
256 ACTCTX_SECTION_KEYED_DATA
data;
317 attrs =
attr->Attributes;
327 attr->RootDirectory = subkey;
334 attr->Attributes = attrs;
345 {
'\\',
'R',
'e',
'g',
'i',
's',
't',
'r',
'y',
'\\',
'M',
'a',
'c',
'h',
'i',
'n',
'e',
346 '\\',
'S',
'o',
'f',
't',
'w',
'a',
'r',
'e',
'\\',
'C',
'l',
'a',
's',
's',
'e',
's',0};
359 attr.RootDirectory = 0;
363 attr.SecurityQualityOfService =
NULL;
392 static const WCHAR wow6432nodeW[] = {
'W',
'o',
'w',
'6',
'4',
'3',
'2',
'N',
'o',
'd',
'e',0};
393 access &= ~KEY_WOW64_32KEY;
410 attr.RootDirectory = hkey;
414 attr.SecurityQualityOfService =
NULL;
428 attr.RootDirectory = hkey;
432 attr.SecurityQualityOfService =
NULL;
469 0, 0, { (
DWORD_PTR)(__FILE__
": csOpenDllList") }
481static const WCHAR wszAptWinClass[] = {
'O',
'l',
'e',
'M',
'a',
'i',
'n',
'T',
'h',
'r',
'e',
'a',
'd',
'W',
'n',
'd',
'C',
'l',
'a',
's',
's',0};
496 if (!
wcsicmp(library_name,
ptr->library_name) &&
527 ERR(
"couldn't load in-process dll %s\n",
debugstr_w(library_name));
538 ERR(
"couldn't find function DllGetClassObject in %s\n",
debugstr_w(library_name));
632 TRACE(
"creating new apartment, model=%d\n", model);
757 if (curClass->
runContext & CLSCTX_LOCAL_SERVER)
817 *
ppv = &
This->ISynchronize_iface;
819 *
ppv = &
This->ISynchronizeHandle_iface;
895 return ISynchronize_QueryInterface(&
This->ISynchronize_iface,
riid,
ppv);
901 return ISynchronize_AddRef(&
This->ISynchronize_iface);
907 return ISynchronize_Release(&
This->ISynchronize_iface);
931 FIXME(
"Aggregation not implemented.\n");
938 hr = ISynchronize_QueryInterface(&
This->ISynchronize_iface, iid,
ppv);
939 ISynchronize_Release(&
This->ISynchronize_iface);
955 *
ppv = &
This->IServiceProvider_iface;
1043 MSHCTX_LOCAL,
NULL, MSHLFLAGS_TABLESTRONG);
1045 IStream_Release(
obj->marshal_stream);
1093 TRACE(
"(%08x)\n",dwRegister);
1097 ERR(
"COM was not initialized\n");
1108 if (curClass->
dwCookie == dwRegister)
1117 ERR(
"called from wrong apartment, should be called from %s\n",
1138 if (
entry->dll->DllCanUnloadNow && (
entry->dll->DllCanUnloadNow() ==
S_OK))
1140 DWORD real_delay = delay;
1148 if (
entry->multi_threaded)
1149 real_delay = 10 * 60 * 1000;
1163 if (!
entry->unload_time)
entry->unload_time = 1;
1166 else if (
entry->unload_time)
1167 entry->unload_time = 0;
1216 IServiceProvider_Release(&
local_server->IServiceProvider_iface);
1341 BOOL apartment_threaded,
1344 static const WCHAR wszOle32[] = {
'o',
'l',
'e',
'3',
'2',
'.',
'd',
'l',
'l',0};
1353 TRACE(
"calling ole32!DllGetClassObject\n");
1398 if (!apartment_threaded)
1427 const WCHAR *quote_start;
1430 const WCHAR *quote_end =
wcschr(quote_start + 1,
'\"');
1433 (quote_end - quote_start - 1) *
sizeof(
WCHAR));
1434 src[quote_end - quote_start - 1] =
'\0';
1444 static const WCHAR dllW[] = {
'.',
'd',
'l',
'l',0};
1492 IUnknown_Release(
object);
1579 DWORD apartment_tid = 0;
1582 if (!multi_threaded && main_apartment)
1592 if (!apartment_hwnd)
1624 if (multi_threaded || !main_apartment)
1645 params.regdata = *regdata;
1651 params.apartment_threaded = !multi_threaded;
1669 ERR(
"host apartment didn't create window\n");
1677 IStream_Release(
params.stream);
1694 memset(&wclass, 0,
sizeof(wclass));
1747 if (
info->errorinfo) IErrorInfo_Release(
info->errorinfo);
1748 if (
info->state) IUnknown_Release(
info->state);
1757 if (
info->context_token) IObjContext_Release(
info->context_token);
1776 TRACE(
"Returning version %d, build %d.\n",
rmm,
rup);
1786 if (
id ==
spy->id &&
spy->spy)
1806 if (--
info->spies_lock)
return;
1810 if (
spy->spy)
continue;
1844 WARN(
"Could not allocate tls\n");
1848 hr = IInitializeSpy_QueryInterface(
spy, &IID_IInitializeSpy, (
void **)&
spy);
1855 IInitializeSpy_Release(
spy);
1903 IInitializeSpy_Release(
spy->spy);
1905 if (!
info->spies_lock)
1924 WARN(
"Attempt to change threading model of this apartment from %s to %s\n",
1925 info->apt->multi_threaded ?
"multi-threaded" :
"apartment threaded",
1941 if (
info->ole_inits)
1942 WARN(
"Uninitializing apartment while Ole is still initialized\n" );
2010 if (lpReserved!=
NULL)
2012 ERR(
"(%p, %x) - Bad parameter passed-in %p, must be an old Windows Application\n", lpReserved, (
int)
dwCoInit, lpReserved);
2026 TRACE(
"() - Initializing the COM libraries\n");
2088 ERR(
"Mismatched CoUninitialize\n");
2093 if (
cursor->spy) IInitializeSpy_PostUninitialize(
cursor->spy,
info->inits);
2110 TRACE(
"() - Releasing the COM libraries\n");
2115 else if (lCOMRefCnt<1) {
2116 ERR(
"CoUninitialize() - not CoInitialized.\n" );
2123 if (
cursor->spy) IInitializeSpy_PostUninitialize(
cursor->spy,
info->inits);
2160 hr = IUnknown_QueryInterface(lpUnk, &IID_IMarshal, (
void **)&marshal);
2163 hr = IMarshal_DisconnectObject(marshal,
reserved);
2164 IMarshal_Release(marshal);
2170 ERR(
"apartment not initialised\n");
2219 if (!(((
c >=
'0') && (
c <=
'9')) ||
2220 ((
c >=
'a') && (
c <=
'f')) ||
2221 ((
c >=
'A') && (
c <=
'F'))))
2228 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2229 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2230 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2231 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
2232 0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2233 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2234 0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf
2242 if (!
s ||
s[0]!=
'{') {
2253 for (
i = 1;
i < 9;
i++) {
2257 if (
s[9]!=
'-')
return FALSE;
2260 for (
i = 10;
i < 14;
i++) {
2264 if (
s[14]!=
'-')
return FALSE;
2267 for (
i = 15;
i < 19;
i++) {
2271 if (
s[19]!=
'-')
return FALSE;
2273 for (
i = 20;
i < 37;
i+=2) {
2282 if (
s[37] ==
'}' &&
s[38] ==
'\0')
2292 static const WCHAR clsidW[] = {
'\\',
'C',
'L',
'S',
'I',
'D',0 };
2294 LONG buf2len =
sizeof(buf2);
2380 memset(iid, 0,
sizeof(*iid));
2436 static const WCHAR formatW[] = {
'{',
'%',
'0',
'8',
'X',
'-',
'%',
'0',
'4',
'X',
'-',
2437 '%',
'0',
'4',
'X',
'-',
'%',
'0',
'2',
'X',
'%',
'0',
'2',
'X',
'-',
2438 '%',
'0',
'2',
'X',
'%',
'0',
'2',
'X',
'%',
'0',
'2',
'X',
'%',
'0',
'2',
'X',
2439 '%',
'0',
'2',
'X',
'%',
'0',
'2',
'X',
'}',0 };
2442 id->Data4[0],
id->Data4[1],
id->Data4[2],
id->Data4[3],
2443 id->Data4[4],
id->Data4[5],
id->Data4[6],
id->Data4[7] );
2450 static const WCHAR wszCLSIDSlash[] = {
'C',
'L',
'S',
'I',
'D',
'\\',0};
2482 static const WCHAR szAppId[] = {
'A',
'p',
'p',
'I',
'd',0 };
2483 static const WCHAR szAppIdKey[] = {
'A',
'p',
'p',
'I',
'd',
'\\',0 };
2532 static const WCHAR wszProgID[] = {
'P',
'r',
'o',
'g',
'I',
'D',0};
2533 ACTCTX_SECTION_KEYED_DATA
data;
2604 ACTCTX_SECTION_KEYED_DATA
data;
2692 static const WCHAR wszInterface[] = {
'I',
'n',
't',
'e',
'r',
'f',
'a',
'c',
'e',
'\\',0};
2693 static const WCHAR wszPSC[] = {
'\\',
'P',
'r',
'o',
'x',
'y',
'S',
't',
'u',
'b',
'C',
'l',
's',
'i',
'd',
'3',
'2',0};
2697 ACTCTX_SECTION_KEYED_DATA
data;
2706 ERR(
"apartment not initialised\n");
2731 *pclsid = ifaceps->
iid;
2787 ERR(
"apartment not initialised\n");
2904 static LONG next_cookie;
2910 TRACE(
"(%s,%p,0x%08x,0x%08x,%p)\n",
2913 if ( (lpdwRegister==0) || (
pUnk==0) )
2918 ERR(
"COM was not initialized\n");
2927 dwClsContext |= CLSCTX_INPROC_SERVER;
2936 if (dwClsContext & CLSCTX_LOCAL_SERVER)
2938 IUnknown_Release(foundObject);
2942 IUnknown_Release(foundObject);
2949 if ( newClass ==
NULL )
2975 *lpdwRegister = newClass->
dwCookie;
2977 if (dwClsContext & CLSCTX_LOCAL_SERVER) {
2991 IStream_Release(marshal_stream);
3001 static const WCHAR wszThreadingModel[] = {
'T',
'h',
'r',
'e',
'a',
'd',
'i',
'n',
'g',
'M',
'o',
'd',
'e',
'l',0};
3002 static const WCHAR wszApartment[] = {
'A',
'p',
'a',
'r',
't',
'm',
'e',
'n',
't',0};
3003 static const WCHAR wszFree[] = {
'F',
'r',
'e',
'e',0};
3004 static const WCHAR wszBoth[] = {
'B',
'o',
't',
'h',0};
3005 WCHAR threading_model[10 ];
3012 threading_model[0] =
'\0';
3023 return data->u.actctx.data->model;
3028 BOOL hostifnecessary,
void **
ppv)
3031 BOOL apartment_threaded;
3033 if (hostifnecessary)
3039 apartment_threaded =
TRUE;
3045 apartment_threaded =
FALSE;
3052 apartment_threaded =
TRUE;
3055 FIXME(
"unrecognised threading model %d for object %s, should be main-threaded?\n", model,
debugstr_guid(rclsid));
3061 apartment_threaded =
FALSE;
3121 ERR(
"apartment not initialised\n");
3126 FIXME(
"pServerInfo->name=%s pAuthInfo=%p\n",
3130 if (CLSCTX_INPROC_SERVER & dwClsContext)
3141 if (CLSCTX_INPROC & dwClsContext)
3143 ACTCTX_SECTION_KEYED_DATA
data;
3148 ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
3173 hres = IUnknown_QueryInterface(regClassObject, iid,
ppv);
3180 IUnknown_Release(regClassObject);
3186 if (CLSCTX_INPROC_SERVER & dwClsContext)
3188 static const WCHAR wszInprocServer32[] = {
'I',
'n',
'p',
'r',
'o',
'c',
'S',
'e',
'r',
'v',
'e',
'r',
'3',
'2',0};
3205 clsreg.
u.
hkey = hkey;
3222 if (CLSCTX_INPROC_HANDLER & dwClsContext)
3224 static const WCHAR wszInprocHandler32[] = {
'I',
'n',
'p',
'r',
'o',
'c',
'H',
'a',
'n',
'd',
'l',
'e',
'r',
'3',
'2',0};
3241 clsreg.
u.
hkey = hkey;
3259 if (CLSCTX_LOCAL_SERVER & dwClsContext)
3267 if (CLSCTX_REMOTE_SERVER & dwClsContext)
3269 FIXME (
"CLSCTX_REMOTE_SERVER not supported\n");
3274 ERR(
"no class object %s could be created for context 0x%x\n",
3332 MULTI_QI multi_qi = { iid };
3335 TRACE(
"(rclsid=%s, pUnkOuter=%p, dwClsContext=%08x, riid=%s, ppv=%p)\n",
debugstr_guid(rclsid),
3342 *
ppv = multi_qi.pItf;
3365 index = fetched = 1;
3370 mqi[
index].hr = IUnknown_QueryInterface(unk, mqi[
index].pIID, (
void**)&mqi[
index].pItf);
3376 IUnknown_Release(unk);
3401 TRACE(
"(%s %p %x %p %u %p)\n",
debugstr_guid(rclsid), pUnkOuter, dwClsContext, pServerInfo, cmq, pResults);
3403 if (!cmq || !pResults)
3407 FIXME(
"() non-NULL pServerInfo not supported!\n");
3417 ERR(
"apartment not initialised\n");
3428 TRACE(
"Retrieving GIT\n");
3449 hres = IClassFactory_CreateInstance(
cf, pUnkOuter, pResults[0].pIID, (
void**)&unk);
3450 IClassFactory_Release(
cf);
3456 FIXME(
"no instance created for interface %s of class %s, hres is 0x%08x\n",
3488 FIXME(
"() non-NULL server_info not supported\n");
3498 ERR(
"failed to get CLSID from a file\n");
3522 IUnknown_Release(unk);
3526 hr = IPersistFile_Load(pf,
filename, grfmode);
3527 IPersistFile_Release(pf);
3533 IUnknown_Release(unk);
3560 FIXME(
"() non-NULL server_info not supported\n");
3571 ERR(
"failed to get CLSID from a file\n");
3575 rclsid = &
stat.clsid;
3590 ERR(
"failed to get IPersistStorage\n");
3594 IPersistStorage_Load(ps,
storage);
3595 IPersistStorage_Release(ps);
3682 ERR(
"apartment not initialised\n");
3746 BOOL fLastUnlockReleases)
3751 TRACE(
"pUnk=%p, fLock=%s, fLastUnlockReleases=%s\n",
3752 pUnk, fLock ?
"TRUE" :
"FALSE", fLastUnlockReleases ?
"TRUE" :
"FALSE");
3756 ERR(
"apartment not initialised\n");
3763 WARN(
"stub object not found %p\n",
pUnk);
3795 FIXME(
"(0x%08x,0x%08x),stub!\n",
x,
y);
3828 IUnknown_AddRef(
info->state);
3856 if (pv) IUnknown_AddRef(pv);
3860 TRACE(
"-- release %p now\n",
info->state);
3861 IUnknown_Release(
info->state);
3888 static const WCHAR wszAutoTreatAs[] = {
'A',
'u',
't',
'o',
'T',
'r',
'e',
'a',
't',
'A',
's',0};
3889 static const WCHAR wszTreatAs[] = {
'T',
'r',
'e',
'a',
't',
'A',
's',0};
3894 LONG auto_treat_as_size =
sizeof(auto_treat_as);
3903 if (!
RegQueryValueW(hkey, wszAutoTreatAs, auto_treat_as, &auto_treat_as_size) &&
3925 WARN(
"StringFromGUID2 failed\n");
3931 WARN(
"RegSetValue failed\n");
3961 static const WCHAR wszTreatAs[] = {
'T',
'r',
'e',
'a',
't',
'A',
's',0};
3965 LONG len =
sizeof(szClsidNew);
3969 if (!clsidOld || !clsidNew)
3972 *clsidNew = *clsidOld;
3987 ERR(
"Failed CLSIDFromStringA(%s), hres 0x%08x\n",
debugstr_w(szClsidNew),
res);
4014 TRACE(
"(%p)\n",
id);
4053 TRACE(
"(%p, %p)\n", lpMessageFilter, lplpMessageFilter);
4060 WARN(
"can't set message filter in MTA or uninitialized apt\n");
4064 if (lpMessageFilter)
4065 IMessageFilter_AddRef(lpMessageFilter);
4069 lpOldMessageFilter = apt->
filter;
4070 apt->
filter = lpMessageFilter;
4074 if (lplpMessageFilter)
4075 *lplpMessageFilter = lpOldMessageFilter;
4076 else if (lpOldMessageFilter)
4077 IMessageFilter_Release(lpOldMessageFilter);
4123 SOLE_AUTHENTICATION_SERVICE* asAuthSvc,
4124 void* pReserved1,
DWORD dwAuthnLevel,
4125 DWORD dwImpLevel,
void* pReserved2,
4126 DWORD dwCapabilities,
void* pReserved3)
4128 FIXME(
"(%p,%d,%p,%p,%d,%d,%p,%d,%p) - stub!\n", pSecDesc, cAuthSvc,
4129 asAuthSvc, pReserved1, dwAuthnLevel, dwImpLevel, pReserved2,
4130 dwCapabilities, pReserved3);
4264 DWORD *pImpLevel,
void **ppAuthInfo,
DWORD *pCapabilities)
4269 TRACE(
"%p\n", pProxy);
4271 hr = IUnknown_QueryInterface(pProxy, &IID_IClientSecurity, (
void **)&pCliSec);
4274 hr = IClientSecurity_QueryBlanket(pCliSec, pProxy, pAuthnSvc,
4275 pAuthzSvc, ppServerPrincName,
4276 pAuthnLevel, pImpLevel, ppAuthInfo,
4278 IClientSecurity_Release(pCliSec);