64位MFC版本访问冲突异常 [英] Access violation exception in 64bit MFC version
问题描述
我正在尝试将 32 位应用程序移植到 64 位.计算似乎运行正确,但我无法正确配置视图.我在 W7 x64 机器上的 VS2005 中使用 MFC、C++ 和 OpenGL、Intel 10.0.027 编译器.
I am trying to port a 32bit application to 64 bit. The calculations appear to run correctly, but I cannot configure the views properly. I am using MFC, C++ and OpenGL, Intel 10.0.027 compiler inside VS2005 on a W7 x64 machine.
发生崩溃时,我收到以下消息:3DApp.exe 中 0xffffffff8043b1b6 处的第一次机会异常:0xC0000005:位置 0xffffffff8043b1b6 处的访问冲突",这是堆栈跟踪:
When the crash happens, I get the following message: "First-chance exception at 0xffffffff8043b1b6 in 3DApp.exe: 0xC0000005: Access violation at location 0xffffffff8043b1b6" and this is the stack trace:
ffffffff8043b1b6()
user32.dll!UserCallWinProcCheckWow() + 0x11d bytes
user32.dll!DispatchMessageWorker() + 0x12a bytes
3DApp.exe!AfxInternalPumpMessage() Line 183 C++
3DApp.exe!CWinThread::PumpMessage() Line 896 C++
3DApp.exe!CWinThread::Run() Line 625 + 0x13 bytes C++
请注意为什么调用UserCallWinProcCheckWow,我以为Wow后缀只是用于在64位计算机上模拟32位应用程序
NOTE PLEASE why is UserCallWinProcCheckWow called, I thought Wow suffix was only for emulating 32 bit applications on 64 bit computer
显然,64 位指针在某处被视为 32 位指针,但我无法指出发生这种情况的地方.我从微软加载了调试符号,它显示了调用堆栈的顶部.
Obviously, somewhere a 64 bit pointer gets treated as a 32 bit pointer, but I cannot pin point where that happens. I loaded debug symbols from microsoft, which show the top of the call stack.
非常感谢任何帮助.莱昂
Any help greatly appreciated. Leon
编辑
调用 DispatchMessage 的代码是:
The code calling DispatchMessage is:
if (pState->m_msgCur.message != WM_KICKIDLE && !AfxPreTranslateMessage(&(pState->m_msgCur)))
{
::TranslateMessage(&(pState->m_msgCur));
::DispatchMessage(&(pState->m_msgCur));
}
pState 的指针在这个阶段看起来是 64 位的.
The pointers of pState appear to be 64 bit at this stage.
pState->m_msgCu 的状态:
State of pState->m_msgCu:
- pState->m_msgCur {msg=0x00000022 wp=0x0000000000000000 lp=0x0000000000000000} tagMSG
- hwnd 0x0000000000020416 {unused=0x00000000 } HWND__ *消息 0x00000022 无符号整数wParam 0x0000000000000000 无符号 __int64lParam 0x0000000000000000 __int64时间 0x000f3967 无符号长
- pt {x=0x0000030f y=0x00000356} tagPOINT
推荐答案
我刚刚修复了一个具有相同行为的问题.错误在于将参数传递给 SetWindowLongPtr(GWLP_WNDPROC),指向 WndProc 的指针被错误地转换为 LONG 而不是正确的 LONG_PTR.通过这种方式,指向 WndProc 的错误指针被放入内部操作系统 WND 结构中,因此对 HWND 的 WndProc 的任何后续调用都崩溃了.
I have just fixed an issue with the same behavior. The bug was in passing parameters to SetWindowLongPtr( GWLP_WNDPROC ), pointer to WndProc was improperly casted to LONG instead of correct LONG_PTR. This way, bad pointer to WndProc was put into internal OS WND struct, so any following call to the HWND's WndProc crashed.
这篇关于64位MFC版本访问冲突异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!