diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-10-22 14:02:25 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-10-22 14:47:33 +0200 |
| commit | 5e96ccd96d615ffe0d2d173e0cb0daafa58f4709 (patch) | |
| tree | 6a94d0d5e555ee018852ab20aa937f3b68f56f83 | |
| parent | e0691e944dd3ce998acdb49fc44f7ec58b4c21d4 (diff) | |
| download | mullvadvpn-5e96ccd96d615ffe0d2d173e0cb0daafa58f4709.tar.xz mullvadvpn-5e96ccd96d615ffe0d2d173e0cb0daafa58f4709.zip | |
Use GetModuleHandleW instead of GetModuleHandleA
| -rw-r--r-- | talpid-core/src/dns/windows/mod.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/talpid-core/src/dns/windows/mod.rs b/talpid-core/src/dns/windows/mod.rs index a61dafbe71..bf3807c9b6 100644 --- a/talpid-core/src/dns/windows/mod.rs +++ b/talpid-core/src/dns/windows/mod.rs @@ -1,11 +1,11 @@ use crate::logging::windows::{log_sink, LogSink}; use log::{error, trace, warn}; -use std::{io, mem, net::IpAddr, path::Path, ptr}; +use std::{ffi::OsString, io, iter, mem, net::IpAddr, os::windows::ffi::OsStrExt, path::Path, ptr}; use talpid_types::ErrorExt; use widestring::WideCString; use winapi::um::{ - libloaderapi::{GetModuleHandleA, GetProcAddress}, + libloaderapi::{GetModuleHandleW, GetProcAddress}, winnt::RTL_OSVERSIONINFOW, }; use winreg::{ @@ -217,7 +217,13 @@ fn is_minimum_windows10() -> bool { fn is_minimum_windows10_inner() -> Result<bool, io::Error> { let rtl_get_version: extern "stdcall" fn(*mut RTL_OSVERSIONINFOW); - let ntdll = unsafe { GetModuleHandleA(b"ntdll\0" as *const _ as *const i8) }; + let module_name: Vec<u16> = OsString::from("ntdll") + .as_os_str() + .encode_wide() + .chain(iter::once(0u16)) + .collect(); + + let ntdll = unsafe { GetModuleHandleW(module_name.as_ptr()) }; if ntdll == ptr::null_mut() { return Err(io::Error::last_os_error()); } |
