mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-21 23:54:26 +08:00
[Feat] Further PLS ctrl & childProc perf improvements
This commit is contained in:
@@ -164,12 +164,12 @@ class ConfigManager {
|
||||
/**
|
||||
*
|
||||
* @param {Record<any, any>} config
|
||||
* @returns {boolean}
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
writeConfig(config) {
|
||||
async writeConfig(config) {
|
||||
try {
|
||||
if (this.useEncConfig) {
|
||||
const hashedPasswdResultObj = this.retrieveEncPassword();
|
||||
const hashedPasswdResultObj = await this.retrieveEncPasswordAsync();
|
||||
if (hashedPasswdResultObj.success && hashedPasswdResultObj.data) {
|
||||
this.encryptConfig(config, hashedPasswdResultObj.data);
|
||||
} else {
|
||||
@@ -261,7 +261,7 @@ class ConfigManager {
|
||||
*
|
||||
* @param {SHA256EncryptedPassword} password
|
||||
*/
|
||||
saveEncPassword(password) {
|
||||
async saveEncPassword(password) {
|
||||
let macAddr = this.priv_getMacAddr();
|
||||
let fallbackToStaticKey = false;
|
||||
|
||||
@@ -290,25 +290,25 @@ class ConfigManager {
|
||||
const ivHex = iv.toString("hex");
|
||||
const saltHex = randomSalt.toString("hex");
|
||||
|
||||
registryManager.createOrUpdateRegKey(
|
||||
await registryManager.createOrUpdateRegKey(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_Value",
|
||||
encryptedPassword,
|
||||
true
|
||||
);
|
||||
registryManager.createOrUpdateRegKey(
|
||||
await registryManager.createOrUpdateRegKey(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_IV",
|
||||
ivHex,
|
||||
true
|
||||
);
|
||||
registryManager.createOrUpdateRegKey(
|
||||
await registryManager.createOrUpdateRegKey(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_Salt",
|
||||
saltHex,
|
||||
true
|
||||
);
|
||||
registryManager.createOrUpdateRegKey(
|
||||
await registryManager.createOrUpdateRegKey(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_AuthTag",
|
||||
authTagHex,
|
||||
@@ -316,7 +316,7 @@ class ConfigManager {
|
||||
);
|
||||
|
||||
if (fallbackToStaticKey) {
|
||||
registryManager.createOrUpdateRegKey(
|
||||
await registryManager.createOrUpdateRegKey(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_FakeMac",
|
||||
macAddr,
|
||||
@@ -329,22 +329,22 @@ class ConfigManager {
|
||||
|
||||
retrieveEncPassword() {
|
||||
try {
|
||||
const authTagHex = registryManager.readRegKey(
|
||||
const authTagHex = registryManager.readRegKeySync(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_AuthTag",
|
||||
true
|
||||
)?.data;
|
||||
const ivHex = registryManager.readRegKey(
|
||||
const ivHex = registryManager.readRegKeySync(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_IV",
|
||||
true
|
||||
)?.data;
|
||||
const saltHex = registryManager.readRegKey(
|
||||
const saltHex = registryManager.readRegKeySync(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_Salt",
|
||||
true
|
||||
)?.data;
|
||||
const encPasswdHex = registryManager.readRegKey(
|
||||
const encPasswdHex = registryManager.readRegKeySync(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_Value",
|
||||
true
|
||||
@@ -353,7 +353,7 @@ class ConfigManager {
|
||||
let macAddr = null;
|
||||
|
||||
try {
|
||||
macAddr = registryManager.readRegKey(
|
||||
macAddr = registryManager.readRegKeySync(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_FakeMac",
|
||||
true
|
||||
@@ -433,8 +433,112 @@ class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
clearEncPasswdRegKey() {
|
||||
registryManager.delRegKey(LMAK_SETTINGS_BASE, null);
|
||||
async retrieveEncPasswordAsync() {
|
||||
try {
|
||||
const authTagHex = (
|
||||
await registryManager.readRegKey(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_AuthTag",
|
||||
true
|
||||
)
|
||||
).data;
|
||||
const ivHex = (
|
||||
await registryManager.readRegKey(LMAK_SETTINGS_BASE, "LMAK_IV", true)
|
||||
).data;
|
||||
const saltHex = (
|
||||
await registryManager.readRegKey(LMAK_SETTINGS_BASE, "LMAK_Salt", true)
|
||||
).data;
|
||||
const encPasswdHex = (
|
||||
await registryManager.readRegKey(LMAK_SETTINGS_BASE, "LMAK_Value", true)
|
||||
).data;
|
||||
let isStaticKey = false;
|
||||
let macAddr = null;
|
||||
|
||||
try {
|
||||
macAddr = (
|
||||
await registryManager.readRegKey(
|
||||
LMAK_SETTINGS_BASE,
|
||||
"LMAK_FakeMac",
|
||||
true
|
||||
)
|
||||
).data;
|
||||
if (!macAddr) {
|
||||
isStaticKey = false;
|
||||
} else {
|
||||
isStaticKey = true;
|
||||
}
|
||||
} catch {
|
||||
isStaticKey = false;
|
||||
}
|
||||
|
||||
if (!isStaticKey) {
|
||||
macAddr = this.priv_getMacAddr();
|
||||
|
||||
if (!macAddr) {
|
||||
console.error(
|
||||
"[HugoAura / Config / ERROR] Failed to retrieve password from reg: MAC Address invalid."
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
error: new Error("Mac is null or undefined"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (!saltHex || !ivHex || !authTagHex || !encPasswdHex) {
|
||||
console.error(
|
||||
"[HugoAura / Config / ERROR] Failed to retrieve password from reg: Reg keys invalid."
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
error: new Error("Reg key invalid"),
|
||||
};
|
||||
}
|
||||
const salt = Buffer.from(saltHex, "hex");
|
||||
const iv = Buffer.from(ivHex, "hex");
|
||||
const authTag = Buffer.from(authTagHex, "hex");
|
||||
const encPasswd = Buffer.from(encPasswdHex, "utf-8").toString();
|
||||
|
||||
const key = crypto.scryptSync(macAddr, salt, 32);
|
||||
const decipherIns = crypto.createDecipheriv(
|
||||
CRYPTO_SETTINGS_AES.mode,
|
||||
key,
|
||||
iv,
|
||||
{
|
||||
// @ts-expect-error
|
||||
authTagLength: CRYPTO_SETTINGS_AES.tagLength,
|
||||
}
|
||||
);
|
||||
|
||||
decipherIns.setAuthTag(authTag);
|
||||
|
||||
const result = Buffer.concat([
|
||||
decipherIns.update(encPasswd, "hex"),
|
||||
decipherIns.final(),
|
||||
]).toString();
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: result,
|
||||
error: null,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error(
|
||||
"[HugoAura / Config / ERROR] Unexpected error occurred while retrieving password from reg, error:",
|
||||
e
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
error: e,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async clearEncPasswdRegKey() {
|
||||
await registryManager.delRegKey(LMAK_SETTINGS_BASE, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -443,7 +547,7 @@ class ConfigManager {
|
||||
* @param {SHA256EncryptedPassword} passwd
|
||||
*/
|
||||
encryptConfig(configData, passwd) {
|
||||
registryManager.initRegistry();
|
||||
registryManager.initRegistrySync();
|
||||
const salt = crypto.randomBytes(CRYPTO_SETTINGS_AES.saltLength);
|
||||
const key = crypto.pbkdf2Sync(
|
||||
passwd,
|
||||
@@ -617,9 +721,9 @@ class ConfigManager {
|
||||
*
|
||||
* @param {Record<any, any> | null} curConfig
|
||||
* @param {SHA256EncryptedPassword | undefined | null} passwd
|
||||
* @returns {{success: boolean}}
|
||||
* @returns {Promise<{success: boolean}>}
|
||||
*/
|
||||
switchToDecConfig(curConfig, passwd = null) {
|
||||
async switchToDecConfig(curConfig, passwd = null) {
|
||||
let decConfig = null;
|
||||
if (!curConfig && passwd) {
|
||||
const getDecConfigResult = this.decryptConfig(passwd);
|
||||
@@ -639,7 +743,7 @@ class ConfigManager {
|
||||
}
|
||||
|
||||
this.useEncConfig = false;
|
||||
this.clearEncPasswdRegKey();
|
||||
await this.clearEncPasswdRegKey();
|
||||
// @ts-expect-error
|
||||
this.writeConfig(curConfig ? curConfig : decConfig);
|
||||
try {
|
||||
|
||||
@@ -1,20 +1,52 @@
|
||||
// @ts-check
|
||||
|
||||
const childProc = require("child_process");
|
||||
const { exec, execSync } = require("child_process");
|
||||
|
||||
// Constants
|
||||
|
||||
const LOG_PREFIX = "[HugoAura / Init / Reg";
|
||||
const LOG_PREFIX_FUNC = "[HugoAura / Reg";
|
||||
const AURA_REGISTRY_PATH = ["HKCU", "SOFTWARE", "HugoAura"].join("\\");
|
||||
const AURA_REGISTRY_PATH = ["HKEY_USERS", ".DEFAULT", "SOFTWARE", "HugoAura"].join("\\");
|
||||
|
||||
class RegistryManager {
|
||||
/**
|
||||
* @param {string} [path]
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
handleCreateReg(path) {
|
||||
async handleCreateReg(path) {
|
||||
try {
|
||||
const createResult = childProc.execSync(["reg", "add", path].join(" "), {
|
||||
const { stdout } = await new Promise((resolve, reject) => {
|
||||
exec(
|
||||
["reg", "add", path].join(" "),
|
||||
{ encoding: "utf8" },
|
||||
(error, stdout, stderr) => {
|
||||
if (error) reject(error);
|
||||
else resolve({ stdout, stderr });
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
console.log(
|
||||
`${LOG_PREFIX} / SUCCESS] Registry path ${path} successfully created.`
|
||||
);
|
||||
console.debug(`${LOG_PREFIX} / DEBUG] Reg add command stdout:`, stdout);
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`${LOG_PREFIX} / ERROR] Failed creating registry path, error:`,
|
||||
e
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [path]
|
||||
* @returns {boolean}
|
||||
*/
|
||||
handleCreateRegSync(path) {
|
||||
try {
|
||||
const createResult = execSync(["reg", "add", path].join(" "), {
|
||||
encoding: "utf8",
|
||||
});
|
||||
|
||||
@@ -27,6 +59,8 @@ class RegistryManager {
|
||||
createResult
|
||||
);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(
|
||||
@@ -37,9 +71,37 @@ class RegistryManager {
|
||||
}
|
||||
}
|
||||
|
||||
initRegistry() {
|
||||
/**
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async initRegistry() {
|
||||
try {
|
||||
const queryResult = childProc.execSync(
|
||||
const { stdout } = await new Promise((resolve, reject) => {
|
||||
exec(
|
||||
["reg", "query", AURA_REGISTRY_PATH].join(" "),
|
||||
{ encoding: "utf8" },
|
||||
(error, stdout, stderr) => {
|
||||
if (error) reject(error);
|
||||
else resolve({ stdout, stderr });
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
console.log(`${LOG_PREFIX}] Registry check up success.`);
|
||||
console.debug(`${LOG_PREFIX}] Command stdout:`, stdout);
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.warn(`${LOG_PREFIX} / WARN] Failed to query registry, error:`, e);
|
||||
return await this.handleCreateReg(AURA_REGISTRY_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
initRegistrySync() {
|
||||
try {
|
||||
const queryResult = execSync(
|
||||
["reg", "query", AURA_REGISTRY_PATH].join(" "),
|
||||
{ encoding: "utf8" }
|
||||
);
|
||||
@@ -48,23 +110,81 @@ class RegistryManager {
|
||||
console.log(`${LOG_PREFIX}] Registry check up success.`);
|
||||
console.debug(`${LOG_PREFIX}] Command stdout:`, queryResult);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(`${LOG_PREFIX} / WARN] Failed to query registry, error:`, e);
|
||||
return this.handleCreateReg(AURA_REGISTRY_PATH);
|
||||
return this.handleCreateRegSync(AURA_REGISTRY_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} relativePath
|
||||
* @param {string} keyName
|
||||
* @param {string} keyVal
|
||||
* @param {boolean | undefined} silent
|
||||
* @returns {Promise<{ success: boolean, error: Error | null }>}
|
||||
*/
|
||||
createOrUpdateRegKey(relativePath, keyName, keyVal, silent = false) {
|
||||
async createOrUpdateRegKey(relativePath, keyName, keyVal, silent = false) {
|
||||
try {
|
||||
const result = childProc.execSync(
|
||||
const { stdout } = await new Promise((resolve, reject) => {
|
||||
exec(
|
||||
[
|
||||
"reg",
|
||||
"add",
|
||||
[AURA_REGISTRY_PATH, relativePath].join("\\"),
|
||||
"/v",
|
||||
keyName,
|
||||
"/t",
|
||||
"REG_SZ",
|
||||
"/d",
|
||||
`\"${keyVal}\"`,
|
||||
"/f",
|
||||
].join(" "),
|
||||
{ encoding: "utf8" },
|
||||
(error, stdout, stderr) => {
|
||||
if (error) reject(error);
|
||||
else resolve({ stdout, stderr });
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (!silent) {
|
||||
console.debug(
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Successfully created / updated reg key ${relativePath}/${keyName} with data: ${keyVal}`
|
||||
);
|
||||
console.debug(
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Add key command stdout:`,
|
||||
stdout
|
||||
);
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
error: null,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`${LOG_PREFIX_FUNC} / ERROR] Failed to create / update reg key, error:`,
|
||||
silent ? "<Hidden>" : e
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
error: e,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} relativePath
|
||||
* @param {string} keyName
|
||||
* @param {string} keyVal
|
||||
* @param {boolean | undefined} silent
|
||||
* @returns {{ success: boolean, error: Error | null }}
|
||||
*/
|
||||
createOrUpdateRegKeySync(relativePath, keyName, keyVal, silent = false) {
|
||||
try {
|
||||
const result = execSync(
|
||||
[
|
||||
"reg",
|
||||
"add",
|
||||
@@ -83,21 +203,76 @@ class RegistryManager {
|
||||
if (result) {
|
||||
if (!silent) {
|
||||
console.debug(
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Successfully created / updated reg key ${relativePath}/${keyName} with data: ${keyVal}`
|
||||
);
|
||||
console.debug(
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Add key command stdout:`,
|
||||
`${LOG_PREFIX} / SUCCESS] Successfully created / updated reg key ${relativePath}/${keyName} with data: ${keyVal}`,
|
||||
result
|
||||
);
|
||||
console.error("");
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
error: null,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`${LOG_PREFIX_FUNC} / ERROR] Failed to create / update reg key, error:`,
|
||||
`${LOG_PREFIX_FUNC} / ERROR] Failed to create / update reg key error:`,
|
||||
e
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
error: e,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} relativePath
|
||||
* @param {string | null} keyName
|
||||
* @param {boolean | undefined} silent
|
||||
* @returns {Promise<{ success: boolean, error: Error | null }>}
|
||||
*/
|
||||
async delRegKey(relativePath, keyName, silent = false) {
|
||||
if (keyName === undefined) {
|
||||
throw new Error(
|
||||
`${LOG_PREFIX_FUNC} / CRITICAL] Arg \"keyName\" for function \"delRegKey\" cannot be undefined. Only null or null accepted.`
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const { stdout } = await new Promise((resolve, reject) => {
|
||||
exec(
|
||||
[
|
||||
"reg",
|
||||
"delete",
|
||||
[AURA_REGISTRY_PATH, relativePath].join("\\"),
|
||||
keyName ? "/v" : "",
|
||||
keyName ? keyName : "",
|
||||
"/f",
|
||||
].join(" "),
|
||||
{ encoding: "utf8" },
|
||||
(error, stdout, stderr) => {
|
||||
if (error) reject(error);
|
||||
else resolve({ stdout, stderr });
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (!silent) {
|
||||
console.debug(
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Successfully deleted reg key ${relativePath}/${keyName}`
|
||||
);
|
||||
console.debug(
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Delete key command stdout:`,
|
||||
stdout
|
||||
);
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
error: null,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`${LOG_PREFIX_FUNC} / ERROR] Failed to delete reg key, error:`,
|
||||
silent ? "<Hidden>" : e
|
||||
);
|
||||
return {
|
||||
@@ -107,24 +282,21 @@ class RegistryManager {
|
||||
}
|
||||
}
|
||||
|
||||
/*>>> BUC <<<
|
||||
keyName === null --> delete the whole entry
|
||||
>>> EUC <<<*/
|
||||
/**
|
||||
*
|
||||
* @param {string} relativePath
|
||||
* @param {string | null} keyName
|
||||
* @param {boolean | undefined} silent
|
||||
* @returns {{ success: boolean, error: Error | null }}
|
||||
*/
|
||||
delRegKey(relativePath, keyName, silent = false) {
|
||||
delRegKeySync(relativePath, keyName, silent = false) {
|
||||
if (keyName === undefined) {
|
||||
throw new Error(
|
||||
`${LOG_PREFIX_FUNC} / CRITICAL] Arg \"keyName\" for function \"delRegKey\" cannot be undefined. Only null or string accepted.`
|
||||
`${LOG_PREFIX_FUNC} / CRITICAL] Arg \"keyName\" for function \"delRegKeySync\" cannot be undefined. Only null or string accepted.`
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const result = childProc.execSync(
|
||||
const result = execSync(
|
||||
[
|
||||
"reg",
|
||||
"delete",
|
||||
@@ -150,6 +322,11 @@ class RegistryManager {
|
||||
success: true,
|
||||
error: null,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
success: false,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(
|
||||
@@ -164,14 +341,76 @@ class RegistryManager {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} relativePath
|
||||
* @param {string} keyName
|
||||
* @param {boolean | undefined} silent
|
||||
* @returns {Promise<{ success: boolean, data: string | null, error: Error | null }>}
|
||||
*/
|
||||
readRegKey(relativePath, keyName, silent = false) {
|
||||
async readRegKey(relativePath, keyName, silent = false) {
|
||||
try {
|
||||
const readResult = childProc.execSync(
|
||||
const { stdout } = await new Promise((resolve, reject) => {
|
||||
exec(
|
||||
[
|
||||
"reg",
|
||||
"query",
|
||||
[AURA_REGISTRY_PATH, relativePath].join("\\"),
|
||||
"/v",
|
||||
`\"${keyName}\"`,
|
||||
].join(" "),
|
||||
{ encoding: "utf8" },
|
||||
(error, stdout, stderr) => {
|
||||
if (error) reject(error);
|
||||
else resolve({ stdout, stderr });
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (!silent) {
|
||||
console.debug(
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Successfully read reg key ${relativePath}/${keyName}, stdout:`,
|
||||
stdout
|
||||
);
|
||||
}
|
||||
|
||||
const match = stdout.match(/REG_SZ\s+(.+)/);
|
||||
|
||||
if (!match) {
|
||||
console.warn(`${LOG_PREFIX} / WARN] Data not found in stdout`);
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
error: new Error("Data not found"),
|
||||
};
|
||||
}
|
||||
|
||||
const data = match[1].trim();
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
error: null,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`${LOG_PREFIX} / ERROR] Failed to read reg key, error:`,
|
||||
e
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
error: e,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} relativePath
|
||||
* @param {string} keyName
|
||||
* @param {boolean | undefined} silent
|
||||
* @returns {{ success: boolean, data: string | null, error: Error | null }}
|
||||
*/
|
||||
readRegKeySync(relativePath, keyName, silent = false) {
|
||||
try {
|
||||
const readResult = execSync(
|
||||
[
|
||||
"reg",
|
||||
"query",
|
||||
@@ -185,14 +424,14 @@ class RegistryManager {
|
||||
if (readResult) {
|
||||
if (!silent) {
|
||||
console.debug(
|
||||
`${LOG_PREFIX}] Successfully read reg key ${relativePath}/${keyName}, stdout:`,
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Successfully read reg key ${relativePath}/${keyName}, stdout:`,
|
||||
readResult
|
||||
);
|
||||
}
|
||||
const match = readResult.match(/REG_SZ\s+(.+)/);
|
||||
|
||||
if (!match) {
|
||||
console.warn(`${LOG_PREFIX_FUNC} / WARN] Data not found in stdout`);
|
||||
console.warn(`${LOG_PREFIX} / WARN] Data not found in stdout`);
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
@@ -206,10 +445,16 @@ class RegistryManager {
|
||||
data,
|
||||
error: null,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`${LOG_PREFIX_FUNC} / ERROR] Failed to read reg key, error:`,
|
||||
`${LOG_PREFIX} / ERROR] Failed to read reg key, error:`,
|
||||
silent ? "<Hidden>" : e
|
||||
);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user