Add aarch64-pc-windows-msvc support (#5)

This commit is contained in:
Alexander Ovchinnikov
2020-10-23 12:38:12 +02:00
committed by GitHub
parent 433abdb8ec
commit b206d2a951
9 changed files with 2460 additions and 23 deletions
+1 -1
View File
@@ -25,7 +25,7 @@
//! [`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")))]
#![cfg(all(windows, any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))]
#![no_std]
#![deny(unused, unused_qualifications)]
#![warn(unused_attributes)]
+3 -3
View File
@@ -1738,7 +1738,7 @@ STRUCT!{struct SYSTEM_IMAGE_FILE_EXECUTION_OPTIONS_INFORMATION {
}}
pub type PSYSTEM_IMAGE_FILE_EXECUTION_OPTIONS_INFORMATION =
*mut SYSTEM_IMAGE_FILE_EXECUTION_OPTIONS_INFORMATION;
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
STRUCT!{struct SYSTEM_VERIFIER_INFORMATION_EX {
VerifyMode: ULONG,
OptionChanges: ULONG,
@@ -2780,7 +2780,7 @@ pub const USER_SHARED_DATA: *const KUSER_SHARED_DATA = 0x7ffe0000 as *const _;
pub unsafe fn NtGetTickCount64() -> ULONGLONG {
#[allow(deprecated)] //fixme
let mut tick_count: ULARGE_INTEGER = uninitialized();
#[cfg(target_arch = "x86_64")] {
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] {
*tick_count.QuadPart_mut() = (*USER_SHARED_DATA).u.TickCountQuad;
}
#[cfg(target_arch = "x86")] {
@@ -2801,7 +2801,7 @@ pub unsafe fn NtGetTickCount64() -> ULONGLONG {
}
#[inline]
pub unsafe fn NtGetTickCount() -> ULONG {
#[cfg(target_arch = "x86_64")] {
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] {
(((*USER_SHARED_DATA).u.TickCountQuad * (*USER_SHARED_DATA).TickCountMultiplier as u64)
>> 24) as u32
}
+2 -2
View File
@@ -68,7 +68,7 @@ pub const LPC_CONNECTION_REQUEST: ULONG = 10;
pub const LPC_KERNELMODE_MESSAGE: CSHORT = 0x8000;
pub const LPC_NO_IMPERSONATE: CSHORT = 0x4000;
pub const PORT_VALID_OBJECT_ATTRIBUTES: u32 = OBJ_CASE_INSENSITIVE;
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
pub const PORT_MAXIMUM_MESSAGE_LENGTH: u32 = 512;
#[cfg(target_arch = "x86")]
pub const PORT_MAXIMUM_MESSAGE_LENGTH: u32 = 256;
@@ -269,7 +269,7 @@ pub type ALPC_HANDLE = HANDLE;
pub const ALPC_PORFLG_ALLOW_LPC_REQUESTS: ULONG = 0x20000;
pub const ALPC_PORFLG_WAITABLE_PORT: ULONG = 0x40000;
pub const ALPC_PORFLG_SYSTEM_PROCESS: ULONG = 0x100000;
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
STRUCT!{struct ALPC_PORT_ATTRIBUTES {
Flags: ULONG,
SecurityQos: SECURITY_QUALITY_OF_SERVICE,
+3 -3
View File
@@ -23,7 +23,7 @@ ENUM!{enum MEMORY_INFORMATION_CLASS {
STRUCT!{struct MEMORY_WORKING_SET_BLOCK {
Bitfields: ULONG_PTR,
}}
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
BITFIELD!{MEMORY_WORKING_SET_BLOCK Bitfields: ULONG_PTR [
Protection set_Protection[0..5],
ShareCount set_ShareCount[5..8],
@@ -78,7 +78,7 @@ UNION!{union MEMORY_WORKING_SET_EX_BLOCK_u {
STRUCT!{struct MEMORY_WORKING_SET_EX_BLOCK {
u: MEMORY_WORKING_SET_EX_BLOCK_u,
}}
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
BITFIELD!{unsafe MEMORY_WORKING_SET_EX_BLOCK_u Bitfields: ULONG_PTR [
Valid set_Valid[0..1],
ShareCount set_ShareCount[1..4],
@@ -93,7 +93,7 @@ BITFIELD!{unsafe MEMORY_WORKING_SET_EX_BLOCK_u Bitfields: ULONG_PTR [
Bad set_Bad[31..32],
ReservedUlong set_ReservedUlong[32..64],
]}
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
BITFIELD!{unsafe MEMORY_WORKING_SET_EX_BLOCK_u Invalid: ULONG_PTR [
Invalid_Valid set_Invalid_Valid[0..1],
Invalid_Reserved0 set_Invalid_Reserved0[1..15],
+1 -1
View File
@@ -213,7 +213,7 @@ UNION!{union TEB_u {
IdealProcessorValue: ULONG,
s: TEB_u_s,
}}
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
STRUCT!{struct TEB {
NtTib: NT_TIB,
EnvironmentPointer: PVOID,
+6 -6
View File
@@ -19,11 +19,11 @@ 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(feature = "nightly")]
#[cfg(all(feature = "nightly", 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;
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
pub const GDI_HANDLE_BUFFER_SIZE: usize = GDI_HANDLE_BUFFER_SIZE64;
#[cfg(target_arch = "x86")]
pub const GDI_HANDLE_BUFFER_SIZE: usize = GDI_HANDLE_BUFFER_SIZE32;
@@ -792,7 +792,7 @@ STRUCT!{struct THREAD_PROFILING_INFORMATION {
PerformanceData: PTHREAD_PERFORMANCE_DATA,
}}
pub type PTHREAD_PROFILING_INFORMATION = *mut THREAD_PROFILING_INFORMATION;
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
STRUCT!{#[repr(align(16))] struct RTL_UMS_CONTEXT {
Link: SINGLE_LIST_ENTRY,
__padding: u64,
@@ -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(feature = "nightly")]
#[inline] #[cfg(all(feature = "nightly", 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(feature = "nightly")]
#[inline] #[cfg(all(feature = "nightly", not(target_arch = "aarch64")))]
pub unsafe fn NtCurrentProcessId() -> HANDLE {
(*NtCurrentTeb()).ClientId.UniqueProcess
}
#[inline] #[cfg(feature = "nightly")]
#[inline] #[cfg(all(feature = "nightly", not(target_arch = "aarch64")))]
pub unsafe fn NtCurrentThreadId() -> HANDLE {
(*NtCurrentTeb()).ClientId.UniqueThread
}
+6 -6
View File
@@ -15,7 +15,7 @@ use winapi::shared::guiddef::GUID;
use winapi::shared::in6addr::in6_addr;
use winapi::shared::inaddr::in_addr;
use winapi::shared::minwindef::{BOOL, DWORD, PBOOL};
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use winapi::shared::ntdef::{LARGE_INTEGER, RTL_BALANCED_NODE};
use winapi::shared::ntdef::{
BOOLEAN, CCHAR, CHAR, CLONG, CSHORT, HANDLE, LCID, LIST_ENTRY, LOGICAL, LONG, LUID, NTSTATUS,
@@ -26,7 +26,7 @@ use winapi::shared::ntdef::{
STRING, UCHAR, ULONG, ULONGLONG, UNICODE_STRING, USHORT, VOID, WCHAR,
};
use winapi::um::minwinbase::PTHREAD_START_ROUTINE;
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use winapi::um::winnt::{PGET_RUNTIME_FUNCTION_CALLBACK, PRUNTIME_FUNCTION, PWOW64_CONTEXT};
use winapi::um::winnt::{
ACCESS_MASK, ACL_INFORMATION_CLASS, APC_CALLBACK_FUNCTION, HEAP_INFORMATION_CLASS,
@@ -1673,7 +1673,7 @@ EXTERN!{extern "system" {
FeatureMask: ULONG64,
);
}}
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
EXTERN!{extern "system" {
fn RtlWow64GetThreadContext(
ThreadHandle: HANDLE,
@@ -1727,7 +1727,7 @@ EXTERN!{extern "system" {
ExceptionPointers: PEXCEPTION_POINTERS,
) -> LONG;
}}
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
IFDEF!{
ENUM!{enum FUNCTION_TABLE_TYPE {
RF_SORTED = 0,
@@ -2196,7 +2196,7 @@ EXTERN!{extern "system" {
MakeReadOnly: BOOLEAN,
);
}}
#[inline] #[cfg(feature = "nightly")]
#[inline] #[cfg(all(feature = "nightly", not(target_arch = "aarch64")))]
pub unsafe fn RtlProcessHeap() -> PVOID {
use crate::ntpsapi::NtCurrentPeb;
(*NtCurrentPeb()).ProcessHeap
@@ -2948,7 +2948,7 @@ pub unsafe fn RtlCheckBit(BitMapHeader: &RTL_BITMAP, BitPosition: ULONG) -> u8 {
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"))))] {
#[cfg(any(target_arch = "x86", all(target_arch = "x86_64", not(feature = "nightly")), target_arch = "aarch64"))] {
(*BitMapHeader.Buffer.offset(BitPosition as isize / 32) >> (BitPosition % 32) & 1) as u8
}
}
+1 -1
View File
@@ -6,7 +6,7 @@ use winapi::um::winnt::{HANDLE, PVOID};
pub const fn UInt32x32To64(a: u32, b: u32) -> u64 {
a as u64 * b as u64
}
#[cfg(feature = "nightly")]
#[cfg(all(feature = "nightly", not(target_arch = "aarch64")))]
IFDEF!{
use crate::ntpebteb::TEB;
#[inline]
File diff suppressed because it is too large Load Diff