ntprocesses/lib.rs
1pub mod process;
2pub mod processes;
3pub mod safe_handle;
4
5pub trait WindowsString {
6 fn to_string_null(&self) -> String;
7}
8
9impl WindowsString for [u16] {
10 fn to_string_null(&self) -> String {
11 // find the position of the first null character.
12 let null_pos = self.iter().position(|&c| c == 0).unwrap_or(self.len());
13
14 // Take the slice up to (but not including) the null terminator
15 let string_data = &self[0..null_pos];
16
17 // Convert the UTF-16 data to a String
18 String::from_utf16_lossy(string_data)
19 }
20}