-
Notifications
You must be signed in to change notification settings - Fork 0
/
imports.cpp
37 lines (30 loc) · 908 Bytes
/
imports.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "pin.H"
#include <iostream>
#include <fstream>
// Instruments the loaded image.
VOID Image(IMG img, VOID *v) {
std::cout << IMG_Name(img) << std::endl;
for (SEC sec = IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec)) {
std::cout << "\t=> " << SEC_Name(sec) << std::endl;
for (RTN rtn = SEC_RtnHead(sec); RTN_Valid(rtn); rtn = RTN_Next(rtn)) {
std::cout << "\t\t=> " << RTN_Name(rtn) << std::endl;
}
}
}
INT32 Usage() {
std::cerr << "Prints all the imports in a hierarchial manner." << std::endl;
return -1;
}
int main(int argc, char *argv[])
{
// Initialize pin & symbol manager.
PIN_InitSymbols();
if( PIN_Init(argc,argv) ) {
return Usage();
}
// Register Image to be called to instrument functions.
IMG_AddInstrumentFunction(Image, 0);
// Never returns.
PIN_StartProgram();
return 0;
}