Skip to content

Commit

Permalink
Fix temporary references for volatile read (#12)
Browse files Browse the repository at this point in the history
* Bump Rust toolchain version for CI to 1.64

* Fix temporary references for volatile read
  • Loading branch information
bdbai authored Sep 23, 2022
1 parent 3a0063a commit 24fc1e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ environment:
- host: i686-pc-windows-gnu
channel: nightly
- host: x86_64-pc-windows-gnu
channel: 1.33.0
channel: 1.64.0
- host: i686-pc-windows-gnu
channel: 1.33.0
channel: 1.64.0

install:
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
Expand Down
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 24fc1e4

Please sign in to comment.