![]() |
Bug in OnHookLoadLibrary() |
Post Reply ![]() |
Author | |
akur ![]() Senior Member ![]() Joined: 16 May 2006 Status: Offline Points: 139 |
![]() ![]() ![]() ![]() ![]() Posted: 21 August 2012 at 1:52am |
We just found out that CXTPSkinManagerApiHook's methods for hooking LoadLibrary() can accidentally change the GetLastError() value returned by system. To overcome some problems this caused to our application, we needed to fix XTP code like this: HMODULE WINAPI CXTPSkinManagerApiHook::OnHookLoadLibraryW(PCWSTR pszModuleName) { typedef HMODULE (WINAPI* LPFNLOADLIBRARYW)(PCWSTR pszModuleName); PROC pfnOrig = GetOriginalProc(xtpSkinApiLoadLibraryW); if (!pfnOrig) return ::LoadLibraryW(pszModuleName); HMODULE hmod = ((LPFNLOADLIBRARYW)pfnOrig)(pszModuleName); // Added test for hmod: the fn. HackModuleOnLoad() can be called only when // hmod is not-NULL, it means the module (some dll) was successfully loaded. // Otherwise the global 'last error value' could be changed. if (hmod) GetInstance()->HackModuleOnLoad(hmod, 0); return hmod; } Can you please add this fix to your future releases, on all code places where relevant? Thank you. It's the same case at least with the following functions: CXTPSkinManagerApiHook::OnHookLoadLibraryA() CXTPSkinManagerApiHook::OnHookLoadLibraryW() CXTPSkinManagerApiHook::OnHookLoadLibraryExA() CXTPSkinManagerApiHook::OnHookLoadLibraryExW() CXTPSkinManagerApiHook::OnHookLoadLibraryEx2W() |
|
![]() |
|
ABuenger ![]() Newbie ![]() ![]() Joined: 02 February 2006 Status: Offline Points: 1075 |
![]() ![]() ![]() ![]() ![]() |
Hi, check added for next release. Andre |
|
Codejock support
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |