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 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/ntapi/src/winapi_local
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
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.rs71
3 files changed, 77 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..0c8efb2625
--- /dev/null
+++ b/third_party/rust/ntapi/src/winapi_local/um/winnt.rs
@@ -0,0 +1,71 @@
+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(not(target_arch = "aarch64"))]
+IFDEF!{
+use core::arch::asm;
+use crate::ntpebteb::TEB;
+#[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;