Example #1
0
MainWindow::MainWindow(QStringList args)
{
    _simProject = new SimProject(this);

    _logWidget = new QTextEdit();
    _logWidget->setReadOnly(true);
    setCentralWidget(_logWidget);
    createMenus();

    connect(SimServer::instance(), SIGNAL(clientAdded(SimClient *)), this, SLOT(setClient(SimClient *)));
    connect(_simProject, SIGNAL(logAppended(QString)), _logWidget, SLOT(insertHtml(QString)));

    if (args.size()>1)
        openProject(args[1]);
}
Example #2
0
bool    MainWindow::openDocument()
{
  _fileName = QFileDialog::getOpenFileName(this, tr("Select a file"));

  if (_fileName.isNull())
    return (false);

  // Opening file and loading module
  _medusa.Open(this->_fileName.toStdWString());
  _medusa.LoadModules(L".");
  _medusa.GetDatabase().StartsEventHandling(new EventProxy(this));

  emit logAppended(QString("Opening %1\n").arg(this->_fileName));

  medusa::Loader::VectorSharedPtr const & loaders = this->_medusa.GetSupportedLoaders();

  // If no compatible loader was found
  if (loaders.empty())
  {
    QMessageBox::critical(this, tr("Loader error"), tr("There is no supported loader for this file"));
    this->closeDocument();
    return (false);
  }

  // Select arch
    medusa::Architecture::VectorSharedPtr const & archis = this->_medusa.GetAvailableArchitectures();

  // If no compatible arch was found
  if (archis.empty())
  {
    QMessageBox::critical(this, tr("Architecture error"), tr("There is no supported architecture for this file"));
    this->closeDocument();
    return (false);
  }

  medusa::Loader::SharedPtr loader;
  medusa::Architecture::SharedPtr architecture;

  if (!this->_loaderChooser.getSelection(loader, architecture))
  {
    this->closeDocument();
    return (false);
  }

  this->_selectedLoader = loader;
  _medusa.RegisterArchitecture(architecture);

  this->statusbar->showMessage(tr("Interpreting executable format using ") + QString::fromStdString(loader->GetName()));
  loader->Map();

  this->statusbar->showMessage(tr("Disassembling ..."));

  this->_medusa.StartAsync(loader, architecture);

  _disasmView.bindMedusa(&_medusa);

  this->actionGoto->setEnabled(true);
  this->_documentOpened = true;
  this->setWindowTitle("Medusa - " + this->_fileName);

  return (true);
}
Example #3
0
void MainWindow::appendLog(std::wstring const& msg)
{
  emit logAppended(QString::fromStdWString(msg));
}