Commit in reactos/lib/shell32 on MAIN
shellord.c+42-481.6 -> 1.7
shell32.spec+4-41.8 -> 1.9
+46-52
2 modified files
Francois Gouget <fgouget@free.fr>
- Don't export the shell32 SHAllocShared functions by name.
  Implement them by calling out their shlwapi equivalent (which had a
  much more complete implementation anyway).
- Fix the prototype of shlwapi's SHAllocShared().
- Don't crash if lpvData is NULL in SHAllocShared().
- Add a conformance test to shlwapi.

reactos/lib/shell32
shellord.c 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- shellord.c	19 Sep 2004 22:02:28 -0000	1.6
+++ shellord.c	20 Sep 2004 18:29:10 -0000	1.7
@@ -69,6 +69,25 @@
 extern INT    WINAPI FindMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
 extern INT    WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
 
+
+/* Get a function pointer from a DLL handle */
+#define GET_FUNC(func, module, name, fail) \
+  do { \
+    if (!func) { \
+      if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \
+      func = (void*)GetProcAddress(SHELL32_h##module, name); \
+      if (!func) return fail; \
+    } \
+  } while (0)
+
+/* Function pointers for GET_FUNC macro */
+static HMODULE SHELL32_hshlwapi=NULL;
+static HANDLE (WINAPI *pSHAllocShared)(LPCVOID,DWORD,DWORD);
+static LPVOID (WINAPI *pSHLockShared)(HANDLE,DWORD);
+static BOOL   (WINAPI *pSHUnlockShared)(LPVOID);
+static BOOL   (WINAPI *pSHFreeShared)(HANDLE,DWORD);
+
+
 /*************************************************************************
  * ParseFieldA					[internal]
  *
@@ -1192,70 +1211,45 @@
 /*************************************************************************
  * SHAllocShared				[SHELL32.520]
  *
- * NOTES
- *  parameter1 is return value from HeapAlloc
- *  parameter2 is equal to the size allocated with HeapAlloc
- *  parameter3 is return value from GetCurrentProcessId
- *
- *  the return value is posted as lParam with 0x402 (WM_USER+2) to somewhere
- *  WM_USER+2 could be the undocumented CWM_SETPATH
- *  the allocated memory contains a pidl
- */
-HGLOBAL WINAPI SHAllocShared(LPVOID psrc, DWORD size, DWORD procID)
-{	HGLOBAL hmem;
-	LPVOID pmem;
-
-	TRACE("ptr=%p size=0x%04lx procID=0x%04lx\n",psrc,size,procID);
-	hmem = GlobalAlloc(GMEM_FIXED, size);
-	if (!hmem)
-	  return 0;
-
-	pmem =  GlobalLock (hmem);
-
-	if (! pmem)
-	  return 0;
-
-	memcpy (pmem, psrc, size);
-	GlobalUnlock(hmem);
-	return hmem;
+ * See shlwapi.SHAllocShared
+ */
+HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId)
+{
+    GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL);
+    return pSHAllocShared(lpvData, dwSize, dwProcId);
 }
+
 /*************************************************************************
  * SHLockShared					[SHELL32.521]
  *
- * NOTES
- *  parameter1 is return value from SHAllocShared
- *  parameter2 is return value from GetCurrentProcessId
- *  the receiver of (WM_USER+2) tries to lock the HANDLE (?)
- *  the return value seems to be a memory address
- */
-LPVOID WINAPI SHLockShared(HANDLE hmem, DWORD procID)
-{	TRACE("handle=%p procID=0x%04lx\n",hmem,procID);
-	return GlobalLock(hmem);
+ * See shlwapi.SHLockShared
+ */
+LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
+{
+    GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL);
+    return pSHLockShared(hShared, dwProcId);
 }
+
 /*************************************************************************
  * SHUnlockShared				[SHELL32.522]
  *
- * NOTES
- *  parameter1 is return value from SHLockShared
+ * See shlwapi.SHUnlockShared
  */
-BOOL WINAPI SHUnlockShared(LPVOID pv)
+BOOL WINAPI SHUnlockShared(LPVOID lpView)
 {
-	TRACE("%p\n",pv);
-	return GlobalUnlock((HANDLE)pv);
+    GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE);
+    return pSHUnlockShared(lpView);
 }
+
 /*************************************************************************
  * SHFreeShared					[SHELL32.523]
  *
- * NOTES
- *  parameter1 is return value from SHAllocShared
- *  parameter2 is return value from GetCurrentProcessId
+ * See shlwapi.SHFreeShared
  */
-BOOL WINAPI SHFreeShared(
-	HANDLE hMem,
-	DWORD pid)
+BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
 {
-	TRACE("handle=%p 0x%04lx\n",hMem,pid);
-	return (BOOL)GlobalFree(hMem);
+    GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE);
+    return pSHFreeShared(hShared, dwProcId);
 }
 
 /*************************************************************************

reactos/lib/shell32
shell32.spec 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- shell32.spec	20 Jun 2004 10:39:21 -0000	1.8
+++ shell32.spec	20 Sep 2004 18:29:10 -0000	1.9
@@ -278,10 +278,10 @@
  511 stdcall SHRegQueryValueExW (long wstr ptr ptr ptr ptr)
  512 stdcall SHRegDeleteKeyW (long wstr)
 
- 520 stdcall SHAllocShared (long long long)
- 521 stdcall SHLockShared (long long)
- 522 stdcall SHUnlockShared (long)
- 523 stdcall SHFreeShared (long long)
+ 520 stdcall -noname SHAllocShared (long long long)
+ 521 stdcall -noname SHLockShared (long long)
+ 522 stdcall -noname SHUnlockShared (long)
+ 523 stdcall -noname SHFreeShared (long long)
  524 stub RealDriveType
  525 stub RealDriveTypeFlags
 
CVSspam 0.2.8