The code is stolen from my scripts(in which i credit CookieRevised for functions to write bytes memory and TheBlasphemer to have helped me to get the scripts working on windows vista/7).The Function patch was made by me not by Cookie.And also this code was stolen from my scripts
code:
var Handle = Interop.Call("Kernel32","GetModuleHandleW",null);
var sBuffer = Interop.Allocate(PatchOld.length);
Address = (Address - 0x00400000) + Handle;
I assume that at least the byte to patch is your own work.