/* Invoked for every signal handler function, adjusts the value of the saved * fault address to its unrelocated counterpart in the CONTEXT structure, * which contains the PC that is used when execution resumes */ void HybridAnalysis::signalHandlerEntryCB2(BPatch_point *point, Address excCtxtAddr) { mal_printf("\nAt signalHandlerEntry2(%lx , %lx)\n", point->getAddress(), (Address)excCtxtAddr); // calculate the offset of the fault address in the EXCEPTION_RECORD CONTEXT *cont= (CONTEXT*)excCtxtAddr; //bogus pointer, but I won't write to it Address pcAddr = excCtxtAddr + (Address)(&(cont->Eip)) - (Address)cont; // set fault address to the unrelocated address of that instruction // and save the PC address in the CONTEXT structure so the exit handler // can read it BPatch_function *func = point->getFunction(); func->setHandlerFaultAddrAddr((Address)pcAddr,true); handlerFunctions[(Address)func->getBaseAddr()].faultPCaddr = pcAddr; }
/* Invoked for every signal handler function, adjusts the value of the saved * fault address to its unrelocated counterpart in the EXCEPTION_RECORD */ void HybridAnalysis::signalHandlerEntryCB(BPatch_point *point, Address excRecAddr) { mal_printf("\nAt signalHandlerEntry(%lx , %lx)\n", point->getAddress(), (Address)excRecAddr); stats_.exceptions++; // calculate the offset of the fault address in the EXCEPTION_RECORD EXCEPTION_RECORD record; proc()->lowlevel_process()->readDataSpace( (void*)excRecAddr, sizeof(EXCEPTION_RECORD), &record, true); Address pcAddr = excRecAddr + (Address) &(record.ExceptionAddress) - (Address) &record; // set fault address to the unrelocated address of that instruction BPatch_function *func = point->getFunction(); func->setHandlerFaultAddrAddr((Address)pcAddr,false); handlerFunctions[(Address)func->getBaseAddr()].isInterrupt = (record.ExceptionCode == EXCEPTION_BREAKPOINT); }