Re: [DynInst_API:] Binary extension with raw bytes using PatchAPI


Date: Fri, 11 Apr 2014 21:30:32 +0200
From: Sergej Proskurin <prosig@xxxxxxx>
Subject: Re: [DynInst_API:] Binary extension with raw bytes using PatchAPI
Bill suggested this project to me.
http://sourceforge.net/p/crafthpc/code/
Great, thank you very much for this - I will definitely take a look at it :)

@Josh: Thank you very much for the hint regarding the private inherited classes: My mistake!

Best regards,
Sergej


On Thu, Apr 10, 2014 at 2:09 AM, Sergej Proskurin <prosig@xxxxxxx> wrote:
Hello,

After first experimentations with the DynsinstAPI, I would like to use
PatchAPI in order to develop a fine-grained binary editing solution.
Unfortunately, at the moment, I have troubles with the extension of the
Snippet class:

For the beginning, I would like to simply include some raw bytes into an
existing binary to be edited. I have followed the recently posted issue
concerning the same topic
(https://www-auth.cs.wisc.edu/lists/dyninst-api/2014/msg00061.shtml) and
wondered whether you could provide me with some existing binary modification
examples, as well. As can be seen in the code below, my current
test-implementation is based on the above mentioned issue, which is as well
provided by the PatchAPI documentation - in more or less same detail.

The following code produces errors during compilation at the point when the
snippet-pointer is created.
Error message: "static Dyninst::PatchAPI::Snippet::Ptr
Dyninst::PatchAPI::Snippet::create(Dyninst::PatchAPI::Snippet*)â is
inaccessible within this context"

---

class MySnippet : Snippet {
public:
     virtual bool generate(Point *point, Buffer &buf) {
         buf.copy((void*)"BBBBBBBBBBBBBBBBBBBB", 20);

         return true;
     }
};

...

/* The folowing line leads to errors during compilation */
MySnippet::Ptr snippet = MySnippet::create(new MySnippet());

Point *point = mgr->findPoint(Location::Instruction(b, b->last()),
Point::BlockExit);

Patcher patcher(mgr);
patcher.add(PushBackCommand::create(point, snippet));
patcher.commit();

---

I would really appreciate it if you could help me with my concern.
Thank you very much in advance.

Best regards,
Sergej

PS: I am using the DynsinstAPI bundle version 8.1.2 (including ParseAPI,
PatchAPI, ...).




_______________________________________________
Dyninst-api mailing list
Dyninst-api@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api


--
Sometimes the problem is to discover what the problem is.

[Gordon Glegg, The Design of Design]

[← Prev in Thread] Current Thread [Next in Thread→]