Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
imbillow committed May 1, 2024
1 parent b29ba49 commit b9da7a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
14 changes: 7 additions & 7 deletions librz/arch/il/analysis_il.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,18 @@ RZ_API bool rz_analysis_il_vm_sync_to_reg(RzAnalysisILVM *vm, RZ_NONNULL RzReg *

static void il_events(RzILVM *vm, RzStrBuf *sb) {
void **it;
RzILEvent *evt;
rz_pvector_foreach (vm->events, it) {
evt = *it;
RzILEvent *evt = *it;
rz_il_event_stringify(evt, sb);
rz_strbuf_append(sb, "\n");
}
}

typedef bool (*cond_callback)(RzAnalysisILVM *vm, void *user);

static RzAnalysisILStepResult analysis_il_vm_step_while(
RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *vm, RZ_NULLABLE RzReg *reg,
bool with_events, bool (*cond)(RzAnalysisILVM *vm, void *user), void *user) {
bool with_events, RZ_NONNULL cond_callback cond, RZ_NULLABLE void *user) {

rz_return_val_if_fail(analysis && vm, false);
RzAnalysisPlugin *cur = analysis->cur;
Expand All @@ -253,9 +254,8 @@ static RzAnalysisILStepResult analysis_il_vm_step_while(
}

RzAnalysisILStepResult res = RZ_ANALYSIS_IL_STEP_RESULT_SUCCESS;
ut64 addr = 0;
while (cond(vm, user)) {
addr = rz_bv_to_ut64(vm->vm->pc);
ut64 addr = rz_bv_to_ut64(vm->vm->pc);
ut8 code[32] = { 0 };
analysis->read_at(analysis, addr, code, sizeof(code));
RzAnalysisOp op = { 0 };
Expand Down Expand Up @@ -318,7 +318,7 @@ static RzAnalysisILStepResult analysis_il_vm_step_while(
*/
RZ_API RzAnalysisILStepResult rz_analysis_il_vm_step_while(
RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *vm, RZ_NULLABLE RzReg *reg,
bool (*cond)(RzAnalysisILVM *vm, void *user), void *user) {
RZ_NONNULL cond_callback cond, RZ_NULLABLE void *user) {
return analysis_il_vm_step_while(analysis, vm, reg, false, cond, user);
}

Expand All @@ -342,7 +342,7 @@ RZ_API RzAnalysisILStepResult rz_analysis_il_vm_step_while(
*/
RZ_API RzAnalysisILStepResult rz_analysis_il_vm_step_while_with_events(
RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *vm, RZ_NULLABLE RzReg *reg,
bool (*cond)(RzAnalysisILVM *vm, void *user), void *user) {
RZ_NONNULL cond_callback cond, RZ_NULLABLE void *user) {
return analysis_il_vm_step_while(analysis, vm, reg, true, cond, user);
}

Expand Down
5 changes: 2 additions & 3 deletions librz/il/il_vm_eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,10 @@ RZ_API void rz_il_vm_mem_storew(RzILVM *vm, RzILMemIndex index, RzBitVector *key
RzBitVector *old_value = rz_il_mem_loadw(mem, key, rz_bv_len(value), vm->big_endian);
if (!rz_il_mem_storew(mem, key, value, vm->big_endian)) {
RZ_LOG_ERROR("StoreW mem %u 0x%llx failed\n", (unsigned int)index, rz_bv_to_ut64(key));
return;
goto end;
}
RzBitVector *new_value = rz_il_mem_loadw(mem, key, rz_bv_len(value), vm->big_endian);
assert(rz_bv_eq(new_value, value));
rz_il_vm_event_add(vm, rz_il_event_mem_write_new(key, old_value, value));
end:
rz_bv_free(old_value);
}

Expand Down

0 comments on commit b9da7a9

Please sign in to comment.