Jump to content
Tuts 4 You

Making Generic Patcher with Delphi


Eleos

Recommended Posts

Posted

Hi all.

Wondering if anyone can provide source code for making

a generic patcher using a search and replace pattern.

Thnx in advance

Posted

i did searched for it Mr Teddy but i only found on VB.

I know most people use VB but i don't that's why i need Delphi code

  • 2 weeks later...
  • 2 weeks later...
Posted

thnx JW. You are the man i was expecting a reply :)

Did you quit RES?

Posted

This is great i hope there's some more of this kind of stuff..... :thumbsup:

Posted
thnx JW. You are the man i was expecting a reply :)

Did you quit RES?

More or less, wasn't around for a long time so now i'm out :)

JW.

Posted

That's sad cause the scene needs so much skillful and talented guys like you

  • 4 weeks later...
Posted

I will provide you an example as soon as i can (too late right now):

1) CreateFile();

- If you wanna write a saved buffer (e.g: cracked .exe) use CREATE_ALWAYS flag to empty the file to ZERO-BYTE length.

- If you want to go to offsets and patch some bytes or words, etc... then OPEN_EXISTSING

1.5) SetFilePointer(); (To go to a specific offset if needed)

2) WriteFile(); on the handle CreateFile returned. (very similiar to WPM)

3) CloseHandle(); on the handle CreateFile returned.

Posted

I can'nt wait to see your example Rot1 :)

Posted
I can'nt wait to see your example Rot1 :)

No problem, here you go:

NOTE: All the ... stuff you see must be filled manually according to your needs, check out MSDN for details.

const
buffer: Array[0..1] of byte = ($90, $90);
var
hFile: THandle; //or Cardinal
beign
hFile := (... , GENERIC_WRITE , ... , OPEN_EXISTING, ... );
SetFilePointer( hFile, $XXXXX, ... , FILE_BEGIN ); //Sets position offset @ address ($offset in hex)
WriteFile( hFile, buffer, sizeof(buffer), ... );
CloseHandle( hFile );
end;

study this code carefully.

Posted (edited)

ah okay i thought this was to be a search and replace example, I will defently look into SetFilePointer API but from what you have wrote you need to know the offset address to patch? or am i missing something here? anyway I will check out the SetFilePointer API, it seems to just point an offset address therefore it seems at first glance nothing to do with Search and replace byte patterns.

//Edit

Okay i had a quick look on msdn site at SetFilePointer, I see what you mean now

Quote Msdn:"You can also use the SetFilePointer function to query the current file pointer position. To do this, specify a move method of FILE_CURRENT and a distance of zero (0)."

Im guessing this means we can loop through the file checking the byte at current position. I still need to look into to this but thanks for the tip.

Edited by Departure
Posted
ah okay i thought this was to be a search and replace example, I will defently look into SetFilePointer API but from what you have wrote you need to know the offset address to patch? or am i missing something here? anyway I will check out the SetFilePointer API, it seems to just point an offset address therefore it seems at first glance nothing to do with Search and replace byte patterns.

//Edit

Okay i had a quick look on msdn site at SetFilePointer, I see what you mean now

Quote Msdn:"You can also use the SetFilePointer function to query the current file pointer position. To do this, specify a move method of FILE_CURRENT and a distance of zero (0)."

Im guessing this means we can loop through the file checking the byte at current position. I still need to look into to this but thanks for the tip.

What SetFilePointer does is setting a different position in a file (offset), for example you open the binary file with a HEX Editor and you see the dumped result, the current offset (FILE_BEGIN) will be 0x00 (0), move 1 byte will be 0x01 (1), get me ?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...