Skip to content

Commit d0d472b

Browse files
iamahumanjulliard
authored andcommitted
ntdll: Don't hard-code DLL manifest resource ID when looking up dependency assembly.
This allows any manifest resource IDs (e.g., ISOLATIONAWARE_MANIFEST_RESOURCE_ID) to be recognized when looking up the assembly manifest of a dependency. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=18889
1 parent 2f78a8f commit d0d472b

File tree

2 files changed

+55
-35
lines changed

2 files changed

+55
-35
lines changed

dlls/kernel32/tests/actctx.c

+30-33
Original file line numberDiff line numberDiff line change
@@ -3754,7 +3754,6 @@ struct multiple_manifest_test
37543754
struct manifest_res_spec manifest_inline; /* optional */
37553755
const struct manifest_res_spec *manifests; /* optional */
37563756
DWORD expected_error;
3757-
BOOL is_todo_wine;
37583757
};
37593758

37603759
#define subtest_manifest_res(d,e,t,l) subtest_manifest_res_(__LINE__,d,e,t,l)
@@ -3853,7 +3852,6 @@ static DWORD subtest_manifest_res_(int line, const char *manifest_exe, const cha
38533852
ok_(__FILE__, line)(handle != NULL, "CreateActCtxA returned %p (error %lu)\n", handle, err);
38543853
ReleaseActCtx(handle);
38553854
}
3856-
todo_wine_if(test_data->is_todo_wine)
38573855
ok_(__FILE__, line)(err == test_data->expected_error,
38583856
"expected error %lu, got %lu\n", test_data->expected_error, err);
38593857

@@ -3917,54 +3915,54 @@ static void test_manifest_resources(void)
39173915
};
39183916
struct multiple_manifest_test tests[] = {
39193917
/* Test well-known manifest resource IDs */
3920-
{ { (char *)CREATEPROCESS_MANIFEST_RESOURCE_ID }, NULL, ERROR_SUCCESS, FALSE },
3921-
{ { (char *)ISOLATIONAWARE_MANIFEST_RESOURCE_ID }, NULL, ERROR_SUCCESS, TRUE },
3922-
{ { (char *)ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID }, NULL, ERROR_SUCCESS, TRUE },
3918+
{ { (char *)CREATEPROCESS_MANIFEST_RESOURCE_ID }, NULL, ERROR_SUCCESS },
3919+
{ { (char *)ISOLATIONAWARE_MANIFEST_RESOURCE_ID }, NULL, ERROR_SUCCESS },
3920+
{ { (char *)ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID }, NULL, ERROR_SUCCESS },
39233921

39243922
/* Test remaining reserved manifest resource IDs */
3925-
{ { (char *)4 }, NULL, ERROR_SUCCESS, TRUE },
3926-
{ { (char *)5 }, NULL, ERROR_SUCCESS, TRUE },
3927-
{ { (char *)6 }, NULL, ERROR_SUCCESS, TRUE },
3928-
{ { (char *)7 }, NULL, ERROR_SUCCESS, TRUE },
3929-
{ { (char *)8 }, NULL, ERROR_SUCCESS, TRUE },
3930-
{ { (char *)9 }, NULL, ERROR_SUCCESS, TRUE },
3931-
{ { (char *)10 }, NULL, ERROR_SUCCESS, TRUE },
3932-
{ { (char *)11 }, NULL, ERROR_SUCCESS, TRUE },
3933-
{ { (char *)12 }, NULL, ERROR_SUCCESS, TRUE },
3934-
{ { (char *)13 }, NULL, ERROR_SUCCESS, TRUE },
3935-
{ { (char *)14 }, NULL, ERROR_SUCCESS, TRUE },
3936-
{ { (char *)15 }, NULL, ERROR_SUCCESS, TRUE },
3937-
{ { (char *)MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID }, NULL, ERROR_SUCCESS, TRUE },
3923+
{ { (char *)4 }, NULL, ERROR_SUCCESS },
3924+
{ { (char *)5 }, NULL, ERROR_SUCCESS },
3925+
{ { (char *)6 }, NULL, ERROR_SUCCESS },
3926+
{ { (char *)7 }, NULL, ERROR_SUCCESS },
3927+
{ { (char *)8 }, NULL, ERROR_SUCCESS },
3928+
{ { (char *)9 }, NULL, ERROR_SUCCESS },
3929+
{ { (char *)10 }, NULL, ERROR_SUCCESS },
3930+
{ { (char *)11 }, NULL, ERROR_SUCCESS },
3931+
{ { (char *)12 }, NULL, ERROR_SUCCESS },
3932+
{ { (char *)13 }, NULL, ERROR_SUCCESS },
3933+
{ { (char *)14 }, NULL, ERROR_SUCCESS },
3934+
{ { (char *)15 }, NULL, ERROR_SUCCESS },
3935+
{ { (char *)MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID }, NULL, ERROR_SUCCESS },
39383936

39393937
/* Test arbitrary resource IDs */
3940-
{ { (char *)0x1234 }, NULL, ERROR_SUCCESS, TRUE },
3941-
{ { (char *)0x89ab }, NULL, ERROR_SUCCESS, TRUE },
3942-
{ { (char *)0xffff }, NULL, ERROR_SUCCESS, TRUE },
3938+
{ { (char *)0x1234 }, NULL, ERROR_SUCCESS },
3939+
{ { (char *)0x89ab }, NULL, ERROR_SUCCESS },
3940+
{ { (char *)0xffff }, NULL, ERROR_SUCCESS },
39433941

39443942
/* Test arbitrary LANGID */
3945-
{ { (char *)2, MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT) }, NULL, ERROR_SUCCESS, TRUE },
3946-
{ { (char *)2, MAKELANGID(LANG_FRENCH,SUBLANG_DEFAULT) }, NULL, ERROR_SUCCESS, TRUE },
3947-
{ { (char *)2, 0x1234 }, NULL, ERROR_SUCCESS, TRUE },
3948-
{ { (char *)2, 0xffff }, NULL, ERROR_SUCCESS, TRUE },
3943+
{ { (char *)2, MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT) }, NULL, ERROR_SUCCESS },
3944+
{ { (char *)2, MAKELANGID(LANG_FRENCH,SUBLANG_DEFAULT) }, NULL, ERROR_SUCCESS },
3945+
{ { (char *)2, 0x1234 }, NULL, ERROR_SUCCESS },
3946+
{ { (char *)2, 0xffff }, NULL, ERROR_SUCCESS },
39493947

39503948
/* Test multiple manifest resources coexisting inside a module */
3951-
{ { (char *)2, 0 }, wrong_manifest_resources_numbered, ERROR_SUCCESS, TRUE },
3949+
{ { (char *)2, 0 }, wrong_manifest_resources_numbered, ERROR_SUCCESS },
39523950
{ { (char *)2, 0, wrong_manifest1 }, correct_manifest_resources_numbered,
3953-
ERROR_SXS_CANT_GEN_ACTCTX, FALSE },
3951+
ERROR_SXS_CANT_GEN_ACTCTX },
39543952

39553953
/* Test that smaller resource ID takes precedence regardless of language ID */
39563954
{ { (char *)2, MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL) },
3957-
wrong_manifest_resources_gte_3, ERROR_SUCCESS, TRUE },
3955+
wrong_manifest_resources_gte_3, ERROR_SUCCESS },
39583956
{ { (char *)2, MAKELANGID(LANG_INVARIANT,SUBLANG_NEUTRAL), wrong_manifest1 },
3959-
correct_manifest_resources_gte_3, ERROR_SXS_CANT_GEN_ACTCTX, FALSE },
3957+
correct_manifest_resources_gte_3, ERROR_SXS_CANT_GEN_ACTCTX },
39603958

39613959
/* Test multiple manifest resources (ID / name) coexisting inside a module */
3962-
{ { (char *)2, 0 }, wrong_manifest_resources_named, ERROR_SUCCESS, TRUE },
3960+
{ { (char *)2, 0 }, wrong_manifest_resources_named, ERROR_SUCCESS },
39633961
{ { (char *)2, 0, wrong_manifest1 },
3964-
correct_manifest_resources_named, ERROR_SXS_CANT_GEN_ACTCTX, FALSE },
3962+
correct_manifest_resources_named, ERROR_SXS_CANT_GEN_ACTCTX },
39653963

39663964
/* Test name-only RT_MANIFEST resources */
3967-
{ { NULL }, correct_manifest_resources_named, ERROR_SXS_CANT_GEN_ACTCTX, FALSE },
3965+
{ { NULL }, correct_manifest_resources_named, ERROR_SXS_CANT_GEN_ACTCTX },
39683966
};
39693967
size_t i;
39703968

@@ -4093,7 +4091,6 @@ static void subtest_valid_manifest_resources_locale(LANGID actctx_lang)
40934091

40944092
test.manifests = specs;
40954093
test.expected_error = ERROR_SUCCESS;
4096-
test.is_todo_wine = TRUE;
40974094
err = subtest_manifest_res(manifest_exe, manifest_dll, &test, actctx_lang);
40984095

40994096
if (winetest_debug > 1 && err != ERROR_SUCCESS)

dlls/ntdll/actctx.c

+25-2
Original file line numberDiff line numberDiff line change
@@ -2929,6 +2929,24 @@ static NTSTATUS open_nt_file( HANDLE *handle, UNICODE_STRING *name )
29292929
FILE_SHARE_READ | FILE_SHARE_DELETE, FILE_SYNCHRONOUS_IO_ALERT );
29302930
}
29312931

2932+
static NTSTATUS find_first_manifest_resource_in_module( HANDLE hModule, const WCHAR **resname )
2933+
{
2934+
static const LDR_RESOURCE_INFO manifest_res_info = { RT_MANIFEST };
2935+
const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry_base, *entry;
2936+
const IMAGE_RESOURCE_DIRECTORY *resdir;
2937+
NTSTATUS status;
2938+
2939+
status = LdrFindResourceDirectory_U( hModule, &manifest_res_info, 1, &resdir );
2940+
if (status != STATUS_SUCCESS) return status;
2941+
2942+
if (!resdir->NumberOfIdEntries) return STATUS_RESOURCE_NAME_NOT_FOUND;
2943+
entry_base = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(resdir + 1);
2944+
entry = entry_base + resdir->NumberOfNamedEntries;
2945+
*resname = (const WCHAR *)(ULONG_PTR)entry->u.Id;
2946+
2947+
return STATUS_SUCCESS;
2948+
}
2949+
29322950
static NTSTATUS get_manifest_in_module( struct actctx_loader* acl, struct assembly_identity* ai,
29332951
LPCWSTR filename, LPCWSTR directory, BOOL shared,
29342952
HANDLE hModule, LPCWSTR resname, ULONG lang )
@@ -2951,6 +2969,12 @@ static NTSTATUS get_manifest_in_module( struct actctx_loader* acl, struct assemb
29512969
hModule, debugstr_w(filename) );
29522970
}
29532971

2972+
if (!resname)
2973+
{
2974+
status = find_first_manifest_resource_in_module( hModule, &resname );
2975+
if (status != STATUS_SUCCESS) return status;
2976+
}
2977+
29542978
info.Type = RT_MANIFEST;
29552979
info.Language = lang;
29562980
if (!((ULONG_PTR)resname >> 16))
@@ -3330,8 +3354,7 @@ static NTSTATUS lookup_assembly(struct actctx_loader* acl,
33303354
status = open_nt_file( &file, &nameW );
33313355
if (!status)
33323356
{
3333-
status = get_manifest_in_pe_file( acl, ai, nameW.Buffer, directory, FALSE, file,
3334-
(LPCWSTR)CREATEPROCESS_MANIFEST_RESOURCE_ID, 0 );
3357+
status = get_manifest_in_pe_file( acl, ai, nameW.Buffer, directory, FALSE, file, NULL, 0 );
33353358
NtClose( file );
33363359
if (status == STATUS_SUCCESS)
33373360
break;

0 commit comments

Comments
 (0)