diff --git a/Cargo.toml b/Cargo.toml index 7f6213c..6bee891 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" [package.metadata.docs.rs] default-target = "x86_64-pc-windows-msvc" -features = ["nightly"] +features = ["beta"] targets = ["aarch64-pc-windows-msvc", "i686-pc-windows-msvc", "x86_64-pc-windows-msvc"] [dependencies.winapi] @@ -27,4 +27,5 @@ func-types = [] impl-default = ["winapi/impl-default"] user = [] kernel = [] -nightly = [] +beta = [] +nightly = ["beta"] \ No newline at end of file diff --git a/README.md b/README.md index 10ddf45..7ae73ee 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Rust FFI bindings for Native API. Mostly based on Process Hacker [phnt](https://github.com/processhacker/processhacker/tree/master/phnt) headers as the most complete source of bindings to be found. The comments there also contain useful information on how to use specific things. ### Minimum supported Rust -Always the latest stable. Some [features][docs_link] require a nightly compiler. +Always the latest stable. Some [features][docs_link] require a beta compiler. [travis_link]: https://travis-ci.org/MSxDOS/ntapi [travis_badge]: https://travis-ci.org/MSxDOS/ntapi.svg?branch=master diff --git a/src/lib.rs b/src/lib.rs index e6cd5fa..30c5458 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ //! **`impl-default`** -- Implement [`Default`] for structs and unions.
//! **`user`** *(default)* -- Link to `ntdll`.
//! **`kernel`** -- Link to `ntoskrnl` on MSVC targets.
-//! **`nightly`** -- Unlock unstable features that require a nightly compiler: +//! **`beta`** -- Unlock unstable features that require a beta compiler: //! - [`NtCurrentTeb`] //! - [`__readfsdword`] //! - [`__readgsqword`] @@ -30,7 +30,6 @@ #![deny(unused, unused_qualifications)] #![warn(unused_attributes)] #![allow(bad_style, overflowing_literals, unused_macros, clippy::cast_lossless, clippy::cast_ptr_alignment, clippy::len_without_is_empty, clippy::trivially_copy_pass_by_ref, clippy::unreadable_literal)] -#![cfg_attr(feature = "nightly", feature(llvm_asm))] #[doc(hidden)] pub extern crate core as _core; #[macro_use] diff --git a/src/ntpsapi.rs b/src/ntpsapi.rs index 938d2ee..b2ba28a 100644 --- a/src/ntpsapi.rs +++ b/src/ntpsapi.rs @@ -19,7 +19,7 @@ use winapi::um::winnt::{ PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY, PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY, PROCESS_MITIGATION_SYSTEM_CALL_FILTER_POLICY, PSECURITY_QUALITY_OF_SERVICE, }; -#[cfg(all(feature = "nightly", not(target_arch = "aarch64")))] +#[cfg(all(feature = "beta", not(target_arch = "aarch64")))] use crate::winapi_local::um::winnt::NtCurrentTeb; pub const GDI_HANDLE_BUFFER_SIZE32: usize = 34; pub const GDI_HANDLE_BUFFER_SIZE64: usize = 60; @@ -932,7 +932,7 @@ pub const NtCurrentThread: HANDLE = -2isize as *mut c_void; pub const ZwCurrentThread: HANDLE = NtCurrentThread; pub const NtCurrentSession: HANDLE = -3isize as *mut c_void; pub const ZwCurrentSession: HANDLE = NtCurrentSession; -#[inline] #[cfg(all(feature = "nightly", not(target_arch = "aarch64")))] +#[inline] #[cfg(all(feature = "beta", not(target_arch = "aarch64")))] pub unsafe fn NtCurrentPeb() -> PPEB { (*NtCurrentTeb()).ProcessEnvironmentBlock } @@ -940,11 +940,11 @@ pub const NtCurrentProcessToken: HANDLE = -4isize as *mut c_void; pub const NtCurrentThreadToken: HANDLE = -5isize as *mut c_void; pub const NtCurrentEffectiveToken: HANDLE = -6isize as *mut c_void; pub const NtCurrentSilo: HANDLE = -1isize as *mut c_void; -#[inline] #[cfg(all(feature = "nightly", not(target_arch = "aarch64")))] +#[inline] #[cfg(all(feature = "beta", not(target_arch = "aarch64")))] pub unsafe fn NtCurrentProcessId() -> HANDLE { (*NtCurrentTeb()).ClientId.UniqueProcess } -#[inline] #[cfg(all(feature = "nightly", not(target_arch = "aarch64")))] +#[inline] #[cfg(all(feature = "beta", not(target_arch = "aarch64")))] pub unsafe fn NtCurrentThreadId() -> HANDLE { (*NtCurrentTeb()).ClientId.UniqueThread } diff --git a/src/ntrtl.rs b/src/ntrtl.rs index afbbb16..9dfa19f 100644 --- a/src/ntrtl.rs +++ b/src/ntrtl.rs @@ -2196,7 +2196,7 @@ EXTERN!{extern "system" { MakeReadOnly: BOOLEAN, ); }} -#[inline] #[cfg(all(feature = "nightly", not(target_arch = "aarch64")))] +#[inline] #[cfg(all(feature = "beta", not(target_arch = "aarch64")))] pub unsafe fn RtlProcessHeap() -> PVOID { use crate::ntpsapi::NtCurrentPeb; (*NtCurrentPeb()).ProcessHeap @@ -2944,13 +2944,13 @@ EXTERN!{extern "system" { }} #[inline] pub unsafe fn RtlCheckBit(BitMapHeader: &RTL_BITMAP, BitPosition: ULONG) -> u8 { - #[cfg(all(target_arch = "x86_64", feature = "nightly"))] { + #[cfg(all(target_arch = "x86_64", feature = "beta"))] { use crate::winapi_local::um::winnt::_bittest64; _bittest64(BitMapHeader.Buffer as *const i64, BitPosition as i64) } #[cfg(any( target_arch = "x86", - all(target_arch = "x86_64", not(feature = "nightly")), + all(target_arch = "x86_64", not(feature = "beta")), target_arch = "aarch64", ))] { (*BitMapHeader.Buffer.offset(BitPosition as isize / 32) >> (BitPosition % 32) & 1) as u8 diff --git a/src/winapi_local/um/winnt.rs b/src/winapi_local/um/winnt.rs index 66a4c2a..653adf9 100644 --- a/src/winapi_local/um/winnt.rs +++ b/src/winapi_local/um/winnt.rs @@ -1,3 +1,5 @@ +#[cfg(all(feature = "beta", not(target_arch = "aarch64")))] +use core::arch::asm; use winapi::shared::basetsd::{DWORD64, SIZE_T, ULONG64}; use winapi::shared::minwindef::DWORD; use winapi::um::winnt::{HANDLE, PVOID}; @@ -6,40 +8,36 @@ use winapi::um::winnt::{HANDLE, PVOID}; pub const fn UInt32x32To64(a: u32, b: u32) -> u64 { a as u64 * b as u64 } -#[cfg(all(feature = "nightly", not(target_arch = "aarch64")))] +#[cfg(all(feature = "beta", not(target_arch = "aarch64")))] IFDEF!{ use crate::ntpebteb::TEB; #[inline] pub unsafe fn _bittest64(Base: *const i64, Offset: i64) -> u8 { let out: u8; - llvm_asm!("bt $1, $2; setb $0" - : "=r"(out) - : "*m"(Base), "r"(Offset) - : "cc" - : "intel" - ); + asm!( + "bt {1}, {2}", + "setb {0}", + out(reg_byte) out, + in(reg) Base, + in(reg) Offset); out } #[inline] pub unsafe fn __readfsdword(Offset: DWORD) -> DWORD { let out: u32; - llvm_asm!("mov $0, fs:[$1]" - : "=r"(out) - : "ri"(Offset) - : - : "intel" - ); + asm!( + "mov {0:e}, fs:[{1:e}]", + out(reg) out, + in(reg) Offset); out } #[inline] pub unsafe fn __readgsqword(Offset: DWORD) -> DWORD64 { let out: u64; - llvm_asm!("mov $0, gs:[$1]" - : "=r"(out) - : "ri"(Offset) - : - : "intel" - ); + asm!( + "mov {0}, gs:[{1:e}]", + out(reg) out, + in(reg) Offset); out } #[inline] #[allow(unused_unsafe)]