Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz
2026-01-12 06:26:11 -05:00
4 changed files with 24 additions and 19 deletions
@@ -417,7 +417,7 @@ bool SubvariableFlow::traceForward(ReplaceVarnode *rvn)
} }
// Is the small variable getting zero padded into something that is fully consumed // Is the small variable getting zero padded into something that is fully consumed
if ((!aggressive)&&((outvn->getConsume() & rvn->mask) != outvn->getConsume())) { if ((!aggressive)&&((outvn->getConsume() & rvn->mask) != outvn->getConsume())) {
addSuggestedPatch(rvn,op,-1); addExtensionPatch(rvn,op,-1);
hcount += 1; // Dealt with this descendant hcount += 1; // Dealt with this descendant
break; break;
} }
@@ -477,10 +477,10 @@ bool SubvariableFlow::traceForward(ReplaceVarnode *rvn)
newmask = (rvn->mask << sa) & calc_mask( outvn->getSize() ); newmask = (rvn->mask << sa) & calc_mask( outvn->getSize() );
if (newmask == 0) break; // Subvar is cleared, truncate flow if (newmask == 0) break; // Subvar is cleared, truncate flow
if (rvn->mask != (newmask >> sa)) return false; // subvar is clipped if (rvn->mask != (newmask >> sa)) return false; // subvar is clipped
// Is the small variable getting zero padded into something that is fully consumed // Is the small variable getting zero padded into something that is consumed beyond the variable
if (((rvn->mask & 1)!=0)&&(sa + bitsize == 8*outvn->getSize()) if (((rvn->mask & 1)!=0)&&(sa + bitsize == 8*outvn->getSize())
&&(calc_mask(outvn->getSize()) == outvn->getConsume())) { &&((outvn->getConsume() & ~newmask) != 0)) {
addSuggestedPatch(rvn,op,sa); addExtensionPatch(rvn,op,sa);
hcount += 1; hcount += 1;
break; break;
} }
@@ -514,10 +514,10 @@ bool SubvariableFlow::traceForward(ReplaceVarnode *rvn)
hcount += 1; // Dealt with this descendant hcount += 1; // Dealt with this descendant
break; break;
} }
// Is the small variable getting zero padded into something that is fully consumed // Is the small variable getting zero padded into something that is consumed beyond the variable
if (((newmask&1)==1)&&(sa + bitsize == 8*outvn->getSize()) if (((newmask&1)==1)&&(sa + bitsize == 8*outvn->getSize())
&&(calc_mask(outvn->getSize()) == outvn->getConsume())) { &&((outvn->getConsume() & ~newmask) != 0)) {
addSuggestedPatch(rvn,op,0); addExtensionPatch(rvn,op,0);
hcount += 1; hcount += 1;
break; break;
} }
@@ -1211,14 +1211,14 @@ void SubvariableFlow::addBooleanPatch(PcodeOp *pullop,ReplaceVarnode *rvn,int4 s
// this is not a true modification // this is not a true modification
} }
/// \brief Mark a subgraph variable flowing to an operation that expands it by padding with zero bits. /// \brief Mark a subgraph variable flowing to an operation that extends it by padding with zero bits.
/// ///
/// Data-flow along the specified edge within the logical subgraph is terminated by added a PatchRecord. /// Data-flow along the specified edge within the logical subgraph is terminated by added a PatchRecord.
/// This doesn't count as a logical value that needs to be patched (by itself). /// This doesn't count as a logical value that needs to be patched (by itself).
/// \param rvn is the given subgraph variable /// \param rvn is the given subgraph variable
/// \param pushop is the operation that pads the variable /// \param pushop is the operation that pads the variable
/// \param sa is the amount the logical value is shifted to the left /// \param sa is the amount the logical value is shifted to the left
void SubvariableFlow::addSuggestedPatch(ReplaceVarnode *rvn,PcodeOp *pushop,int4 sa) void SubvariableFlow::addExtensionPatch(ReplaceVarnode *rvn,PcodeOp *pushop,int4 sa)
{ {
patchlist.emplace_back(); patchlist.emplace_back();
@@ -114,7 +114,7 @@ class SubvariableFlow {
void addTerminalPatch(PcodeOp *pullop,ReplaceVarnode *rvn); void addTerminalPatch(PcodeOp *pullop,ReplaceVarnode *rvn);
void addTerminalPatchSameOp(PcodeOp *pullop,ReplaceVarnode *rvn,int4 slot); void addTerminalPatchSameOp(PcodeOp *pullop,ReplaceVarnode *rvn,int4 slot);
void addBooleanPatch(PcodeOp *pullop,ReplaceVarnode *rvn,int4 slot); void addBooleanPatch(PcodeOp *pullop,ReplaceVarnode *rvn,int4 slot);
void addSuggestedPatch(ReplaceVarnode *rvn,PcodeOp *pushop,int4 sa); void addExtensionPatch(ReplaceVarnode *rvn,PcodeOp *pushop,int4 sa);
void addComparePatch(ReplaceVarnode *in1,ReplaceVarnode *in2,PcodeOp *op); void addComparePatch(ReplaceVarnode *in1,ReplaceVarnode *in2,PcodeOp *op);
ReplaceVarnode *addConstant(ReplaceOp *rop,uintb mask,uint4 slot,Varnode *constvn); ReplaceVarnode *addConstant(ReplaceOp *rop,uintb mask,uint4 slot,Varnode *constvn);
ReplaceVarnode *addNewConstant(ReplaceOp *rop,uint4 slot,uintb val); ReplaceVarnode *addNewConstant(ReplaceOp *rop,uint4 slot,uintb val);
@@ -228,12 +228,12 @@ def program_loader() -> "ProgramLoader.Builder":
```python ```python
def task_monitor( def task_monitor(
timeout: Optional[int] = None timeout: Optional[int] = None
) -> "PyGhidraTaskMonitor": ) -> "TaskMonitor":
""" """
Convenience function to get a "PyGhidraTaskMonitor" object. Convenience function to get a "TaskMonitor" object.
:param timeout: An optional number of seconds to wait before canceling the monitor. :param timeout: An optional number of seconds to wait before canceling the monitor.
:return: A "PyGhidraTaskMonitor" object. :return: A "TaskMonitor" object.
""" """
``` ```
@@ -577,7 +577,9 @@ __3.1.0__
__3.0.2__ __3.0.2__
* Fixed an issue that prevented [`pyghidra.analysis_properties()`](#pyghidraanalysis_properties) * Fixed an issue that prevented [`pyghidra.analysis_properties()`](#pyghidraanalysis_properties)
from having access to all of the analysis properties. from having access to all of the analysis properties.
* Fixed issues related to the PyGhidra API inadvertently squashing exceptions * Fixed issues related to the PyGhidra API inadvertently squashing exceptions.
* Calling [`pyghidra.task_monitor()`](#pyghidratask_monitor) with no `timeout` parameter will now
return a `TaskMonitor.DUMMY` instead of a `PyGhidraTaskMonitor`.
__3.0.1__ __3.0.1__
* Fixed `AttributeError: module 'pyghidra' has no attribute 'program_conext'` when performing a * Fixed `AttributeError: module 'pyghidra' has no attribute 'program_conext'` when performing a
@@ -305,17 +305,20 @@ def program_loader() -> "ProgramLoader.Builder":
def task_monitor( def task_monitor(
timeout: Optional[int] = None timeout: Optional[int] = None
) -> "PyGhidraTaskMonitor": ) -> "TaskMonitor":
""" """
Convenience function to get a "PyGhidraTaskMonitor" object. Convenience function to get a "TaskMonitor" object.
:param timeout: An optional number of seconds to wait before canceling the monitor. :param timeout: An optional number of seconds to wait before canceling the monitor.
:return: A "PyGhidraTaskMonitor" object. :return: A "TaskMonitor" object.
""" """
from ghidra.util.task import TaskMonitor
from ghidra.pyghidra import PyGhidraTaskMonitor from ghidra.pyghidra import PyGhidraTaskMonitor
from jpype.types import JInt from jpype.types import JInt
t = None if timeout is None else JInt(timeout) if timeout is None:
return PyGhidraTaskMonitor(t, None) return TaskMonitor.DUMMY
else:
return PyGhidraTaskMonitor(JInt(timeout), None)
def walk_project( def walk_project(
project: "Project", project: "Project",