aboutsummaryrefslogtreecommitdiff
path: root/src/time.rs
diff options
context:
space:
mode:
authorpravic <[email protected]>2016-04-14 00:01:22 +0300
committerpravic <[email protected]>2016-04-14 00:01:22 +0300
commitb365946875e776e271b3e91bb042a999acdb408b (patch)
tree7a1dc905b97a4994c98985c31695b19b86228ddf /src/time.rs
parentnote about staticlib compilation (diff)
downloadwinapi-kmd-rs-b365946875e776e271b3e91bb042a999acdb408b.tar.xz
winapi-kmd-rs-b365946875e776e271b3e91bb042a999acdb408b.zip
implement KeQuerySystemTime routine for x64 kernel, since it exported only at x86.
Diffstat (limited to 'src/time.rs')
-rw-r--r--src/time.rs32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/time.rs b/src/time.rs
index b4d0e99..eac3bc3 100644
--- a/src/time.rs
+++ b/src/time.rs
@@ -1,26 +1,54 @@
//! NT Time routines.
-/// System time is a count of 100-nanosecond intervals since January 1, 1601.
-pub type SYSTEMTIME = i64;
+use ::shared::{SYSTEMTIME};
+
+#[cfg(target_arch = "x86_64")]
+use ::shared::{KUSER_SHARED_DATA};
+
extern "system"
{
+ // The following exports exists only on x86 kernels.
+ // x64 drivers must use KUSER_SHARED_DATA to obtain these values.
+
+ #[cfg(target_arch = "x86")]
fn KeQuerySystemTime(CurrentTime: *mut SYSTEMTIME);
+ #[cfg(target_arch = "x86")]
fn KeQueryTickCount(TickCount: *mut i64);
+
/// Converts a GMT system time value to the local system time for the current time zone.
pub fn ExSystemTimeToLocalTime(SystemTime: *const SYSTEMTIME, LocalTime: *mut SYSTEMTIME);
}
+
/// Obtains the current system time.
+#[cfg(target_arch = "x86")]
pub fn QuerySystemTime() -> SYSTEMTIME {
let mut t = 0i64;
unsafe { KeQuerySystemTime(&mut t) };
return t;
}
+/// Obtains the current system time.
+#[cfg(target_arch = "x86_64")]
+pub fn QuerySystemTime() -> SYSTEMTIME {
+ let shared = KUSER_SHARED_DATA::get();
+ SYSTEMTIME::from(shared.SystemTime)
+}
+
+
/// A count of the interval timer interrupts that have occurred since the system was booted.
+#[cfg(target_arch = "x86")]
pub fn QueryTickCount() -> i64 {
let mut t = 0i64;
unsafe { KeQueryTickCount(&mut t) };
return t;
}
+
+
+/// A count of the interval timer interrupts that have occurred since the system was booted.
+#[cfg(target_arch = "x86_64")]
+pub fn QueryTickCount() -> i64 {
+ let shared = KUSER_SHARED_DATA::get();
+ SYSTEMTIME::from(shared.TickCount)
+}