2013-09-22 3 views
0

Как я могу обнаружить загрузку IMG? Im пытается обнаружить, когда программа загружается в память, чтобы помещать прерывания перед каждой функцией. Я пытаюсь сделать что-то вроде IMG_AddInstrumentFunction от PIN.Ptrace: датчик загрузки IMG

Я потерян, и я не могу найти информацию об этом.

Thx

ответ

1

Это именно то, что r_brk для. См включают/link.h:

struct r_debug 
    { 
    ..... 
    /* This is the address of a function internal to the run-time linker, 
     that will always be called when the linker begins to map in a 
     library or unmap it, and again when the mapping change is complete. 
     The debugger can set a breakpoint at this address if it wants to 
     notice shared object mapping changes. */ 
    ElfW(Addr) r_brk; 
    .... 
    }; 

Они даже пойти дальше и объяснить, как найти это значение в debugee:

/* This symbol refers to the "dynamic structure" in the `.dynamic' section 
    of whatever module refers to `_DYNAMIC'. So, to find its own 
    `struct r_debug', a program could do: 
    for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) 
     if (dyn->d_tag == DT_DEBUG) 
    r_debug = (struct r_debug *) dyn->d_un.d_ptr; 
    */ 
Смежные вопросы