first, the simple C code
void fill_array(int array[]) { array[0] = 3; array[1] = 4; array[2] = 5; }paste that into the generator, choose C code,x86, and HEX, and you can verify my hex output below.
here is the AHK_L code:
fill_array := MCode("1,x86:8b442404c700030000c740040400c740080500c3") VarSetCapacity(myarray, 100000, 0) DllCall(fill_array, "UInt", &myarray, "cdecl") MsgBox, % "myarray[0]=" NumGet(myarray, 0*4, "uint") ;// should be 3 MsgBox, % "myarray[1]=" NumGet(myarray, 1*4, "uint") ;// should be 4 MsgBox, % "myarray[2]=" NumGet(myarray, 2*4, "uint") ;// should be 5 MsgBox, % "myarray[3]=" NumGet(myarray, 3*4, "uint") ;// should be 0 from VarSetCapacity FillByte return 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) }what am i doing wrong ? the msgboxes outputs a random large integer for array[0] and 0's for the others.