1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use ::shared::{SYSTEMTIME};
#[cfg(target_arch = "x86_64")]
use ::shared::{KUSER_SHARED_DATA};
extern "system"
{
#[cfg(target_arch = "x86")]
fn KeQuerySystemTime(CurrentTime: *mut SYSTEMTIME);
#[cfg(target_arch = "x86")]
fn KeQueryTickCount(TickCount: *mut i64);
pub fn ExSystemTimeToLocalTime(SystemTime: *const SYSTEMTIME, LocalTime: *mut SYSTEMTIME);
}
#[cfg(target_arch = "x86")]
pub fn QuerySystemTime() -> SYSTEMTIME {
let mut t = 0i64;
unsafe { KeQuerySystemTime(&mut t) };
return t;
}
#[cfg(target_arch = "x86_64")]
pub fn QuerySystemTime() -> SYSTEMTIME {
let shared = KUSER_SHARED_DATA::get();
SYSTEMTIME::from(shared.SystemTime)
}
#[cfg(target_arch = "x86")]
pub fn QueryTickCount() -> i64 {
let mut t = 0i64;
unsafe { KeQueryTickCount(&mut t) };
return t;
}
#[cfg(target_arch = "x86_64")]
pub fn QueryTickCount() -> i64 {
let shared = KUSER_SHARED_DATA::get();
SYSTEMTIME::from(shared.TickCount)
}