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

Add disasm mode setting support #24

Merged
merged 7 commits into from
Jun 22, 2021
Merged

Conversation

ioo0s
Copy link
Contributor

@ioo0s ioo0s commented Jun 22, 2021

Add support for Disasm mode setting.Currently only supports rust and python binding, nodejs binding will support in the near future.
#23
#20
In rust, We can set the mode for SleighBuilder(this setting is optional, default mode is 16 bit)

#[test]
fn test_x86_64_bit() {
    let mut sleigh_builder = SleighBuilder::default();
    let spec = arch("x86-64").unwrap();
    let buf = [72, 49, 192];
    let mut loader = PlainLoadImage::from_buf(&buf, 0);
    sleigh_builder.loader(&mut loader);
    sleigh_builder.spec(spec);
    // this setting is optional, default mode is 16 bit
    sleigh_builder.mode(MODE64);
    let mut asm_emit = CollectingAssemblyEmit::default();
    let mut pcode_emit = CollectingPcodeEmit::default();
    sleigh_builder.asm_emit(&mut asm_emit);
    sleigh_builder.pcode_emit(&mut pcode_emit);
    let mut sleigh = sleigh_builder.try_build().unwrap();

    sleigh.decode(0).unwrap();

    println!("{:?}", asm_emit.asms);
    println!("{:?}", pcode_emit.pcode_asms);
}

In python, the third parameter setting mode when new Sleigh(),this setting is optional also, default mode is 16 bit.

from bincraft import *
    code = [72, 49, 192]
    sleigh = Sleigh(ARCH_X86_64, code, MODE_64)
    for asm in sleigh.disasm(0):
        print(asm.mnemonic() + "\t" + asm.body())

@Escapingbug Escapingbug merged commit d715b3e into StarCrossPortal:master Jun 22, 2021
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

Successfully merging this pull request may close these issues.

2 participants