• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

问题-Delphi编译到最后Linking时总是出现与ntdll.dll有关的错误还有FatalErrorOutofme ...

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
1.跳出错误法  ===================================================
在主界面的implementation  {$R *.dfm} 下放入以下代码:
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;
然后在窗体的Create中调用 PatchInt3 ;或者在窗体代码的最后一个end.前加入一下代码即可以解决
//-------------------------------------------------------------- i
initialization
begin
PatchInt3; //防止关闭窗口时出现CPU: ntdll.DbgBreakPoint
end;
2.DELPHI 7控件漏洞法=====================================================
文件名:D7ComboBoxStringsGetPatch.pas
原代码:
unit D7ComboBoxStringsGetPatch;
 
// The patch fixes TCustomComboBoxStrings.Get method for empty string item in Delphi 7.
 
interface
 
{$IF RTLVersion <> 15.0}
'This patch is intended for Delphi 7 only';
{$IFEND}
 
implementation
 
uses
  Windows, SysUtils, StdCtrls;
 
resourcestring
  RsPatchingFailed = 'TCustomComboBoxStrings.Get patching failed.';
 
type
  TPatchResult = (prNotNeeded, prOk, prError);
 
function PatchCode(RoutineStartAddr: Pointer; PatchOffset: Cardinal; OriginalCode: Pointer;
  OriginalCodeLen: Cardinal; PatchedCode: Pointer; PatchedCodeLen: Cardinal): TPatchResult;
const
  JmpOpCode = $25FF;
type
  PPackageThunk = ^TPackageThunk;
  TPackageThunk = packed record
    JmpInstruction: Word;
    JmpAddress: PPointer;
  end;
var
  CodeStart: Pointer;
  BytesWritten: DWORD;
begin
  if FindClassHInstance(System.TObject) <> HInstance then
    with PPackageThunk(RoutineStartAddr)^ do
      if JmpInstruction = JmpOpCode then
        RoutineStartAddr := JmpAddress^
      else
      begin
        Result := prError;
        Exit;
      end;
  CodeStart := Pointer(LongWord(RoutineStartAddr) + PatchOffset);
  if CompareMem(CodeStart, OriginalCode, OriginalCodeLen) then
  begin
    if WriteProcessMemory(GetCurrentProcess, CodeStart, PatchedCode, PatchedCodeLen, BytesWritten) and
      (BytesWritten = PatchedCodeLen) then
    begin
      FlushInstructionCache(GetCurrentProcess, CodeStart, PatchedCodeLen);
      Result := prOk;
    end
    else
      Result := prError;
  end
  else
    Result := prNotNeeded;
end;
 
type
  TCustomComboBoxStringsHack = class(TCustomComboBoxStrings);
 
function AddrOfTCustomComboBoxStringsGet: Pointer;
begin
  Result := @TCustomComboBoxStringsHack.Get;
end;
 
procedure PatchTCustomComboBoxStringsGet;
const
  OriginalCode: Cardinal  = $74FFF883; // CMP EAX, -1 | JZ  +$26
  PatchedCode: Cardinal   = $7E00F883; // CMP EAX,  0 | JLE +$26
  PatchOffset             = $1F;
  // for DEBUG DCU by Pavel Rogulin
  OriginalCodeD: Cardinal = $FFF07D83;
  PatchedCodeD: Cardinal  = $00F07D83;
  PatchOffsetD            = $2E;
var
  PatchResult: TPatchResult;
begin
  PatchResult := PatchCode(AddrOfTCustomComboBoxStringsGet, PatchOffset, @OriginalCode, SizeOf(OriginalCode),
    @PatchedCode, SizeOf(PatchedCode));
  if PatchResult = prNotNeeded then
    PatchResult := PatchCode(AddrOfTCustomComboBoxStringsGet, PatchOffsetD, @OriginalCodeD, SizeOf(OriginalCodeD),
      @PatchedCodeD, SizeOf(PatchedCodeD));
  case PatchResult of
    prError:
      begin
        if IsConsole then
          WriteLn(ErrOutput, RsPatchingFailed)
        else
          MessageBox(0, PChar(RsPatchingFailed), nil, MB_OK or MB_ICONSTOP or MB_TASKMODAL);
        RunError(1);
      end;
  end;
end;
 
initialization
  PatchTCustomComboBoxStringsGet;
 
end.
3.内存处理法(这个也是我单位出现的问题)========================== 
方法:
将XE2的borlndmm.dll,rlink32.dll二个文件给复制到D:\delphi\Borland\Delphi7\Bin 中。
原因:
说是因为DLPHI7的内存管理没有XE2的好。

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
DELPHI用户登录窗口框架发布时间:2022-07-18
下一篇:
【MATLAB深度学习】神经网络与分类问题发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap