From 917abb1ceb487008adf1a74e87d237b091e61cf8 Mon Sep 17 00:00:00 2001 From: danghongquan Date: Fri, 7 Mar 2025 14:01:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=E6=9C=8D=E5=8A=A1=E7=AB=AF=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E7=AB=AF=E5=8F=A3=E5=8D=A0=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: danghongquan --- app.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app.js b/app.js index 609cbaa..46e7db5 100644 --- a/app.js +++ b/app.js @@ -88,6 +88,9 @@ wss.on('connection', function connection(ws) { // 当发生错误时触发 ws.on('error', function error(err) { + if(err.code === 'EADDRINUSE') { + logger.err(`Port ${Utils.AuthMsg.SW_PORT} is occupied`); + } logger.error(`Connection error:${err}`); }); }) -- Gitee From ce656f3528a54bc66d5147107b164ccece512714 Mon Sep 17 00:00:00 2001 From: danghongquan Date: Fri, 7 Mar 2025 14:02:25 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E8=AF=8A=E6=96=AD?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: danghongquan --- ai/ai.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai/ai.js b/ai/ai.js index 13ae385..501d3c6 100644 --- a/ai/ai.js +++ b/ai/ai.js @@ -115,7 +115,7 @@ function diagnosis(dirPath, filePath, session_id, data) { // 文件存在时,调用算法库,获取诊断结果 const mainExePath = path.join(__dirname, '..', 'bin', 'main.exe'); let command = `"${mainExePath.replace(/\\/g, "/")}" --db_path "${filePath.replace(/\\/g, "/")}"${str}`; - exec(command, {encoding: 'buffer'}, (error, stdout, stderr) => { + exec(command, {encoding: 'buffer',maxBuffer: 1024 * 1024 * 500}, (error, stdout, stderr) => { if (error || (stderr && stderr.length > 0)) { message.code = 1; message.message = `error: ${error ? error.message : stderr.toString()}`; -- Gitee From 58bf37efe19618ea15d2f8d12bda2bfe49f1a543 Mon Sep 17 00:00:00 2001 From: danghongquan Date: Fri, 7 Mar 2025 14:03:44 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E7=82=B9=E5=87=BBfun?= =?UTF-8?q?ction=E6=B5=81=E7=A8=8B&&=E7=82=B9=E5=87=BBfunction=E8=B6=85?= =?UTF-8?q?=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: danghongquan --- disassembly/disassembly.js | 65 ++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 14 deletions(-) diff --git a/disassembly/disassembly.js b/disassembly/disassembly.js index 7a79d60..b78b44b 100644 --- a/disassembly/disassembly.js +++ b/disassembly/disassembly.js @@ -24,6 +24,7 @@ const SAVE_CMD = 1; // {file_name:str, buffer:str, buffer_size:num, tota const SAVE_BACK_CMD = 2; // {result:num, msg:str} const QUERY_CMD = 3; // {elf_name:str, vaddr:str, func:str} const QUERY_BACK_CMD = 4; // {result:num, msg:str} +const DISASSEMBLY_QUERY_ELF_CMD = 5;// {elf_name:str, vaddr:str, func:str} const logger = winston.createLogger(require('./../winston.config.js')); const decoder = new TextDecoder('utf-8'); // 'utf-8' 是常见的字符编码 @@ -55,9 +56,40 @@ function process(session_id, cmd, data) { save(session_id, data); } else if (cmd === QUERY_CMD) { queryData(session_id, data); + } else if (cmd === DISASSEMBLY_QUERY_ELF_CMD) { + checkElf(session_id, data); } } +/** + * 搜索so/an文件 + */ +function checkElf(session_id, data) { + const decodedData = decoder.decode(data); + const jsonData = JSON.parse(decodedData); + let { elf_name, vaddr, func } = jsonData; + if (elf_name.endsWith('.an')) { + let anFilePath = path.join(TEMP_DIR, `session_${session_id}`, elf_name); + if (!fs.existsSync(anFilePath)) { + const msg = `FileNotFoundError: please import "${elf_name}"`; + logger.error('error:' + msg); + sendMsg(session_id, DISASSEMBLY_QUERY_ELF_CMD, { code: 1, message: msg }); + return; + } else { + sendMsg(session_id, DISASSEMBLY_QUERY_ELF_CMD, { code: 0, message: 'OK' }); + } + } else { + let soInfoTxt = path.join(TEMP_DIR, `session_${session_id}`, `${elf_name.replace('.', '_')}.txt`); + if (!fs.existsSync(soInfoTxt)) { + const msg = `FileNotFoundError: please import "${elf_name}"`; + logger.error('error:' + msg); + sendMsg(session_id, DISASSEMBLY_QUERY_ELF_CMD, { code: 1, message: msg }); + return; + } else { + sendMsg(session_id, DISASSEMBLY_QUERY_ELF_CMD, { code: 0, message: 'OK' }); + } + } +} /** * 写入ELF文件 */ @@ -282,23 +314,28 @@ function queryData(session_id, data) { let resultString = ''; let addrArray = []; rl.on('line', (line) => { - if (isInTargetRange) { - if (line.startsWith(prefix)) { - isInTargetRange = false; - rl.close(); - } else if (line.trim() !== '') { - let addr = line.split(`:`)[0].replace(/\s+/g, ''); - let instruction = line.split(`:`)[1]; - instruction = instruction.substring(instruction.indexOf(' ')); - instruction = instruction.replace(/\s+/g, ' ').trimStart().trimEnd(); - addrArray.push("0x"+addr) - resultString += `{\"addr\":\"0x${addr}\", \"instruction\":\"${instruction}\"},`; + try { + if (isInTargetRange) { + if (line.startsWith(prefix)) { + isInTargetRange = false; + rl.close(); + } else if (line.trim() !== '') { + let addr = line.split(`:`)[0].replace(/\s+/g, ''); + let instruction = line.split(`:`)[1]; + instruction = instruction.substring(instruction.indexOf(' ')); + instruction = instruction.replace(/\s+/g, ' ').trimStart().trimEnd(); + addrArray.push("0x" + addr) + resultString += `{\"addr\":\"0x${addr}\", \"instruction\":\"${instruction}\"},`; + } } - } - if (!isInTargetRange && line.startsWith(target)) { - isInTargetRange = true; + if (!isInTargetRange && line.startsWith(target)) { + isInTargetRange = true; + } + } catch (error) { + const errMsg = `Reading failed.Error):[${error.message}]`; } + }); rl.on('close', async () => { -- Gitee From 18c50b4c852041fa3e91092c446492ffb52916cc Mon Sep 17 00:00:00 2001 From: danghongquan Date: Fri, 7 Mar 2025 14:04:57 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=E6=89=A9=E5=B1=95=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: danghongquan --- version.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.js b/version.js index 0ca4ca8..b67bf7a 100644 --- a/version.js +++ b/version.js @@ -13,7 +13,7 @@ * limitations under the License. */ class version { - static version = '1.1.0'; //版本号 + static version = '1.1.1'; //版本号 } module.exports = { -- Gitee