1
1
#[ allow( deprecated) ] //fixme
2
2
use core:: mem:: uninitialized;
3
+ use core:: ptr:: read_volatile;
3
4
#[ cfg( target_arch = "x86" ) ]
4
5
use core:: sync:: atomic:: spin_loop_hint;
5
6
use crate :: ntapi_base:: { CLIENT_ID , KPRIORITY , KSYSTEM_TIME , PRTL_ATOM , RTL_ATOM } ;
@@ -2781,13 +2782,16 @@ pub unsafe fn NtGetTickCount64() -> ULONGLONG {
2781
2782
#[ allow( deprecated) ] //fixme
2782
2783
let mut tick_count: ULARGE_INTEGER = uninitialized ( ) ;
2783
2784
#[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ] {
2784
- * tick_count. QuadPart_mut ( ) = ( * USER_SHARED_DATA ) . u . TickCountQuad ;
2785
+ * tick_count. QuadPart_mut ( ) = read_volatile ( & ( * USER_SHARED_DATA ) . u . TickCountQuad ) ;
2785
2786
}
2786
2787
#[ cfg( target_arch = "x86" ) ] {
2787
2788
loop {
2788
- tick_count. s_mut ( ) . HighPart = ( * USER_SHARED_DATA ) . u . TickCount . High1Time as u32 ;
2789
- tick_count. s_mut ( ) . LowPart = ( * USER_SHARED_DATA ) . u . TickCount . LowPart ;
2790
- if tick_count. s ( ) . HighPart == ( * USER_SHARED_DATA ) . u . TickCount . High2Time as u32 {
2789
+ tick_count. s_mut ( ) . HighPart =
2790
+ read_volatile ( & ( * USER_SHARED_DATA ) . u . TickCount . High1Time ) as u32 ;
2791
+ tick_count. s_mut ( ) . LowPart = read_volatile ( & ( * USER_SHARED_DATA ) . u . TickCount . LowPart ) ;
2792
+ if tick_count. s ( ) . HighPart == read_volatile ( & ( * USER_SHARED_DATA ) . u . TickCount . High2Time )
2793
+ as u32
2794
+ {
2791
2795
break ;
2792
2796
}
2793
2797
spin_loop_hint ( ) ;
@@ -2802,16 +2806,19 @@ pub unsafe fn NtGetTickCount64() -> ULONGLONG {
2802
2806
#[ inline]
2803
2807
pub unsafe fn NtGetTickCount ( ) -> ULONG {
2804
2808
#[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ] {
2805
- ( ( ( * USER_SHARED_DATA ) . u . TickCountQuad * ( * USER_SHARED_DATA ) . TickCountMultiplier as u64 )
2806
- >> 24 ) as u32
2809
+ ( ( read_volatile ( & ( * USER_SHARED_DATA ) . u . TickCountQuad )
2810
+ * ( * USER_SHARED_DATA ) . TickCountMultiplier as u64 ) >> 24 ) as u32
2807
2811
}
2808
2812
#[ cfg( target_arch = "x86" ) ] {
2809
2813
#[ allow( deprecated) ] //fixme
2810
2814
let mut tick_count: ULARGE_INTEGER = uninitialized ( ) ;
2811
2815
loop {
2812
- tick_count. s_mut ( ) . HighPart = ( * USER_SHARED_DATA ) . u . TickCount . High1Time as u32 ;
2813
- tick_count. s_mut ( ) . LowPart = ( * USER_SHARED_DATA ) . u . TickCount . LowPart ;
2814
- if tick_count. s ( ) . HighPart == ( * USER_SHARED_DATA ) . u . TickCount . High2Time as u32 {
2816
+ tick_count. s_mut ( ) . HighPart = read_volatile ( & ( * USER_SHARED_DATA ) . u . TickCount . High1Time )
2817
+ as u32 ;
2818
+ tick_count. s_mut ( ) . LowPart = read_volatile ( & ( * USER_SHARED_DATA ) . u . TickCount . LowPart ) ;
2819
+ if tick_count. s ( ) . HighPart == read_volatile ( & ( * USER_SHARED_DATA ) . u . TickCount . High2Time )
2820
+ as u32
2821
+ {
2815
2822
break ;
2816
2823
}
2817
2824
spin_loop_hint ( ) ;
0 commit comments