/// <summary> /// Attach process for injection /// </summary> /// <param name="process"></param> private void AttachProcess(Process process) { try { oProcess.clearActiveProcess(tabManager); if (process == null) { FormSelectProcess selectProcess = new FormSelectProcess(); oConsole.printMessage("Prompting user for process to attach to..."); selectProcess.ShowDialog(this); } else { // Set the active process oProcess.activeProcess = process; } // If we have an active process then make our code injections if (oProcess.activeProcess != null) { // Let the user select the modules formSelectModules selectModule = new formSelectModules(); oConsole.printMessage("Prompting user for modules to analyze..."); if (selectModule.ShowDialog(this) == DialogResult.OK) { oConsole.printMessage(oProcess.activeModules.Count + " modules were selected by user."); // Initialize the process information oProcess.generateMemoryMap(); initProcessInformation(); // Let the user modify the selected heaps if desired formSelectHeaps selectHeaps = new formSelectHeaps(oProcess.map, oProcess.activeModules, oProcess.disassemblyMode, this); selectHeaps.ShowDialog(this); if (selectHeaps.DialogResult == DialogResult.OK) { // Begin disassembly process oConsole.printMessage("Disassemblying active modules..."); oProcess.disassembleProcess(this, selectHeaps.getSelectedHeaps()); // Begin the injection process if (oProcess.inject(this, selectHeaps.getInvalidSourceHeaps())) { tabManager.addFunctionListTab("Function List: Full", new oFunctionList(oFunctionMaster.functions), true, false); tabManager.mainLock(false); // release our lock } else { tabManager.mainLock(true); // lock the tab bar oConsole.printMessageShow("ERROR: Failed to inject code."); } } else { tabManager.mainLock(true); // lock the tab bar oConsole.printMessage("The user cancelled at the heap selection menu."); } } else { tabManager.mainLock(true); // lock the tab bar oConsole.printMessage("No modules were selected by user."); } } else { tabManager.mainLock(true); // lock the tab bar } } catch (Exception ex) { tabManager.mainLock(true); // lock the tab bar oConsole.printException(ex); } }