From 640b6111462d2002bc48f470c0022193bf9e455f Mon Sep 17 00:00:00 2001 From: jam1garner Date: Sun, 19 Apr 2020 03:22:02 -0400 Subject: [PATCH] Generate missing build IDs --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/format/nxo.rs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a876df3..60914bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -405,7 +405,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "linkle" -version = "0.2.9" +version = "0.2.10" dependencies = [ "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 9869677..116a2d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "linkle" -version = "0.2.9" +version = "0.2.10" authors = ["Thog "] license = "MIT/Apache-2.0" homepage = "https://github.com/MegatonHammer/linkle/" diff --git a/src/format/nxo.rs b/src/format/nxo.rs index 8066cc4..f85fd96 100644 --- a/src/format/nxo.rs +++ b/src/format/nxo.rs @@ -48,7 +48,7 @@ fn pad_segment(previous_segment_data: &mut Vec, offset: usize, segment: &Pro } } -fn write_build_id(build_id: &Option>, output_writter: &mut T) -> std::io::Result<()> +fn write_build_id(build_id: &Option>, output_writter: &mut T, text_data: &[u8]) -> std::io::Result<()> where T: Write, { @@ -66,7 +66,7 @@ where output_writter.write_all(&build_id_data[0x10..])?; } None => { - output_writter.write_all(&[0; 0x20])?; + output_writter.write_all(&utils::calculate_sha256(text_data)?[..0x20])?; } } Ok(()) @@ -300,7 +300,7 @@ impl NxoFile { // Reserved output_writter.write_u32::(0)?; - write_build_id(&self.build_id, output_writter)?; + write_build_id(&self.build_id, output_writter, &code)?; // TODO: DSO Module Offset (unused) output_writter.write_u32::(0)?; @@ -555,7 +555,7 @@ impl NxoFile { } } - write_build_id(&self.build_id, output_writter)?; + write_build_id(&self.build_id, output_writter, &code)?; // Compressed size output_writter.write_u32::(compressed_code_size)?;