-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathusage.rs
36 lines (26 loc) · 1.25 KB
/
usage.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//! A small and basic sample of how to use the library's functionality, without needing an Electron app present.
use electron_hardener::{patcher::ElectronOption, BinaryError, ElectronApp, Fuse, PatcherError};
fn main() {
let mut application_bytes = {
let mut bytes = include_bytes!("./fake_electron_fuses.bin").to_vec();
bytes.extend_from_slice(include_bytes!("./fake_electron_flags.bin"));
bytes
};
let mut app = ElectronApp::from_bytes(&mut application_bytes).unwrap();
let fuse = Fuse::RunAsNode;
let original_status = app.get_fuse_status(fuse).unwrap();
println!("The unmodified fuse status is `{:?}`", original_status);
println!("Removing RUN_AS_NODE functionality");
app.set_fuse_status(fuse, false).unwrap();
let new_status = app.get_fuse_status(fuse).unwrap();
println!("The new fuse status is now `{:?}`", new_status);
let flag = ElectronOption::JsFlags;
println!("Removing {:?} functionality from the app", flag);
app.patch_option(flag).unwrap();
match app.patch_option(flag) {
Err(PatcherError::Binary(BinaryError::ElectronOptionNotPresent(_))) => {
println!("Removed the Electron flag!")
}
_ => println!("Didn't remove the flag!"),
}
}