MCode()

Author: Laszlo Last Modified: 20080107


In AHK v1.0.46.08+, the 1st parameter of a DllCall can be an integer, the address of a function to call. If we copy the binary machine code of a function into an AHK variable, its addresses can be used in DllCalls, executing our machine code function.

MCode(ByRef code, hex)

For more details of the functions's parameters and return value, please see it's source code.

Remarks

Requires at least Ahk v1.0.46.08.

For update's details and remarks related to the functions, please see the AutoHotkey Forum: http://www.autohotkey.com/forum/viewtopic.php?t=21172

License

nonexistent

Example

; #Include mcode.ahk
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

; For example, the following line stores the code of the function swapping 
; the bytes of short (16-bit) value.
MCode(BSwap16,"8AE18AC5C3")

; The result is 0x3412 in hex form. These do not involve any external dll's,
; so swapping bytes is almost as fast as if it was a built-in function.
; We can extend the list of built-in function arbitrarily. 
MsgBox % dllcall(&BSwap16, "short",0x1234, "cdecl ushort")