Skip to content

Commit

Permalink
Generate missing build IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
jam1garner committed Apr 19, 2020
1 parent f4669fd commit 640b611
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "linkle"
version = "0.2.9"
version = "0.2.10"
authors = ["Thog <[email protected]>"]
license = "MIT/Apache-2.0"
homepage = "https://github.com/MegatonHammer/linkle/"
Expand Down
8 changes: 4 additions & 4 deletions src/format/nxo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn pad_segment(previous_segment_data: &mut Vec<u8>, offset: usize, segment: &Pro
}
}

fn write_build_id<T>(build_id: &Option<Vec<u8>>, output_writter: &mut T) -> std::io::Result<()>
fn write_build_id<T>(build_id: &Option<Vec<u8>>, output_writter: &mut T, text_data: &[u8]) -> std::io::Result<()>
where
T: Write,
{
Expand All @@ -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(())
Expand Down Expand Up @@ -300,7 +300,7 @@ impl NxoFile {
// Reserved
output_writter.write_u32::<LittleEndian>(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::<LittleEndian>(0)?;
Expand Down Expand Up @@ -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::<LittleEndian>(compressed_code_size)?;
Expand Down

0 comments on commit 640b611

Please sign in to comment.