Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix temporary references for volatile read #12

Merged
merged 2 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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