mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
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. svn path=/trunk/; revision=10944
This commit is contained in:
parent
cccdc00157
commit
6382d705ab
2 changed files with 44 additions and 50 deletions
|
@ -278,10 +278,10 @@
|
||||||
511 stdcall SHRegQueryValueExW (long wstr ptr ptr ptr ptr)
|
511 stdcall SHRegQueryValueExW (long wstr ptr ptr ptr ptr)
|
||||||
512 stdcall SHRegDeleteKeyW (long wstr)
|
512 stdcall SHRegDeleteKeyW (long wstr)
|
||||||
|
|
||||||
520 stdcall SHAllocShared (long long long)
|
520 stdcall -noname SHAllocShared (long long long)
|
||||||
521 stdcall SHLockShared (long long)
|
521 stdcall -noname SHLockShared (long long)
|
||||||
522 stdcall SHUnlockShared (long)
|
522 stdcall -noname SHUnlockShared (long)
|
||||||
523 stdcall SHFreeShared (long long)
|
523 stdcall -noname SHFreeShared (long long)
|
||||||
524 stub RealDriveType
|
524 stub RealDriveType
|
||||||
525 stub RealDriveTypeFlags
|
525 stub RealDriveTypeFlags
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,25 @@ extern INT WINAPI AddMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData);
|
||||||
extern INT WINAPI FindMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
|
extern INT WINAPI FindMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
|
||||||
extern INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
|
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]
|
* ParseFieldA [internal]
|
||||||
*
|
*
|
||||||
|
@ -1192,70 +1211,45 @@ HRESULT WINAPI IsUserAdmin(void)
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* SHAllocShared [SHELL32.520]
|
* SHAllocShared [SHELL32.520]
|
||||||
*
|
*
|
||||||
* NOTES
|
* See shlwapi.SHAllocShared
|
||||||
* 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)
|
HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId)
|
||||||
{ HGLOBAL hmem;
|
{
|
||||||
LPVOID pmem;
|
GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL);
|
||||||
|
return pSHAllocShared(lpvData, dwSize, dwProcId);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* SHLockShared [SHELL32.521]
|
* SHLockShared [SHELL32.521]
|
||||||
*
|
*
|
||||||
* NOTES
|
* See shlwapi.SHLockShared
|
||||||
* 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)
|
LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
|
||||||
{ TRACE("handle=%p procID=0x%04lx\n",hmem,procID);
|
{
|
||||||
return GlobalLock(hmem);
|
GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL);
|
||||||
|
return pSHLockShared(hShared, dwProcId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* SHUnlockShared [SHELL32.522]
|
* SHUnlockShared [SHELL32.522]
|
||||||
*
|
*
|
||||||
* NOTES
|
* See shlwapi.SHUnlockShared
|
||||||
* parameter1 is return value from SHLockShared
|
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI SHUnlockShared(LPVOID pv)
|
BOOL WINAPI SHUnlockShared(LPVOID lpView)
|
||||||
{
|
{
|
||||||
TRACE("%p\n",pv);
|
GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE);
|
||||||
return GlobalUnlock((HANDLE)pv);
|
return pSHUnlockShared(lpView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* SHFreeShared [SHELL32.523]
|
* SHFreeShared [SHELL32.523]
|
||||||
*
|
*
|
||||||
* NOTES
|
* See shlwapi.SHFreeShared
|
||||||
* parameter1 is return value from SHAllocShared
|
|
||||||
* parameter2 is return value from GetCurrentProcessId
|
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI SHFreeShared(
|
BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
|
||||||
HANDLE hMem,
|
|
||||||
DWORD pid)
|
|
||||||
{
|
{
|
||||||
TRACE("handle=%p 0x%04lx\n",hMem,pid);
|
GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE);
|
||||||
return (BOOL)GlobalFree(hMem);
|
return pSHFreeShared(hShared, dwProcId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|
Loading…
Reference in a new issue