diff --git a/Cargo.lock b/Cargo.lock index 2b30226..2a46ec9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,21 +27,16 @@ dependencies = [ ] [[package]] -name = "anstyle" -version = "1.0.6" +name = "anes" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] -name = "atty" -version = "0.2.14" +name = "anstyle" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "autocfg" @@ -55,10 +50,10 @@ version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ - "bitflags 2.5.0", + "bitflags", "cexpr", "clang-sys", - "itertools", + "itertools 0.12.1", "lazy_static", "lazycell", "log", @@ -72,12 +67,6 @@ dependencies = [ "which", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.5.0" @@ -97,8 +86,6 @@ dependencies = [ "capstone-sys", "criterion", "libc", - "macho", - "rayon", ] [[package]] @@ -129,7 +116,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ - "nom 7.1.3", + "nom", ] [[package]] @@ -140,9 +127,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -152,6 +139,33 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "clang-sys" version = "1.7.0" @@ -163,17 +177,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "bitflags 1.3.2", - "textwrap", - "unicode-width", -] - [[package]] name = "clap" version = "4.4.18" @@ -207,24 +210,24 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "criterion" -version = "0.3.6" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" dependencies = [ - "atty", + "anes", "cast", - "clap 2.34.0", + "ciborium", + "clap", "criterion-plot", - "csv", - "itertools", - "lazy_static", + "is-terminal", + "itertools 0.10.5", "num-traits", + "once_cell", "oorandom", "plotters", "rayon", "regex", "serde", - "serde_cbor", "serde_derive", "serde_json", "tinytemplate", @@ -233,12 +236,12 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.5" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools", + "itertools 0.10.5", ] [[package]] @@ -266,37 +269,22 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "cstool" version = "0.1.0" dependencies = [ "capstone", - "clap 4.4.18", + "clap", "log", "stderrlog", ] -[[package]] -name = "csv" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" -dependencies = [ - "csv-core", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "csv-core" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" -dependencies = [ - "memchr", -] - [[package]] name = "either" version = "1.11.0" @@ -321,17 +309,12 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "half" -version = "1.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" - -[[package]] -name = "hermit-abi" -version = "0.1.19" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ - "libc", + "cfg-if", + "crunchy", ] [[package]] @@ -378,7 +361,7 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", "windows-sys", ] @@ -392,6 +375,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -447,16 +439,6 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" -[[package]] -name = "macho" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6febc6e2fc6e59ce078ff24136a624b00ebbc3a4c7178fab55ab592a930c3704" -dependencies = [ - "nom 1.2.4", - "uuid", -] - [[package]] name = "memchr" version = "2.7.2" @@ -469,12 +451,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "nom" -version = "1.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce" - [[package]] name = "nom" version = "7.1.3" @@ -536,9 +512,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" +checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" dependencies = [ "proc-macro2", "syn", @@ -623,7 +599,7 @@ version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.5.0", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -654,16 +630,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde_cbor" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" -dependencies = [ - "half", - "serde", -] - [[package]] name = "serde_derive" version = "1.0.197" @@ -677,9 +643,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", @@ -707,9 +673,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" dependencies = [ "proc-macro2", "quote", @@ -725,15 +691,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thread_local" version = "1.1.8" @@ -760,18 +717,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" - -[[package]] -name = "uuid" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9ff57156caf7e22f37baf3c9d8f6ce8194842c23419dafcb0716024514d162" - [[package]] name = "walkdir" version = "2.5.0" diff --git a/capstone-rs/Cargo.toml b/capstone-rs/Cargo.toml index a7e886f..6adab34 100644 --- a/capstone-rs/Cargo.toml +++ b/capstone-rs/Cargo.toml @@ -20,9 +20,7 @@ capstone-sys = { path = "../capstone-sys", version = "0.16.0", default_features libc = { version = "0.2", default-features = false } [dev-dependencies] -macho = "0.4.1" -criterion = "0.3" -rayon = "1.1" +criterion = "0.5" [[bench]] name = "my_benchmark" diff --git a/capstone-rs/ci/test.sh b/capstone-rs/ci/test.sh index 3a665cc..c90a625 100755 --- a/capstone-rs/ci/test.sh +++ b/capstone-rs/ci/test.sh @@ -50,7 +50,7 @@ CARGO_FEATURE_ARGS=( TARGET="../target" TARGET_COV="${TARGET}/cov" -SIMPLE_RUN_EXAMPLES="${SIMPLE_RUN_EXAMPLES:-demo parallel}" +SIMPLE_RUN_EXAMPLES="${SIMPLE_RUN_EXAMPLES:-demo}" export USER="${USER:-$(id -u -n)}" PASS="PASS" diff --git a/capstone-rs/examples/darwin b/capstone-rs/examples/darwin deleted file mode 100755 index 3f10bad..0000000 Binary files a/capstone-rs/examples/darwin and /dev/null differ diff --git a/capstone-rs/examples/objdump.rs b/capstone-rs/examples/objdump.rs deleted file mode 100644 index cc09f04..0000000 --- a/capstone-rs/examples/objdump.rs +++ /dev/null @@ -1,54 +0,0 @@ -extern crate capstone; -extern crate macho; - -use capstone::prelude::*; -use std::env; -use std::fs; -use std::io::Read; -use std::process; - -fn main() { - let cs = Capstone::new() - .x86() - .mode(arch::x86::ArchMode::Mode64) - .build() - .expect("Failed to create capstone handle"); - - let args: Vec<_> = env::args().collect(); - if args.len() != 2 { - println!("Usage: {} ", args[0]); - return; - } - - let mut fh = fs::File::open(&args[1]).unwrap(); - let mut buf: Vec = Vec::new(); - let _ = fh.read_to_end(&mut buf); - - let header = macho::MachObject::parse(&buf[..]).unwrap(); - // Find the text segment - for segment in header.segments { - if segment.segname == "__TEXT" { - for section in segment.sections { - if section.sectname == "__text" { - let text = &buf[section.offset as usize - ..(u64::from(section.offset) + section.size) as usize]; - match cs.disasm_all(text, section.addr) { - Ok(insns) => { - println!("Got {} instructions", insns.len()); - - for i in insns.iter() { - println!("{}", i); - } - } - Err(err) => { - println!("Error: {}", err); - process::exit(1); - } - } - return; - } - } - } - } - panic!("No __TEXT segment"); -} diff --git a/capstone-rs/examples/parallel.rs b/capstone-rs/examples/parallel.rs deleted file mode 100644 index 6d21bdd..0000000 --- a/capstone-rs/examples/parallel.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! This example shows how to disassemble in parallel. You need a separate `Capstone` struct for -//! each thread. -//! -//! We shard the input by using parallel iterators from the rayon crate. - -use capstone::prelude::*; -use rayon::prelude::*; - -fn main() -> CsResult<()> { - // Closure to create `Capstone` instance - let create_cs = || -> CsResult { - let cs = Capstone::new() - .x86() - .mode(arch::x86::ArchMode::Mode64) - .detail(true) - .build()?; - Ok(cs) - }; - - // Slice of code to disassemble - let input_code: &[&[u8]] = &[ - b"\x55\x48\x8b\x05\xb8\x13\x00\x00\xe9\x14\x9e\x08\x00\x45\x31\xe4", - b"\x90\x41\xe8\x04\x03\x02\x01", - b"\xff\xff\xff\xff\xff", - ]; - - let results: Vec>> = input_code - .par_iter() // iterate in parallel - .map(|bytes| { - // map input byte to output mnemonic - let cs = create_cs()?; - let insns = cs.disasm_all(bytes, 0x1000)?; - let result: Option> = insns - .iter() - .map(|insn| -> Option { Some(insn.mnemonic()?.to_string()) }) - .collect(); - let result = result.ok_or(capstone::Error::CustomError("No mnemonic"))?; - Ok(result) - }) - .collect(); - - println!("{:#?}", results); - - Ok(()) -}