Skip to content

Commit

Permalink
build: ➖ Use windows-sys crate instead of windows crate
Browse files Browse the repository at this point in the history
  • Loading branch information
oberrich committed Apr 17, 2024
1 parent 5dda2bc commit aa29ecb
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 38 deletions.
66 changes: 49 additions & 17 deletions Cargo.lock

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

14 changes: 5 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,15 @@ targets = ["x86_64-pc-windows-msvc"]
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]

[build-dependencies]
windows.features = ["Win32_Foundation"]
windows-targets = "0.52.0"
windows.version = "0.52.0"

# optional
[build-dependencies] # optional
regex = { version = "1.10.3", optional = true }
bindgen = { version = "0.69.4", optional = true }
chrono = { version = "0.4.37", optional = true }

[dependencies.windows-sys]
version = "0.27.0"
features = ["Win32_Foundation"]

[dependencies]
windows.features = ["Win32_Foundation"]
windows-targets = "0.52.0"
windows.version = "0.52.0"
nt-string = "0.1.1"
cty = "0.2.2"
2 changes: 1 addition & 1 deletion deps/phnt-nightly
Submodule phnt-nightly updated 1 files
+1 −0 ntmmapi.h
12 changes: 6 additions & 6 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ mod regen {
impl Default for BindgenConfig {
fn default() -> Self {
let type_overrides: HashMap<_, _> = HashMap::from([
("NTSTATUS", "windows::Win32::Foundation::NTSTATUS"),
("BOOL" , "windows::Win32::Foundation::BOOL"),
("BOOLEAN" , "windows::Win32::Foundation::BOOLEAN"),
("NTSTATUS", "windows_sys::Win32::Foundation::NTSTATUS"),
("BOOL" , "windows_sys::Win32::Foundation::BOOL"),
("BOOLEAN" , "windows_sys::Win32::Foundation::BOOLEAN"),
( "UNICODE_STRING", "nt_string::unicode_string::NtUnicodeString"),
("_UNICODE_STRING", "nt_string::unicode_string::NtUnicodeString"),
])
Expand Down Expand Up @@ -146,7 +146,7 @@ mod regen {

pub fn main() {
std::process::Command::new("git")
.args(["submodule", "update", "--remote", "--recursive"])
.args(["submodule", "update", "--init", "--remote", "--recursive"])
.output()
.expect("phnt/build.rs: failed to update the `phnt-nightly` submodule!");

Expand All @@ -161,9 +161,9 @@ mod regen {
BindgenConfig::default()
.generate_bindings()
.expect("Unable to generate bindings!")
.write_to_file(out_path)
.write_to_file(out_path.clone())
.expect("Unable to write bindings");

println!("Generated bindings successfully.");
println!("cargo:info=Wrote phnt bindings to `{}`", out_path.display());
}
}
11 changes: 6 additions & 5 deletions src/ffi/generated.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* automatically generated by rust-bindgen 0.69.4 */

// Generated at 2024-04-10 11:51:38.944305 +02:00
// Generated at 2024-04-17 08:55:54.310885200 +02:00
use cty;
pub use nt_string::unicode_string::NtUnicodeString as UNICODE_STRING;
pub use nt_string::unicode_string::NtUnicodeString as _UNICODE_STRING;
pub use windows::Win32::Foundation::BOOL;
pub use windows::Win32::Foundation::BOOLEAN;
pub use windows::Win32::Foundation::NTSTATUS;
pub use nt_string::unicode_string::NtUnicodeString as UNICODE_STRING;
pub use windows_sys::Win32::Foundation::BOOL;
pub use windows_sys::Win32::Foundation::BOOLEAN;
pub use windows_sys::Win32::Foundation::NTSTATUS;

#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
Expand Down Expand Up @@ -1049,6 +1049,7 @@ pub const BCD_OBJECT_DESCRIPTION_VERSION: u32 = 1;
pub const BCD_ELEMENT_DESCRIPTION_VERSION: u32 = 1;
pub const PAGE_ENCLAVE_NO_CHANGE: u32 = 536870912;
pub const MEM_DOS_LIM: u32 = 1073741824;
pub const SEC_DRIVER_IMAGE: u32 = 1048576;
pub const SEC_BASED: u32 = 2097152;
pub const SEC_NO_CHANGE: u32 = 4194304;
pub const SEC_GLOBAL: u32 = 536870912;
Expand Down

0 comments on commit aa29ecb

Please sign in to comment.