mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-13 13:39:07 +08:00
GP-6482: fixes
This commit is contained in:
@@ -48,6 +48,9 @@ function Compute-Python-Args {
|
||||
if ("$Env:OPT_TARGET_IMG" -ne "") {
|
||||
$arglist+=($Env:OPT_TARGET_IMG)
|
||||
}
|
||||
if ("$Env:OPT_X64DBG_EXE" -ne "") {
|
||||
$arglist+=($Env:OPT_X64DBG_EXE)
|
||||
}
|
||||
if ("$Env:OPT_TARGET_DIR" -ne "") {
|
||||
$arglist+=($Env:OPT_TARGET_DIR)
|
||||
}
|
||||
|
||||
@@ -665,15 +665,22 @@ def read_mem(process: Process, range: AddressRange) -> None:
|
||||
def write_mem(process: Process, address: Address, data: bytes) -> None:
|
||||
"""Write memory."""
|
||||
nproc = find_proc_by_obj(process)
|
||||
offset = process.trace.extra.required_mm().map_back(nproc, address)
|
||||
offset = process.trace.extra.require_mm().map_back(nproc, address)
|
||||
dbg().write_memory(offset, data)
|
||||
with commands.open_tracked_tx('Write memory'):
|
||||
commands.putmem(offset, len(data), True, True)
|
||||
|
||||
|
||||
@REGISTRY.method(action='set_reg', display='Set Register')
|
||||
def write_reg(reg: RegisterValueContainer, name: str, value: int) -> None:
|
||||
@REGISTRY.method(action='write_reg', display='Write Register')
|
||||
def write_reg(reg: RegisterValueContainer, name: str, value: bytes) -> None:
|
||||
"""Write a register."""
|
||||
nproc = util.selected_process()
|
||||
dbg().set_reg(name, value)
|
||||
trace: Trace[commands.Extra] = reg.trace
|
||||
rv = trace.extra.require_rm().map_value_back(nproc, name, value)
|
||||
rval = int.from_bytes(rv.value, signed=False)
|
||||
dbg().set_reg(name, rval)
|
||||
with commands.open_tracked_tx('Write Register'):
|
||||
commands.putreg()
|
||||
|
||||
|
||||
def dbg():
|
||||
|
||||
+16
-1
@@ -765,6 +765,10 @@ public class TraceRmiTarget extends AbstractTarget {
|
||||
}
|
||||
|
||||
record WriteRegMatcher(int score, List<ParamSpec> spec) implements MethodMatcher {
|
||||
static final WriteRegMatcher HAS_CONTAINER_NAME_VALUE = new WriteRegMatcher(4, List.of(
|
||||
new TypeParamSpec("container", TraceRegisterContainer.class),
|
||||
new TypeParamSpec("name", String.class),
|
||||
new TypeParamSpec("value", byte[].class)));
|
||||
static final WriteRegMatcher HAS_FRAME_NAME_VALUE = new WriteRegMatcher(3, List.of(
|
||||
new TypeParamSpec("frame", TraceStackFrame.class),
|
||||
new TypeParamSpec("name", String.class),
|
||||
@@ -776,7 +780,8 @@ public class TraceRmiTarget extends AbstractTarget {
|
||||
static final WriteRegMatcher HAS_REG_VALUE = new WriteRegMatcher(1, List.of(
|
||||
new TypeParamSpec("register", TraceRegister.class),
|
||||
new TypeParamSpec("value", byte[].class)));
|
||||
static final List<WriteRegMatcher> ALL = matchers(HAS_FRAME_NAME_VALUE, HAS_REG_VALUE);
|
||||
static final List<WriteRegMatcher> ALL = matchers(HAS_CONTAINER_NAME_VALUE,
|
||||
HAS_FRAME_NAME_VALUE, HAS_THREAD_NAME_VALUE, HAS_REG_VALUE);
|
||||
}
|
||||
|
||||
record BreakExecMatcher(int score, List<ParamSpec> spec) implements MethodMatcher {
|
||||
@@ -1357,6 +1362,16 @@ public class TraceRmiTarget extends AbstractTarget {
|
||||
.toCompletableFuture()
|
||||
.thenApply(__ -> null);
|
||||
}
|
||||
|
||||
RemoteParameter paramContainer = writeReg.params.get("container");
|
||||
if (paramContainer != null) {
|
||||
return writeReg.method.invokeAsync(Map.ofEntries(
|
||||
Map.entry(paramContainer.name(), thread.getObject().findRegisterContainer(0)),
|
||||
Map.entry(writeReg.params.get("name").name(), found.name()),
|
||||
Map.entry(writeReg.params.get("value").name(), getBytes(value))))
|
||||
.toCompletableFuture()
|
||||
.thenApply(__ -> null);
|
||||
}
|
||||
if (found == null || !found.value.isObject()) {
|
||||
return AsyncUtils.nil();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user