summaryrefslogtreecommitdiffstats
path: root/third_party/rust/ntapi/src/winapi_local
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/ntapi/src/winapi_local
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/ntapi/src/winapi_local')
-rw-r--r--third_party/rust/ntapi/src/winapi_local/um.rs2
-rw-r--r--third_party/rust/ntapi/src/winapi_local/um/winioctl.rs4
-rw-r--r--third_party/rust/ntapi/src/winapi_local/um/winnt.rs86
3 files changed, 92 insertions, 0 deletions
diff --git a/third_party/rust/ntapi/src/winapi_local/um.rs b/third_party/rust/ntapi/src/winapi_local/um.rs
new file mode 100644
index 0000000000..5f862d511a
--- /dev/null
+++ b/third_party/rust/ntapi/src/winapi_local/um.rs
@@ -0,0 +1,2 @@
+pub(crate) mod winioctl;
+pub mod winnt;
diff --git a/third_party/rust/ntapi/src/winapi_local/um/winioctl.rs b/third_party/rust/ntapi/src/winapi_local/um/winioctl.rs
new file mode 100644
index 0000000000..da490269a0
--- /dev/null
+++ b/third_party/rust/ntapi/src/winapi_local/um/winioctl.rs
@@ -0,0 +1,4 @@
+#[inline]
+pub(crate) const fn CTL_CODE(DeviceType: u32, Function: u32, Method: u32, Access: u32) -> u32 {
+ (DeviceType << 16) | (Access << 14) | (Function << 2) | Method
+}
diff --git a/third_party/rust/ntapi/src/winapi_local/um/winnt.rs b/third_party/rust/ntapi/src/winapi_local/um/winnt.rs
new file mode 100644
index 0000000000..5c4f7b2fb1
--- /dev/null
+++ b/third_party/rust/ntapi/src/winapi_local/um/winnt.rs
@@ -0,0 +1,86 @@
+#[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};
+#[doc(hidden)]
+#[inline]
+pub const fn UInt32x32To64(a: u32, b: u32) -> u64 {
+ a as u64 * b as u64
+}
+#[cfg(all(feature = "beta", not(target_arch = "aarch64")))]
+IFDEF!{
+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!(
+ "mov {:e}, fs:[{:e}]",
+ lateout(reg) out,
+ in(reg) Offset,
+ options(nostack, pure, readonly),
+ );
+ out
+}
+#[inline]
+#[cfg(target_pointer_width = "64")]
+pub unsafe fn __readgsqword(Offset: DWORD) -> DWORD64 {
+ let out: u64;
+ asm!(
+ "mov {}, gs:[{:e}]",
+ lateout(reg) out,
+ in(reg) Offset,
+ options(nostack, pure, readonly),
+ );
+ out
+}
+#[inline] #[allow(unused_unsafe)]
+pub unsafe fn NtCurrentTeb() -> *mut TEB {
+ use winapi::um::winnt::NT_TIB;
+ let teb_offset = FIELD_OFFSET!(NT_TIB, _Self) as u32;
+ #[cfg(target_arch = "x86_64")] {
+ __readgsqword(teb_offset) as *mut TEB
+ }
+ #[cfg(target_arch = "x86")] {
+ __readfsdword(teb_offset) as *mut TEB
+ }
+}
+}
+ENUM!{enum MEM_EXTENDED_PARAMETER_TYPE {
+ MemExtendedParameterInvalidType = 0,
+ MemExtendedParameterAddressRequirements = 1,
+ MemExtendedParameterNumaNode = 2,
+ MemExtendedParameterPartitionHandle = 3,
+ MemExtendedParameterMax = 4,
+}}
+pub type PMEM_EXTENDED_PARAMETER_TYPE = *mut MEM_EXTENDED_PARAMETER_TYPE;
+UNION!{union MEM_EXTENDED_PARAMETER_u {
+ ULong64: DWORD64,
+ Pointer: PVOID,
+ Size: SIZE_T,
+ Handle: HANDLE,
+ ULong: DWORD,
+}}
+STRUCT!{struct MEM_EXTENDED_PARAMETER {
+ BitFields: ULONG64,
+ u: MEM_EXTENDED_PARAMETER_u,
+}}
+BITFIELD!{MEM_EXTENDED_PARAMETER BitFields: ULONG64 [
+ Type set_Type[0..8],
+ Reserved set_Reserved[8..64],
+]}
+pub type PMEM_EXTENDED_PARAMETER = *mut MEM_EXTENDED_PARAMETER;