From 2148881c30e8da6a3ff585efd1c7d8ad125ccd2c Mon Sep 17 00:00:00 2001
From: MSxDOS <15524350+MSxDOS@users.noreply.github.com>
Date: Sat, 24 Sep 2022 00:24:20 +0300
Subject: [PATCH] Remove the 'beta' feature and everything related to it
---
Cargo.toml | 3 ---
README.md | 2 +-
appveyor.yml | 8 ++------
src/lib.rs | 19 -------------------
src/ntpsapi.rs | 8 ++++----
src/ntrtl.rs | 13 ++++---------
src/winapi_local/um/winnt.rs | 19 ++-----------------
7 files changed, 13 insertions(+), 59 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 206e5c9..d63ff19 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,6 @@ edition = "2018"
[package.metadata.docs.rs]
default-target = "x86_64-pc-windows-msvc"
-features = ["beta"]
targets = ["aarch64-pc-windows-msvc", "i686-pc-windows-msvc", "x86_64-pc-windows-msvc"]
[dependencies.winapi]
@@ -27,5 +26,3 @@ func-types = []
impl-default = ["winapi/impl-default"]
user = []
kernel = []
-beta = []
-nightly = ["beta"]
diff --git a/README.md b/README.md
index d438de3..5011acc 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 beta compiler.
+1.64
[appveyor_link]: https://ci.appveyor.com/project/MSxDOS/ntapi
[appveyor_badge]: https://ci.appveyor.com/api/projects/status/i1fcmm0c5b7c6b6u/branch/master?svg=true
diff --git a/appveyor.yml b/appveyor.yml
index ebbb7eb..ce32f0b 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -28,11 +28,7 @@ install:
)
build_script:
- - if "%channel%"=="nightly" (
- cargo test --verbose --color always --features "func-types impl-default nightly user"
- ) else (
- cargo test --verbose --color always --features "func-types impl-default user"
- )
+ - cargo test --verbose --color always --features "func-types impl-default user"
- if defined aarch64 (
- cargo test --verbose --color always --features "func-types impl-default nightly user" --target aarch64-pc-windows-msvc --no-run
+ cargo test --verbose --color always --features "func-types impl-default user" --target aarch64-pc-windows-msvc --no-run
)
diff --git a/src/lib.rs b/src/lib.rs
index 6b06b6c..0f7708c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,26 +3,7 @@
//! **`impl-default`** -- Implement [`Default`] for structs and unions.
//! **`user`** *(default)* -- Link to `ntdll`.
//! **`kernel`** -- Link to `ntoskrnl` on MSVC targets.
-//! **`beta`** -- Unlock unstable features that require a beta compiler:
-//! - [`NtCurrentTeb`]
-//! - [`__readfsdword`]
-//! - [`__readgsqword`]
-//! - [`_bittest64`]
-//! - [`NtCurrentPeb`]
-//! - [`NtCurrentProcessId`]
-//! - [`NtCurrentThreadId`]
-//! - [`RtlProcessHeap`]
-//! - [`RtlCheckBit`] implementation using [`_bittest64`] on x86_64.
//!
-//! [`NtCurrentTeb`]: winapi_local/um/winnt/fn.NtCurrentTeb.html
-//! [`__readfsdword`]: winapi_local/um/winnt/fn.__readfsdword.html
-//! [`__readgsqword`]: winapi_local/um/winnt/fn.__readgsqword.html
-//! [`_bittest64`]: winapi_local/um/winnt/fn._bittest64.html
-//! [`NtCurrentPeb`]: ntpsapi/fn.NtCurrentPeb.html
-//! [`NtCurrentProcessId`]: ntpsapi/fn.NtCurrentProcessId.html
-//! [`NtCurrentThreadId`]: ntpsapi/fn.NtCurrentThreadId.html
-//! [`RtlProcessHeap`]: ntrtl/fn.RtlProcessHeap.html
-//! [`RtlCheckBit`]: ntrtl/fn.RtlCheckBit.html
//! [fn_ptr]: https://doc.rust-lang.org/reference/types.html#function-pointer-types
//! [`Default`]: https://doc.rust-lang.org/std/default/trait.Default.html#tymethod.default
#![cfg(all(windows, any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))]
diff --git a/src/ntpsapi.rs b/src/ntpsapi.rs
index f46eeb7..2a0d3cd 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 = "beta", not(target_arch = "aarch64")))]
+#[cfg(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 = "beta", not(target_arch = "aarch64")))]
+#[inline] #[cfg(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 = "beta", not(target_arch = "aarch64")))]
+#[inline] #[cfg(not(target_arch = "aarch64"))]
pub unsafe fn NtCurrentProcessId() -> HANDLE {
(*NtCurrentTeb()).ClientId.UniqueProcess
}
-#[inline] #[cfg(all(feature = "beta", not(target_arch = "aarch64")))]
+#[inline] #[cfg(not(target_arch = "aarch64"))]
pub unsafe fn NtCurrentThreadId() -> HANDLE {
(*NtCurrentTeb()).ClientId.UniqueThread
}
diff --git a/src/ntrtl.rs b/src/ntrtl.rs
index 2eed356..abbc386 100644
--- a/src/ntrtl.rs
+++ b/src/ntrtl.rs
@@ -2196,7 +2196,7 @@ EXTERN!{extern "system" {
MakeReadOnly: BOOLEAN,
);
}}
-#[inline] #[cfg(all(feature = "beta", not(target_arch = "aarch64")))]
+#[inline] #[cfg(not(target_arch = "aarch64"))]
pub unsafe fn RtlProcessHeap() -> PVOID {
use crate::ntpsapi::NtCurrentPeb;
(*NtCurrentPeb()).ProcessHeap
@@ -2944,15 +2944,10 @@ EXTERN!{extern "system" {
}}
#[inline]
pub unsafe fn RtlCheckBit(BitMapHeader: &RTL_BITMAP, BitPosition: ULONG) -> u8 {
- #[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(target_arch = "x86_64")] {
+ core::arch::x86_64::_bittest64(BitMapHeader.Buffer as *const i64, BitPosition as i64)
}
- #[cfg(any(
- target_arch = "x86",
- all(target_arch = "x86_64", not(feature = "beta")),
- target_arch = "aarch64",
- ))] {
+ #[cfg(any(target_arch = "x86", 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 5c4f7b2..0c8efb2 100644
--- a/src/winapi_local/um/winnt.rs
+++ b/src/winapi_local/um/winnt.rs
@@ -1,5 +1,3 @@
-#[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};
@@ -8,24 +6,11 @@ use winapi::um::winnt::{HANDLE, PVOID};
pub const fn UInt32x32To64(a: u32, b: u32) -> u64 {
a as u64 * b as u64
}
-#[cfg(all(feature = "beta", not(target_arch = "aarch64")))]
+#[cfg(not(target_arch = "aarch64"))]
IFDEF!{
+use core::arch::asm;
use crate::ntpebteb::TEB;
#[inline]
-#[cfg(target_pointer_width = "64")]
-pub unsafe fn _bittest64(Base: *const i64, Offset: i64) -> u8 {
- let out: u8;
- asm!(
- "bt {1}, {2}",
- "setb {0}",
- out(reg_byte) out,
- in(reg) Base,
- in(reg) Offset,
- options(nostack, pure, readonly),
- );
- out
-}
-#[inline]
pub unsafe fn __readfsdword(Offset: DWORD) -> DWORD {
let out: u32;
asm!(