From 08f5c4633962d6d79ee60f9038391727dd5f4884 Mon Sep 17 00:00:00 2001 From: oberrich <6305520+oberrich@users.noreply.github.com> Date: Wed, 10 Apr 2024 12:35:44 +0200 Subject: [PATCH] Move non-phnt extensions to `ext` namespace --- Cargo.lock | 2 +- src/ffi/generated.rs | 6 +++--- src/lib.rs | 44 ++++++++++++++++++++++++-------------------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 578d4b8..0f8ef3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -297,7 +297,7 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "phnt" -version = "0.0.14" +version = "0.0.15" dependencies = [ "bindgen", "chrono", diff --git a/src/ffi/generated.rs b/src/ffi/generated.rs index 40868c1..47d69cc 100644 --- a/src/ffi/generated.rs +++ b/src/ffi/generated.rs @@ -2,11 +2,11 @@ // Generated at 2024-04-10 11:51:38.944305 +02:00 use cty; -pub use windows::Win32::Foundation::BOOLEAN as BOOLEAN; -pub use windows::Win32::Foundation::NTSTATUS as NTSTATUS; 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 as BOOL; +pub use windows::Win32::Foundation::BOOL; +pub use windows::Win32::Foundation::BOOLEAN; +pub use windows::Win32::Foundation::NTSTATUS; #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] diff --git a/src/lib.rs b/src/lib.rs index 3ef23a7..5ceae90 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,18 +1,25 @@ #![doc = include_str!("../README.md")] +#![allow( + warnings, + unused, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] // MIT License -// +// // Copyright (c) 2024 oberrich -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -20,22 +27,19 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -// -#[allow( - warnings, - unused, - non_snake_case, - non_camel_case_types, - non_upper_case_globals -)] +// + pub mod ffi { // use vendored `generated.rs` for docs.rs - #[cfg(feature="docsrs")] + #[cfg(feature = "docsrs")] include!("ffi/generated.rs"); - #[cfg(not(feature="docsrs"))] + #[cfg(not(feature = "docsrs"))] include!(concat!(env!("OUT_DIR"), "\\generated.rs")); +} +pub mod ext { + use crate::ffi::*; use std::arch::asm; #[macro_export] @@ -52,12 +56,12 @@ pub mod ffi { } macro_rules! FIELD_OFFSET { - ($_type:ty, $field:ident$(.$cfields:ident)*) => {{ - let obj = core::mem::MaybeUninit::<$_type>::uninit(); - let base = obj.as_ptr(); - unsafe { core::ptr::addr_of!((*base).$field$(.$cfields)*) as usize - base as usize } - }}; - } + ($_type:ty, $field:ident$(.$cfields:ident)*) => {{ + let obj = core::mem::MaybeUninit::<$_type>::uninit(); + let base = obj.as_ptr(); + unsafe { core::ptr::addr_of!((*base).$field$(.$cfields)*) as usize - base as usize } + }}; + } #[inline] pub unsafe fn __readfsdword(offset: u32) -> usize {