This commit is contained in:
hzlinyiyu 2023-01-31 22:40:28 +08:00
parent 8342c1e9f2
commit f89e58f300
2 changed files with 5 additions and 5 deletions

View File

@ -38,13 +38,13 @@ impl Credential for WindowsCredential {
fn get(&self, index_url: &str) -> Result<String, Error> {
let target_name = target_name(index_url);
let mut p_credential: CREDENTIALW = std::ptr::null_mut();
let p_credential: *mut CREDENTIALW = std::ptr::null_mut() as *mut _;
unsafe {
if CredReadW(
target_name.as_ptr(),
CRED_TYPE_GENERIC,
0,
&mut p_credential as *mut _,
p_credential as *mut _ as *mut _,
) != TRUE
{
return Err(
@ -52,8 +52,8 @@ impl Credential for WindowsCredential {
);
}
let bytes = std::slice::from_raw_parts(
p_credential.CredentialBlob,
p_credential.CredentialBlobSize as usize,
(*p_credential).CredentialBlob,
(*p_credential).CredentialBlobSize as usize,
);
String::from_utf8(bytes.to_vec()).map_err(|_| "failed to convert token to UTF8".into())
}

View File

@ -16,5 +16,5 @@ readme = "README.md"
repository = "https://github.com/brson/home"
description = "Shared definitions of home directories"
[target."cfg(windows)".dependencies]
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.45.0", features = ["Win32_Foundation", "Win32_UI_Shell"] }