当前位置: 首页 > news >正文

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

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的好。

相关文章:

  • 《重构:改善既有代码的设计》—第2章2.7节重构与性能
  • 【C/C++】知识点
  • SWIFT中获取配置文件路径的方法
  • 《Arduino实战》——1.8 小结
  • hdu 4035 可能性DP 成都网络游戏
  • 如何用Nagios远程执行插件(NRPE)来检测服务器内存使用率
  • Android-往来:添加到联系人
  • 《嵌入式Linux软硬件开发详解——基于S5PV210处理器》——1.1 硬件系统资源
  • ajaxFileUpload plugin上传文件 chrome、Firefox中出现SyntaxError:unexpected token
  • 《C++编程风格(修订版)》——2.6 动态内存的回收
  • wp-query调用前几篇文章的方法
  • 《思科UCS服务器统一计算》一1.3 统一计算系统(UCS)
  • 从平凡通往伟大——大数据技术学习
  • 《UML面向对象设计基础》—第1章1.7节继承
  • 启动页广告
  • 《Javascript高级程序设计 (第三版)》第五章 引用类型
  • 《微软的软件测试之道》成书始末、出版宣告、补充致谢名单及相关信息
  • 「译」Node.js Streams 基础
  • 【MySQL经典案例分析】 Waiting for table metadata lock
  • 002-读书笔记-JavaScript高级程序设计 在HTML中使用JavaScript
  • 78. Subsets
  • 8年软件测试工程师感悟——写给还在迷茫中的朋友
  • canvas实际项目操作,包含:线条,圆形,扇形,图片绘制,图片圆角遮罩,矩形,弧形文字...
  • golang中接口赋值与方法集
  • iOS小技巧之UIImagePickerController实现头像选择
  • Octave 入门
  • PHP CLI应用的调试原理
  • React系列之 Redux 架构模式
  • Vue UI框架库开发介绍
  • 从0实现一个tiny react(三)生命周期
  • 从零到一:用Phaser.js写意地开发小游戏(Chapter 3 - 加载游戏资源)
  • 翻译--Thinking in React
  • 腾讯大梁:DevOps最后一棒,有效构建海量运营的持续反馈能力
  • 微信小程序开发问题汇总
  • 用element的upload组件实现多图片上传和压缩
  • 如何通过报表单元格右键控制报表跳转到不同链接地址 ...
  • ## 临床数据 两两比较 加显著性boxplot加显著性
  • #NOIP 2014# day.2 T2 寻找道路
  • #单片机(TB6600驱动42步进电机)
  • #我与Java虚拟机的故事#连载05:Java虚拟机的修炼之道
  • (¥1011)-(一千零一拾一元整)输出
  • (C语言)二分查找 超详细
  • (简单有案例)前端实现主题切换、动态换肤的两种简单方式
  • (牛客腾讯思维编程题)编码编码分组打印下标(java 版本+ C版本)
  • (一)pytest自动化测试框架之生成测试报告(mac系统)
  • (转) 深度模型优化性能 调参
  • *p=a是把a的值赋给p,p=a是把a的地址赋给p。
  • .Net Core缓存组件(MemoryCache)源码解析
  • .net 程序发生了一个不可捕获的异常
  • .NET下ASPX编程的几个小问题
  • .net项目IIS、VS 附加进程调试
  • .sdf和.msp文件读取
  • /*在DataTable中更新、删除数据*/
  • /var/spool/postfix/maildrop 下有大量文件
  • ;号自动换行