public static void downloadFileUsingAscxDownload(string sFileToDownload, String sTargetFileOrFolder,
                                                         Callbacks.dMethod_String dCallbackWhenCompleted)
        {
            O2Thread.mtaThread(
                () =>
            {
                var windowTitle = string.Format("{0} : {1}", "Download File", sFileToDownload);
                O2Messages.openControlInGUISync(typeof(ascx_DownloadFile), O2DockState.Float, windowTitle);

                O2Messages.getAscx(windowTitle,
                                   guiControl =>
                {
                    if (guiControl != null && guiControl is ascx_DownloadFile)
                    {
                        //var downloadFile = (IControl_DownloadFile)guiControl;
                        //O2Messages.openAscxGui(typeof (ascx_DownloadFile), O2DockState.Float, "Download File");
                        var adfDownloadFile = (ascx_DownloadFile)guiControl;
                        // Exec.openNewWindowWithControl("DownloadFile");
                        adfDownloadFile.invokeOnThread(
                            delegate
                        {
                            adfDownloadFile.setDownloadDetails(sFileToDownload, sTargetFileOrFolder);
                            adfDownloadFile.setAutoCloseOnDownload(true);
                            adfDownloadFile.setCallBackWhenCompleted(dCallbackWhenCompleted);
                            adfDownloadFile.downloadFile();
                            return(null);
                        });
                    }
                });
            });
        }
Beispiel #2
0
 private void lbLoadedAssemblies_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (File.Exists(lbLoadedAssemblies.Text))
     {
         O2Messages.dotNetAssemblyAvailable(lbLoadedAssemblies.Text);
     }
 }
Beispiel #3
0
 private void raiseSetCirDataAnalysisO2Message()
 {
     //setO2CirDataAnalysisObject(cirDataAnalysis);
     CirDataAnalysisUtils.remapIsCalledByXrefs(cirDataAnalysis);                 // this is called when everything has been added, so it is the best place to remap the ISCalledBy XRefs
     O2Messages.setCirDataAnalysis(cirDataAnalysis);
     updateCirDataStats();
 }
Beispiel #4
0
 public void raiseO2MDbgDebugMethodInfoRequest(string loadDllsFrom)
 {
     if (Method != null)
     {
         O2Messages.raiseO2MDbgDebugMethodInfoRequest(Method, loadDllsFrom);
     }
 }
        //public static string ascx_ScriptControl { get; set; }
        //[STAThread]

        private static void Main()

        {
            if (O2Messages.openAscxGui())
            {
                KO2MessageQueue.getO2KernelQueue().onMessages += ascx_Scripts_onMessages;

                // O2 Debugger
                O2AscxGUI.openAscx(typeof(ascx_O2MdbgShell), O2DockState.DockBottom, ascx_O2MdbgShellName); //this needs to be opened before the ascx_Breakpoints


                // scripts controls
                //O2AscxGUI.openAscx(typeof(ascx_Scripts), O2DockState.Document, ascx_ScriptsName); // this needs to loaded before ascx_ScriptsFolder
                var scriptsFolder = (ascx_ScriptsFolder)O2AscxGUI.openAscx(typeof(ascx_ScriptsFolder), O2DockState.DockLeft, ascx_ScriptsFolderName);
                scriptsFolder.loadSampleScripts();

                O2AscxGUI.openAscx(typeof(ascx_AssemblyInvoke), O2DockState.DockRight, ascx_AssemblyInvokeName);

                /*O2AscxGUI.openAscx(typeof(ascx_Breakpoints), O2DockState.DockRightAutoHide, ascx_BreakpointsName);
                *  O2AscxGUI.openAscx(typeof(ascx_BreakpointCreator), O2DockState.DockRightAutoHide, ascx_BreakpointCreatorName);
                *  O2AscxGUI.openAscx(typeof(ascx_Variables), O2DockState.DockRightAutoHide, ascx_CurrentFrameDetailsName);
                *  O2AscxGUI.openAscx(typeof(ascx_FindingsCreator), O2DockState.DockRight, ascx_FindingsCreatorName);*/
                O2AscxGUI.addControlToMenu(typeof(ascx_Breakpoints), O2DockState.DockRightAutoHide, ascx_BreakpointsName);
                O2AscxGUI.addControlToMenu(typeof(ascx_BreakpointCreator), O2DockState.DockRightAutoHide, ascx_BreakpointCreatorName);
                O2AscxGUI.addControlToMenu(typeof(ascx_Variables), O2DockState.DockRightAutoHide, ascx_CurrentFrameDetailsName);
                O2AscxGUI.addControlToMenu(typeof(ascx_FindingsCreator), O2DockState.DockRight, ascx_FindingsCreatorName);
            }
        }
        /* private void dgvSearchResults_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
         * {
         *   dgvSearchResults_SelectionChanged(null, null);
         * }*/

        private void dgvSearchResults_SelectionChanged(object sender, EventArgs e)
        {
            if (cbOpenSelectedItemInMainGUIWindow.Checked && dgvSearchResults.SelectedRows.Count == 1)
            {
                var tsrSearchResult = (TextSearchResult)dgvSearchResults.SelectedRows[0].Tag;
                if (tsrSearchResult != null)
                {
                    O2Messages.fileOrFolderSelected(tsrSearchResult.sFile, tsrSearchResult.iLineNumber + 1);
                    //asceSourceCodeEditor.gotoLine(tsrSearchResult.sFile, tsrSearchResult.iLineNumber + 1);


                    O2Thread.mtaThread(
                        () =>
                    {
                        Thread.Sleep(200);
                        var searchResultsForm = O2Forms.findParentThatHostsControl(this);
                        //var searchResultsForm = O2DockUtils.getO2DockContentForm("Search Results");
                        searchResultsForm.invokeOnThread(
                            () =>
                        {
                            searchResultsForm.Focus();
                            dgvSearchResults.Focus();
                        });
                        // DI.dO2LoadedO2DockContent[name].dockContent.invokeOnThread(
                        //     () => { DI.dO2LoadedO2DockContent[name].dockContent.Focus(); });
                    });
                }
            }
        }
Beispiel #7
0
 private void lbLoadedFiles_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbOpenFileOnSelect.Checked)
     {
         var selectedFile = lbLoadedFiles.Text;
         O2Messages.fileOrFolderSelected(selectedFile);
     }
 }
        void Processes_ProcessAdded(object sender, ProcessCollectionChangedEventArgs e)
        {
            // now that a process has been added, lets add a onBreakpoint event to it
            setOnBreakpointEvent();

            // and let others that we have a new debug sessions
            O2Messages.raiseO2MDbgAction(IM_O2MdbgActions.startDebugSession);
        }
Beispiel #9
0
        private void executeAndDebugAssembly()
        {
            O2Messages.raiseO2MDbgDebugProcessRequest(compiledAssembly.Location);

            //Object[] aoMethodParameters =
            //    DI.reflection.getParameterObjectsFromDataGridColumn(
            //        dgvSourceCode_SelectedMethodParameters, "Value");
            //executeStaticMethod();
        }
Beispiel #10
0
        private void tryToLoadFileInMainDocumentArea(DragEventArgs e) // todo:to implement tryToLoadFileInMainDocumentArea
        {
            string file = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);

            if (File.Exists(file))
            {
                O2Messages.fileOrFolderSelected(file);
            }
        }
        //public ascx_ScriptsFolder scriptsFolder;

/*        public void addCurrentAppDomainsDllsAsReferences()
 *      {
 *          foreach(var assembly in AppDomain.CurrentDomain.GetAssemblies())
 *          {
 *              var assemblyName = Path.GetFileName(assembly.Location);
 *              if (false == lsExtraReferenceAssembliesToAdd.Contains(assemblyName))
 *                  if (assemblyName.IndexOf("JetBrains")==-1 &&
 *                      assemblyName.IndexOf("VisualStudio") == -1 &&
 *                      assemblyName.IndexOf("SMDiagnostics") == -1) // don't add these assemblies
 *                      lsExtraReferenceAssembliesToAdd.Add(assemblyName);
 *
 *          }
 *      }*/


        public void compileSourceCode()
        {
            if (sourceCodeEditor.partialFileViewMode == false)
            {
                if (this.okThread(delegate { compileSourceCode(); }))
                {
                    var      lsExtraReferencesToAdd = new List <string>(); //lsExtraReferenceAssembliesToAdd.ToArray());
                    String   sErrorMessages         = "";
                    var      compileEngine          = new CompileEngine();
                    Assembly aCompiledAssembly      = null;
                    if (tbExtraReferencesToAdd.Text != "")
                    {
                        lsExtraReferencesToAdd.AddRange(tbExtraReferencesToAdd.Text.Split(new[] { Environment.NewLine },
                                                                                          StringSplitOptions.
                                                                                          RemoveEmptyEntries));
                    }

                    lbSourceCode_CompilationResult.Items.Clear();
                    var exeMainClass       = (rbCreateExe.Checked) ? tbMainClass.Text : "";
                    var outputAssemblyName = ""; // todo expose outputAssemblyName on GUI

                    //DI.config.addPathToCurrentExecutableEnvironmentPathVariable(DI.config.O2TempDir);

                    sourceCodeEditor.saveSourceCode();
                    var filesToCompile = new List <String> {
                        sourceCodeEditor.sPathToFileLoaded
                    };
                    if (compileEngine.compileSourceFiles(filesToCompile, lsExtraReferencesToAdd.ToArray(),
                                                         ref aCompiledAssembly, ref sErrorMessages, false /*verbose*/,
                                                         exeMainClass,
                                                         outputAssemblyName))
                    {
                        // if we only have 1 class in the completed code, set tbMainClass.Text to it
                        if (aCompiledAssembly.GetTypes().Length == 1)
                        {
                            tbMainClass.Text = aCompiledAssembly.GetTypes()[0].FullName;
                        }
                        lbSourceCode_CompilationResult.ForeColor = Color.Black;
                        lbSourceCode_CompilationResult.Items.Add("No errors");
                        O2Messages.dotNetAssemblyAvailable(aCompiledAssembly.Location);
                        //if (assemblyInvoke != null)
                        //    assemblyInvoke.loadAssembly(aCompiledAssembly, cbAutoExecuteOnMethodCompile.Checked);
                    }
                    else
                    {
                        //assemblyInvoke.setControlsEnableState(false);
                        lbSourceCode_CompilationResult.ForeColor = Color.Red;
                        compileEngine.addErrorsListToListBox(sErrorMessages, lbSourceCode_CompilationResult);
                    }
                    if (cbAutoSaveOnCompile.Checked)
                    {
                        sourceCodeEditor.saveSourceCode();
                    }
                }
            }
        }
 public bool handleCommandExecutionMessage(string message)
 {
     if (LogCommandExecutionMessage)
     {
         DI.log.info("[MDbg.CommandExecutionMessage]: {0}", message);
     }
     lastCommandExecutionMessage = message;
     O2Messages.raiseO2MDbgCommandExecutionMessage(IM_O2MdbgActions.commandExecutionMessage, lastCommandExecutionMessage);
     return(true);
 }
Beispiel #13
0
 private void raiseShowLineInSourceCodeFile(string fileName, int lineNumber)
 {
     O2Thread.mtaThread(
         () =>
     {
         var thread = O2Messages.fileOrFolderSelected(fileName, lineNumber);
         thread.Join();         // wait for O2MessageExecution
         traceTreeView.invokeOnThread(() => traceTreeView.Focus());
     });
 }
Beispiel #14
0
 private void createStandAloneExeAndDebugMethod(string loadDllsFrom)
 {
     O2Thread.mtaThread(() =>
     {
         if (selectedMethod != null)
         {
             O2Messages.raiseO2MDbgDebugMethodInfoRequest(selectedMethod, loadDllsFrom);
         }
     });
 }
Beispiel #15
0
 public void openGui()
 {
     DI.log.info("Opening GUI");
     if (O2AscxGUI.launch())
     {
         O2AscxGUI.setLogViewerDockState(O2DockState.DockBottom);
         O2Messages.openControlInGUISync(typeof(ascx_CirCreator), O2DockState.Document, cirAnalysisControlName);
         //DI.log.info("after launch");
         //O2AscxGUI.logInfo("from Test_CirCreatorAscxControl");  // this is actually a hack since there is still a bug in the thread invocation which makes sometimes the getGuiAscx below to fail
     }
 }
Beispiel #16
0
 public static void raiseSourceCodeReferenceEvent(bool raiseEvent, ICirFunctionCall functionCall, bool remapLineNumber)
 {
     if (raiseEvent)
     {
         if (functionCall.cirFunction != null && functionCall.fileName != null && functionCall.lineNumber > -1)
         {
             int mappedLineNumber = GetMappedLineNumber(functionCall.cirFunction.FunctionName, functionCall.fileName, functionCall.lineNumber, false, remapLineNumber);
             O2Messages.fileOrFolderSelected(functionCall.fileName, mappedLineNumber);
         }
     }
 }
Beispiel #17
0
 public static void raiseSourceCodeReferenceEvent(bool raiseEvent, ICirClass cirClass, bool remapLineNumber)
 {
     if (raiseEvent)
     {
         if (cirClass.File != null && cirClass.FileLine != null)
         {
             int mappedLineNumber = GetMappedLineNumber(cirClass.Name, cirClass.File, cirClass.FileLine, true, remapLineNumber);
             O2Messages.fileOrFolderSelected(cirClass.File, mappedLineNumber);
         }
     }
 }
Beispiel #18
0
 private void openSourceCodeFile(string sourceCodeFileToOpen)
 {
     // if the sourceCodeEditor has not been DI, then raise a global message, other wise, open the file directly on it
     if (sourceCodeEditor != null)
     {
         sourceCodeEditor.loadSourceCodeFile(sourceCodeFileToOpen);
     }
     else
     {
         O2Messages.fileOrFolderSelected(sourceCodeFileToOpen);
     };
 }
Beispiel #19
0
        private void onCirDataCompletion(object pProcess)
        {
            setControlsEnableState(true);
            var currentScanTarget = (IScanTarget)lbScanTargets.SelectedItem;
            var cirDataFile       = currentScanTarget.ApplicationFile + ".CirData";

            if (File.Exists(cirDataFile))
            {
                var cirData = CirLoad.loadFile(cirDataFile);
                //var cirData = CirLoad.loadSerializedO2CirDataObject(cirDataFile);
                O2Messages.setCirData(cirData);
            }
        }
Beispiel #20
0
        public void createCirDataObject()
        {
            var      cirFactory = new CirFactory();
            ICirData cirData    = new CirData();

            DI.log.info("using assembly:{0} and O2_Kernel.dll", Assembly.GetExecutingAssembly().Location);
            cirFactory.processAssemblyDefinition(cirData, Assembly.GetExecutingAssembly().Location);
            cirFactory.processAssemblyDefinition(cirData, DI.config.ExecutingAssembly);
            Assert.That(cirData.dClasses_bySignature.Count > 0, "There were no classes in cirData object");
            Assert.That(cirData.dFunctions_bySignature.Count > 0, "There were no function in cirData object");
            O2Messages.setCirData(cirData);
            //CirFactoryUtils.showCirDataStats();
        }
 public static void viewCirFunctionSignatureOnNewForm(ICirFunction cirFunction)
 {
     O2Thread.mtaThread(
         () =>
     {
         var windowName = string.Format("Function Viewer: {0}", cirFunction.FunctionSignature);
         O2Messages.openControlInGUISync(typeof(ascx_FunctionCalls), O2DockState.Float, windowName);
         O2Messages.getAscx(windowName,
                            ascxControl =>
                            ((ascx_FunctionCalls)ascxControl).viewCirFunction(cirFunction));
     }
         );
 }
Beispiel #22
0
 public void openGui()
 {
     DI.log.info("Opening GUI");
     // first set up GUI
     if (O2AscxGUI.launch())
     {
         O2AscxGUI.setLogViewerDockState(O2DockState.DockBottom);
         cirDataViewer = (ascx_CirDataViewer)O2Messages.openControlInGUISync(typeof(ascx_CirDataViewer), O2DockState.Document, cirDataViewerControlName);
         Assert.That(cirDataViewer != null, "cirDataViewer was null");
         // Then create CirData and fire global O2Message showCirDataStats
         createCirDataObject();
     }
 }
Beispiel #23
0
        public void Test_LoadFindingsInGui()
        {
            DI.log.info("Opening GUI");
            if (O2AscxGUI.launch())
            {
                O2Messages.openControlInGUI(typeof(ascx_CirViewer_CirData), O2DockState.Document, "Cir Viewer");
                var cirAnalysisControlName = "Cir Analysis";
                O2Messages.openControlInGUI(typeof(ascx_CirAnalysis), O2DockState.DockTop, cirAnalysisControlName);
                O2Messages.getAscx(cirAnalysisControlName, actionsToExecuteOnCirAnalysisControl);

                //O2Messages.setCirData(cirData);
            }
        }
Beispiel #24
0
 public void test_openAscxGui()
 {
     DI.log.info("Opening AscxGui");
     O2Messages.openAscxGui();
     DI.log.info("Opening Ascxs");
     O2Messages.openControlInGUI("ascx_LogViewer O2_External_WinFormsUI", O2DockState.DockTop, "Extra Log Viewer");
     O2Messages.openControlInGUI("ascx_Scripts O2_Views_ASCX", O2DockState.DockRight, "O2 Scripts");
     Thread.Sleep(2000);
     DI.log.info("Waiting for AscxGui close");
     O2Messages.closeAscxGui();
     //O2Messages.waitForAscxGuiEnd();
     DI.log.info("Closed AscxGui");
 }
Beispiel #25
0
 private void addBreakpointOnSelectedMethodifBreakpointIsEnabledToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (currentSelectedFunction != null &&
         false == string.IsNullOrEmpty(currentSelectedFunction.File) &&
         false == string.IsNullOrEmpty(currentSelectedFunction.FileLine))
     {
         var   file = currentSelectedFunction.File;
         Int32 lineNumber;
         if (Int32.TryParse(currentSelectedFunction.FileLine, out lineNumber))
         {
             O2Messages.raiseO2MDbg_SetBreakPointOnFile(file, lineNumber);
         }
     }
 }
Beispiel #26
0
 public static Thread openInFloatWindow(List <IO2Finding> o2Findings, string windowTitle)
 {
     return(O2Thread.mtaThread(() =>
     {
         O2Messages.openControlInGUISync(typeof(ascx_FindingsViewer), O2DockState.Float, windowTitle);
         O2Messages.getAscx(windowTitle, guiControl =>
         {
             if (guiControl != null && guiControl is ascx_FindingsViewer)
             {
                 var findingsViewer = (ascx_FindingsViewer)guiControl;
                 findingsViewer.loadO2Findings(o2Findings);
             }
         });
     }));
 }
Beispiel #27
0
        private void raiseO2KernelMessageWithSelectedNode(TreeNode treeNode)
        {
            string assemblyName = "Assembly";
            string _typeName    = "typeName";
            string _methodName  = "methodName";

            object[] _methodParameters = new object[0];
            switch (treeNode.Tag.GetType().Name)
            {
            case "Assembly":
                break;
            }

            O2Messages.selectedTypeOrMethod(assemblyName, _typeName, _methodName, _methodParameters);
        }
        public void test_openCirDataControlUsingO2Messages()
        {
            // get control
            var ascxControlName = "Cir Analysis";

            O2Messages.openAscxAsForm(typeof(ascx_CirAnalysis).FullName, ascxControlName);

            O2Messages.executeOnAscxSync(ascxControlName, "loadO2CirDataFile", new [] { DI.config.ExecutingAssembly });
            var returnedData = O2Messages.executeOnAscxSync(ascxControlName, "getCirDataAnalysisObject", new string[0]);

            Assert.That(returnedData != null && returnedData is ICirDataAnalysis, "probs with returned data");
            var cirData = (ICirDataAnalysis)returnedData;

            Assert.That(cirData.dCirClass.Count > 0, "There were no classes loaded in CirDataAnalysis object");
            O2Messages.closeAscxParent(ascxControlName);
        }
Beispiel #29
0
        public void onTreeViewAfterSelect(TreeNode selectedNode)
        {
            if (selectedNode.Tag != null)
            {
                selectedMethod        = null;
                btDebugMethod.Enabled = false;
                btExecuteMethodWithoutDebugger.Enabled = false;
                switch (selectedNode.Tag.GetType().Name)
                {
                case "RuntimeMethodInfo":
                    //Callbacks.raiseRegistedCallbacks(onSelectedMethod, new[] {e.Node.Tag});
                    selectedMethod = (MethodInfo)selectedNode.Tag;
                    raiseO2MessageWithMethodInfo(selectedMethod);
                    lbLastMethodExecuted.Text = selectedMethod.Name;
                    DI.reflection.loadMethodInfoParametersInDataGridView(selectedMethod, dgvSourceCode_SelectedMethodParameters);
//                        btSourceCode_executeStaticMethod.Enabled =
//                            DI.reflection.doesMethodOnlyHasSupportedParameters((MethodInfo)selectedNode.Tag);
                    dgvSourceCode_SelectedMethodParameters.Enabled = true;
                    btDebugMethod.Enabled = O2Messages.isDebuggerAvailable();
                    btExecuteMethodWithoutDebugger.Enabled = true;
                    break;

                case "RuntimeType":
                    foreach (TreeNode childNode in selectedNode.Nodes)
                    {
                        if (childNode.Tag != null && childNode.Tag.GetType().Name == "RuntimeMethodInfo")
                        {
                            raiseO2MessageWithMethodInfo((MethodInfo)childNode.Tag);
                        }
                    }
                    //var type = (Type) e.Node.Tag;
                    //foreach (var methodInfo in DI.reflection.getMethods(type))
                    //    raiseO2MessageWithMethodInfo(methodInfo);
                    break;

                case "Assembly":
                    var assembly = (Assembly)selectedNode.Tag;
                    foreach (var methodInfo in DI.reflection.getMethods(assembly))
                    {
                        raiseO2MessageWithMethodInfo(methodInfo);
                    }
                    break;
                }
            }
        }
Beispiel #30
0
 private void lbArchivedBreakpoints_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (lbArchivedBreakpoints.SelectedItem is String)
     {
         var breakpointSignature = lbArchivedBreakpoints.SelectedItem.ToString();
         var lastIndexOfColon    = breakpointSignature.LastIndexOf(':');
         if (lastIndexOfColon > -1)
         {
             var fileName           = breakpointSignature.Substring(0, lastIndexOfColon);
             var lineNumberAsString = breakpointSignature.Substring(lastIndexOfColon + 1);
             int lineNumber;
             if (Int32.TryParse(lineNumberAsString, out lineNumber))
             {
                 O2Messages.fileOrFolderSelected(fileName, lineNumber);
             }
         }
     }
 }