gpt4 book ai didi

c++ - PeekMessage() 抛出未处理的异常(访问冲突)

转载 作者:可可西里 更新时间:2023-11-01 10:50:53 27 4
gpt4 key购买 nike

大家好

在我的应用程序中,我使用以下代码:

bool HandleMessages()
{
MSG msg;

if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
return FALSE;

TranslateMessage(&msg);
DispatchMessage(&msg);
}

return true;
}

我认为这是 Windows 中消息处理的标准代码,但现在当我尝试运行该程序时,我总是在调用 PeekMessage() 时遇到异常。

异常信息是

Unhandled exception at 0x57a10eed (msvcr100d.dll) in testing.exe: 0xC0000005: access violation while reading at Position 0x6666665c.

我完全迷失在这里,不明白为什么它会抛出异常。有人有提示吗?

调用堆栈:

msvcr100d.dll!__local_unwind2() + 0x48 Bytes Asm

msvcr100d.dll!_except_handler3() + 0xed Bytes Asm

Testing.exe!_except_handler4(_EXCEPTION_RECORD * ExceptionRecord, _EXCEPTION_REGISTRATION_RECORD * EstablisherFrame, _CONTEXT * ContextRecord, void * DispatcherContext) + 0x24 Bytes C

Testing.exe!_except_handler4(_EXCEPTION_RECORD * ExceptionRecord, _EXCEPTION_REGISTRATION_RECORD * EstablisherFrame, _CONTEXT * ContextRecord, void * DispatcherContext) + 0x24 Bytes C

反汇编:

continue:

57CE0EEA lea esi,[esi+esi*2]
57CE0EED mov ecx,dword ptr [ebx+esi*4]
57CE0EF0 mov dword ptr [esp+0Ch],ecx
57CE0EF4 mov dword ptr [eax+0Ch],ecx
57CE0EF7 cmp dword ptr [ebx+esi*4+4],0
57CE0EFC jne _lu_continue (57CE0F15h)
57CE0EFE push 101h
57CE0F03 mov eax,dword ptr [ebx+esi*4+8]
57CE0F07 call _NLG_Notify (57CE0F55h)
57CE0F0C mov eax,dword ptr [ebx+esi*4+8]
57CE0F10 call _NLG_Call (57CE0F74h)

最佳答案

  • 向我们展示您的调用堆栈。如果它在 msvcr100d.dll 中崩溃,则它发生在 PeekMessage 之外(调用之前或之后)。你应该有很好的调试信息。
  • 查看 this 指针(如果适用)
  • 全部重建
  • 进入反汇编

关于c++ - PeekMessage() 抛出未处理的异常(访问冲突),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3721998/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com