Print Page | Close Window

Bug in OnHookLoadLibrary()

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Skin Framework
Forum Description: Topics Related to Codejock Skin Framework
URL: http://forum.codejock.com/forum_posts.asp?TID=20071
Printed Date: 24 November 2024 at 7:13am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Bug in OnHookLoadLibrary()
Posted By: akur
Subject: Bug in OnHookLoadLibrary()
Date 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()




Replies:
Posted By: ABuenger
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net