diff --git a/deps/phnt-nightly b/deps/phnt-nightly index 0e71500..5175c7a 160000 --- a/deps/phnt-nightly +++ b/deps/phnt-nightly @@ -1 +1 @@ -Subproject commit 0e715005fcc7a66fcdbc3fbdd8602ef1d5c20371 +Subproject commit 5175c7a7c61a83d56c194714b2a92da9d28cc2dd diff --git a/src/build.rs b/src/build.rs index 0911d64..a1733a7 100644 --- a/src/build.rs +++ b/src/build.rs @@ -93,7 +93,7 @@ mod regen { let mut raw_lines = vec![ format!("// Generated at {}", chrono::offset::Local::now()), - format!("#[cfg(not(target_arch = \"{}\"))]", std::env::consts::ARCH), + format!("#[cfg(not(target_arch = \"{}\"))]", std::env::var("CARGO_CFG_TARGET_ARCH").unwrap()), format!("compile_error!(\"These bindings can only be used on `{}` architectures. To generate bindings for your target architecture, consider using the `regenerate` feature.\");", std::env::consts::ARCH), "".into(), "use cty;".into(), @@ -173,7 +173,10 @@ mod regen { "\\deps\\phnt-nightly" )); - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("generated.rs"); + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join(format!( + "{}_bindgen.rs", + std::env::var("CARGO_CFG_TARGET_ARCH").unwrap() + )); BindgenConfig::default() .generate_bindings() diff --git a/src/lib.rs b/src/lib.rs index 5fa6249..8467314 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,7 +36,13 @@ pub mod ffi { // use vendored bindings (only available for `x86_64` arch) #[cfg_attr(docsrs, doc(cfg(not(feature = "regenerate"))))] #[cfg(all(not(feature = "regenerate"), target_arch = "x86_64"))] - include!("ffi/generated.rs"); + include!("ffi/x86_64_bindgen.rs"); + #[cfg_attr(docsrs, doc(cfg(not(feature = "regenerate"))))] + #[cfg(all(not(feature = "regenerate"), target_arch = "x86"))] + include!("ffi/i686_bindgen.rs"); + #[cfg_attr(docsrs, doc(cfg(not(feature = "regenerate"))))] + #[cfg(all(not(feature = "regenerate"), target_arch = "aarch64"))] + include!("ffi/aarch64_bindgen.rs"); // use re-generated bindings #[cfg_attr(docsrs, doc(cfg(feature = "regenerate")))] @@ -73,6 +79,12 @@ pub mod ext { out } + #[inline] + #[cfg(target_arch = "aarch64")] + pub unsafe fn __readgsqword(offset: u32) -> usize { + 0usize + } + #[inline] pub unsafe fn NtCurrentTeb() -> *mut TEB { const TEB_OFFSET: u32 = mem::offset_of!(NT_TIB, Self_) as u32; @@ -80,6 +92,9 @@ pub mod ext { __readgsqword(TEB_OFFSET) as *mut TEB } else if cfg!(target_arch = "x86") { __readfsdword(TEB_OFFSET) as *mut TEB + } else if cfg!(target_arch = "aarch64") { + let p: *mut TEB = core::ptr::null(); + p } else { unimplemented!("target architecture not implemented yet") }