-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01def0e
commit 3c64f62
Showing
12 changed files
with
4,098 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use libsui::Elf; | ||
use libsui::Macho; | ||
use libsui::PortableExecutable; | ||
|
||
use libsui::utils; | ||
|
||
const CHANNELS: [&str; 4] = ["stable", "lts", "canary", "rc"]; | ||
const SECTION: &str = "denover"; | ||
|
||
pub fn patchver<W: std::io::Write>( | ||
exe: Vec<u8>, | ||
data: String, | ||
out: &mut W, | ||
) -> Result<(), Box<dyn std::error::Error>> { | ||
if !CHANNELS.contains(&data.as_str()) { | ||
panic!("Invalid channel. Expected one of: stable, lts, canary, rc"); | ||
} | ||
|
||
let data = data.as_bytes().to_vec(); | ||
if utils::is_pe(&exe) { | ||
PortableExecutable::from(&exe)? | ||
.write_resource(SECTION, data)? | ||
.build(out)?; | ||
} else if utils::is_macho(&exe) { | ||
Macho::from(exe)? | ||
.write_section(SECTION, data)? | ||
.build_and_sign(out)?; | ||
} else if utils::is_elf(&exe) { | ||
Elf::new(&exe).append(SECTION, &data, out)?; | ||
} else { | ||
panic!("Unsupported file format"); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target/ |
Oops, something went wrong.