- UID
- 2198
注册时间2005-6-29
阅读权限255
最后登录1970-1-1
副坛主
该用户从未签到
|
发表于 2008-4-26 01:42:16
|
显示全部楼层
转一下作者的Patch源码
procedure WriteRegInfo;
const FPath= '\software\flash player pro';
Var
Reg : TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
If Reg.OpenKey(FPath, False) then
begin
Reg.WriteString('Username','黄仁来[BEYOND0769]');
Reg.WriteString('code','http://hi.baidu.com/beyond0769');
end;
finally
Reg.CloseKey;
Reg.Free;
end;
end;
然后打补丁过程(简化代码):
var
FileName: PChar = 'Flash Player Pro.exe'; //破解目标文件完整名称
IntFileSize: Cardinal = 6866944; //破解目标文件的大小字节
RBuffer: array[0..1] of Byte = ($75, $48); //目标破解文件原有的偏移量
WBuffer: array[0..1] of Byte = ($74, $48); //修改后的偏移量
OffsetPos: TOVERLAPPED = (Internal: 0; InternalHigh: 0; Offset: $001122DF; OffsetHigh: 0; hEvent: 0);
procedure PatchFile;
var
Res:boolean;
begin
Setfileattributes(FileName, FILE_ATTRIBUTE_NORMAL + FILE_ATTRIBUTE_ARCHIVE); //设置文件的属性为正常
hFile := CreateFile(FileName, GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ or
FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
try
if hFile <> INVALID_HANDLE_VALUE then
begin
if Word(Buffer[0]) = Word(RBuffer[0]) then {// 读取偏移是否正确;}
begin
CopyFile(FileName, PChar('备份' + FileName), False); //备份破解目标文件;
if WriteFile(hFile, WBuffer, 2, Numb, @OffsetPos) then
begin
MessageBox(0, PChar('成功打上补丁!'), PChar('海浪轻风温馨提示:'), nType);
Res:=True;
end;
end;
end;
finally
CloseHandle(hFile);
if Res then ShellExecute(0, nil, szLink, nil, nil, 0);
end;
end; |
|