Fix/win query arch (#7786)

* fix: win, query arch with GetNativeSystemInfo

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* refact: idd, ci

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2024-04-21 14:55:42 +08:00 committed by GitHub
parent 33c8bdfabf
commit ad062486ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 36 additions and 34 deletions

View File

@ -115,16 +115,11 @@ jobs:
- name: Build rustdesk - name: Build rustdesk
run: | run: |
Invoke-WebRequest -Uri https://github.com/rustdesk-org/rdev/releases/download/usbmmidd_v2/usbmmidd_v2.zip -OutFile usbmmidd_v2.zip Invoke-WebRequest -Uri https://github.com/rustdesk-org/rdev/releases/download/usbmmidd_v2/usbmmidd_v2.zip -OutFile usbmmidd_v2.zip
$SHA256_SUM = '629b51e9944762bae73948171c65d09a79595cf4c771a82ebc003fbba5b24f51' Expand-Archive usbmmidd_v2.zip -DestinationPath .
if ((Get-FileHash -Path .\usbmmidd_v2.zip -Algorithm SHA256).Hash -ne $SHA256_SUM) { python3 .\build.py --portable --hwcodec --flutter --vram --skip-portable-pack --virtual-display
Write-Error "SHA256 sum mismatch, falling back to the non-virtual-display version" Remove-Item -Path usbmmidd_v2\Win32 -Recurse
python3 .\build.py --portable --hwcodec --flutter --vram --skip-portable-pack Remove-Item -Path usbmmidd_v2\deviceinstaller.exe
} else { mv -Force .\usbmmidd_v2 ./flutter/build/windows/x64/runner/Release/
Write-Host "SHA256 sum matched, using the virtual-display version"
Expand-Archive usbmmidd_v2.zip -DestinationPath .
python3 .\build.py --portable --hwcodec --flutter --vram --skip-portable-pack --virtual-display
mv -Force .\usbmmidd_v2 ./flutter/build/windows/x64/runner/Release/
}
- name: find Runner.res - name: find Runner.res
# Windows: find Runner.res (compiled from ./flutter/windows/runner/Runner.rc), copy to ./Runner.res # Windows: find Runner.res (compiled from ./flutter/windows/runner/Runner.rc), copy to ./Runner.res
@ -262,11 +257,14 @@ jobs:
python3 res/inline-sciter.py python3 res/inline-sciter.py
# Patch sciter x86 # Patch sciter x86
sed -i 's/branch = "dyn"/branch = "dyn_x86"/g' ./Cargo.toml sed -i 's/branch = "dyn"/branch = "dyn_x86"/g' ./Cargo.toml
cargo build --features inline,vram,hwcodec --release --bins cargo build --features inline,vram,hwcodec,virtual_display_driver --release --bins
mkdir -p ./Release mkdir -p ./Release
mv ./target/release/rustdesk.exe ./Release/rustdesk.exe mv ./target/release/rustdesk.exe ./Release/rustdesk.exe
curl -LJ -o ./Release/sciter.dll https://github.com/c-smile/sciter-sdk/raw/master/bin.win/x32/sciter.dll curl -LJ -o ./Release/sciter.dll https://github.com/c-smile/sciter-sdk/raw/master/bin.win/x32/sciter.dll
echo "output_folder=./Release" >> $GITHUB_OUTPUT echo "output_folder=./Release" >> $GITHUB_OUTPUT
curl -LJ -o ./usbmmidd_v2.zip https://github.com/rustdesk-org/rdev/releases/download/usbmmidd_v2/usbmmidd_v2.zip
unzip usbmmidd_v2.zip
mv ./usbmmidd_v2 ./Release || true
- name: find Runner.res - name: find Runner.res
# Windows: find Runner.res (compiled from ./flutter/windows/runner/Runner.rc), copy to ./Runner.res # Windows: find Runner.res (compiled from ./flutter/windows/runner/Runner.rc), copy to ./Runner.res

View File

@ -607,9 +607,7 @@ UINT __stdcall RemoveAmyuniIdd(
DWORD fileAttributes = 0; DWORD fileAttributes = 0;
HINSTANCE hi = 0; HINSTANCE hi = 0;
USHORT processMachine = 0; SYSTEM_INFO si;
USHORT nativeMachine = 0;
BOOL isWow64Res = FALSE;
LPCWSTR exe = NULL; LPCWSTR exe = NULL;
hr = WcaInitialize(hInstall, "RemoveAmyuniIdd"); hr = WcaInitialize(hInstall, "RemoveAmyuniIdd");
@ -630,24 +628,22 @@ UINT __stdcall RemoveAmyuniIdd(
goto LExit; goto LExit;
} }
isWow64Res = IsWow64Process2(GetCurrentProcess(), &processMachine, &nativeMachine); GetNativeSystemInfo(&si);
if (isWow64Res == TRUE) { if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
if (nativeMachine == IMAGE_FILE_MACHINE_AMD64) { exe = L"deviceinstaller64.exe";
exe = L"deviceinstaller64.exe";
} else {
exe = L"deviceinstaller.exe";
}
WcaLog(LOGMSG_STANDARD, "Remove amyuni idd %ls in %ls", exe, workDir);
hi = ShellExecuteW(NULL, L"open", exe, L"remove usbmmidd", workDir, SW_HIDE);
// https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutew
if ((int)hi <= 32) {
WcaLog(LOGMSG_STANDARD, "Failed to remove amyuni idd : %d, last error: %d", (int)hi, GetLastError());
}
else {
WcaLog(LOGMSG_STANDARD, "Amyuni idd is removed");
}
} else { } else {
WcaLog(LOGMSG_STANDARD, "Failed to call IsWow64Process2(): %d", GetLastError()); // No need to check if is other architecture.
// Because the driver is only for x86 and x64. It will not work at on other architectures.
exe = L"deviceinstaller.exe";
}
WcaLog(LOGMSG_STANDARD, "Remove amyuni idd %ls in %ls", exe, workDir);
hi = ShellExecuteW(NULL, L"open", exe, L"remove usbmmidd", workDir, SW_HIDE);
// https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutew
if ((int)hi <= 32) {
WcaLog(LOGMSG_STANDARD, "Failed to remove amyuni idd : %d, last error: %d", (int)hi, GetLastError());
}
else {
WcaLog(LOGMSG_STANDARD, "Amyuni idd is removed");
} }
LExit: LExit:

View File

@ -42,6 +42,7 @@ use winapi::{
}, },
securitybaseapi::GetTokenInformation, securitybaseapi::GetTokenInformation,
shellapi::ShellExecuteW, shellapi::ShellExecuteW,
sysinfoapi::{GetNativeSystemInfo, SYSTEM_INFO},
winbase::*, winbase::*,
wingdi::*, wingdi::*,
winnt::{ winnt::{
@ -2370,9 +2371,16 @@ impl Drop for WallPaperRemover {
} }
pub fn get_amyuni_exe_name() -> Option<String> { pub fn get_amyuni_exe_name() -> Option<String> {
let exe = match std::env::consts::ARCH { let mut sys_info = SYSTEM_INFO::default();
"x86" => "deviceinstaller.exe", unsafe {
"x86_64" => "deviceinstaller64.exe", GetNativeSystemInfo(&mut sys_info as _);
}
const PROCESSOR_ARCHITECTURE_INTEL: u16 = 0;
const PROCESSOR_ARCHITECTURE_AMD64: u16 = 9;
let exe = match unsafe { sys_info.u.s().wProcessorArchitecture } {
PROCESSOR_ARCHITECTURE_INTEL => "deviceinstaller.exe",
PROCESSOR_ARCHITECTURE_AMD64 => "deviceinstaller64.exe",
_ => { _ => {
log::error!("Unsupported machine architecture"); log::error!("Unsupported machine architecture");
return None; return None;