Example #1
0
inline THREAD_SAFE int idaapi enumerate_system_files(
       char *answer,
       size_t answer_size,
       const char *subdir,
       const char *fname,
       int (idaapi*func)(const char *file,void *ud),
       void *ud)
{
  return enumerate_files(answer, answer_size, idadir(subdir), fname, func, ud);
}
Example #2
0
void Core::preprocessStylesheet(QString &qss, const QString &themeDirPath)
{
    qss.replace("<IDADIR>", idadir(nullptr));
    qss.replace("<SKINDIR>", themeDirPath);

    auto applyFontReplacements = [&](const QString &keyword, IdaFontConfig::FontType type)
    {
        IdaFontConfig settings(type);
        QString prefix = "<" + keyword + "_FONT_";

        qss.replace(prefix + "FAMILY>", settings.family());
        qss.replace(prefix + "STYLE>", settings.italic() ? " italic" : "");
        qss.replace(prefix + "WEIGHT>", settings.bold() ? " bold" : "");
        qss.replace(prefix + "SIZE>", QString::number(settings.size()) + "pt");
    };

    applyFontReplacements("DISASSEMBLY",     IdaFontConfig::FONT_DISASSEMBLY);
    applyFontReplacements("HEXVIEW",         IdaFontConfig::FONT_HEXVIEW);
    applyFontReplacements("DEBUG_REGISTERS", IdaFontConfig::FONT_DEBUG_REGISTERS);
    applyFontReplacements("TEXT_INPUT",      IdaFontConfig::FONT_TEXT_INPUT);
    applyFontReplacements("OUTPUT_WINDOW",   IdaFontConfig::FONT_OUTPUT_WINDOW);

    //msg("%s\n", qss.toAscii().data());
}
//--------------------------------------------------------------------------
bool win32_debmod_t::create_process(
    const char *path,
    const char *args,
    const char *startdir,
    bool is_gui,
    PROCESS_INFORMATION *ProcessInformation)
{
#ifndef __X64__
  linput_t *li = open_linput(path, false);
  if ( li == NULL )
    return false;

  pe_loader_t pl;
  pl.read_header(li, true);
  close_linput(li);
  if ( pl.pe.is_pe_plus() )
  {
    static const char server_name[] = "win64_remotex64.exe";
#ifdef __EA64__
    if ( askyn_c(1, "AUTOHIDE REGISTRY\nHIDECANCEL\nDebugging 64-bit applications is only possible with the %s server. Launch it now?", server_name) == 1 ) do
    {
      // Switch to the remote win32 debugger
      if ( !load_debugger("win32_stub", true))
      {
        warning("Failed to switch to the remote windows debugger!");
        break;
      }

      // Form the server path
      char server_exe[QMAXPATH];
      qmakepath(server_exe, sizeof(server_exe), idadir(NULL), server_name, NULL);

      // Try to launch the server
      STARTUPINFO si = {sizeof(si)};
      PROCESS_INFORMATION pi;
      if ( !::CreateProcess(server_exe, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) )
      {
        warning("Failed to run the 64-bit remote server!");
        break;
      }

      // Set the remote debugging options: localhost
      set_remote_debugger("localhost", "", -1);

      // Notify the user
      info("Debugging server has been started, please try debugging the program again.");
    } while ( false );
#else
    dwarning("AUTOHIDE NONE\n"
      "Please use %s remote server to debug 64-bit applications", server_name);
#endif // __EA64__
    SetLastError(ERROR_NOT_SUPPORTED);
    return false;
  }
#endif // __X64__

  // Empty directory means our directory
  if ( startdir != NULL && startdir[0] == '\0' )
    startdir = NULL;

  // Args passed as empty string?
  if ( args != NULL && args[0] == '\0' )
    args = NULL;

  launch_process_params_t lpp;
  lpp.flags |= LP_TRACE | LP_PATH_WITH_ARGS;
  if ( !is_gui )
    lpp.flags |= LP_NEW_CONSOLE;
  lpp.path = path;
  lpp.args = args;
  lpp.startdir = startdir;
  lpp.info = ProcessInformation;

  qstring errbuf;
  if ( launch_process(lpp, &errbuf) == NULL )
  {
    dwarning("AUTOHIDE NONE\n%s", errbuf.c_str());
    return false;
  }
  return true;
}