Exemplo n.º 1
0
/*
 * initialization of the core tagging engine;
 * it must be called before using everything else
 *
 * returns: 0 on success, 1 on error
 */
int
libdft_part_init()
{
	/* initialize thread contexts; optimized branch */
	if (unlikely(thread_ctx_init()))
		/* thread contexts failed */
		return 1;

	/* initialize the tagmap; optimized branch */
	if (unlikely(tagmap_alloc()))
//		/* tagmap initialization failed */
		return 2;

	/* initialize the ins descriptors */
	(void)memset(ins_desc, 0, sizeof(ins_desc));

	/* register trace_ins() to be called for every trace */
	TRACE_AddInstrumentFunction(trace_inspect, NULL);


	/* FIXME: ugly hack for bypassing unaligned address checks */
	PIN_AddInternalExceptionHandler(fix_eflags, NULL);

	/* success */
	return 0;
}
Exemplo n.º 2
0
int main(int argc, char * argv[])
{
    if (PIN_Init(argc, argv)) return Usage();
    INS_AddInstrumentFunction(InstrumentDivide, 0);
    PIN_AddInternalExceptionHandler(GlobalHandler, NULL);
    PIN_StartProgram();    // Never returns
    return 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();
	}

	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.º 4
0
/*
 * initialization of the core tagging engine;
 * it must be called before using everything else
 *
 * returns: 0 on success, 1 on error
 */
int
libdft_init()
{
	/* initialize thread contexts; optimized branch */
	if (unlikely(thread_ctx_init()))
		/* thread contexts failed */
		return 1;

	/* initialize the tagmap; optimized branch */
	if (unlikely(tagmap_alloc()))
		/* tagmap initialization failed */
		return 1;
    trace_tls_key = PIN_CreateThreadDataKey(0);

	/*
	 * syscall hooks; store the context of every syscall
	 * and invoke registered callbacks (if any)
	 */

	/* register sysenter_save() to be called before every syscall */
	PIN_AddSyscallEntryFunction(sysenter_save, NULL);

	/* register sysexit_save() to be called after every syscall */
	PIN_AddSyscallExitFunction(sysexit_save, NULL);

	/* initialize the ins descriptors */
	(void)memset(ins_desc, 0, sizeof(ins_desc));

	/* register trace_ins() to be called for every trace */
	TRACE_AddInstrumentFunction(trace_inspect, NULL);

	/* FIXME: ugly hack for bypassing unaligned address checks */
	PIN_AddInternalExceptionHandler(fix_eflags, NULL);

	/* success */
	return 0;
}
Exemplo n.º 5
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;
	
}