diff options
Diffstat (limited to 'crates/windows-kernel-rs/src/string.rs')
| -rw-r--r-- | crates/windows-kernel-rs/src/string.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/windows-kernel-rs/src/string.rs b/crates/windows-kernel-rs/src/string.rs new file mode 100644 index 0000000..71ad169 --- /dev/null +++ b/crates/windows-kernel-rs/src/string.rs @@ -0,0 +1,17 @@ +use windows_kernel_sys::base::UNICODE_STRING; + +pub fn create_unicode_string(s: &[u16]) -> UNICODE_STRING { + let len = s.len(); + + let n = if len > 0 && s[len - 1] == 0 { + len - 1 + } else { + len + }; + + UNICODE_STRING { + Length: (n * 2) as u16, + MaximumLength: (len * 2) as u16, + Buffer: s.as_ptr() as _, + } +} |