MCode Tutorial (Compiled Code in AHK)

Helpful script writing tricks and HowTo's
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

Re: MCode Tutorial (Compiled Code in AHK)

25 Mar 2015, 14:40

Which compiler are you using? I was just wanting to test this application so downloaded

x86_64-w64-mingw32-gcc-4.9.2.exe
User avatar
nnnik
Posts: 4329
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: MCode Tutorial (Compiled Code in AHK)

25 Mar 2015, 14:45

I use an assembly compiler for all tasks I'm doing in MCode.
Its not quite comfortable but useable.
Recommends AHK Studio
guest3456
Posts: 2796
Joined: 09 Oct 2013, 10:31

Re: MCode Tutorial (Compiled Code in AHK)

20 Nov 2019, 00:40

nnnik wrote:
30 Sep 2013, 12:00
3. an MCode Function:
I use this one:

Code: Select all

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)
}
are you sure VirtualProtect is only needed on AHKx64?

paulpma
Posts: 24
Joined: 08 Sep 2018, 22:05

Re: MCode Tutorial (Compiled Code in AHK)

20 Nov 2019, 13:38

Hi all,

I am a bit new to MCODE, but I have managed to install compiler TDM-GCC-64\bin\gcc.exe and was able to generate MCODE. However, I have been searching for at least couple hours but can't find a way to set compiler to generate MCODE encoding in hexadecimal vs base64(the default). The function is writeen in C.
Any help is appreciated, thank you.
paulpma
Posts: 24
Joined: 08 Sep 2018, 22:05

Re: MCode Tutorial (Compiled Code in AHK)

20 Nov 2019, 23:38

Someone helped me.. thank you..
You have to change it under "Settings" here :thumbup: :
"Laszlo Style" for Hex
"Bentschi Style" for Base64
User avatar
nnnik
Posts: 4329
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: MCode Tutorial (Compiled Code in AHK)

21 Nov 2019, 04:12

Which compiler did you use? Also why do you want to use Hex instead of base64?
Recommends AHK Studio

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 9 guests