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] Disassembly Error, capstone failed to handle some long multi-byte nop in x86 #2550

Open
Mar3yZhang opened this issue Nov 22, 2024 · 2 comments
Labels
bug Something is not working as it should X86 Arch

Comments

@Mar3yZhang
Copy link

Work environment

Questions Answers
OS/arch/bits x86_64 Ubuntu 20.04
Architecture x86_64
Source of Capstone git clone, default on next branch.
Version/git commit v6.0.0, d7be5f9

Instruction bytes giving faulty results

0x0f 0x1a 0xde

Expected results

It should be:

nop esi, ebx

Steps to get the wrong result

With cstool:

$ ./cstool -d x64 "0x0f 0x1a 0xde"
ERROR: invalid assembly code
        
$ ./cstool -d x64 "0xf0 0x1d 0xee" 
ERROR: invalid assembly code

$ ./cstool -d x64 "0x0f 0x1f 0x00"
 0  0f 1f 00                                         nop        dword ptr [rax]
        ID: 510 (nop)
        Prefix:0x00 0x00 0x00 0x00
        Opcode:0x0f 0x1f 0x00 0x00
        rex: 0x0
        addr_size: 8
        modrm: 0x0
        disp: 0x0
        sib: 0x0
        op_count: 1
                operands[0].type: MEM
                        operands[0].mem.base: REG = rax
                operands[0].size: 4
                operands[0].access: READ
        Registers read: rax

Additional Logs, screenshots, source code, configuration dump, ...

x86 (and x86_64) processors have single-byte NOP instructions and various multi-byte NOP-like instructions. Real-world compilers sometimes use multi-byte NOPs for code alignment and performance optimization purposes. Capstone seems to fail when encountering unusual multi-byte NOPs. Other x86 instruction decoders like Zydis, ICED, and XED can translate the byte sequence "0x0f 0x1a 0xde" into NOP.

@Rot127 Rot127 added bug Something is not working as it should X86 Arch labels Nov 22, 2024
@Rot127
Copy link
Collaborator

Rot127 commented Nov 22, 2024

fyi: #2505

@Mar3yZhang
Copy link
Author

fyi: #2505

Thank you for your prompt reply!

@Mar3yZhang Mar3yZhang changed the title Disassembly Error, capstone failed to handle some long multi-byte NOPs in x86 [X86] Disassembly Error, capstone failed to handle some long multi-byte nop in x86 Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working as it should X86 Arch
Projects
None yet
Development

No branches or pull requests

2 participants