-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
46 lines (31 loc) · 862 Bytes
/
build.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
37
38
39
40
41
42
43
44
mod salt;
use std::fs::File;
use std::io::Write;
use rand::Rng;
fn main() -> Result<(), std::io::Error>
{
let mut rng = rand::thread_rng();
let mut xs_gen = salt::XorShift128::from_seed(rng.gen::<u64>(), rng.gen::<u64>());
let salt = format!("{:x}", xs_gen.pick());
let mut file = File::create("src/lib.rs").unwrap();
// Generation of lib.rs
write!(&mut file, "{}", r#"
/*
*
* FILE AUTOGENERATED BY build.rs
*
*/
pub mod asmcalls;
pub mod ntcalls;
pub mod err;
pub mod oncecell;
use oncecell::*;
use ntcalls::*;
// Reexports the assembly direct calls skeletons
// for cleaner use
pub use crate::asmcalls::*;
"#)?;
writeln!(&mut file, "pub static SALT: &str = \"{}\";", salt)?;
writeln!(&mut file, "{}", "pub static NT: OnceCell<NTApi> = OnceCell::new(|| {NTApi::new().unwrap()} );")?;
Ok(())
}