public static SosController set_Breakpoint(this SosController sosController, string module, string method)
        {
            var command = "!bpmd {0} {1}".format(module, method);

            sosController.executeCommand(command).info();
            return(sosController);
        }
        public static SosController breakpoints_Clear(this SosController sosController)
        {
            var command = "!bpmd -clearall";

            sosController.executeCommand(command).info();
            return(sosController);
        }
        public static SosController execute(this SosController sosController, string commandToExecute)
        {
            string response = null;

            sosController.execute(commandToExecute, ref response);
            return(sosController);
        }
 public static List <InstanceFieldInfo> instance_Fields(this SosController sosController, string instanceAddress)
 {
     return(new  InstanceFieldInfoCommand(instanceAddress)
            .Result(sosController.cdbProcess())
            .toList()
            .where ((instance) => instance.FieldAddress.contains(">").isFalse()));                                   //fix bug in SoSNet parsing code
 }
        public static SosController loadSoS(this SosController sosController)
        {
            var clr2 = clr.clr2();
            var x64  = clr.x64();

            return(sosController.loadSoS(clr2, x64));
        }
 public static SosController detach(this SosController sosController)
 {
     if (sosController.Attached)
     {
         sosController.Detach();
     }
     return(sosController);
 }
        public static SosController attach(this SosController sosController, int processId)
        {
            "[SosController] attaching to process with ID: {0}".info(processId);
            sosController.loadSettings();
            sosController.AttachToProcess(processId.str());

            sosController.loadSoS();
            return(sosController);
        }
        public static SosController loadSoS(this SosController sosController, bool clr2, bool x64)
        {
            var sosFile = (clr2) ?  (x64) ? @"C:\Windows\Microsoft.NET\Framework64\v2.0.50727\sos.dll"
                                                                                  : @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\sos.dll"
                                                                 :      (x64) ? @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\sos.dll"
                                                                                  : @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos.dll";

            return(sosController.execute(".load " + sosFile));
        }
        public static List <string> types_In_Heap_Raw(this SosController sosController, string typeName)
        {
            var result = sosController.executeCommand("!DumpHeap -short -type " + typeName);

            if (result.contains("Missing value for option -type"))
            {
                return(new List <string>());
            }
            return(result.split(" ").where ((value) => value.contains(">", "-").isFalse()));
        }
        public static SosController loadSettings(this SosController sosController)
        {
            var settings = new CdbSettings()
            {
                CdbPath = (clr.x64())
                                                                        ? @"C:\Program Files\Windows Kits\8.0\Debuggers\x64"
                                                                        : @"C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x86"
            };

            sosController.field("settings", settings);
            sosController.setDefaultController();
            return(sosController);
        }
 public static string eax(this SosController sosController)
 {
     try
     {
         sosController.setController();
         var eax = "!dso".sosExec().split_onLines()[2]
                   .split(" ")
                   .removeEmpty()
                   .second();
         return(eax);
     }
     catch (Exception ex)
     {
         "Prob getting eax".error();
         return(null);
     }
 }
 public static SosController setDefaultController(this SosController _sosController)
 {
     sosController = _sosController;
     return(sosController);
 }
 public static string dumpObject_Raw(this SosController sosController, string instanceAddress)
 {
     return(sosController.executeCommand("!DumpObj " + instanceAddress));
 }
 public static InstanceFieldInfo instance_Field(this SosController sosController, string instanceAddress, string name)
 {
     return(sosController.instance_Fields(instanceAddress).name(name));
 }
 public static CdbProcess cdbProcess(this SosController sosController)
 {
     return((CdbProcess)sosController.field("cdb"));
 }
 public static InstanceInfoDetails instance_Details(this SosController sosController, string instanceAddress)
 {
     return(new  InstanceInfoDetailsCommand(instanceAddress).Result(sosController.cdbProcess()).toList().first());
 }
 public static string sos_Help(this SosController sosController)
 {
     return(sosController.executeCommand("!help"));
 }
 public static TypeInfo type_In_Heap(this SosController sosController, string name)
 {
     return(sosController.types_In_Heap().where ((typeInfo) => typeInfo.ClassName == name).first());
 }
 public static List <TypeInfo> types_In_Heap(this SosController sosController)
 {
     return(sosController.cdbProcess().GetTypes().toList());
 }
 public static string breakpoints(this SosController sosController)
 {
     return(sosController.executeCommand("!bpmd -list"));
 }
 public static SosController execute(this SosController sosController, string commandToExecute, ref string response)
 {
     //"[SosController] ExecuteCommand: {0} \n\n{1}".info(commandToExecute, response);
     response = sosController.ExecuteCommand(commandToExecute);
     return(sosController);
 }
 public static SosController setController(this SosController _sosController)
 {
     return(_sosController.setDefaultController());
 }
 public static List <AssemblyInfo> assemblies(this SosController sosController)
 {
     return(new AssemblyInfoCommand().Result(sosController.cdbProcess()).toList());
 }
 //this will hang the current thread until there is a breakpoint or Ctrl+C
 public static string go(this SosController sosController)
 {
     return(sosController.executeCommand("g"));
 }