Print Page | Close Window

CXTPCommandBarsFrameHook causing aborts

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=24587
Printed Date: 02 August 2025 at 11:36pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPCommandBarsFrameHook causing aborts
Posted By: rdhd
Subject: CXTPCommandBarsFrameHook causing aborts
Date Posted: 01 August 2025 at 1:32pm
Our app is crashing in a specific workflow because CXTPCommandBarsFrameHook:RedrawRibbonBar is being called after CXTPCommandBarsFrameHook::~CXTPCommandBarsFrameHook has been called.

The workflow is as follows. We are an MDI app and we call EnableFrameTheme on the CXTPRibbonBar. The ribbon bar pointer is stored in CXTPCommandBarsFrameHook.

The user modifies a document. Then the user right clicks the app icon in the Windows App Bar and clicks the Close entry the OS shows. The user is prompted to save the file and clicks "No". The app starts to shut  down.

CXTPCommandBarsFrameHook::GetAutoHideBar gets called. SHAppBarMessage is called and that eventually leads to the CXTPCommandBarsFrameHook destructor. 

This leads to a crash, for example, in RedrawFrame because GetFramePaintManager() call returns a null pointer. 

>    ToolkitPro2410vc170x64U.dll!CXTPCommandBarsFrameHook::RedrawFrame() Line 642    C++
     ToolkitPro2410vc170x64U.dll!CXTPCommandBarsFrameHook::OnHookMessage(HWND__ * hWnd, unsigned int nMessage, unsigned __int64 & wParam, __int64 & lParam, __int64 & lResult) Line 1285    C++
     ToolkitPro2410vc170x64U.dll!CXTPHookManager::CHookSink::OnHookMessage(HWND__ * hWnd, unsigned int nMessage, unsigned __int64 & wParam, __int64 & lParam, __int64 & lResult) Line 322    C++
     ToolkitPro2410vc170x64U.dll!CXTPHookManager::HookWndProc(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 443    C++
     user32.dll!UserCallWinProcCheckWow(struct _ACTIVATION_CONTEXT *,__int64 (*)(struct tagWND *,unsigned int,unsigned __int64,__int64),struct HWND__ *,enum _WM_VALUE,unsigned __int64,__int64,void *,int)    Unknown
     user32.dll!DispatchClientMessage()    Unknown
     user32.dll!__fnDWORD()    Unknown
     ntdll.dll!KiUserCallbackDispatcherContinue()    Unknown
     win32u.dll!NtUserMessageCall()    Unknown
     user32.dll!SendMessageWorker()    Unknown
     user32.dll!SendMessageW()    Unknown
     [Inline Frame] mfc140u.dll!CWnd::SendMessageW(unsigned int) Line 32    C++
     mfc140u.dll!CFrameWnd::NotifyFloatingWindows(unsigned long dwFlags) Line 570    C++
     mfc140u.dll!CFrameWnd::OnActivate(unsigned int nState, CWnd * pWndOther, int bMinimized) Line 1082    C++

In debug the crash can occur elsewhere as m_pRibbonbar is accessed in RedrawRibbonBar because it is not null (it is 0xdddddddddddddddd - debug poison pill). In that case CXTPCommandBarsFrameHook::GetAutoHideBar is still on the stack.


Fortunately, I can duplicate this with the MFC\Xtreme ToolkitPro  24.1.0\Samples\CommandBars\CommandBarsSample

Just run the sample and in the MDI window type some text. Then right click the icon in the app/task bar and choose close. Then just say No when prompted to save the file.

I am trying to build that sample using Dynamic Unicode Release but I get a build failure due to a "missing file", which of course the IDE knows the name of but as is typical of Microsoft programming the IDE is keeping the name of said file to itself. 

Here is the call stack for that sample built with static unicode release (I turned on debug info).

>    CommandBarsSample.exe!CXTPCommandBarsFrameHook::RedrawFrame() Line 642    C++
     CommandBarsSample.exe!CXTPCommandBarsFrameHook::OnHookMessage(HWND__ * hWnd, unsigned int nMessage, unsigned __int64 & wParam, __int64 & lParam, __int64 & lResult) Line 1285    C++
     CommandBarsSample.exe!CXTPHookManager::CHookSink::OnHookMessage(HWND__ * hWnd, unsigned int nMessage, unsigned __int64 & wParam, __int64 & lParam, __int64 & lResult) Line 322    C++
     CommandBarsSample.exe!CXTPHookManager::HookWndProc(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 443    C++
     user32.dll!UserCallWinProcCheckWow(struct _ACTIVATION_CONTEXT *,__int64 (*)(struct tagWND *,unsigned int,unsigned __int64,__int64),struct HWND__ *,enum _WM_VALUE,unsigned __int64,__int64,void *,int)    Unknown
     user32.dll!DispatchClientMessage()    Unknown
     user32.dll!__fnDWORD()    Unknown
     ntdll.dll!KiUserCallbackDispatcherContinue()    Unknown
     win32u.dll!NtUserGetMessage()    Unknown
     user32.dll!GetMessageW()    Unknown
     CommandBarsSample.exe!AfxInternalPumpMessage() Line 153    C++
     CommandBarsSample.exe!CWinThread::Run() Line 629    C++
     CommandBarsSample.exe!AfxWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 61    C++
     [Inline Frame] CommandBarsSample.exe!invoke_main() Line 118    C++
     CommandBarsSample.exe!__scrt_common_main_seh() Line 288    C++
     kernel32.dll!BaseThreadInitThunk()    Unknown
     ntdll.dll!RtlUserThreadStart()    Unknown

I really need a fix for this, both in debug and release.



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