var
FileName:PChar = 'Crackme5.exe';
AppName:PChar = 'Crackme 5 Pathc';
Done:PChar = 'File patched succesfully!';
NoFile:PChar = 'Can''t find crackme5.exe!';
ReFile:PChar = 'Wrong version of crackme5.exe!';
WrFile:PChar = 'Error writing to crackme5.exe!';
RBuffer:Array[0..1] of Byte = ($75,$15);
WBuffer:Array[0..1] of Byte = ($90,$90);
OffsetPos:TOVERLAPPED = (Internal:0;InternalHigh:0;Offset:$53f;OffsetHigh:0;hEvent:0);
CommandLine:PChar;
hwndname:HWND;
hFile:THANDLE;
Numb:DWORD;
Buffer:Array[0..1] of Byte;
nType:DWORD;
pMsg:PChar;
begin
hFile := CreateFile(FileName,GENERIC_READ OR GENERIC_WRITE,FILE_SHARE_READ OR FILE_SHARE_WRITE,nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if hFile <> INVALID_HANDLE_VALUE then
begin
ReadFile(hFile,Buffer,2,Numb,@OffsetPos);
if WORD(Buffer[0]) = Word(RBuffer[0]) then
if WriteFile(hFile,WBuffer,2,Numb,@OffsetPos) then
begin
nType := MB_OK;
pMsg := Done;
end
else
begin
nType := MB_OK or MB_ICONINFORMATION;
pMsg := WrFile;
end
else
begin
nType := MB_OK or MB_ICONINFORMATION;
pMsg := ReFile;
end;
end
else
begin
nType := MB_OK or MB_ICONINFORMATION;
pMsg := NoFile;
end;
CloseHandle(hFile);
MessageBox(0,pMsg,AppName,nType);
ExitProcess(0);
end.