Hello there I have fully ported the x86 assembler (and auto assembler) from cheat engine to c#.
Everything works fine for the most part however the "VEX" prefix instructions are currently broken.
There is 2 sections of code I wasn't able to convert just yet so I wonder if anybody can provide a solution to it.
Commented out sections are the ones that I'm not sure how to deal with.
2 byte vex
//2byte vex
bytes.SetLength(bytes.Length + 2);
for (i = bytes.Length - 1; i >= RexPrefixLocation + 2; i--)
bytes[i] = bytes[i - 2];
bytes[RexPrefixLocation] = 0xc5; //2 byte VEX
//pvex2byte(&bytes[RexPrefixLocation + 1])->pp = (int) (Assembler.OpCodes[j].VexLeadingOpCode);
//pvex2byte(&bytes[RexPrefixLocation + 1])->l = Assembler.OpCodes[j].VexL;
//pvex2byte(&bytes[RexPrefixLocation + 1])->vvvv = vexvvvv;
//pvex2byte(&bytes[RexPrefixLocation + 1])->r = RexR ? 0 : 1;
if (RelativeAddressLocation != -1)
RelativeAddressLocation += 2;
3 byte vex
//3byte vex
bytes.SetLength(bytes.Length + 3);
for (i = bytes.Length - 1; i >= RexPrefixLocation + 3; i--)
bytes[i] = bytes[i - 3];
bytes[RexPrefixLocation] = 0xc4; //3 byte VEX
//pvex3byte(&bytes[RexPrefixLocation + 1])->mmmmm = (int)(Assembler.OpCodes[j].VexLeadingOpCode);
//pvex3byte(&bytes[RexPrefixLocation + 1])->b = RexB ? 0 : 1;
//pvex3byte(&bytes[RexPrefixLocation + 1])->x = RexX ? 0 : 1;
//pvex3byte(&bytes[RexPrefixLocation + 1])->r = RexR ? 0 : 1;
//pvex3byte(&bytes[RexPrefixLocation + 1])->pp = (int)(Assembler.OpCodes[j].VexLeadingOpCode);
//pvex3byte(&bytes[RexPrefixLocation + 1])->l = Assembler.OpCodes[j].VexL;
//pvex3byte(&bytes[RexPrefixLocation + 1])->vvvv = vexvvvv;
//pvex3byte(&bytes[RexPrefixLocation + 1])->w = RexW ? 1 : 0; //not inverted
if (RelativeAddressLocation != -1)
RelativeAddressLocation += 3;
The original assembly/auto assembler is made in pascal (lazarus) and here is the definition of the pvex3byte
TVEX3Byte=bitpacked record
mmmmm: 0..31;
B: 0..1;
X: 0..1;
R: 0..1;
pp: 0..3;
L: 0..1;
vvvv: 0..15;
W: 0..1;
end;
PVEX3Byte=^TVEX3Byte;
TVEX2Byte=bitpacked record
pp: 0..3;
L: 0..1;
vvvv: 0..15;
R: 0..1;
end;
PVex2Byte=^TVex2Byte;
Can somebody solve how to fill this part in? If possible a complete class or extension for the "bytes" (byte[]) array to allow editing/reading the vexs properly?
I figure its something to do with bits, unfortunately there's no bit struct in c# (none that work in this way).