Skip to content

Commit

Permalink
Fix temporary references for volatile read
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbai committed Sep 23, 2022
1 parent 5389676 commit f8a698f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ntexapi.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use core::mem::uninitialized;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use core::ptr::addr_of;
use core::ptr::read_volatile;
#[cfg(target_arch = "x86")]
use core::sync::atomic::spin_loop_hint;
Expand Down Expand Up @@ -2780,7 +2782,7 @@ pub const USER_SHARED_DATA: *const KUSER_SHARED_DATA = 0x7ffe0000 as *const _;
pub unsafe fn NtGetTickCount64() -> ULONGLONG {
let mut tick_count: ULARGE_INTEGER = uninitialized();
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] {
*tick_count.QuadPart_mut() = read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad);
*tick_count.QuadPart_mut() = read_volatile(addr_of!((*USER_SHARED_DATA).u.TickCountQuad));
}
#[cfg(target_arch = "x86")] {
loop {
Expand All @@ -2804,7 +2806,7 @@ pub unsafe fn NtGetTickCount64() -> ULONGLONG {
#[inline]
pub unsafe fn NtGetTickCount() -> ULONG {
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] {
((read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad)
((read_volatile(addr_of!((*USER_SHARED_DATA).u.TickCountQuad))
* (*USER_SHARED_DATA).TickCountMultiplier as u64) >> 24) as u32
}
#[cfg(target_arch = "x86")] {
Expand Down

0 comments on commit f8a698f

Please sign in to comment.