CString中的内存访问冲突

时间:2013-10-22 17:23:16

标签: c++ crash windbg access-violation

我正在使用一个解析某些二进制文件的Windows应用程序。每次在某个位置,应用程序都会崩溃(读取访问冲突)。

我试图找出崩溃的根本原因。

(f74.fac): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=02b74141 ebx=00000000 ecx=02760000 edx=00414141 esi=00000000 edi=01426fe4
eip=7c91081e esp=0012eb64 ebp=0012eb8c iopl=0         nv up ei ng nz na pe cy
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00010287
ntdll!RtlpImageNtHeader+0x35:
7c91081e 813850450000    cmp     dword ptr [eax],4550h ds:0023:02b74141=????????

在Crash Point:

0:000> u eip
ntdll!RtlpImageNtHeader+0x35:
7c91081e 813850450000    cmp     dword ptr [eax],4550h
7c910824 0f858b830200    jne     ntdll!RtlpImageNtHeader+0x3d (7c938bb5)
7c91082a 834dfcff        or      dword ptr [ebp-4],0FFFFFFFFh
7c91082e e8cfe5ffff      call    ntdll!_SEH_epilog (7c90ee02)
7c910833 c20400          ret     4
7c910836 90              nop
7c910837 90              nop
7c910838 ff              ???

堆栈追踪:

0:000> kb
ChildEBP RetAddr  Args to Child              
0012eb8c 7c91708f 02760000 00000216 0012f3d0 ntdll!RtlpImageNtHeader+0x35
0012ee40 7c916042 02734da8 0012eeb8 00000000 ntdll!LdrpCheckForLoadedDll+0x4cd
0012f0fc 7c9162da 00000000 02734da8 0012f3f0 ntdll!LdrpLoadDll+0x1ba
0012f3a4 7c801bb9 02734da8 0012f3f0 0012f3d0 ntdll!LdrLoadDll+0x230
0012f40c 7c801d6e 7ffdec00 00000000 00000001 kernel32!LoadLibraryExW+0x18e
*** WARNING: Unable to verify checksum for image00400000
*** ERROR: Module load completed but symbols could not be loaded for image00400000
0012f420 00407b8c 017f3ed8 00000000 00000001 kernel32!LoadLibraryExA+0x1f
WARNING: Stack unwind information not available. Following frames may be wrong.
0012f4a4 7c80c710 73eae590 0012f49c 0012f558 image00400000+0x7b8c
0012f4c8 73dd4381 017f3ed8 017f3db8 00000047 kernel32!lstrlenA+0x3b
0012f528 73dd2263 0012f628 00000000 0012f4f0 MFC42!CString::CString+0x47
0012f538 73dd2725 017ef0ac 0012f628 00407846 MFC42!CFixedAlloc::Free+0x28
0012f544 00407846 0012f628 00000000 017ef158 MFC42!CString::~CString+0x1c
00000000 00000000 00000000 00000000 00000000 image00400000+0x7846

不确定,但我猜它是一个与堆相关的问题,因为CString使用堆分配。 所以请说明这次崩溃的可能原因。 如果需要更多信息,请告诉我。

先谢谢,

1 个答案:

答案 0 :(得分:0)

解析二进制文件没有有效的MZ / PE标头。 ecx=02760000中的二进制基数有效,edx=00414141必须是以字节为单位的IMAGE_NT_HEADERS结构的偏移,而不是414141'AAA'。您可以使用dd 02760000+3c L1命令查看00414141。 RtlpImageNtHeader向您添加414141 Base,这是PE签名。显示!address 02760000!dh 02760000!address 02b74141的输出我可能会认为02b74141根本没有映射。