Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X86 Prefix ordering #82

Closed
lintile opened this issue Mar 18, 2014 · 7 comments
Closed

X86 Prefix ordering #82

lintile opened this issue Mar 18, 2014 · 7 comments

Comments

@lintile
Copy link

lintile commented Mar 18, 2014

I have found an issue with prefix ordering that causes the disassembler to ignore both the osz and the repe/repne prefixes:

% ./quickcs 66 f2 af
scasd eax, dword ptr es:[edi]
% ./quickcs f2 66 af
repne scasw ax, word ptr es:[edi]

This is currently a problem in LLVM ToT, but the prefix handling in this base is much closer to reality. Thanks!

@radare
Copy link
Contributor

radare commented Mar 18, 2014

As a note: udis86 shows repne scasw in both cases:

capstone

pair:~ pancake$ rasm2 -a x86.cs -d 66f2af
scasd eax, dword es:[edi]
pair:~ pancake$ rasm2 -a x86.cs -d f266af
repne scasw ax, word es:[edi]

udis86

pair:~ pancake$ rasm2 -a x86 -d f266af
repne scasw
pair:~ pancake$ rasm2 -a x86 -d 66f2af
repne scasw

olly disasm:

pair:~ pancake$ rasm2 -a x86.olly -d f266af
repne scas word ptr es:[edi]
pair:~ pancake$ rasm2 -a x86.olly -d 66f2af
repne scas word ptr es:[edi]

And I guess gnu would do something completely different here too :P

Who’s right?

On 18 Mar 2014, at 17:32, lintile notifications@github.com wrote:

I have found an issue with prefix ordering that causes the disassembler to ignore both the osz and the repe/repne prefixes:

% ./quickcs 66 f2 af
scasd eax, dword ptr es:[edi]
% ./quickcs f2 66 af
repne scasw ax, word ptr es:[edi]

This is currently a problem in LLVM ToT, but the prefix handling in this base is much closer to reality. Thanks!


Reply to this email directly or view it on GitHub.

@lintile
Copy link
Author

lintile commented Mar 18, 2014

Well, I can tell you that there are at least 3 different compilers on different platforms which generate this instruction, and when executed on the processor, they are equivalent.

@aquynh
Copy link
Collaborator

aquynh commented Mar 18, 2014

thanks for the report! we will work on these cases & get back to you soon.

usually when there are differences, we would trust IDAPro more than others.
so it is a good idea for you to try these with IDA, too.

best!

On Wed, Mar 19, 2014 at 12:40 AM, radare notifications@github.com wrote:

As a note: udis86 shows repne scasw in both cases:

capstone

pair:~ pancake$ rasm2 -a x86.cs -d 66f2af
scasd eax, dword es:[edi]
pair:~ pancake$ rasm2 -a x86.cs -d f266af
repne scasw ax, word es:[edi]

udis86

pair:~ pancake$ rasm2 -a x86 -d f266af
repne scasw
pair:~ pancake$ rasm2 -a x86 -d 66f2af
repne scasw

olly disasm:

pair:~ pancake$ rasm2 -a x86.olly -d f266af
repne scas word ptr es:[edi]
pair:~ pancake$ rasm2 -a x86.olly -d 66f2af
repne scas word ptr es:[edi]

And I guess gnu would do something completely different here too :P

Who's right?

On 18 Mar 2014, at 17:32, lintile notifications@github.com wrote:

I have found an issue with prefix ordering that causes the disassembler
to ignore both the osz and the repe/repne prefixes:

% ./quickcs 66 f2 af
scasd eax, dword ptr es:[edi]
% ./quickcs f2 66 af
repne scasw ax, word ptr es:[edi]

This is currently a problem in LLVM ToT, but the prefix handling in this
base is much closer to reality. Thanks!

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/82#issuecomment-37955778
.

@lintile
Copy link
Author

lintile commented Mar 18, 2014

IDA agrees:

seg000:00000004 66 F2 AF repne scasw
seg000:00000007 F2 66 AF repne scasw

@radare
Copy link
Contributor

radare commented Mar 18, 2014

udis wins

On 18 Mar 2014, at 17:58, lintile notifications@github.com wrote:

IDA agrees:

seg000:00000004 66 F2 AF repne scasw
seg000:00000007 F2 66 AF repne scasw


Reply to this email directly or view it on GitHub.

@aquynh
Copy link
Collaborator

aquynh commented Apr 28, 2014

Lintile, this problem has been fixed in the "next" branch. can you confirm?

thanks.

@aquynh
Copy link
Collaborator

aquynh commented May 8, 2014

this has been fixed in the "next" branch. if you still have this issue with some input, please reopen it.

thanks.

@aquynh aquynh closed this as completed May 8, 2014
tmfink pushed a commit to tmfink/capstone that referenced this issue Sep 8, 2021
Part of PR capstone-engine#82

Adds a test to make sure that cs_insn and Insn have the same size and
alignment and that conversions between them are valid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants