关于网友提出的“ Delphi 7编译时经常出现错误 ntdldll读内存错误”问题疑问,本网通过在网上对“ Delphi 7编译时经常出现错误 ntdldll读内存错误”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: Delphi 7编译时经常出现错误 ntdldll读内存错误描述:
Access violation at address 7C94C86B in module 'ntdll.dll'.Read of address 0D8AC2B0
我用生成MAP文件的方式查找错误,但内存地址对应不上,请问如何解决,上述地址如何换算成MAP文件中对应的地址,谢谢.
解决方案1:
dll和应用程序的source文件中都引用ShareMem单元再试试,一般都是这个错误(当然,假设你dll中没有逻辑错误)
解决方案2:Delphi 7编译时经常出现错误 ntdl.dll读内存错误?如果是DELPHI7的错误,建议把DELPHI 7重启一下,这个问题除了重启无解,如果是你的程序出错,就检查一下内存,一般加ShareMem。
解决方案3:照这个错误提示的意思是,你在访问一个已经被释放了的对象。
仔细检查。
ps: AV错误就两种,一种地址全0,表示访问一个还没创建的对象。还有一种地址不全0,表示对象已经释放掉了还在访问。
这个应该很好理解的。
uses加上sharemem;
procedure PatchInt3;
var
NOP: Byte;
NTDLL: THandle;
BytesWritten: DWORD;
Address: Pointer;
begin
if Win32Platform <> VER_PLATFORM_WIN32_NT then
Exit;
NTDLL := GetModuleHandle('NTDLL.DLL');
if NTDLL = 0 then
Exit;
Address := GetProcAddress(NTDLL, 'DbgBreakPoint');
if Address = nil then
Exit;
try
if Char(Address^) <> #$CC then
Exit;
NOP := $90;
if WriteProcessMemory(GetCurrentProcess, Address, @NOP, 1, BytesWritten) and
(BytesWritten = 1) then
FlushInstructionCache(GetCurrentProcess, Address, 1);
except
// Do not panic if you see an EAccessViolation here, it is perfectly harmless!
on EAccessViolation do
;
else
raise;
end;
end;
initialization
begin
PatchInt3; //防止关闭窗口时出现CPU: ntdll.DbgBreakPoint
end;