Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libemu: fix 'test dword ptr [reg], imm'.
The instruction length decoder properly decoded its length, but eip was not incremented properly. This is because the immediate argument was never read. 'Test' is the only instruction in group3_f6/f7 with immediate values, which means we can't just add II_IMM to the instruction description as it would break the other instructions in the group. So use the 'type' flag in the instruction to denote that the first instruction in the group can have immediate values. Now this instruction is emulated properly, and eip is incremented correctly too. I used this small function to test: 00000000 <main>: 0: f7 01 ff ff ff ff testl $0xffffffff,(%ecx) 6: 67 f7 07 ff ff ff ff addr16 testl $0xffffffff,(%bx) d: f7 d3 not %ebx f: 66 f7 d1 not %cx 12: f7 d8 neg %eax 14: 66 f7 da neg %dx 17: f7 e3 mul %ebx 19: 66 f7 e2 mul %dx 1c: f7 eb imul %ebx 1e: 66 f7 e8 imul %ax 21: f7 f3 div %ebx 23: 66 f7 f1 div %cx 26: c3 ret Signed-off-by: Török Edwin <[email protected]> Signed-off-by: common <[email protected]>
- Loading branch information