non of you understand this at all
in my first attempt in javascript...
ive allocated some memory for my function,.
Put each individual instruction into an array (in hex of course)
Used a for(i in Patch_Function) to help store each instruction into the allocated memory like so
code:
var BuffAddr = FunctionBuffer.DataPtr;
for(var i = 0; i < Patch_Function.length; i++){
Patch(BuffAddr, Patch_Function[i]);
BuffAddr += Patch_Function[i].length;
}
this works fine and well but now i have to create a JMP to this FunctionBuffer.DataPtr so it can execute my code and IT CANNOT BE HARD CODED which you have all obviously got wrong even though you have read it is dynamically allocated!
to create the jump ive done this
code:
Hook_JMP = Interop.Allocate(6);
var tmp = Interop.Allocate(6);
tmp.WriteDWORD(1, FunctionBuffer.DataPtr-Hook_Address-5);
var tmpbyte = tmp.GetAt(0);
Hook_JMP.SetAt(5,tmpbyte);
tmpbyte = tmp.GetAt(1);
Hook_JMP.SetAt(4,tmpbyte);
tmpbyte = tmp.GetAt(2);
Hook_JMP.SetAt(3,tmpbyte);
tmpbyte = tmp.GetAt(3);
Hook_JMP.SetAt(2,tmpbyte);
tmpbyte = tmp.GetAt(4);
Hook_JMP.SetAt(0,tmpbyte);
Hook_JMP.SetAt(0,0xE9);
I think the bytes have to be reversed thats why ive put the in a temp buffer then read it backwards but i am unsure.
OBVIOUSLY since its dynamic memory i can just use "asm (jmp $0xE900000000)"