On Feb 26, 2013, at 5:42 AM, E.Robbins <[email protected]> wrote:

> I'm using the ParseAPI and I'd like to access the raw bytes of certain 
> blocks/functions, I'm not sure if there is a way to do this with DynInst 
> already? 

There is, but it's a little obtuse. Here's some code that gets a raw byte 
pointer for a ParseAPI::Block:

ParseAPI::Block *block; 
 Offset off = block->start();
  const unsigned char *ptr =
    (const unsigned char *) (block->region()->getPtrToInstruction(off));

> If there isn't, I was looking for something that can translate the memory 
> addresses of blocks/functions back in to file offsets? I see a lot of code 
> for address translation, but I'm don't think I've found what I'm looking for.

The address translation code is mapping from a virtual offset in a file to an 
address in memory, taking into account the base address a library was loaded 
at. So that's not what you want. I believe that the SymtabAPI::Region class has 
a virtual->physical mapping, but if you use the code above you shouldn't have 
to deal with that. 

Drew

> 
> Any pointers would be great.
> 
> Thanks,
> Ed
> _______________________________________________
> Dyninst-api mailing list
> [email protected]
> https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api

--
Andrew Bernat
Paradyn Project
[email protected]
http://www.cs.wisc.edu/~bernat




_______________________________________________
Dyninst-api mailing list
[email protected]
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api

Reply via email to