Closed GoogleCodeExporter closed 9 years ago
0x1179: "CMPSS",
is also missing in distorm3.Mnemonics
Original comment by cesare.d...@gmail.com
on 24 Jan 2012 at 8:43
The same happens for normal (without REX prefix) version:
>>> i = distorm3.Decompose(0x0000000001646b2e, "f30fc2ce06".decode('hex'),
distorm3.Decode64Bits)[0]
>>> i.opcode
9: 4474
>>> i.mnemonic
10: 'UNDEFINED'
>>> i.valid
11: True
0x1179: "CMPSS",
is also missing in distorm3.Mnemonics
Original comment by cesare.d...@gmail.com
on 24 Jan 2012 at 8:50
This issue and issue 30 seem to be caused by this line:
http://code.google.com/p/distorm/source/browse/trunk/src/decoder.c#296
di->opcode = ii->opcodeId + cmpType;
The index into the _MNEMONICS array is being offset by cmpType which has a
value of 0-7 bytes. For the extended mnemonics of the cmpss/cmpsd/cmpps/cmppd
instructions, we really want to offset by 0-7 mnemonics.
Original comment by spa...@rotateright.com
on 7 Feb 2012 at 5:28
Here's a possible fix:
int i;
unsigned int stringOffset = 0;
/*
* The _MNEMONICS string contains pascal-style strings with the length of each mnemonic specified.
* We will sum each mnemonic length to arrive at the final mnemonic offset.
*/
for (i=0; i<cmpType; i++) {
/* +1 is for the null terminator, +1 is for the length byte itself */
if (_MNEMONICS_SIZE <= (ii->opcodeId + stringOffset)) goto _Undecodable;
stringOffset += _MNEMONICS[ii->opcodeId + stringOffset] + 2;
}
if (_MNEMONICS_SIZE <= (ii->opcodeId + stringOffset)) goto _Undecodable;
di->opcode = ii->opcodeId + stringOffset;
I added _MNEMONICS_SIZE to mnemonics.c for safety checking:
const unsigned int _MNEMONICS_SIZE = sizeof(_MNEMONICS);
Original comment by spa...@rotateright.com
on 7 Feb 2012 at 5:31
Issue 30 has been merged into this issue.
Original comment by distorm@gmail.com
on 26 Feb 2012 at 11:38
Original comment by distorm@gmail.com
on 26 Feb 2012 at 11:38
Original comment by distorm@gmail.com
on 26 Feb 2012 at 3:55
Sanjay, thanks for your patch suggestion, but I used another way that doesn't
need to loop - just another static table to look up the offsets.
Original comment by distorm@gmail.com
on 27 Feb 2012 at 5:37
This issue was closed by revision r195.
Original comment by distorm@gmail.com
on 27 Feb 2012 at 6:05
This issue was closed by revision r197.
Original comment by distorm@gmail.com
on 28 Feb 2012 at 2:53
Original issue reported on code.google.com by
cesare.d...@gmail.com
on 24 Jan 2012 at 8:34