mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 13:10:30 +08:00
fix: migrate from WMIC to modern APIs and improve privilege checks (#945)
* fix: WMIC is deprecated on windows-latest * opt: remove WMIC * fix: correctly detect high-privilege processes
This commit is contained in:
parent
348c429855
commit
35f51e1e39
@ -518,10 +518,11 @@ async function checkHighPrivilegeMihomoProcess(): Promise<boolean> {
|
|||||||
if (parts.length >= 2) {
|
if (parts.length >= 2) {
|
||||||
const pid = parts[1].replace(/"/g, '').trim()
|
const pid = parts[1].replace(/"/g, '').trim()
|
||||||
try {
|
try {
|
||||||
const { stdout: processInfo } = await execPromise(`wmic process where "ProcessId=${pid}" get Name,ProcessId,ExecutablePath,CommandLine /format:csv`)
|
const { stdout: processInfo } = await execPromise(`powershell -Command "Get-Process -Id ${pid} | Select-Object Name,Id,Path,CommandLine | ConvertTo-Json"`)
|
||||||
|
const processJson = JSON.parse(processInfo)
|
||||||
await managerLogger.info(`Process ${pid} info: ${processInfo.substring(0, 200)}`)
|
await managerLogger.info(`Process ${pid} info: ${processInfo.substring(0, 200)}`)
|
||||||
|
|
||||||
if (processInfo.includes('mihomo')) {
|
if (processJson.Name === "mihomo" && processJson.Path === null) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user