|
@@ -73,24 +73,42 @@ export async function downloadFileURL(url, name) {
|
|
|
}
|
|
|
|
|
|
export function checkMainExe() {
|
|
|
- let iid = window.nodeRequire("process").pid;
|
|
|
- iid = window
|
|
|
- .nodeRequire("child_process")
|
|
|
- .execSync(
|
|
|
- `cmd /c chcp 65001>nul && wmic process where ^(processid^=${iid}^) get parentprocessid /value`
|
|
|
- )
|
|
|
- .toString();
|
|
|
- const executablePath = window
|
|
|
- .nodeRequire("child_process")
|
|
|
- .execSync(
|
|
|
- `cmd /c chcp 65001>nul && wmic process where ^(processid^=${iid}^) get executablepath`
|
|
|
- )
|
|
|
- .toString();
|
|
|
- const getHash = window
|
|
|
- .nodeRequire("crypto")
|
|
|
- .createHmac("sha256", "abcdefg")
|
|
|
- .update(window.nodeRequire("fs").readFileSync(executablePath))
|
|
|
- .digest("hex");
|
|
|
- console.log("the hash: ", getHash);
|
|
|
- // check filepath executablePath md5
|
|
|
+ try {
|
|
|
+ let iid = window.nodeRequire("process").pid;
|
|
|
+ const cp = window.nodeRequire("child_process");
|
|
|
+ iid = cp
|
|
|
+ .execSync(
|
|
|
+ `cmd /c chcp 65001>nul && C:\\Windows\\System32\\wbem\\wmic process where ^(processid^=${iid}^) get parentprocessid /value`
|
|
|
+ )
|
|
|
+ .toString();
|
|
|
+ iid = iid.replace("ParentProcessId=", "").trim();
|
|
|
+ console.log(iid);
|
|
|
+ iid = cp
|
|
|
+ .execSync(
|
|
|
+ `cmd /c chcp 65001>nul && C:\\Windows\\System32\\wbem\\wmic process where ^(processid^=${iid}^) get parentprocessid /value`
|
|
|
+ )
|
|
|
+ .toString();
|
|
|
+ iid = iid.replace("ParentProcessId=", "").trim();
|
|
|
+ console.log(iid);
|
|
|
+
|
|
|
+ let executablePath = cp.execSync(
|
|
|
+ `cmd /c chcp 65001>nul && C:\\Windows\\System32\\wbem\\wmic process where ^(processid^=${iid}^) get executablepath /value`
|
|
|
+ );
|
|
|
+ console.log(executablePath);
|
|
|
+ const encoding = window.nodeRequire("encoding");
|
|
|
+ executablePath = encoding.convert(executablePath, "utf8", "gbk").toString();
|
|
|
+ console.log(executablePath);
|
|
|
+ executablePath = executablePath.replace("ExecutablePath=", "").trim();
|
|
|
+ if (executablePath === eval(`process.env.PORTABLE_EXECUTABLE_FILE`)) {
|
|
|
+ const getHash = window
|
|
|
+ .nodeRequire("crypto")
|
|
|
+ .createHmac("sha256", "abcdefg")
|
|
|
+ .update(window.nodeRequire("fs").readFileSync(executablePath))
|
|
|
+ .digest("hex");
|
|
|
+ console.log("the hash: ", getHash);
|
|
|
+ }
|
|
|
+ // check filepath executablePath md5
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
}
|