Original Thread (German/Deutsch):
http://www.autohotke...or-x86-und-x64/
Hi,
I have tried to play around with MCode, but i have recognized that most of the old scripts does'nt work anymore.
So i decided to make a rewrite of the old scripts and try to improve what's possible.
The Features are:
- The MCode function automaticly selects between x86 and x64
- VirtualProtect (execution permission) for x64 (there are problems in most of all old scripts)
- The MCode can be encoded in HEX or Base64
- Fast decoding functions
- Online generator
Requirements:
- Windows XP, Windows 2003 or newer
- AutoHotkey 1.1+
You can find the online generator here:
http://bentschi.no-ip.org/mcode/
And here the new MCode function:
MCode(mcode) { static e := {1:4, 2:1}, c := (A_PtrSize=8) ? "x64" : "x86" if (!regexmatch(mcode, "^([0-9]+),(" c ":|.*?," c ":)([^,]+)", m)) return if (!DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", 0, "uint*", s, "ptr", 0, "ptr", 0)) return p := DllCall("GlobalAlloc", "uint", 0, "ptr", s, "ptr") if (c="x64") DllCall("VirtualProtect", "ptr", p, "ptr", s, "uint", 0x40, "uint*", op) if (DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", p, "uint*", s, "ptr", 0, "ptr", 0)) return p DllCall("GlobalFree", "ptr", p) }
Example: (the compiled startcode from the generator)
MyFunction := MCode("2,x86:aipYww==,x64:uCoAAADD") MsgBox, % DllCall(MyFunction, "cdecl")