verity_memory/macros/
wide_string.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#[macro_export]
macro_rules! w {
    ($text:literal $(, $args:expr)*) => {{
        let formatted = format!($text $(, $args)*);
        let os_str = std::ffi::OsStr::new(&formatted);
        let wide_string: Vec<u16> = std::os::windows::ffi::OsStrExt::encode_wide(os_str)
            .chain(Some(0))
            .collect();
        wide_string.as_ptr()
    }};
    
    ($text:expr) => {{
        let formatted = $text.to_string();
        let os_str = std::ffi::OsStr::new(&formatted);
        let wide_string: Vec<u16> = std::os::windows::ffi::OsStrExt::encode_wide(os_str)
            .chain(Some(0))
            .collect();
        wide_string.as_ptr()
    }};
}