Skip to content

Commit

Permalink
Add patchAPI/PatchModifier.h
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent 5d0babf commit c8a15e9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 10 deletions.
48 changes: 46 additions & 2 deletions docs/patchAPI/public/PatchModifier.h.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
.. _`sec:PatchModifier.h`:

PatchModifier.h
===============
###############

.. cpp:namespace:: Dyninst::PatchAPI

.. cpp:class:: PatchModifier

.. cpp:function:: static bool redirect(PatchEdge *edge, PatchBlock *target)

Set the target of the existing edge, ``edge``, to ``target``.

.. cpp:function:: static PatchBlock* split(PatchBlock* b, Address addr, bool trust = false, Address newlast = (Address)-1)

Split the block, ``b``, at the address ``addr``.

We double-check whether the address is a valid instruction boundary unless trust is true.

.. cpp:function:: static bool remove(std::vector<PatchBlock *> &blocks, bool force = false)

Remove the blocks, ``blocks`` from the CFG.

The block must be unreachable (that is, have no in-edges) unless ``force`` is ``true``.

.. cpp:function:: static bool remove(PatchFunction* f)

Removes the function ``f`` and all of its blocks.

.. cpp:function:: static InsertedCode::Ptr insert(PatchObject* o, SnippetPtr snip, Point* point)

Inserts the snippet ``snip`` into the object ``o`` at point ``point``.

Returns the inserted code block.

.. cpp:function:: static InsertedCode::Ptr insert(PatchObject* o, void* start, unsigned size)

Inserts the ``size`` bytes from ``start`` into the first free address in object ``o``.

Returns the inserted code block.

.. cpp:class:: InsertedCode

.. cpp:namespace:: Dyninst::patchAPI
.. cpp:type:: boost::shared_ptr<InsertedCode> Ptr

.. cpp:function:: InsertedCode()
.. cpp:function:: PatchBlock* entry()
.. cpp:function:: const std::vector<PatchEdge*> &exits()
.. cpp:function:: const std::set<PatchBlock*> &blocks()
8 changes: 0 additions & 8 deletions patchAPI/h/PatchModifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,15 @@ class PATCHAPI_EXPORT InsertedCode {

class PATCHAPI_EXPORT PatchModifier {
public:
// These are all static methods as this class has no state; so really,
// it's just a namespace.

// Redirect the target of an existing edge.
static bool redirect(PatchEdge *edge, PatchBlock *target);

// Split a block at a provided point.; we double-check whether the address
// is a valid instruction boundary unless trust is true.
static PatchBlock *split(PatchBlock *, Address,
bool trust = false,
Address newlast = (Address)-1);

// Remove a block from the CFG; the block must be unreachable
// (that is, have no in-edges) unless force is true.
static bool remove(std::vector<PatchBlock *> &blocks, bool force = false);

// As the above, but for functions.
static bool remove(PatchFunction *);

static InsertedCode::Ptr insert(PatchObject *, SnippetPtr snip, Point *point);
Expand Down

0 comments on commit c8a15e9

Please sign in to comment.