Writing a Patcher?

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

Writing a Patcher?

Post by SP534 on Thu May 01, 2008 2:15 pm
([msg=1865]see Writing a Patcher?[/msg])

Hey guys, I've recently been trying to get into app cracking, and have been wondering how to write my own patcher. I have some programming experience in vb, and C++, among others, so I'd like some help in c++ preferably...

I've tried so many different techniques, downloaded source code, basically everything I can, but I just can't get it right!
I have, until now been using programs to create patches, such as dUP2, and CodeFusion, but I'd simply like to actually make my own :D

Hopefully someone out there can help, thanks!
SP534
New User
New User
 
Posts: 5
Joined: Thu May 01, 2008 2:08 pm
Blog: View Blog (0)


Re: Writing a Patcher?

Post by BhaaL on Fri May 02, 2008 8:38 am
([msg=1917]see Re: Writing a Patcher?[/msg])

Most simple patching is replacing code 1:1.
Commonly used, replacing a JNE with a JE/JMP (*hint* serial checks *hint*) does not change the filesize or moves offsets, because both are the same size. For that, open the file in binary mode, seek to the position, and simply overwrite the byte you need to change. Practically you'd open the file, open a copy, and write from one to the other, replacing stuff (or reading into a buffer, replacing in-memory, and writing the whole buffer to a new file).

It could be a bit harder tho, when your patched code does not match the size of the original code fragment. For that matter, you have to come up with your own solution that keeps offsets and such from breaking.
One way is parsing the PE header and following references, plus rewriting them after patching (the long way round, basically requires you to write somewhat a PE parser/interpreter), while another way scans the executable for unused space and writes the patch to that location, replacing the original location with a JMP/CALL.

I guess that should be enough to get you started.
BhaaL
Poster
Poster
 
Posts: 270
Joined: Sun Apr 13, 2008 11:16 am
Blog: View Blog (0)


Re: Writing a Patcher?

Post by SP534 on Fri May 02, 2008 11:11 am
([msg=1921]see Re: Writing a Patcher?[/msg])

Thanks for the help! I'll see what I can do ;)
SP534
New User
New User
 
Posts: 5
Joined: Thu May 01, 2008 2:08 pm
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests