mirror of
https://github.com/rizinorg/jsdec.git
synced 2026-11-07 18:36:34 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8180b60b9a | ||
|
|
1903c99b3a | ||
|
|
d958b56f64 |
No files matched your search
@@ -17,7 +17,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout commit
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Install dependencies
|
||||
run: sudo apt -y install meson ninja-build
|
||||
- name: Build & run jsdec as rizin plugin
|
||||
@@ -33,8 +33,8 @@ jobs:
|
||||
- "windows-latest"
|
||||
- "windows-2022"
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-python@v7
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: 3.9.x
|
||||
- name: Preparing msvc toolchain
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v4
|
||||
|
||||
@@ -11,8 +11,8 @@ jobs:
|
||||
name: eslint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v7
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: "21"
|
||||
- name: eslint
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
name: tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v6
|
||||
- name: tests
|
||||
run: chmod +x .ci-scripts/ci-tests.sh && .ci-scripts/ci-tests.sh "${{ github.ref_name }}"
|
||||
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Reuse Compliance Check
|
||||
uses: fsfe/reuse-action@v6
|
||||
with:
|
||||
|
||||
+11
-12
@@ -53,12 +53,11 @@ static JSValue js_analysis_opcodes(JSContext *ctx, RzCore *core) {
|
||||
JSValue ops = JS_NewArray(ctx);
|
||||
st64 op_idx = 0;
|
||||
|
||||
RzIterator iter = (RzIterator){ 0 };
|
||||
if (!rz_core_analysis_bytes(core, core->offset, core->block, core->blocksize, 0, &iter)) {
|
||||
RzIterator *iter = rz_core_analysis_bytes(core, core->offset, core->block, core->blocksize, 0);
|
||||
if (!iter) {
|
||||
return ops;
|
||||
}
|
||||
|
||||
rz_iterator_foreach(&iter, cdb) {
|
||||
rz_iterator_foreach(iter, cdb) {
|
||||
if (!cdb || !strcmp(cdb->opcode, "nop")) {
|
||||
continue;
|
||||
}
|
||||
@@ -66,7 +65,7 @@ static JSValue js_analysis_opcodes(JSContext *ctx, RzCore *core) {
|
||||
JS_SetPropertyInt64(ctx, ops, op_idx, op);
|
||||
op_idx++;
|
||||
}
|
||||
rz_iterator_fini(&iter);
|
||||
rz_iterator_free(iter);
|
||||
return ops;
|
||||
}
|
||||
|
||||
@@ -112,14 +111,14 @@ static JSValue js_command(JSContext *ctx, JSValueConst jsThis, int argc, JSValue
|
||||
|
||||
ExecContext *ectx = (ExecContext *)JS_GetContextOpaque(ctx);
|
||||
RzCore *core = ectx->core;
|
||||
rz_interrupt_sleep_end(core->intr, ectx->bed);
|
||||
rz_cons_sleep_end(ectx->bed);
|
||||
|
||||
char *output = rz_core_cmd_str(core, command);
|
||||
JS_FreeCString(ctx, command);
|
||||
JSValue result = JS_NewString(ctx, output ? output : "");
|
||||
free(output);
|
||||
|
||||
ectx->bed = rz_interrupt_sleep_begin(core->intr);
|
||||
ectx->bed = rz_cons_sleep_begin();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -129,11 +128,11 @@ static JSValue js_graph(JSContext *ctx, JSValueConst jsThis, int argc, JSValueCo
|
||||
}
|
||||
ExecContext *ectx = (ExecContext *)JS_GetContextOpaque(ctx);
|
||||
RzCore *core = ectx->core;
|
||||
rz_interrupt_sleep_end(core->intr, ectx->bed);
|
||||
rz_cons_sleep_end(ectx->bed);
|
||||
|
||||
RzAnalysisFunction *fcn = rz_analysis_get_fcn_in(core->analysis, core->offset, -1);
|
||||
if (!fcn) {
|
||||
ectx->bed = rz_interrupt_sleep_begin(core->intr);
|
||||
ectx->bed = rz_cons_sleep_begin();
|
||||
return JS_ThrowInternalError(ctx, "Cannot find function at 0x%08" PFMT64x, core->offset);
|
||||
}
|
||||
|
||||
@@ -143,7 +142,7 @@ static JSValue js_graph(JSContext *ctx, JSValueConst jsThis, int argc, JSValueCo
|
||||
JS_SetPropertyStr(ctx, object, "name", JS_NewString(ctx, rz_str_get_null(fcn->name)));
|
||||
JSValue blocks = js_function_bbs(ctx, core, fcn);
|
||||
JS_SetPropertyStr(ctx, object, "blocks", blocks);
|
||||
ectx->bed = rz_interrupt_sleep_begin(core->intr);
|
||||
ectx->bed = rz_cons_sleep_begin();
|
||||
return graph;
|
||||
}
|
||||
|
||||
@@ -357,9 +356,9 @@ RZ_API RzAnnotatedCode *jsdec_as_annotation(RzCore *core, ut64 addr) {
|
||||
rz_core_seek(core, addr, true);
|
||||
}
|
||||
|
||||
ectx.bed = rz_interrupt_sleep_begin(core->intr);
|
||||
ectx.bed = rz_cons_sleep_begin();
|
||||
bool ret = jsdec_run(dec);
|
||||
rz_interrupt_sleep_end(core->intr, ectx.bed);
|
||||
rz_cons_sleep_end(ectx.bed);
|
||||
|
||||
if (offset != addr) {
|
||||
rz_core_seek(core, offset, true);
|
||||
|
||||
+15
-21
@@ -11,7 +11,6 @@
|
||||
#include <rz_analysis.h>
|
||||
|
||||
#include "jsdec.h"
|
||||
#include "rz_util/rz_iterator.h"
|
||||
|
||||
typedef struct rz_core_t RzCore;
|
||||
|
||||
@@ -81,11 +80,11 @@ static JSValue js_analysis_opcodes(JSContext *ctx, RzCore *core) {
|
||||
JSValue ops = JS_NewArray(ctx);
|
||||
st64 op_idx = 0;
|
||||
|
||||
RzIterator iter = (RzIterator){ 0 };
|
||||
if (!rz_core_analysis_bytes(core, core->offset, core->block, core->blocksize, 0, &iter)) {
|
||||
RzIterator *iter = rz_core_analysis_bytes(core, core->offset, core->block, core->blocksize, 0);
|
||||
if (!iter) {
|
||||
return ops;
|
||||
}
|
||||
rz_iterator_foreach(&iter, cdb) {
|
||||
rz_iterator_foreach (iter, cdb) {
|
||||
if (!cdb || !strcmp(cdb->opcode, "nop")) {
|
||||
continue;
|
||||
}
|
||||
@@ -93,7 +92,7 @@ static JSValue js_analysis_opcodes(JSContext *ctx, RzCore *core) {
|
||||
JS_SetPropertyInt64(ctx, ops, op_idx, op);
|
||||
op_idx++;
|
||||
}
|
||||
rz_iterator_fini(&iter);
|
||||
rz_iterator_free(iter);
|
||||
return ops;
|
||||
}
|
||||
|
||||
@@ -139,14 +138,14 @@ static JSValue js_command(JSContext *ctx, JSValueConst jsThis, int argc, JSValue
|
||||
|
||||
ExecContext *ectx = (ExecContext *)JS_GetContextOpaque(ctx);
|
||||
RzCore *core = ectx->core;
|
||||
rz_interrupt_sleep_end(core->intr, ectx->bed);
|
||||
rz_cons_sleep_end(ectx->bed);
|
||||
|
||||
char *output = rz_core_cmd_str(core, command);
|
||||
JS_FreeCString(ctx, command);
|
||||
JSValue result = JS_NewString(ctx, output ? output : "");
|
||||
free(output);
|
||||
|
||||
ectx->bed = rz_interrupt_sleep_begin(core->intr);
|
||||
ectx->bed = rz_cons_sleep_begin();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -156,11 +155,11 @@ static JSValue js_graph(JSContext *ctx, JSValueConst jsThis, int argc, JSValueCo
|
||||
}
|
||||
ExecContext *ectx = (ExecContext *)JS_GetContextOpaque(ctx);
|
||||
RzCore *core = ectx->core;
|
||||
rz_interrupt_sleep_end(core->intr, ectx->bed);
|
||||
rz_cons_sleep_end(ectx->bed);
|
||||
|
||||
RzAnalysisFunction *fcn = rz_analysis_get_fcn_in(core->analysis, core->offset, -1);
|
||||
if (!fcn) {
|
||||
ectx->bed = rz_interrupt_sleep_begin(core->intr);
|
||||
ectx->bed = rz_cons_sleep_begin();
|
||||
return JS_ThrowInternalError(ctx, "Cannot find function at 0x%08" PFMT64x, core->offset);
|
||||
}
|
||||
|
||||
@@ -170,29 +169,24 @@ static JSValue js_graph(JSContext *ctx, JSValueConst jsThis, int argc, JSValueCo
|
||||
JS_SetPropertyStr(ctx, object, "name", JS_NewString(ctx, rz_str_get_null(fcn->name)));
|
||||
JSValue blocks = js_function_bbs(ctx, core, fcn);
|
||||
JS_SetPropertyStr(ctx, object, "blocks", blocks);
|
||||
ectx->bed = rz_interrupt_sleep_begin(core->intr);
|
||||
ectx->bed = rz_cons_sleep_begin();
|
||||
return graph;
|
||||
}
|
||||
|
||||
static JSValue js_console_log(JSContext *ctx, JSValueConst jsThis, int argc, JSValueConst *argv) {
|
||||
ExecContext *ectx = (ExecContext *)JS_GetContextOpaque(ctx);
|
||||
if (!ectx || !ectx->core) {
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
RzCons *cons = ectx->core->cons;
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
if (i != 0) {
|
||||
rz_cons_print(cons, " ");
|
||||
rz_cons_print(" ");
|
||||
}
|
||||
const char *str = JS_ToCString(ctx, argv[i]);
|
||||
if (!str) {
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
rz_cons_print(cons, str);
|
||||
rz_cons_print(str);
|
||||
JS_FreeCString(ctx, str);
|
||||
}
|
||||
rz_cons_newline(cons);
|
||||
rz_cons_flush(cons);
|
||||
rz_cons_newline();
|
||||
rz_cons_flush();
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
@@ -251,9 +245,9 @@ static bool jsdec_main(RzCore *core, const char *arg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ectx.bed = rz_interrupt_sleep_begin(core->intr);
|
||||
ectx.bed = rz_cons_sleep_begin();
|
||||
bool ret = jsdec_run(dec);
|
||||
rz_interrupt_sleep_end(core->intr, ectx.bed);
|
||||
rz_cons_sleep_end(ectx.bed);
|
||||
|
||||
jsdec_destroy(dec, &ectx);
|
||||
return ret;
|
||||
|
||||
@@ -9,15 +9,11 @@ import ColorsInvalid from './colors/invalid.js';
|
||||
|
||||
function initializeColors() {
|
||||
const config = {};
|
||||
if (rizin) {
|
||||
const raw = rizin.command("ecj");
|
||||
const colors = JSON.parse(raw || "{}");
|
||||
if (colors && typeof colors === 'object' && !Array.isArray(colors)) {
|
||||
Object.keys(colors).forEach(function(key) {
|
||||
config[key] = colors[key];
|
||||
});
|
||||
}
|
||||
}
|
||||
const colors = rizin ? rizin.command("ec*") : '';
|
||||
colors.split('\n').forEach(function(line) {
|
||||
const tok = line.split(' ');
|
||||
config[tok[1]] = tok[2];
|
||||
});
|
||||
return {
|
||||
"callname": config['call'] || 'gray',
|
||||
"integers": config['num'] || 'cyan',
|
||||
|
||||
Reference in new issue
Block a user