Commit 2a5a8bc4 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ntdll: Implement compatible section for dll redirects.

parent cddea89d
......@@ -108,6 +108,7 @@ static const char manifest_wndcls1[] =
"<windowClass versioned=\"yes\">wndClass1</windowClass>"
"<windowClass>wndClass2</windowClass>"
"</file>"
"<file name=\"testlib1_2.dll\" />"
"</assembly>";
static const char manifest_wndcls2[] =
......@@ -117,6 +118,7 @@ static const char manifest_wndcls2[] =
"<windowClass versioned=\"no\">wndClass3</windowClass>"
"<windowClass>wndClass4</windowClass>"
"</file>"
"<file name=\"testlib2_2.dll\" />"
"</assembly>";
static const char manifest_wndcls_main[] =
......@@ -754,7 +756,37 @@ static void test_create_fail(void)
test_create_and_fail(manifest2, wrong_depmanifest1, 0 );
}
struct dllredirect_keyed_data
struct strsection_header
{
DWORD magic;
ULONG size;
DWORD unk1[3];
ULONG count;
ULONG index_offset;
DWORD unk2[4];
};
struct string_index
{
ULONG hash;
ULONG name_offset;
ULONG name_len;
ULONG data_offset;
ULONG data_len;
ULONG rosterindex;
};
struct wndclass_redirect_data
{
ULONG size;
DWORD res;
ULONG name_len;
ULONG name_offset; /* versioned name offset */
ULONG module_len;
ULONG module_offset;/* container name offset */
};
struct dllredirect_data
{
ULONG size;
ULONG unk;
......@@ -773,11 +805,7 @@ static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid
ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
libname, &data);
ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError());
if(!ret)
{
skip("couldn't find %s\n",strw(libname));
return;
}
if (!ret) return;
ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
......@@ -786,25 +814,20 @@ static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid
if (data.lpData)
{
struct dllredirect_keyed_data *dlldata = (struct dllredirect_keyed_data*)data.lpData;
todo_wine
struct dllredirect_data *dlldata = (struct dllredirect_data*)data.lpData;
ok_(__FILE__, line)(dlldata->size == data.ulLength, "got wrong size %d\n", dlldata->size);
if (dlldata->size == data.ulLength)
{
ok_(__FILE__, line)(dlldata->unk == 2, "got wrong field value %d\n", dlldata->unk);
ok_(__FILE__, line)(dlldata->res[0] == 0, "got wrong res[0] value %d\n", dlldata->res[0]);
ok_(__FILE__, line)(dlldata->res[1] == 0, "got wrong res[1] value %d\n", dlldata->res[1]);
ok_(__FILE__, line)(dlldata->res[2] == 0, "got wrong res[2] value %d\n", dlldata->res[2]);
}
}
ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
data.ulSectionGlobalDataLength);
ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
/* ok_(__FILE__, line)(data.ulSectionTotalLength == ??, "data.ulSectionTotalLength=%u\n",
data.ulSectionTotalLength); */
ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
data.ulSectionTotalLength);
ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
data.ulAssemblyRosterIndex, exid);
......@@ -816,11 +839,7 @@ if (dlldata->size == data.ulLength)
ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
libname, &data);
ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError());
if(!ret)
{
skip("couldn't find\n");
return;
}
if (!ret) return;
ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
......@@ -830,8 +849,8 @@ if (dlldata->size == data.ulLength)
ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
data.ulSectionGlobalDataLength);
ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
/* ok_(__FILE__, line)(data.ulSectionTotalLength == ?? , "data.ulSectionTotalLength=%u\n",
data.ulSectionTotalLength); */
ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
data.ulSectionTotalLength);
ok_(__FILE__, line)(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx);
ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
data.ulAssemblyRosterIndex, exid);
......@@ -839,39 +858,10 @@ if (dlldata->size == data.ulLength)
pReleaseActCtx(handle);
}
struct wndclass_header
{
DWORD magic;
DWORD unk1[4];
ULONG count;
ULONG index_offset;
DWORD unk2[4];
};
struct wndclass_index
{
ULONG hash;
ULONG name_offset;
ULONG name_len;
ULONG data_offset;
ULONG data_len;
ULONG rosterindex;
};
struct wndclass_redirect_data
{
ULONG size;
DWORD res;
ULONG name_len;
ULONG name_offset; /* versioned name offset */
ULONG module_len;
ULONG module_offset;/* container name offset */
};
static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid, int line)
{
struct wndclass_redirect_data *wnddata;
struct wndclass_header *header;
struct strsection_header *header;
ACTCTX_SECTION_KEYED_DATA data;
BOOL ret;
......@@ -885,7 +875,7 @@ static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid, i
wine_dbgstr_w(clsname));
if (!ret) return;
header = (struct wndclass_header*)data.lpSectionBase;
header = (struct strsection_header*)data.lpSectionBase;
wnddata = (struct wndclass_redirect_data*)data.lpData;
ok_(__FILE__, line)(header->magic == 0x64487353, "got wrong magic 0x%08x\n", header->magic);
......@@ -1143,6 +1133,7 @@ static void test_wndclass_section(void)
static const WCHAR cls1W[] = {'1','.','2','.','3','.','4','!','w','n','d','C','l','a','s','s','1',0};
ACTCTX_SECTION_KEYED_DATA data, data2;
struct wndclass_redirect_data *classdata;
struct strsection_header *section;
ULONG_PTR cookie;
HANDLE handle;
WCHAR *ptrW;
......@@ -1176,6 +1167,10 @@ static void test_wndclass_section(void)
wndClass3W, &data2);
ok(ret, "got %d\n", ret);
section = (struct strsection_header*)data.lpSectionBase;
ok(section->count == 4, "got %d\n", section->count);
ok(section->size == sizeof(*section), "got %d\n", section->size);
/* For both string same section is returned, meaning it's one wndclass section per context */
ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase);
ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
......@@ -1196,6 +1191,59 @@ static void test_wndclass_section(void)
pReleaseActCtx(handle);
}
static void test_dllredirect_section(void)
{
static const WCHAR testlib1W[] = {'t','e','s','t','l','i','b','1','.','d','l','l',0};
static const WCHAR testlib2W[] = {'t','e','s','t','l','i','b','2','.','d','l','l',0};
ACTCTX_SECTION_KEYED_DATA data, data2;
struct strsection_header *section;
ULONG_PTR cookie;
HANDLE handle;
BOOL ret;
/* use two dependent manifests, 4 'files' total */
create_manifest_file("testdep1.manifest", manifest_wndcls1, -1, NULL, NULL);
create_manifest_file("testdep2.manifest", manifest_wndcls2, -1, NULL, NULL);
create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
handle = test_create("main_wndcls.manifest");
DeleteFileA("testdep1.manifest");
DeleteFileA("testdep2.manifest");
DeleteFileA("main_wndcls.manifest");
ret = pActivateActCtx(handle, &cookie);
ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
memset(&data, 0, sizeof(data));
memset(&data2, 0, sizeof(data2));
data.cbSize = sizeof(data);
data2.cbSize = sizeof(data2);
/* get data for two files from different assemblies */
ret = pFindActCtxSectionStringW(0, NULL,
ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
testlib1W, &data);
ok(ret, "got %d\n", ret);
ret = pFindActCtxSectionStringW(0, NULL,
ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
testlib2W, &data2);
ok(ret, "got %d\n", ret);
section = (struct strsection_header*)data.lpSectionBase;
ok(section->count == 4, "got %d\n", section->count);
ok(section->size == sizeof(*section), "got %d\n", section->size);
/* For both string same section is returned, meaning it's one dll redirect section per context */
ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase);
ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
data2.ulSectionTotalLength);
ret = pDeactivateActCtx(0, cookie);
ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
pReleaseActCtx(handle);
}
static void test_actctx(void)
{
ULONG_PTR cookie;
......@@ -1415,6 +1463,7 @@ static void test_actctx(void)
}
test_wndclass_section();
test_dllredirect_section();
}
static void test_app_manifest(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment