// Called every time a new image is loaded
// Look for routines that we want to probe
VOID ImageLoad(IMG img, VOID *v)
{
    const ANNOTATION *ann = 0;
    USIZE num = 0;

    printf("Processing %s\n", IMG_Name(img).c_str());
    
    for (SEC sec = IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec))
    {
        if (SEC_Name(sec) == "MyAnnot")
        {
            ann = reinterpret_cast<const ANNOTATION*>(SEC_Data(sec));
            num = SEC_Size(sec) / sizeof(ANNOTATION);
        }
    }

    if (ann)
    {
        printf("Found annotations: \n");
        for (UINT32 i = 0; i < num; i++)
        {
            ADDRINT addr = ann[i].addr;
            ADDRINT val = ann[i].value;
            printf("\t%p %p\t", Addrint2VoidStar(addr), Addrint2VoidStar(val));
            if (PIN_IsSafeForProbedInsertion(addr))
            {
                PIN_InsertCallProbed(addr, AFUNPTR(Notification), IARG_ADDRINT, val, IARG_END);
                printf(" - OK\n");
            }
            else
            {
                printf(" - Failed\n");
            }
        }

        // Set the write line function, from the image of the annotations (i.e. the main executable).
        RTN writeRtn = RTN_FindByName(img, "write_line");
        if (RTN_Valid(writeRtn))
        {
            writeFun = (void (*)(char *))RTN_Funptr(writeRtn);
        }
    }

    printf("Completed %s\n", IMG_Name(img).c_str());
}
예제 #2
0
파일: lua_rtn.cpp 프로젝트: cherry-wb/pint
int rtn_funptr (lua_State *L) {
  RTN* v1 = check_rtn(L,1);
  AFUNPTR r = RTN_Funptr(*v1);
  lua_pushnumber(L, (UINT64)r);
  return 1;
}