From: Dmitry Timoshkov
"Casper Hornstrup" chorns@users.sourceforge.net wrote:
I would like to have the call to the Win16 API LockResource16 removed from ole32.dll. I guess there is a reason for it being LockResource16 and not LockResource. What is the reason?
Because LoadAcceleratorsA/W returns a value allocated by GlobalAlloc16.
How can the call be removed?
Only if you or someone else can prove that under real windows LoadAcceleratorsA/W behaves differently (taking into account Win9x weirdness).
Would the attached patch be an acceptable solution? Basically it does a GetProcAddress on LockResource16 and uses it if found (Wine case). If it's not found, it uses LockResource().
Ge van Geldorp.
Index: dlls/ole32/ole2.c =================================================================== RCS file: /home/wine/wine/dlls/ole32/ole2.c,v retrieving revision 1.48 diff -u -r1.48 ole2.c --- dlls/ole32/ole2.c 8 Dec 2003 22:46:08 -0000 1.48 +++ dlls/ole32/ole2.c 23 Jan 2004 14:17:06 -0000 @@ -1422,9 +1422,34 @@ /* YES, Accel16! */ LPACCEL16 lpAccelTbl; int i; + HMODULE Kernel32; + LPVOID (WINAPI *LockResource16Ptr)(HGLOBAL16 ResData);
if(!lpMsg) return FALSE; - if (!hAccel || !(lpAccelTbl = (LPACCEL16)LockResource16(HACCEL_16(hAccel)))) + if (!hAccel) + { + WARN_(accel)("NULL accel handle\n"); + return FALSE; + } + Kernel32 = GetModuleHandleA("kernel32.dll"); + if (NULL != Kernel32) + { + LockResource16Ptr = (LPVOID (WINAPI *)(HGLOBAL16)) + GetProcAddress(Kernel32, "LockResource16"); + } + else + { + LockResource16Ptr = NULL; + } + if (NULL != LockResource16Ptr) + { + lpAccelTbl = (LPACCEL16) LockResource16Ptr(HACCEL_16(hAccel)); + } + else + { + lpAccelTbl = (LPACCEL16) LockResource(hAccel); + } + if (NULL == lpAccelTbl) { WARN_(accel)("invalid accel handle=%p\n", hAccel); return FALSE;