diff options
author | Andrzej Janik <[email protected]> | 2021-04-10 23:01:01 +0200 |
---|---|---|
committer | Andrzej Janik <[email protected]> | 2021-04-10 23:01:01 +0200 |
commit | a39dda67d1fb3897c5ea778ae00c4079e8e2939a (patch) | |
tree | d04bf8554b27be20673877ad0c35caee498baeba /zluda_dump/src/os_win.rs | |
parent | 8393dbd6e963ee59161dbbe3447a876156bea1c3 (diff) | |
download | ZLUDA-a39dda67d1fb3897c5ea778ae00c4079e8e2939a.tar.gz ZLUDA-a39dda67d1fb3897c5ea778ae00c4079e8e2939a.zip |
Make dumper compatible with older versions of CUDA
Diffstat (limited to 'zluda_dump/src/os_win.rs')
-rw-r--r-- | zluda_dump/src/os_win.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/zluda_dump/src/os_win.rs b/zluda_dump/src/os_win.rs index 7e411ac..70a2b42 100644 --- a/zluda_dump/src/os_win.rs +++ b/zluda_dump/src/os_win.rs @@ -5,9 +5,11 @@ use std::{ ptr,
};
+use std::os::windows::io::AsRawHandle;
use wchar::wch_c;
use winapi::{
shared::minwindef::HMODULE,
+ um::debugapi::OutputDebugStringA,
um::libloaderapi::{GetProcAddress, LoadLibraryW},
};
@@ -66,3 +68,32 @@ unsafe fn get_non_detoured_load_library( pub unsafe fn get_proc_address(handle: *mut c_void, func: &CStr) -> *mut c_void {
GetProcAddress(handle as *mut _, func.as_ptr()) as *mut _
}
+
+#[macro_export]
+macro_rules! os_log {
+ ($format:tt) => {
+ {
+ use crate::os::__log_impl;
+ __log_impl(format!($format));
+ }
+ };
+ ($format:tt, $($obj: expr),+) => {
+ {
+ use crate::os::__log_impl;
+ __log_impl(format!($format, $($obj,)+));
+ }
+ };
+}
+
+pub fn __log_impl(s: String) {
+ let log_to_stderr = std::io::stderr().as_raw_handle() != ptr::null_mut();
+ if log_to_stderr {
+ eprintln!("[ZLUDA_DUMP] {}\n", s);
+ } else {
+ let mut win_str = String::with_capacity("[ZLUDA_DUMP] ".len() + s.len() + 2);
+ win_str.push_str("[ZLUDA_DUMP] ");
+ win_str.push_str(&s);
+ win_str.push_str("\n\0");
+ unsafe { OutputDebugStringA(win_str.as_ptr() as *const _) };
+ }
+}
|