int main(int argc, char * argv[]){

	//If we want to debug the program manually setup the proper options in order to attach an external debugger
	if(Config::ATTACH_DEBUGGER){
		initDebug();
	}

	MYINFO("->Configuring Pintool<-\n");

	//get the start time of the execution (benchmark)
	tStart = clock();
	
	// Initialize pin
	PIN_InitSymbols();

	if (PIN_Init(argc, argv)) return Usage();

	//Register PIN Callbacks
	INS_AddInstrumentFunction(Instruction,0);
	
	//TRACE_AddInstrumentFunction(Trace,0);

	PIN_AddThreadStartFunction(OnThreadStart, 0);

	IMG_AddInstrumentFunction(imageLoadCallback, 0);
	PIN_AddFiniFunction(Fini, 0);
	PIN_AddInternalExceptionHandler(ExceptionHandler,NULL);

	//get theknob args
	ConfigureTool();

	if(Config::getInstance()->POLYMORPHIC_CODE_PATCH){
		TRACE_AddInstrumentFunction(Trace,0);
	}
	proc_info->addProcAddresses();

	//init the hooking system
	HookSyscalls::enumSyscalls();
	HookSyscalls::initHooks();
	// Start the program, never returns

	MYINFO("->Starting instrumented program<-\n");


	PIN_StartProgram();
	
	return 0;
	
}
Exemplo n.º 2
0
int main(int argc, char * argv[]){

	//If we want to debug the program manually setup the proper options in order to attach an external debugger
	if(Config::ATTACH_DEBUGGER){
		initDebug();
	}
	
	//get the start time of the execution (benchmark)
	tStart = clock();	
	// Initialize pin
	PIN_InitSymbols();
	if (PIN_Init(argc, argv)) return Usage();
	//Register PIN Callbacks
	INS_AddInstrumentFunction(Instruction,0);
	PIN_AddThreadStartFunction(OnThreadStart, 0);
	IMG_AddInstrumentFunction(imageLoadCallback, 0);
	PIN_AddFiniFunction(Fini, 0);
	PIN_AddInternalExceptionHandler(ExceptionHandler,NULL);
	PIN_AddFollowChildProcessFunction(followChild, NULL);
	
	printf("[INFO] Configuring Pintool\n");
	//get theknob args
	ConfigureTool();	
	if(Config::getInstance()->POLYMORPHIC_CODE_PATCH){
		TRACE_AddInstrumentFunction(Trace,0);
	}
	proc_info->addProcAddresses();

	//init the hooking system
	HookSyscalls::enumSyscalls();
	HookSyscalls::initHooks();
	printf("[INFO] Starting instrumented program\n\n");
	//MYINFO(" knob inizio %d %d %d",Config::getInstance()->getDumpNumber(), Config::getInstance()->getDumpNumber(),Config::getInstance()->WRITEINTERVAL_MAX_NUMBER_JMP);
	PIN_StartProgram();	
	return 0;
	
}