Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Skin Framework
  New Posts New Posts RSS Feed - Bug in OnHookLoadLibrary()
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Bug in OnHookLoadLibrary()

 Post Reply Post Reply
Author
Message
akur View Drop Down
Senior Member
Senior Member


Joined: 16 May 2006
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote akur Quote  Post ReplyReply Direct Link To This Post Topic: Bug in OnHookLoadLibrary()
    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()

Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Posted: 21 August 2012 at 12:09pm
Originally posted by akur akur wrote:

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()


Hi,

check added for next release.

Andre

Codejock support
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.125 seconds.