void AppearanceDialog::on_editBackgroundColor_textChanged(const QString & arg1) { QString text = arg1; if(!arg1.length()) { ui->editBackgroundColor->setText("#"); text = ui->editBackgroundColor->text(); return; } if(arg1.at(0) != '#') { ui->editBackgroundColor->setText("#" + arg1); text = ui->editBackgroundColor->text(); } QString styleSheet; QString id = colorInfoList.at(colorInfoIndex).backgroundColorName; if(text == "#XXXXXX") { styleSheet = "border: 2px solid black; background-color: #C0C0C0"; ui->buttonBackgroundColor->setText("X"); if(colorMap->contains(id)) { (*colorMap)[id] = Qt::transparent; ui->buttonSave->setEnabled(true); Config()->emitColorsUpdated(); GuiUpdateAllViews(); } } else { ui->buttonBackgroundColor->setText(""); if(QColor(text).isValid()) { styleSheet = "border: 2px solid black; background-color: " + text; if(colorMap->contains(id)) { (*colorMap)[id] = QColor(text); ui->buttonSave->setEnabled(true); Config()->emitColorsUpdated(); GuiUpdateAllViews(); } } else { styleSheet = "border: 2px solid red; background-color: #FFFFFF"; if(colorMap->contains(id)) ui->buttonSave->setEnabled(false); //we cannot save with an invalid color } } ui->buttonBackgroundColor->setStyleSheet(styleSheet); }
bool cbInstrAssemble(int argc, char* argv[]) { if(IsArgumentsLessThan(argc, 3)) return false; duint addr = 0; if(!valfromstring(argv[1], &addr)) { dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid expression: \"%s\"!\n"), argv[1]); return false; } if(!DbgMemIsValidReadPtr(addr)) { dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid address: %p!\n"), addr); return false; } bool fillnop = false; if(argc > 3) fillnop = true; char error[MAX_ERROR_SIZE] = ""; int size = 0; if(!assembleat(addr, argv[2], &size, error, fillnop)) { varset("$result", size, false); dprintf(QT_TRANSLATE_NOOP("DBG", "Failed to assemble \"%s\" (%s)\n"), argv[2], error); return false; } varset("$result", size, false); GuiUpdateAllViews(); return true; }
void AppearanceDialog::rejectedSlot() { Config()->Colors = colorBackupMap; Config()->emitColorsUpdated(); Config()->Fonts = fontBackupMap; Config()->emitFontsUpdated(); GuiUpdateAllViews(); }
void AppearanceDialog::on_buttonSave_clicked() { Config()->writeColors(); Config()->writeFonts(); GuiUpdateAllViews(); BridgeSettingFlush(); GuiAddStatusBarMessage(tr("Settings saved!\n").toUtf8().constData()); }
void AppearanceDialog::on_buttonFontDefaults_clicked() { (*fontMap) = Config()->defaultFonts; isInit = true; fontInit(); isInit = false; Config()->emitFontsUpdated(); GuiUpdateAllViews(); }
void AppearanceDialog::on_fontLogSize_currentIndexChanged(const QString & arg1) { QString id = "Log"; QFont font = fontMap->find(id).value(); font.setPointSize(arg1.toInt()); (*fontMap)[id] = font; if(isInit) return; Config()->emitFontsUpdated(); GuiUpdateAllViews(); }
void AppearanceDialog::on_fontLog_currentFontChanged(const QFont & f) { QString id = "Log"; QFont font = fontMap->find(id).value(); font.setFamily(f.family()); (*fontMap)[id] = font; if(isInit) return; Config()->emitFontsUpdated(); GuiUpdateAllViews(); }
void AppearanceDialog::on_buttonApplicationFont_clicked() { QString id = "Application"; QFontDialog fontDialog(this); fontDialog.setCurrentFont(fontMap->find(id).value()); if(fontDialog.exec() != QDialog::Accepted) return; (*fontMap)[id] = fontDialog.currentFont(); ui->labelApplicationFont->setText(fontDialog.currentFont().family()); if(isInit) return; Config()->emitFontsUpdated(); GuiUpdateAllViews(); }
void AppearanceDialog::on_fontLogStyle_currentIndexChanged(int index) { QString id = "Log"; QFont font = fontMap->find(id).value(); font.setBold(false); font.setItalic(false); if(index == 1 || index == 3) font.setBold(true); if(index == 2 || index == 3) font.setItalic(true); (*fontMap)[id] = font; if(isInit) return; Config()->emitFontsUpdated(); GuiUpdateAllViews(); }
bool FunctionPass::Analyse() { // THREAD_WORK = ceil(TOTAL / # THREADS) duint workAmount = (m_MainBlocks.size() + (IdealThreadCount() - 1)) / IdealThreadCount(); // Initialize thread vector auto threadFunctions = new std::vector<FunctionDef>[IdealThreadCount()]; concurrency::parallel_for(duint(0), IdealThreadCount(), [&](duint i) { // Memory allocation optimization // TODO: Option to conserve memory threadFunctions[i].reserve(30000); // Execute duint threadWorkStart = (workAmount * i); duint threadWorkStop = min((threadWorkStart + workAmount), m_MainBlocks.size()); AnalysisWorker(threadWorkStart, threadWorkStop, &threadFunctions[i]); }); // Merge thread vectors into single local std::vector<FunctionDef> funcs; for(duint i = 0; i < IdealThreadCount(); i++) std::move(threadFunctions[i].begin(), threadFunctions[i].end(), std::back_inserter(funcs)); // Sort and remove duplicates std::sort(funcs.begin(), funcs.end()); funcs.erase(std::unique(funcs.begin(), funcs.end()), funcs.end()); dprintf(QT_TRANSLATE_NOOP("DBG", "%u functions\n"), DWORD(funcs.size())); FunctionDelRange(m_VirtualStart, m_VirtualEnd - 1, false); for(auto & func : funcs) { FunctionAdd(func.VirtualStart, func.VirtualEnd, false, func.InstrCount); } GuiUpdateAllViews(); delete[] threadFunctions; return true; }
void MenuEntryCallback(CBTYPE Type, PLUG_CB_MENUENTRY *Info) { switch (Info->hEntry) { case PLUGIN_MENU_LOADSIG: OpenSelectionDialog("Open an IDA signature file", "Signatures (*.sig)\0*.sig\0\0", false, ApplySignatureSymbols); break; case PLUGIN_MENU_LOADDIF: OpenSelectionDialog("Open an IDA DIF file", "Diff files (*.dif)\0*.dif\0\0", false, ApplyDiffSymbols); break; case PLUGIN_MENU_LOADMAP: OpenSelectionDialog("Open a linker map file", "Map files (*.map)\0*.map\0\0", false, ApplyMapSymbols); break; case PLUGIN_MENU_LOADPEID: OpenSelectionDialog("Open a PEiD database", "Any file (*.*)\0*.*\0\0", false, ApplyPEiDSymbols); break; case PLUGIN_MENU_EXPORTDIF: OpenSelectionDialog("Save a DIF file", "Diff files (*.dif)\0*.dif\0\0", true, ExportDiffSymbols); break; case PLUGIN_MENU_EXPORTMAP: OpenSelectionDialog("Save a MAP file", "Map files (*.map)\0*.map\0\0", true, ExportMapSymbols); break; case PLUGIN_MENU_FINDCRYPTO: FindcryptScanModule(); break; case PLUGIN_MENU_AESFINDER: AESFinderScanModule(); break; case PLUGIN_MENU_MAKESIG: OpenSigMakeDialog(); break; case PLUGIN_MENU_SETTINGS: OpenSettingsDialog(); break; case PLUGIN_MENU_ABOUT: MessageBoxA(GuiGetWindowHandle(), "Plugin created by Nukem.\n\n" "Source code at:\n" "https://github.com/Nukem9/SwissArmyKnife" "\n\nFindcrypt2-with-MMX:\n" "https://github.com/vlad902/findcrypt2-with-mmx" "\n\nAES-Finder:\n" "https://github.com/mmozeiko/aes-finder" "\n\nZLIB:\n" "http://www.zlib.net/" , "About", 0); break; } // // Update GUI // GuiUpdateAllViews(); }
void MakeSigDialogExecute(HWND hwndDlg) { int dataLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_SIGMAKE_EDIT1)) + 1; int maskLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_SIGMAKE_EDIT2)) + 1; char *data = (char *)BridgeAlloc(dataLen); char *mask = (char *)BridgeAlloc(maskLen); GetWindowText(GetDlgItem(hwndDlg, IDC_SIGMAKE_EDIT1), data, dataLen); GetWindowText(GetDlgItem(hwndDlg, IDC_SIGMAKE_EDIT2), mask, maskLen); // // Convert the string to a code descriptor // SIG_DESCRIPTOR *desc = nullptr; switch (Settings::LastType) { case SIG_CODE: desc = DescriptorFromCode(data, mask); break; case SIG_IDA: desc = DescriptorFromIDA(data); break; case SIG_PEID: desc = DescriptorFromPEiD(data); break; case SIG_CRC: desc = DescriptorFromCRC(data); break; } // // Scan // std::vector<duint> results; PatternScan(desc, results); // // Log it in the GUI // GuiReferenceDeleteAllColumns(); GuiReferenceAddColumn(20, "Address"); GuiReferenceAddColumn(100, "Disassembly"); GuiReferenceSetRowCount((int)results.size()); GuiReferenceSetProgress(0); int i = 0; for (auto& match : results) { DISASM_INSTR inst; DbgDisasmAt(match, &inst); char temp[32]; sprintf_s(temp, "%p", (PVOID)match); GuiReferenceSetCellContent(i, 0, temp); GuiReferenceSetCellContent(i++, 1, inst.instruction); } _plugin_logprintf("Found %d references(s)\n", results.size()); GuiReferenceSetProgress(100); GuiUpdateAllViews(); // // Cleanup // BridgeFree(data); BridgeFree(mask); BridgeFree(desc); }
void SettingsDialog::SaveSettings() { //Events tab BridgeSettingSetUint("Events", "SystemBreakpoint", settings.eventSystemBreakpoint); BridgeSettingSetUint("Events", "TlsCallbacks", settings.eventTlsCallbacks); BridgeSettingSetUint("Events", "EntryBreakpoint", settings.eventEntryBreakpoint); BridgeSettingSetUint("Events", "DllEntry", settings.eventDllEntry); BridgeSettingSetUint("Events", "ThreadEntry", settings.eventThreadEntry); BridgeSettingSetUint("Events", "AttachBreakpoint", settings.eventAttachBreakpoint); BridgeSettingSetUint("Events", "DllLoad", settings.eventDllLoad); BridgeSettingSetUint("Events", "DllUnload", settings.eventDllUnload); BridgeSettingSetUint("Events", "ThreadStart", settings.eventThreadStart); BridgeSettingSetUint("Events", "ThreadEnd", settings.eventThreadEnd); BridgeSettingSetUint("Events", "DebugStrings", settings.eventDebugStrings); //Engine tab BridgeSettingSetUint("Engine", "CalculationType", settings.engineCalcType); BridgeSettingSetUint("Engine", "BreakpointType", settings.engineBreakpointType); BridgeSettingSetUint("Engine", "UndecorateSymbolNames", settings.engineUndecorateSymbolNames); BridgeSettingSetUint("Engine", "EnableDebugPrivilege", settings.engineEnableDebugPrivilege); BridgeSettingSetUint("Engine", "EnableSourceDebugging", settings.engineEnableSourceDebugging); BridgeSettingSetUint("Engine", "SaveDatabaseInProgramDirectory", settings.engineSaveDatabaseInProgramDirectory); BridgeSettingSetUint("Engine", "DisableDatabaseCompression", settings.engineDisableDatabaseCompression); //Exceptions tab QString exceptionRange = ""; for(int i = 0; i < settings.exceptionRanges->size(); i++) exceptionRange.append(QString().sprintf("%.8X-%.8X", settings.exceptionRanges->at(i).start, settings.exceptionRanges->at(i).end) + QString(",")); exceptionRange.chop(1); //remove last comma if(exceptionRange.size()) BridgeSettingSet("Exceptions", "IgnoreRange", exceptionRange.toUtf8().constData()); else BridgeSettingSet("Exceptions", "IgnoreRange", ""); //Disasm tab BridgeSettingSetUint("Disassembler", "ArgumentSpaces", settings.disasmArgumentSpaces); BridgeSettingSetUint("Disassembler", "MemorySpaces", settings.disasmMemorySpaces); BridgeSettingSetUint("Disassembler", "Uppercase", settings.disasmUppercase); BridgeSettingSetUint("Disassembler", "OnlyCipAutoComments", settings.disasmOnlyCipAutoComments); BridgeSettingSetUint("Disassembler", "TabbedMnemonic", settings.disasmTabBetweenMnemonicAndArguments); //Misc tab if(DbgFunctions()->GetJit) { if(bJitOld != settings.miscSetJIT) { if(settings.miscSetJIT) DbgCmdExecDirect("setjit oldsave"); else DbgCmdExecDirect("setjit restore"); } if(bJitAutoOld != settings.miscSetJITAuto) { if(!settings.miscSetJITAuto) DbgCmdExecDirect("setjitauto on"); else DbgCmdExecDirect("setjitauto off"); } } if(settings.miscSymbolStore) BridgeSettingSet("Symbols", "DefaultStore", ui->editSymbolStore->text().toUtf8().constData()); if(settings.miscSymbolCache) BridgeSettingSet("Symbols", "CachePath", ui->editSymbolCache->text().toUtf8().constData()); BridgeSettingFlush(); Config()->load(); DbgSettingsUpdated(); GuiUpdateAllViews(); }