sxs: Add support for SXS_LOOKUP_CLR_GUID_USE_ACTCTX in SxsLookupClrGuid().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-07-21 15:03:29 +03:00 committed by Alexandre Julliard
parent fe2c271ecc
commit 2cfc85dc55
2 changed files with 53 additions and 27 deletions

View File

@ -112,59 +112,58 @@ BOOL WINAPI SxsLookupClrGuid(DWORD flags, GUID *clsid, HANDLE actctx, void *buff
SIZE_T *buffer_len_required)
{
ACTCTX_SECTION_KEYED_DATA guid_info = { sizeof(ACTCTX_SECTION_KEYED_DATA) };
ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *assembly_info;
ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *assembly_info = NULL;
SIZE_T bytes_assembly_info;
unsigned int len_version = 0, len_name, len_identity;
const void *ptr_name, *ptr_version, *ptr_identity;
SXS_GUID_INFORMATION_CLR *ret = buffer;
BOOL retval = FALSE;
char *ret_strings;
ULONG_PTR cookie;
TRACE("%#x, %s, %p, %p, %lx, %p.\n", flags, wine_dbgstr_guid(clsid), actctx,
buffer, buffer_len, buffer_len_required);
if (flags & ~SXS_LOOKUP_CLR_GUID_FIND_ANY)
FIXME("Ignored flags: %x\n", flags & ~SXS_LOOKUP_CLR_GUID_FIND_ANY);
if (flags & SXS_LOOKUP_CLR_GUID_USE_ACTCTX)
{
if (!ActivateActCtx(actctx, &cookie))
{
WARN("Failed to activate context.\n");
return FALSE;
}
}
if (flags & SXS_LOOKUP_CLR_GUID_FIND_SURROGATE)
{
if ((retval = FindActCtxSectionGuid(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, 0,
ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES, clsid, &guid_info)))
{
if ((retval = FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES, clsid, &guid_info)))
flags &= ~SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS;
}
}
if (!retval && (flags & SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS))
{
if ((retval = FindActCtxSectionGuid(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, 0,
ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, clsid, &guid_info)))
{
if ((retval = FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, clsid, &guid_info)))
flags &= ~SXS_LOOKUP_CLR_GUID_FIND_SURROGATE;
}
}
if (!retval)
{
SetLastError(ERROR_NOT_FOUND);
return FALSE;
goto out;
}
QueryActCtxW(0, guid_info.hActCtx, &guid_info.ulAssemblyRosterIndex,
retval = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX, NULL, &guid_info.ulAssemblyRosterIndex,
AssemblyDetailedInformationInActivationContext, NULL, 0, &bytes_assembly_info);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
if (!retval && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
ReleaseActCtx(guid_info.hActCtx);
return FALSE;
goto out;
}
assembly_info = heap_alloc(bytes_assembly_info);
if(!QueryActCtxW(0, guid_info.hActCtx, &guid_info.ulAssemblyRosterIndex,
if (!(retval = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX, NULL, &guid_info.ulAssemblyRosterIndex,
AssemblyDetailedInformationInActivationContext, assembly_info,
bytes_assembly_info, &bytes_assembly_info))
bytes_assembly_info, &bytes_assembly_info)))
{
heap_free(assembly_info);
ReleaseActCtx(guid_info.hActCtx);
return FALSE;
goto out;
}
if (flags & SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS)
@ -192,13 +191,12 @@ BOOL WINAPI SxsLookupClrGuid(DWORD flags, GUID *clsid, HANDLE actctx, void *buff
ptr_identity = assembly_info->lpAssemblyEncodedAssemblyIdentity;
len_identity = assembly_info->ulEncodedAssemblyIdentityLength + sizeof(WCHAR);
*buffer_len_required = sizeof(SXS_GUID_INFORMATION_CLR) + len_identity + len_version + len_name;
*buffer_len_required = sizeof(*ret) + len_identity + len_version + len_name;
if (!buffer || buffer_len < *buffer_len_required)
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
heap_free(assembly_info);
ReleaseActCtx(guid_info.hActCtx);
return FALSE;
retval = FALSE;
goto out;
}
ret->cbSize = sizeof(*ret);
@ -226,7 +224,11 @@ BOOL WINAPI SxsLookupClrGuid(DWORD flags, GUID *clsid, HANDLE actctx, void *buff
SetLastError(0);
ReleaseActCtx(guid_info.hActCtx);
out:
if (flags & SXS_LOOKUP_CLR_GUID_USE_ACTCTX)
DeactivateActCtx(0, cookie);
heap_free(assembly_info);
return TRUE;
return retval;
}

View File

@ -86,15 +86,30 @@ static void run_test(void)
BOOL ret;
SXS_GUID_INFORMATION_CLR *info;
SetLastError(0xdeadbeef);
ret = SxsLookupClrGuid(SXS_LOOKUP_CLR_GUID_FIND_ANY | SXS_LOOKUP_CLR_GUID_USE_ACTCTX, (GUID *)&CLSID_Test,
NULL, NULL, 0, &buffer_size);
ok(!ret, "Unexpected return value %d.\n", ret);
ok(GetLastError() == ERROR_NOT_FOUND, "Unexpected error %d.\n", GetLastError());
SetLastError(0xdeadbeef);
ret = SxsLookupClrGuid(SXS_LOOKUP_CLR_GUID_FIND_ANY | SXS_LOOKUP_CLR_GUID_USE_ACTCTX, (GUID *)&CLSID_Test,
NULL, NULL, 0, &buffer_size);
ok(!ret, "Unexpected return value %d.\n", ret);
ok(GetLastError() == ERROR_NOT_FOUND, "Unexpected error %d.\n", GetLastError());
SetLastError(0xdeadbeef);
ret = SxsLookupClrGuid(SXS_LOOKUP_CLR_GUID_FIND_ANY, (GUID*)&CLSID_Test, NULL, NULL, 0, &buffer_size);
ok(!ret, "Unexpected return value %d.\n", ret);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got %d\n", GetLastError());
SetLastError(0xdeadbeef);
ret = SxsLookupClrGuid(SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS, (GUID*)&CLSID_Test, NULL, NULL, 0, &buffer_size);
ok(ret == FALSE, "Got %d\n", ret);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got %d\n", GetLastError());
info = heap_alloc(buffer_size);
SetLastError(0xdeadbeef);
ret = SxsLookupClrGuid(SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS, (GUID*)&CLSID_Test, NULL, info, buffer_size, &buffer_size);
ok(ret == TRUE, "Got %d\n", ret);
ok(GetLastError() == 0, "Got %d\n", GetLastError());
@ -108,11 +123,13 @@ static void run_test(void)
heap_free(info);
SetLastError(0xdeadbeef);
ret = SxsLookupClrGuid(SXS_LOOKUP_CLR_GUID_FIND_SURROGATE, (GUID *)&CLSID_SurrogateTest, NULL, NULL, 0, &buffer_size);
ok(!ret, "Unexpected return value %d.\n", ret);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got %d\n", GetLastError());
info = heap_alloc(buffer_size);
SetLastError(0xdeadbeef);
ret = SxsLookupClrGuid(SXS_LOOKUP_CLR_GUID_FIND_SURROGATE, (GUID *)&CLSID_SurrogateTest, NULL, info,
buffer_size, &buffer_size);
ok(ret, "Unexpected return value %d.\n", ret);
@ -127,6 +144,7 @@ static void run_test(void)
heap_free(info);
SetLastError(0xdeadbeef);
ret = SxsLookupClrGuid(SXS_LOOKUP_CLR_GUID_FIND_ANY, (GUID *)&CLSID_SurrogateTest, NULL, NULL, 0, &buffer_size);
ok(!ret, "Unexpected return value %d.\n", ret);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got %d\n", GetLastError());
@ -231,6 +249,12 @@ static void test_SxsLookupClrGuid(void)
ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
ok(GetLastError() == ERROR_NOT_FOUND, "Expected ERROR_NOT_FOUND, got %d\n", GetLastError());
SetLastError(0xdeadbeef);
ret = SxsLookupClrGuid(SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS | SXS_LOOKUP_CLR_GUID_USE_ACTCTX, (GUID *)&CLSID_Test,
NULL, NULL, 0, &buffer_size);
ok(!ret, "Unexpected return value %d.\n", ret);
ok(GetLastError() == ERROR_NOT_FOUND, "Expected ERROR_NOT_FOUND, got %d\n", GetLastError());
SetLastError(0xdeadbeef);
ret = SxsLookupClrGuid(SXS_LOOKUP_CLR_GUID_FIND_SURROGATE, (GUID *)&CLSID_Test, NULL, NULL, 0, &buffer_size);
ok(!ret, "Unexpected return value %d.\n", ret);