https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7fcdf0be03da1905f5523…
commit 7fcdf0be03da1905f5523d7fb4e5730e62f757df
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Mar 11 00:03:45 2020 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Mar 11 00:03:45 2020 +0900
[SHLWAPI] Implement SHLockSharedEx function (#2430)
- Implement shlwapi!SHLockSharedEx function.
- Modify shlwapi.spec file (some argument conversions from long to ptr).
CORE-13950
---
dll/win32/shlwapi/ordinal.c | 44 ++++++++++++++++++++++++++++++++++++++++++
dll/win32/shlwapi/shlwapi.spec | 8 ++++----
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/dll/win32/shlwapi/ordinal.c b/dll/win32/shlwapi/ordinal.c
index 9adf962ed2a..8773234e2df 100644
--- a/dll/win32/shlwapi/ordinal.c
+++ b/dll/win32/shlwapi/ordinal.c
@@ -193,6 +193,46 @@ HANDLE WINAPI SHAllocShared(LPCVOID lpvData, DWORD dwSize, DWORD
dwProcId)
return hRet;
}
+#ifdef __REACTOS__
+/*************************************************************************
+ * @ [SHLWAPI.510]
+ *
+ * Get a pointer to a block of shared memory from a shared memory handle,
+ * with specified access rights.
+ *
+ * PARAMS
+ * hShared [I] Shared memory handle
+ * dwProcId [I] ID of process owning hShared
+ * bWriteAccess [I] TRUE to get a writable block,
+ * FALSE to get a read-only block
+ *
+ * RETURNS
+ * Success: A pointer to the shared memory
+ * Failure: NULL
+ */
+LPVOID WINAPI
+SHLockSharedEx(HANDLE hShared, DWORD dwProcId, BOOL bWriteAccess)
+{
+ HANDLE hDup;
+ LPVOID pMapped;
+ DWORD dwAccess;
+
+ TRACE("(%p %d %d)\n", hShared, dwProcId, bWriteAccess);
+
+ /* Get handle to shared memory for current process */
+ hDup = SHMapHandle(hShared, dwProcId, GetCurrentProcessId(), FILE_MAP_ALL_ACCESS, 0);
+
+ /* Get View */
+ dwAccess = (FILE_MAP_READ | (bWriteAccess ? FILE_MAP_WRITE : 0));
+ pMapped = MapViewOfFile(hDup, dwAccess, 0, 0, 0);
+ CloseHandle(hDup);
+
+ if (pMapped)
+ return (char *) pMapped + sizeof(DWORD); /* Hide size */
+ return NULL;
+}
+
+#endif
/*************************************************************************
* @ [SHLWAPI.8]
*
@@ -209,6 +249,9 @@ HANDLE WINAPI SHAllocShared(LPCVOID lpvData, DWORD dwSize, DWORD
dwProcId)
*/
PVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
{
+#ifdef __REACTOS__
+ return SHLockSharedEx(hShared, dwProcId, TRUE);
+#else
HANDLE hDup;
LPVOID pMapped;
@@ -224,6 +267,7 @@ PVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
if (pMapped)
return (char *) pMapped + sizeof(DWORD); /* Hide size */
return NULL;
+#endif
}
/*************************************************************************
diff --git a/dll/win32/shlwapi/shlwapi.spec b/dll/win32/shlwapi/shlwapi.spec
index a369d974b88..1b3525c6dd3 100644
--- a/dll/win32/shlwapi/shlwapi.spec
+++ b/dll/win32/shlwapi/shlwapi.spec
@@ -5,10 +5,10 @@
5 stdcall -noname PathFindOnPathExA(str ptr long)
6 stdcall -noname PathFindOnPathExW(wstr ptr long)
7 stdcall -ordinal SHAllocShared(ptr long long)
-8 stdcall -ordinal SHLockShared(long long)
+8 stdcall -ordinal SHLockShared(ptr long)
9 stdcall -ordinal SHUnlockShared(ptr)
-10 stdcall -ordinal SHFreeShared(long long)
-11 stdcall -noname SHMapHandle(long long long long long)
+10 stdcall -ordinal SHFreeShared(ptr long)
+11 stdcall -noname SHMapHandle(ptr long long long long)
12 stdcall -noname SHCreateMemStream(ptr long)
13 stdcall -noname RegisterDefaultAcceptHeaders(ptr ptr)
14 stdcall -ordinal GetAcceptLanguagesA(ptr ptr)
@@ -507,7 +507,7 @@
507 stdcall -stub -noname SHPropertyBag_ReadDWORD(ptr ptr ptr)
508 stub -noname SHPropertyBag_WriteDWORD
509 stdcall -noname IUnknown_OnFocusChangeIS(ptr ptr long)
-510 stub -noname SHLockSharedEx
+510 stdcall -noname SHLockSharedEx(ptr long long)
511 stdcall -stub -noname PathFileExistsDefExtAndAttributesW(wstr long ptr)
512 stub -ordinal IStream_ReadPidl
513 stub -ordinal IStream_WritePidl