0

I am a newbie to Pin, and basically, I would like to use a Pintool to initialize a memory region, which can be read/write by the user process later during run time.

I would like to make the memory region on heap, as the data structure I want to initialize is relatively large. After reading the Pin manual, I am aware of Pin safecopy which can be used for memory copy.

However, I don't know how to allocate memory on the heap, which, should be accessible by the attached client process.

Am I clear enough? Could anyone give me some help on it? Thank you!

lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
  • 1
    Could you be more specific on what you are trying to achieve by having memory accessible by both the pintool and the instrumented application? Usually, PIN tries to be completely transparent to the instrumented application. If you have a big block of memory you could use a named shared memory (`shm_open`on *nix and `CreateFileMapping` on windows) so both pintool and application could use the same shared name and read/write from the shared mem. – Neitsa Mar 23 '16 at 17:30
  • Hello @Neitsa, I would like to initialize a memory region, which contains a pointer array. Due to the specific analysis I am trying to do, it is very likely that client program got crash due to `invalid_memory_access`. On that case, I would like to make the memory pointer refer to the pointer array I initialized in the memory. Am I clear? Thank you! – lllllllllllll Mar 23 '16 at 23:27
  • 1
    I couldn't remember any primitive from PIN to allocate memory, so I took a deep look at all PIN methods and couldn't find one. In fact you just have to allocate memory from the pintool (malloc / new / OS specific functions) and it should be visible to the application. See my first comment for a named shared memory. – Neitsa Mar 25 '16 at 10:26

0 Answers0