summaryrefslogtreecommitdiff
path: root/crates/windows-kernel-rs/src/string.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-01-03 03:20:12 -0800
committerFuwn <[email protected]>2022-01-03 03:20:12 -0800
commit85db2b507f3f69b32811c54a89d9ac7bbbc46121 (patch)
tree2efd66da452f8a6a2cc6c91584c925f237506ddf /crates/windows-kernel-rs/src/string.rs
downloaddriver-85db2b507f3f69b32811c54a89d9ac7bbbc46121.tar.xz
driver-85db2b507f3f69b32811c54a89d9ac7bbbc46121.zip
feat(driver): commit primer
Diffstat (limited to 'crates/windows-kernel-rs/src/string.rs')
-rw-r--r--crates/windows-kernel-rs/src/string.rs17
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 _,
+ }
+}