`
eueuy
  • 浏览: 70550 次
  • 性别: Icon_minigender_1
  • 来自: 天津
最近访客 更多访客>>
社区版块
存档分类
最新评论

利用MPHexEditorEx控件实现2进制替换

 
阅读更多
窗体上放MPHexEditorEx控件
用以下函数替换EXE文件字符
设置MPHexEditorEx的CrateBackup为False;
 
 
function TFormMain.ReplacePass(Filename,Find, Replace: string): boolean;
var
  LIntSize,
  LIntPos,
  LIntPos2: Integer;
 
  strdata,
  LStrFind,
  LStrReplace: string;
 
begin
//result:=false;
mphexeditorex1.LoadFromFile(filename);   //exe file name
strdata:=find ;         // want to find string
LstrReplace:=replace ;     // want to replace string
LIntPos := 0  ;
with mphexeditorex1 do
begin
   LStrFind := PrepareFindReplaceData(StrData, false, true);
   LIntPos2 := Find(pchar(LStrFind), Length(LStrFind), LIntPos, DataSize -1,false);
   SelStart := LIntPos2;
   SelEnd := LIntPos2 + Length(LStrFind)-1;
   if LStrReplace <> '' then ReplaceSelection(PChar(LStrReplace), Length(LStrReplace), '', False);
   mphexeditorex1.SaveToFile(filename);
end;
result:=true
end;
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics