]> git.proxmox.com Git - rustc.git/blame - vendor/ntapi/src/winapi_local/um/winnt.rs
New upstream version 1.64.0+dfsg1
[rustc.git] / vendor / ntapi / src / winapi_local / um / winnt.rs
CommitLineData
064997fb
FG
1#[cfg(all(feature = "beta", not(target_arch = "aarch64")))]
2use core::arch::asm;
923072b8
FG
3use winapi::shared::basetsd::{DWORD64, SIZE_T, ULONG64};
4use winapi::shared::minwindef::DWORD;
5use winapi::um::winnt::{HANDLE, PVOID};
6#[doc(hidden)]
7#[inline]
8pub const fn UInt32x32To64(a: u32, b: u32) -> u64 {
9 a as u64 * b as u64
10}
064997fb 11#[cfg(all(feature = "beta", not(target_arch = "aarch64")))]
923072b8
FG
12IFDEF!{
13use crate::ntpebteb::TEB;
14#[inline]
064997fb 15#[cfg(target_pointer_width = "64")]
923072b8
FG
16pub unsafe fn _bittest64(Base: *const i64, Offset: i64) -> u8 {
17 let out: u8;
064997fb
FG
18 asm!(
19 "bt {1}, {2}",
20 "setb {0}",
21 out(reg_byte) out,
22 in(reg) Base,
23 in(reg) Offset,
24 options(nostack, pure, readonly),
923072b8
FG
25 );
26 out
27}
28#[inline]
29pub unsafe fn __readfsdword(Offset: DWORD) -> DWORD {
30 let out: u32;
064997fb
FG
31 asm!(
32 "mov {:e}, fs:[{:e}]",
33 lateout(reg) out,
34 in(reg) Offset,
35 options(nostack, pure, readonly),
923072b8
FG
36 );
37 out
38}
39#[inline]
064997fb 40#[cfg(target_pointer_width = "64")]
923072b8
FG
41pub unsafe fn __readgsqword(Offset: DWORD) -> DWORD64 {
42 let out: u64;
064997fb
FG
43 asm!(
44 "mov {}, gs:[{:e}]",
45 lateout(reg) out,
46 in(reg) Offset,
47 options(nostack, pure, readonly),
923072b8
FG
48 );
49 out
50}
51#[inline] #[allow(unused_unsafe)]
52pub unsafe fn NtCurrentTeb() -> *mut TEB {
53 use winapi::um::winnt::NT_TIB;
54 let teb_offset = FIELD_OFFSET!(NT_TIB, _Self) as u32;
55 #[cfg(target_arch = "x86_64")] {
56 __readgsqword(teb_offset) as *mut TEB
57 }
58 #[cfg(target_arch = "x86")] {
59 __readfsdword(teb_offset) as *mut TEB
60 }
61}
62}
63ENUM!{enum MEM_EXTENDED_PARAMETER_TYPE {
64 MemExtendedParameterInvalidType = 0,
65 MemExtendedParameterAddressRequirements = 1,
66 MemExtendedParameterNumaNode = 2,
67 MemExtendedParameterPartitionHandle = 3,
68 MemExtendedParameterMax = 4,
69}}
70pub type PMEM_EXTENDED_PARAMETER_TYPE = *mut MEM_EXTENDED_PARAMETER_TYPE;
71UNION!{union MEM_EXTENDED_PARAMETER_u {
72 ULong64: DWORD64,
73 Pointer: PVOID,
74 Size: SIZE_T,
75 Handle: HANDLE,
76 ULong: DWORD,
77}}
78STRUCT!{struct MEM_EXTENDED_PARAMETER {
79 BitFields: ULONG64,
80 u: MEM_EXTENDED_PARAMETER_u,
81}}
82BITFIELD!{MEM_EXTENDED_PARAMETER BitFields: ULONG64 [
83 Type set_Type[0..8],
84 Reserved set_Reserved[8..64],
85]}
86pub type PMEM_EXTENDED_PARAMETER = *mut MEM_EXTENDED_PARAMETER;