
                                PATCHER 0.1
                                 10/04/2012

~~~~~~~~~~~
What is it?
~~~~~~~~~~~

Using PATCHER, you can easily build an executable WIN32 file to patch any other file. You can patch several files at once, and for each file you can patch at several locations at once.


~~~~~~~~~~~~~~~~~
How does it work?
~~~~~~~~~~~~~~~~~

You need FASM to compile it: get the WIN32 version of this great assembler at http://flatassembler.net/, then open the FAMSW editor. Type:

  include 'patcher.inc'

Then you can define your patches using the macros 'file', 'at' and 'done'. 'file' needs one parameter, the name (and possibly path) of a file to open. 'at' needs one parameter, the offset from where the data must be writen. 'done' needs no parameter.

Use 'file' each time you need to specify a new file, use 'at' each time you need to specify an offset position, after which you can declare data to be writen, using the usual assembler directives like 'db', 'dw' and even opcodes like 'push eax'. When it's all done, write 'done' and your patch is ready to compile & run!


~~~~~~~~~~~~~~~~~~~~~~~
Do you have an example?
~~~~~~~~~~~~~~~~~~~~~~~

Sure! Here it is:

  include 'patcher.inc'
  file "patchme.exe"
    at 0x100
      db 0x25, 3, 12
      db "hello world!", 0
      dd 0x12345678
      dw -1, 0x2289
    at 23
      mov eax, ecx
      push ecx
      jmp short 5
    at 0x453
      db 15
  file "..\metoo.dll"
    at 1387
      dw 1
  done

This example will first open the file "patchme.exe", write some data at offset 0x100, then som code at offset 23, then data again at offset 0x453. After that it will open the file "..\metoo.dll" and write data at offset 1387.


~~~~~~~~~~~~~~~~~~~~~~~
Is there an easier way?
~~~~~~~~~~~~~~~~~~~~~~~

There is! If you only need to write one series of bytes, at one location, in a single file, use the 'patch' macro. Please note that you can't use this macro several times, if you need to patch several files or locations, use the syntax shown previously.

  patch "filename", offset, byte_1, byte_2,... byte_n

Some examples:

  patch "patcheme.exe", 0x40500, "hello world", 0
  patch "metoo.dll", 0x05A3DD0, 0
  patch "notepad.exe", 354, 0x55, 0x2f, 0x30


~~~~~~~~~~~~~~~~~~~~~
Other things to know?
~~~~~~~~~~~~~~~~~~~~~

Not much. The program does NOT make a backup of the modified files, it's up to you do it before launching the program. The author is not responsible of the damage you can do to your files by misusing this program: if you're not sure, don't do it, or at least make a backup!

The way the 'SetFilePointer' Win32 API function works, you can give an offset which is much larger than the file to modify, and write something: by doing that, you'll grow the size of the file. If the original file is 10 bytes long, and you write 4 bytes at the offset 1000, the modified file will be 1004 bytes long. Knowing that, you can append code or data at the end of a file.