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

时间:2010-09-15 21:32:35

标签: c++ windows

问候所有人,

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

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()调用中得到一个Exception。

异常消息是

  

0x57a10eed处的未处理异常   test.exe中的(msvcr100d.dll):   0xC0000005:访问冲突时   阅读位置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

拆卸:

  

继续

     

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推101h
  57CE0F03 mov eax,dword ptr [ebx + esi * 4 + 8]
  57CE0F07调用_NLG_Notify(57CE0F55h)
  57CE0F0C mov eax,dword ptr [ebx + esi * 4 + 8]
  57CE0F10调用_NLG_Call(57CE0F74h)

2 个答案:

答案 0 :(得分:0)

  • 告诉我们你的电话堆栈。如果它在msvcr100d.dll中崩溃,那么它发生在PeekMessage之外(在通话之前或之后)。你应该有很好的调试信息。
  • 查看this指针(如果适用)
  • 重建所有
  • 进入反汇编

答案 1 :(得分:0)

我认为您发布的callstack不足以从中发布任何内容。

您是否有机会在回复消息时调用HandleMessages()?这可能导致递归/堆栈耗尽。

相关问题