Skip to content

Commit 04b5bcc

Browse files
committed
raw_ptr
1 parent 11c3d01 commit 04b5bcc

File tree

1 file changed

+18
-11
lines changed
  • lib/bencher_context/src/client/platform/target_os

1 file changed

+18
-11
lines changed

lib/bencher_context/src/client/platform/target_os/windows.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use core::ffi::c_void;
12
use std::cmp;
23

34
use uuid::Uuid;
@@ -33,17 +34,23 @@ fn digital_product_id() -> Option<Uuid> {
3334

3435
let mut data = vec![0u8; 256];
3536
let mut data_size = data.len() as u32;
36-
RegGetValueW(
37-
HKEY_LOCAL_MACHINE,
38-
sub_key,
39-
value,
40-
RRF_RT_ANY,
41-
None,
42-
Some(&mut data),
43-
Some(&mut data_size),
44-
)
45-
.ok()
46-
.ok()?;
37+
// Safety: The accuracy of the data returned by `RegGetValueW` is not of any importance,
38+
// rather the consistency of the data is what is important.
39+
// https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-reggetvaluew
40+
#[allow(unsafe_code)]
41+
unsafe {
42+
RegGetValueW(
43+
HKEY_LOCAL_MACHINE,
44+
sub_key,
45+
value,
46+
RRF_RT_ANY,
47+
None,
48+
Some(data.as_mut_ptr() as *mut c_void),
49+
Some(&mut data_size),
50+
)
51+
.ok()
52+
.ok()?;
53+
}
4754

4855
let digital_product_id = data
4956
.into_iter()

0 commit comments

Comments
 (0)