Posted October 13, 200816 yr Hi all.Wondering if anyone can provide source code for makinga generic patcher using a search and replace pattern.Thnx in advance
October 14, 200816 yr One of the tick box's when you join is a promise to use search http://forum.tuts4you.com/index.php?act=Se...Bsearch+replace Ted.
October 14, 200816 yr Author 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
October 25, 200816 yr Here's a very basic example. Delphi.SnR.Patch.Example.rar With a little tweaking you can do masked searching. P.S. i didn't bothered cleaning up the code JW.
November 19, 200816 yr 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.
November 19, 200816 yr Author That's sad cause the scene needs so much skillful and talented guys like you
December 16, 200816 yr 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_EXISTSING1.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.
December 17, 200816 yr 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 Cardinalbeign 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.
December 17, 200816 yr 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.//EditOkay 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 December 17, 200816 yr by Departure
December 17, 200816 yr 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.//EditOkay 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