static VOID OnImage(IMG img, VOID *) { for (SYM sym = IMG_RegsymHead(img); SYM_Valid(sym); sym = SYM_Next(sym)) { if (SYM_Name(sym) == "Breakpoint") { FoundBreakpointFunction = TRUE; BreakpointFunction = SYM_Address(sym); } if (SYM_Name(sym) == "BreakpointLocation") { FoundBreakpointLocation = TRUE; BreakpointLocation = SYM_Address(sym); } if (SYM_Name(sym) == "One") { FoundOneFunction = TRUE; OneFunction = SYM_Address(sym); } if (SYM_Name(sym) == "Two") { FoundTwoFunction = TRUE; TwoFunction = SYM_Address(sym); } } }
RTN FindRTN(IMG img, const char *func_name) { RTN rtn = RTN_FindByName(img, func_name); if (RTN_Valid(rtn)) return rtn; // handle those symbols with version numbers. // e.g. pthread_create has global name: pthread_create@@GLIBC... std::string func_name_v(func_name); func_name_v.append("@@"); for(SYM sym = IMG_RegsymHead(img); SYM_Valid(sym); sym = SYM_Next(sym)) { if (SYM_Name(sym).find(func_name_v) != std::string::npos) { RTN rtn = RTN_FindByAddress(SYM_Address(sym)); DEBUG_ASSERT(RTN_Valid(rtn)); return rtn; } } return RTN_Invalid(); }
int sym_address (lua_State *L) { SYM* v1 = check_sym(L,1); ADDRINT r = SYM_Address(*v1); lua_pushnumber(L, r); return 1; }