Added patch to fix implementation of SH*Shared commands.

This commit is contained in:
Sebastian Lackner 2014-10-01 02:44:22 +02:00
parent fa52b6489a
commit f062a5a3ba
5 changed files with 248 additions and 0 deletions

1
debian/changelog vendored
View File

@ -10,6 +10,7 @@ wine-compholio (1.7.28) UNRELEASED; urgency=low
* Added patch to export ?_BADOFF@std@@3_JB on both i386 and win64.
* Added patch to limit cross thread access to ImmSet* functions.
* Added patch for IRichEditOle and ITextDocument support for ITextServices.
* Added patch to fix implementation of SH*Shared commands.
* Removed patch to support FIND_FIRST_EX_CASE_SENSITIVE flag in FindFirstFileExW (accepted upstream).
-- Sebastian Lackner <sebastian@fds-team.de> Sun, 21 Sep 2014 01:44:14 +0200

View File

@ -67,6 +67,7 @@ PATCHLIST := \
shell32-RunDLL_CallEntry16.ok \
shell32-SHCreateSessionKey.ok \
shlwapi-PathIsDirectoryEmptyW.ok \
shlwapi-SH_Shared.ok \
shlwapi-UrlCombine.ok \
user32-Dialog_Paint_Event.ok \
user32-GetSystemMetrics.ok \
@ -1082,6 +1083,22 @@ shlwapi-PathIsDirectoryEmptyW.ok:
echo '+ { "shlwapi-PathIsDirectoryEmptyW", "Michael Müller", "Correctly treat '\''.'\'' when enumerating files in PathIsDirectoryEmptyW." },'; \
) > shlwapi-PathIsDirectoryEmptyW.ok
# Patchset shlwapi-SH_Shared
# |
# | Included patches:
# | * Fix implementation of SH*Shared commands. [by Sebastian Lackner]
# |
# | Modified files:
# | * dlls/shlwapi/ordinal.c, dlls/shlwapi/tests/ordinal.c
# |
.INTERMEDIATE: shlwapi-SH_Shared.ok
shlwapi-SH_Shared.ok:
$(call APPLY_FILE,shlwapi-SH_Shared/0001-shlwapi-tests-Add-SH-Shared-inter-process-tests.patch)
$(call APPLY_FILE,shlwapi-SH_Shared/0002-shlwapi-Fixed-swapped-argument-order-in-SHLWAPI_DupS.patch)
@( \
echo '+ { "shlwapi-SH_Shared", "Sebastian Lackner", "Fix implementation of SH*Shared commands." },'; \
) > shlwapi-SH_Shared.ok
# Patchset shlwapi-UrlCombine
# |
# | Included patches:

View File

@ -0,0 +1,161 @@
From db243f2450c75fe4adade70f6895de83858ec0ca Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 1 Oct 2014 02:36:47 +0200
Subject: shlwapi/tests: Add SH*Shared inter-process tests.
---
dlls/shlwapi/tests/ordinal.c | 98 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 90 insertions(+), 8 deletions(-)
diff --git a/dlls/shlwapi/tests/ordinal.c b/dlls/shlwapi/tests/ordinal.c
index cb90d31..7bd1692 100644
--- a/dlls/shlwapi/tests/ordinal.c
+++ b/dlls/shlwapi/tests/ordinal.c
@@ -444,12 +444,20 @@ static void test_SHSearchMapInt(void)
ok(i == values[0], "Len 3, expected %d, got %d\n", values[0], i);
}
-static void test_alloc_shared(void)
+struct shared_struct
{
+ DWORD value;
+ HANDLE handle;
+};
+
+static void test_alloc_shared(int argc, char **argv)
+{
+ char cmdline[MAX_PATH];
+ PROCESS_INFORMATION pi;
+ STARTUPINFOA si = { 0 };
DWORD procid;
- HANDLE hmem;
- int val;
- int* p;
+ HANDLE hmem, hmem2 = 0;
+ struct shared_struct val, *p;
BOOL ret;
procid=GetCurrentProcessId();
@@ -458,19 +466,79 @@ static void test_alloc_shared(void)
ret = pSHFreeShared(hmem, procid);
ok( ret, "SHFreeShared failed: %u\n", GetLastError());
- val=0x12345678;
- hmem=pSHAllocShared(&val,4,procid);
+ val.value = 0x12345678;
+ val.handle = 0;
+ hmem = pSHAllocShared(&val, sizeof(val), procid);
ok(hmem!=NULL,"SHAllocShared(NULL...) failed: %u\n", GetLastError());
p=pSHLockShared(hmem,procid);
ok(p!=NULL,"SHLockShared failed: %u\n", GetLastError());
if (p!=NULL)
- ok(*p==val,"Wrong value in shared memory: %d instead of %d\n",*p,val);
+ ok(p->value == 0x12345678, "Wrong value in shared memory: %d instead of %d\n", p->value, 0x12345678);
ret = pSHUnlockShared(p);
ok( ret, "SHUnlockShared failed: %u\n", GetLastError());
+ sprintf(cmdline, "%s %s %d %p", argv[0], argv[1], procid, hmem);
+ ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
+ ok(ret, "could not create child process error: %u\n", GetLastError());
+ if (ret)
+ {
+ winetest_wait_child_process(pi.hProcess);
+ CloseHandle(pi.hThread);
+ CloseHandle(pi.hProcess);
+
+ p = pSHLockShared(hmem, procid);
+ ok(p != NULL,"SHLockShared failed: %u\n", GetLastError());
+ if (p != NULL)
+ {
+ ok(p->value == 0x12345679, "Wrong value in shared memory: %d instead of %d\n", p->value, 0x12345679);
+ hmem2 = p->handle;
+ ok(hmem2 != NULL, "Expected handle in shared memory\n");
+ }
+ ret = pSHUnlockShared(p);
+ ok(ret, "SHUnlockShared failed: %u\n", GetLastError());
+ }
+
ret = pSHFreeShared(hmem, procid);
ok( ret, "SHFreeShared failed: %u\n", GetLastError());
+
+ if (hmem2)
+ {
+ p = pSHLockShared(hmem2, procid);
+ todo_wine
+ ok(p != NULL,"SHLockShared failed: %u\n", GetLastError());
+ if (p != NULL)
+ ok(p->value == 0xDEADBEEF, "Wrong value in shared memory: %d instead of %d\n", p->value, 0xDEADBEEF);
+ ret = pSHUnlockShared(p);
+ todo_wine
+ ok(ret, "SHUnlockShared failed: %u\n", GetLastError());
+
+ ret = pSHFreeShared(hmem2, procid);
+ todo_wine
+ ok(ret, "SHFreeShared failed: %u\n", GetLastError());
+ }
+}
+
+static void test_alloc_shared_remote(DWORD procid, HANDLE hmem)
+{
+ struct shared_struct val, *p;
+ BOOL ret;
+
+ p = pSHLockShared(hmem, procid);
+ ok(p != NULL,"SHLockShared failed: %u\n", GetLastError());
+ if (p != NULL)
+ {
+ ok(p->value == 0x12345678, "Wrong value in shared memory: %d instead of %d\n", p->value, 0x12345678);
+
+ val.value = 0xDEADBEEF;
+ val.handle = 0;
+
+ p->handle = pSHAllocShared(&val, sizeof(val), procid);
+ ok(p->handle != NULL, "SHAllocShared(NULL...) failed: %u\n", GetLastError());
+ p->value++;
+ }
+ ret = pSHUnlockShared(p);
+ ok(ret, "SHUnlockShared failed: %u\n", GetLastError());
}
static void test_fdsa(void)
@@ -3057,6 +3125,9 @@ static void test_SHSetParentHwnd(void)
START_TEST(ordinal)
{
+ char **argv;
+ int argc;
+
hShlwapi = GetModuleHandleA("shlwapi.dll");
is_win2k_and_lower = GetProcAddress(hShlwapi, "StrChrNW") == 0;
is_win9x = GetProcAddress(hShlwapi, (LPSTR)99) == 0; /* StrCpyNXA */
@@ -3069,6 +3140,17 @@ START_TEST(ordinal)
init_pointers();
+ argc = winetest_get_mainargs(&argv);
+ if (argc >= 4)
+ {
+ DWORD procid;
+ HANDLE hmem;
+ sscanf(argv[2], "%d", &procid);
+ sscanf(argv[3], "%p", &hmem);
+ test_alloc_shared_remote(procid, hmem);
+ return;
+ }
+
hmlang = LoadLibraryA("mlang.dll");
pLcidToRfc1766A = (void *)GetProcAddress(hmlang, "LcidToRfc1766A");
@@ -3077,7 +3159,7 @@ START_TEST(ordinal)
test_GetAcceptLanguagesA();
test_SHSearchMapInt();
- test_alloc_shared();
+ test_alloc_shared(argc, argv);
test_fdsa();
test_GetShellSecurityDescriptor();
test_SHPackDispParams();
--
2.1.1

View File

@ -0,0 +1,66 @@
From d343442b0729be73af148458a9a49f5faca63e0d Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 1 Oct 2014 02:39:49 +0200
Subject: shlwapi: Fixed swapped argument order in SHLWAPI_DupSharedHandle
command.
---
dlls/shlwapi/ordinal.c | 6 +++---
dlls/shlwapi/tests/ordinal.c | 3 ---
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/dlls/shlwapi/ordinal.c b/dlls/shlwapi/ordinal.c
index 303c63a..e5da1cf 100644
--- a/dlls/shlwapi/ordinal.c
+++ b/dlls/shlwapi/ordinal.c
@@ -106,7 +106,7 @@ static HANDLE SHLWAPI_DupSharedHandle(HANDLE hShared, DWORD dwDstProcId,
if (hSrc)
{
/* Make handle available to dest process */
- if (!DuplicateHandle(hDst, hShared, hSrc, &hRet,
+ if (!DuplicateHandle(hSrc, hShared, hDst, &hRet,
dwAccess, 0, dwOptions | DUPLICATE_SAME_ACCESS))
hRet = NULL;
@@ -201,7 +201,7 @@ PVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
TRACE("(%p %d)\n", hShared, dwProcId);
/* Get handle to shared memory for current process */
- hDup = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
+ hDup = SHLWAPI_DupSharedHandle(hShared, GetCurrentProcessId(), dwProcId,
FILE_MAP_ALL_ACCESS, 0);
/* Get View */
pMapped = MapViewOfFile(hDup, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
@@ -252,7 +252,7 @@ BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
TRACE("(%p %d)\n", hShared, dwProcId);
/* Get a copy of the handle for our process, closing the source handle */
- hClose = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
+ hClose = SHLWAPI_DupSharedHandle(hShared, GetCurrentProcessId(), dwProcId,
FILE_MAP_ALL_ACCESS,DUPLICATE_CLOSE_SOURCE);
/* Close local copy */
return CloseHandle(hClose);
diff --git a/dlls/shlwapi/tests/ordinal.c b/dlls/shlwapi/tests/ordinal.c
index 7bd1692..409ff3f 100644
--- a/dlls/shlwapi/tests/ordinal.c
+++ b/dlls/shlwapi/tests/ordinal.c
@@ -505,16 +505,13 @@ static void test_alloc_shared(int argc, char **argv)
if (hmem2)
{
p = pSHLockShared(hmem2, procid);
- todo_wine
ok(p != NULL,"SHLockShared failed: %u\n", GetLastError());
if (p != NULL)
ok(p->value == 0xDEADBEEF, "Wrong value in shared memory: %d instead of %d\n", p->value, 0xDEADBEEF);
ret = pSHUnlockShared(p);
- todo_wine
ok(ret, "SHUnlockShared failed: %u\n", GetLastError());
ret = pSHFreeShared(hmem2, procid);
- todo_wine
ok(ret, "SHFreeShared failed: %u\n", GetLastError());
}
}
--
2.1.1

View File

@ -0,0 +1,3 @@
Author: Sebastian Lackner
Subject: Fix implementation of SH*Shared commands.
Revision: 1