chore: 更新 .gitignore 文件以排除交叉编译产物和刷机工具相关目录

This commit is contained in:
Nixevol
2026-11-27 07:28:40 +08:00
parent 6cd92aec2c
commit 64b01f886b
13 changed files with 1916 additions and 0 deletions
+121
View File
@@ -0,0 +1,121 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bitflags"
version = "2.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
[[package]]
name = "cc"
version = "1.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02f0e023adb368345ce0ca6cdfc0f24a06554468d0e8503e14a0841de79bfa69"
dependencies = [
"find-msvc-tools",
"shlex",
]
[[package]]
name = "cmake"
version = "0.1.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678"
dependencies = [
"cc",
]
[[package]]
name = "cmk"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fd5de2a10e31b3ec3e8d75e7ccf8281ab3ee55de68f7ab6ffa9e21be8d82f22"
[[package]]
name = "crossbeam-channel"
version = "0.5.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
[[package]]
name = "find-msvc-tools"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
[[package]]
name = "flasher"
version = "0.1.0"
dependencies = [
"fltk",
]
[[package]]
name = "fltk"
version = "1.5.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6acfa51a6d98065984e5f6f21fca6d421791b7b8b6a1351d1966c9799d2c7c60"
dependencies = [
"bitflags",
"crossbeam-channel",
"fltk-sys",
"minipaste",
"once_cell",
]
[[package]]
name = "fltk-sys"
version = "1.5.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c4875e000369874f50a6c09abf99f08ff45b867daa340ffe5965122a849c83b"
dependencies = [
"cmake",
"cmk",
]
[[package]]
name = "minipaste"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bbcafc6544efab7decec8e8e63d6e7cbaac0a699a4adead308a80f9c302d6ae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "shlex"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
[[package]]
name = "unicode-ident"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
+8
View File
@@ -0,0 +1,8 @@
[package]
name = "flasher"
version = "0.1.0"
edition = "2021"
description = "9008 离线刷机工具"
[dependencies]
fltk = { version = "1.5", features = ["fltk-bundled"] }
Binary file not shown.
+62
View File
@@ -0,0 +1,62 @@
param([switch]$Install)
$ErrorActionPreference = 'Stop'
$inf = Join-Path $PSScriptRoot 'qhsusb.inf'
$cer = Join-Path $PSScriptRoot 'qhsusb.cer'
function Test-QhsusbInstalled {
$files = @(Get-ChildItem 'C:\Windows\INF\oem*.inf' -ErrorAction SilentlyContinue)
foreach ($file in $files) {
try {
$text = Get-Content -LiteralPath $file.FullName -Raw -ErrorAction Stop
} catch {
continue
}
if ($text -match 'QHSUSB__BULK' -and $text -match 'VID_05C6&PID_9008') {
return $true
}
}
return $false
}
function Test-Admin {
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($identity)
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
if (-not $Install) {
if (Test-QhsusbInstalled) {
Write-Output "DRIVER`tREADY"
} else {
Write-Output "DRIVER`tMISSING"
}
exit 0
}
if (-not (Test-Admin)) {
$arg = "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" -Install"
try {
Start-Process -FilePath powershell.exe -ArgumentList $arg -Verb RunAs -Wait | Out-Null
} catch {
Write-Output "DRIVER`tFAIL`tcancel"
exit 1
}
if (Test-QhsusbInstalled) {
Write-Output "DRIVER`tINSTALLED"
exit 0
}
Write-Output "DRIVER`tFAIL"
exit 1
}
if (Test-Path -LiteralPath $cer) {
& certutil.exe -addstore -f TrustedPublisher $cer | Out-Null
}
$proc = Start-Process -FilePath "$env:SystemRoot\System32\pnputil.exe" -ArgumentList @('/add-driver', $inf, '/install') -Wait -PassThru -NoNewWindow
if (Test-QhsusbInstalled) {
Write-Output "DRIVER`tINSTALLED"
exit 0
}
Write-Output ("DRIVER`tFAIL`t" + $proc.ExitCode)
exit 1
Binary file not shown.
Binary file not shown.
+107
View File
@@ -0,0 +1,107 @@
param(
[Parameter(Mandatory = $true)][string]$InstanceId
)
$ErrorActionPreference = 'Stop'
$inf = (Resolve-Path (Join-Path $PSScriptRoot 'qhsusb.inf')).Path
if (-not (Test-Path -LiteralPath $inf)) {
throw '找不到 WinUSB 驱动描述'
}
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
using System.Text;
public static class QhsusbOne {
public const uint DIGCF_PRESENT = 0x2;
public const uint DIGCF_ALLCLASSES = 0x4;
public const uint DI_ENUMSINGLEINF = 0x00010000;
public const uint DIF_SELECTBESTCOMPATDRV = 0x17;
public const uint DIF_INSTALLDEVICE = 0x2;
public const uint SPDIT_COMPATDRIVER = 2;
[StructLayout(LayoutKind.Sequential)]
public struct SP_DEVINFO_DATA {
public int cbSize;
public Guid ClassGuid;
public uint DevInst;
public IntPtr Reserved;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SP_DEVINSTALL_PARAMS {
public int cbSize;
public int Flags;
public int FlagsEx;
public IntPtr hwndParent;
public IntPtr InstallMsgHandler;
public IntPtr InstallMsgHandlerContext;
public IntPtr FileQueue;
public IntPtr ClassInstallReserved;
public int Reserved;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string DriverPath;
}
[DllImport("setupapi.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr SetupDiGetClassDevs(IntPtr classGuid, string enumerator, IntPtr hwnd, uint flags);
[DllImport("setupapi.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SetupDiOpenDeviceInfo(IntPtr deviceInfoSet, string deviceInstanceId, IntPtr hwnd, uint flags, ref SP_DEVINFO_DATA data);
[DllImport("setupapi.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SetupDiGetDeviceInstallParams(IntPtr deviceInfoSet, ref SP_DEVINFO_DATA data, ref SP_DEVINSTALL_PARAMS parms);
[DllImport("setupapi.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SetupDiSetDeviceInstallParams(IntPtr deviceInfoSet, ref SP_DEVINFO_DATA data, ref SP_DEVINSTALL_PARAMS parms);
[DllImport("setupapi.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SetupDiBuildDriverInfoList(IntPtr deviceInfoSet, ref SP_DEVINFO_DATA data, uint type);
[DllImport("setupapi.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SetupDiCallClassInstaller(uint installFunction, IntPtr deviceInfoSet, ref SP_DEVINFO_DATA data);
[DllImport("setupapi.dll", SetLastError = true)]
public static extern bool SetupDiDestroyDriverInfoList(IntPtr deviceInfoSet, ref SP_DEVINFO_DATA data, uint type);
[DllImport("setupapi.dll", SetLastError = true)]
public static extern bool SetupDiDestroyDeviceInfoList(IntPtr deviceInfoSet);
}
"@
function Throw-IfFailed([bool]$ok, [string]$step) {
if ($ok) { return }
$code = [Runtime.InteropServices.Marshal]::GetLastWin32Error()
throw ($step + ' 失败,Win32 错误 ' + $code)
}
$set = [QhsusbOne]::SetupDiGetClassDevs([IntPtr]::Zero, 'USB', [IntPtr]::Zero, [QhsusbOne]::DIGCF_PRESENT -bor [QhsusbOne]::DIGCF_ALLCLASSES)
Throw-IfFailed (-not ($set -eq [IntPtr]::Zero -or $set -eq [IntPtr]-1)) '打开设备列表'
$dev = New-Object QhsusbOne+SP_DEVINFO_DATA
$dev.cbSize = [Runtime.InteropServices.Marshal]::SizeOf($dev)
try {
$ok = [QhsusbOne]::SetupDiOpenDeviceInfo($set, $InstanceId, [IntPtr]::Zero, 0, [ref]$dev)
Throw-IfFailed $ok '定位这一台设备'
$parms = New-Object QhsusbOne+SP_DEVINSTALL_PARAMS
$parms.cbSize = [Runtime.InteropServices.Marshal]::SizeOf($parms)
$ok = [QhsusbOne]::SetupDiGetDeviceInstallParams($set, [ref]$dev, [ref]$parms)
Throw-IfFailed $ok '读取安装参数'
$parms.Flags = $parms.Flags -bor [QhsusbOne]::DI_ENUMSINGLEINF
$parms.DriverPath = $inf
$ok = [QhsusbOne]::SetupDiSetDeviceInstallParams($set, [ref]$dev, [ref]$parms)
Throw-IfFailed $ok '指定驱动文件'
$ok = [QhsusbOne]::SetupDiBuildDriverInfoList($set, [ref]$dev, [QhsusbOne]::SPDIT_COMPATDRIVER)
Throw-IfFailed $ok '建立驱动列表'
try {
$ok = [QhsusbOne]::SetupDiCallClassInstaller([QhsusbOne]::DIF_SELECTBESTCOMPATDRV, $set, [ref]$dev)
Throw-IfFailed $ok '选择驱动'
$ok = [QhsusbOne]::SetupDiCallClassInstaller([QhsusbOne]::DIF_INSTALLDEVICE, $set, [ref]$dev)
Throw-IfFailed $ok '安装驱动'
} finally {
[void][QhsusbOne]::SetupDiDestroyDriverInfoList($set, [ref]$dev, [QhsusbOne]::SPDIT_COMPATDRIVER)
}
} finally {
[void][QhsusbOne]::SetupDiDestroyDeviceInfoList($set)
}
Write-Output 'OK'
+1067
View File
File diff suppressed because it is too large Load Diff