if hFile=INVALID_HANDLE_VALUE then
begin
Messagebox(Handle, '要修补的升级程序文件不存在或访问被拒绝!', '错误', MB_OK + MB_ICONSTOP);
CloseHandle(hFile);
exit;
end;
CloseHandle(hFile);
if GetFileSize(fname1)<>2788352 then
begin
Messagebox(Handle, '要修补的主程序文件大小不正确,无法进行修补!', '错误', MB_OK + MB_ICONSTOP);
exit;
end;
if GetFileSize(fname2)<>176128 then
begin
Messagebox(Handle, '要修补的升级程序文件大小不正确,无法进行修补!', '错误', MB_OK + MB_ICONSTOP);
exit;
end;
if CheckBox1.Checked then
begin
CopyFile(PChar(fname1),PChar(fname1+'.bak'),false);
CopyFile(PChar(fname2),PChar(fname2+'.bak'),false);
end;
//修补主文件
LblMsg.Visible :=True;
ProgressBar1.Position :=0;
ProgressBar1.Max :=100;
try
LblMsg.Caption :='开始修补主程序文件...';
FHandle :=FileOpen(fname1,fmOpenReadWrite);
if FHandle<>0 then
begin
FileSeek(FHandle,$000028BB, 0);
ProgressBar1.Position :=25;
FileWrite(FHandle,MainPFW[0],sizeof(MainPFW[0])*5);
FileClose(FHandle);
end;
LblMsg.Caption :='主程序文件修补结束...';
ProgressBar1.Position :=50;
//修补升级程序文件
LblMsg.Caption :='开始修补升级程序文件...';
FHandle :=FileOpen(fname2,fmOpenReadWrite);
if FHandle<>0 then
begin
FileSeek(FHandle,$00005502, 0);
ProgressBar1.Position :=75;
FileWrite(FHandle,PFWLiveUpdate[0],sizeof(PFWLiveUpdate[0])*11);
FileClose(FHandle);
end;
LblMsg.Caption :='升级程序文件修补结束...';
ProgressBar1.Position :=100;
LblMsg.Visible :=False;
Messagebox(Handle, '修补结束!', '提示', MB_OK + MB_ICONINFORMATION);
except
Messagebox(Handle, '修补过程出错,操作终止!', '错误', MB_OK + MB_ICONSTOP);
FileClose(FHandle);
ProgressBar1.Position :=100;
LblMsg.Visible :=False;
exit;
end;
end;
procedure TForm1.Label4Click(Sender: TObject);
begin
ShellExecute(Handle, 'open','http://blog.csdn.net/hnxyy/', '', '', SW_SHOWNORMAL);
end;
procedure TForm1.Label5Click(Sender: TObject);
begin
ShellExecute(Handle, 'open','http://forum.wrsky.com', '', '', SW_SHOWNORMAL);
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if (trim(Edit1.Text)='') or (trim(edit2.Text)='') then
begin
Messagebox(Handle, '请选择要修补的文件!', '错误', MB_OK + MB_ICONSTOP);
Exit;
end;
Crack(trim(edit1.Text),trim(edit2.Text));
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
OpenDialog1.Filter :='PFW.exe|PFW.exe';
OpenDialog1.InitialDir :=ExtractFileDir(Application.ExeName);
if OpenDialog1.Execute then edit1.Text :=OpenDialog1.FileName;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
OpenDialog2.Filter :='PFWLiveUpdate.exe|PFWLiveUpdate.exe';
OpenDialog2.InitialDir :=ExtractFileDir(Application.ExeName);
if OpenDialog2.Execute then edit2.Text :=OpenDialog2.FileName;
end;
end.