Exemplo n.º 1
0
void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& name,
                                 Symbol::Type type)
{
  XFuncMap::iterator iter = functions.find(startAddr);
  if (iter != functions.end())
  {
    // already got it, let's just update name, checksum & size to be sure.
    Symbol* tempfunc = &iter->second;
    tempfunc->Rename(name);
    tempfunc->hash = HashSignatureDB::ComputeCodeChecksum(startAddr, startAddr + size - 4);
    tempfunc->type = type;
    tempfunc->size = size;
  }
  else
  {
    // new symbol. run analyze.
    Symbol tf;
    tf.Rename(name);
    tf.type = type;
    tf.address = startAddr;
    if (tf.type == Symbol::Type::Function)
    {
      PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
      checksumToFunction[tf.hash].insert(&functions[startAddr]);
    }
    tf.size = size;
    functions[startAddr] = tf;
  }
}
Exemplo n.º 2
0
void RSOView::Apply(PPCSymbolDB* symbol_db) const
{
  for (const RSOExport& rso_export : GetExports())
  {
    u32 address = GetExportAddress(rso_export);
    if (address != 0)
    {
      Symbol* symbol = symbol_db->AddFunction(address);
      if (!symbol)
        symbol = symbol_db->GetSymbolFromAddr(address);

      const std::string export_name = GetExportName(rso_export);
      if (symbol)
      {
        // Function symbol
        symbol->Rename(export_name);
      }
      else
      {
        // Data symbol
        symbol_db->AddKnownSymbol(address, 0, export_name, Symbol::Type::Data);
      }
    }
  }
  DEBUG_LOG(SYMBOLS, "RSO(%s): %zu symbols applied", GetName().c_str(), GetExportsCount());
}
Exemplo n.º 3
0
void CodeViewWidget::OnRenameSymbol()
{
  const u32 addr = GetContextAddress();

  Symbol* symbol = g_symbolDB.GetSymbolFromAddr(addr);

  if (!symbol)
    return;

  bool good;
  QString name =
      QInputDialog::getText(this, tr("Rename symbol"), tr("Symbol name:"), QLineEdit::Normal,
                            QString::fromStdString(symbol->name), &good);

  if (good && !name.isEmpty())
  {
    symbol->Rename(name.toStdString());
    emit SymbolsChanged();
    Update();
  }
}