コード例 #1
0
ファイル: own_gdb_cmds.cpp プロジェクト: hexgolems/schem
static BOOL DebugInterpreter(THREADID tid, CONTEXT *ctxt, const string &cmd, string *result, VOID *)
{
    TINFO_MAP::iterator it = ThreadInfos.find(tid);
    if (it == ThreadInfos.end())
        return FALSE;
    TINFO *tinfo = it->second;

    std::string line = TrimWhitespace(cmd);
    *result = "";

    if (line == "help")
    {
        result->append("mappings             -- Mappings.\n");
        return TRUE;
    }
    else if(line == "mappings")
    {
      tinfo->_os.str("");
      tinfo->_os << "{"; //open JSON
      for( IMG img= APP_ImgHead(); IMG_Valid(img); img = IMG_Next(img) )
      {
        const string& name = LEVEL_PINCLIENT::IMG_Name(img);
        tinfo->_os <<"\""<< name << "\":{"; //open img
        ADDRINT address = LEVEL_PINCLIENT::IMG_LowAddress(img);
        tinfo->_os << "\"start\":" << address << ",";
        address = LEVEL_PINCLIENT::IMG_HighAddress(img);
        tinfo->_os << "\"end\":" << address << ",";
        tinfo->_os << "\"sections\":" << "{"; //open sections
        for( SEC sec = IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec))
        {
          const string& name = LEVEL_PINCLIENT::SEC_Name(sec);
          if(name != "")
          {
            tinfo->_os << "\"" << name <<"\":{"; //open section
            ADDRINT address = LEVEL_PINCLIENT::SEC_Address(sec);
            tinfo->_os << "\"start\":" << address << ",";
            USIZE size = LEVEL_PINCLIENT::SEC_Size(sec);
            if(SEC_Valid(SEC_Next(sec)))
            {
              tinfo->_os << "\"size\":" << size << "},"; //close section
            }else
            {
              tinfo->_os << "\"size\":" << size << "}}"; //close section and sections
            }
          }
        }
        if(IMG_Valid(IMG_Next(img)))
        {
          tinfo->_os << "},"; //close img
        }else
        {
          tinfo->_os << "}}"; //close img and json
        }
      }
      *result = tinfo->_os.str();
      return TRUE;
    }

    return FALSE;   /* Unknown command */
}
コード例 #2
0
static void reportError(ADDRINT addr)
{
    fprintf (stderr, "BAD Fetch from 0x%08x\n", addr);
    for (IMG img= APP_ImgHead(); IMG_Valid(img); img = IMG_Next(img))
    {
        fprintf (stderr, "%-30s: 0x%08x:0x%08x\n", IMG_Name(img).c_str(),
                 IMG_LowAddress(img),IMG_HighAddress(img));
    }
    exit (-1);
}
コード例 #3
0
ファイル: MyPinTool.cpp プロジェクト: imholulu/DTA
VOID InstructionProp(INS ins, VOID *v)
{
	PIN_LockClient();
	for (IMG image = APP_ImgHead();image!=IMG_Invalid();image=IMG_Next(image))
	{
		inst_func_summary(image);
	}
	PIN_UnlockClient();

}
コード例 #4
0
// Print the list of images currently loaded, with some information about each.
static VOID PrintImageList()
{
    for (IMG img= APP_ImgHead(); IMG_Valid(img); img = IMG_Next(img))
    {
        ADDRESS_RANGE range = FindImageTextMargin(img);

        fprintf (trace, "   L  %-40s %2d [0x%llx:0x%llx] offset 0x%llx %4d RTNs\n", IMG_Name(img).c_str(), (int)IMG_Id(img),
                 (unsigned long long)range._low, (unsigned long long)range._high, (unsigned long long)IMG_LoadOffset(img),
                   CountImageRtns (img));
    }    
}
コード例 #5
0
// Print the list of images currently loaded, with some information about each.
static VOID PrintImageList()
{
    for (IMG img= APP_ImgHead(); IMG_Valid(img); img = IMG_Next(img))
    {
        int nSecs;
        int nRtns;

        CountImageSecsAndRtns (img, &nSecs, &nRtns);
        fprintf (trace, "   L  %-40s %2d [0x%lx:0x%lx] offset 0x%lx %2d SECs %4d RTNs\n", IMG_Name(img).c_str(), IMG_Id(img),
                 (unsigned long)IMG_LowAddress(img), (unsigned long)IMG_HighAddress(img), (unsigned long)IMG_LoadOffset(img), nSecs, nRtns);
    }    
}
コード例 #6
0
ファイル: shellcode.cpp プロジェクト: JaonLin/pin-tools
/**
* Given an address, this function determines the name of the loaded module the
* address belongs to. If the address does not belong to any module, the empty
* string is returned.
**/
std::string getModule(ADDRINT address)
{
	// To find the module name of an address, iterate over all sections of all
	// modules until a section is found that contains the address.

	for(IMG img=APP_ImgHead(); IMG_Valid(img); img = IMG_Next(img))
	{
		for(SEC sec=IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec))
		{
			if (address >= SEC_Address(sec) && address < SEC_Address(sec) + SEC_Size(sec))
			{
				return extractFilename(IMG_Name(img));
			}
		}
	}

	return "";
}
コード例 #7
0
ファイル: shellcode.cpp プロジェクト: JaonLin/pin-tools
/**
* Determines whether a given address belongs to a known module or not.
**/
bool isUnknownAddress(ADDRINT address)
{
	// An address belongs to a known module, if the address belongs to any
	// section of any module in the target address space.

	for(IMG img=APP_ImgHead(); IMG_Valid(img); img = IMG_Next(img))
	{
		for(SEC sec=IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec))
		{
			if (address >= SEC_Address(sec) && address < SEC_Address(sec) + SEC_Size(sec))
			{
				return false;
			}
		}
	}

	return true;
}