[英]PeekMessage() throws an unhandled exception (access violation)
大家問候,
在我的應用程序中,我使用以下代碼:
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()調用中獲得異常。
異常消息是
testing.exe中0x57a10eed(msvcr100d.dll)處未處理的異常:0xC0000005:在位置0x6666665c讀取時訪問沖突。
我在這里完全迷失了,看不到為什么會拋出異常。 有人提示嗎?
調用堆棧:
msvcr100d.dll!__ local_unwind2()+ 0x48字節的Asm
msvcr100d.dll!_except_handler3()+ 0xed字節匯編
Testing.exe!_except_handler4(_EXCEPTION_RECORD * ExceptionRecord,_EXCEPTION_REGISTRATION_RECORD * FounderFrame,_CONTEXT * ContextRecord,void * DispatcherContext)+ 0x24字節C
Testing.exe!_except_handler4(_EXCEPTION_RECORD * ExceptionRecord,_EXCEPTION_REGISTRATION_RECORD * FounderFrame,_CONTEXT * ContextRecord,void * DispatcherContext)+ 0x24字節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)
msvcr100d.dll
崩潰,則發生在PeekMessage
之外(調用之前或之后)。 您應該對此具有良好的調試信息。 this
指針(如果適用) 我認為您發布的調用棧不足以使它產生任何效果。
您是否有可能會響應消息而調用HandleMessages()? 這可能導致遞歸/堆棧耗盡。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.