Code: Select all
MyFunction := MCode("2,x86:uCoAAADD,x64:uCoAAADD")
Msgbox(DllCall(MyFunction, "Cdecl"))
MCode(mcode)
{
e := [[0x00000004], [0x00000001]]
c := (A_PtrSize == 8) ? "x64" : "x86"
if (!RegExMatch(mcode, "^([0-9]+),(" c ":|.*?," c ":)([^,]+)", &m))
{
return
}
if (!DllCall("crypt32\CryptStringToBinary", "Str", m[3], "UInt", 0, "UInt", e[m[1]][1], "Ptr", 0, "UInt*", &s := 0, "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 := 0)
}
if (DllCall("crypt32\CryptStringToBinary", "Str", m[3], "UInt", 0, "UInt", e[m[1]][1], "Ptr", 0, "UInt*", &s := 0, "Ptr", 0, "Ptr", 0))
{
return p
}
DllCall("GlobalFree", "Ptr", p)
}
Code: Select all
MyFunction := MCode("2,x86:uCoAAADD,x64:uCoAAADD")
Msgbox % DllCall(MyFunction, "cdecl")
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)
}