Esempio n. 1
0
        internal List <O2MDbgVariable> getCurrentFrameVariable(O2MDbgVariable o2MDbgVariable)
        {
            var o2MDbgVariables = new List <O2MDbgVariable>();

            try
            {
                MDbgFrame frame     = DI.o2MDbg.ActiveProcess.Threads.Active.CurrentFrame;
                MDbgValue mbbgValue = DI.o2MDbg.ActiveProcess.ResolveVariable(o2MDbgVariable.fullName, frame);
                if (mbbgValue != null && mbbgValue.IsComplexType)
                {
                    try
                    {
                        // add properties
                        var valueType     = mbbgValue.TypeName;
                        var valueAssembly = mbbgValue.CorValue.ExactType.Class.Module.Assembly.Name;
                        //var properties2 = DI.reflection.getProperties(DI.reflection.getType(valueAssembly,valueType));
                        var properties = DI.reflection.getProperties(DI.reflection.getType(valueAssembly, valueType));
                        foreach (var property in properties)
                        {
                            o2MDbgVariables.Add(new O2MDbgVariable(property, o2MDbgVariable));
                        }
                    }
                    catch (Exception ex)
                    {
                        DI.log.ex(ex, "in getCurrentFrameVariable , add properties");
                    }
                    // add values
                    try
                    {
                        foreach (MDbgValue mdbgValue in mbbgValue.GetFields())
                        {
                            if (mdbgValue != null)
                            {
                                o2MDbgVariables.Add(new O2MDbgVariable(mdbgValue, o2MDbgVariable));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        DI.log.ex(ex, "in getCurrentFrameVariable , add values");
                    }
                }
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "in getCurrentFrameVariable");
            }
            return(o2MDbgVariables);
        }
Esempio n. 2
0
        public Dictionary <string, O2MDbgVariable> getVariableDictionary(O2MDbgVariable variableToGet)
        {
            var variablesDictionary = new Dictionary <string, O2MDbgVariable>();

            try
            {
                foreach (var variable in getCurrentFrameVariable(variableToGet))
                {
                    if (false == variablesDictionary.ContainsKey(variable.name))
                    {
                        variablesDictionary[variable.name] = variable;
                    }
                }
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "in getVariableDictionary()");
            }
            return(variablesDictionary);
        }
Esempio n. 3
0
        public O2MDbgVariable(PropertyInfo propertyInfo, O2MDbgVariable _parentVariable)
        {
            IsProperty = true;
            parentVariable = _parentVariable;
            name = propertyInfo.Name;
            /*try
            {
                value = mdbgValue.GetStringValue(false);
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "in O2MDbgVariable(MDbgValue mdbgValue), while trying to get value for: " + mdbgValue.Name);
                value = O2MDbgUtils.getPropertyValue(this);
            }*/
            //fullName = parentVariableName + ".get_" + propertyInfo.Name;
            //     value = O2MDbgUtils.getPropertyValue(this);
            type = propertyInfo.PropertyType.FullName;

            //complexType = true;        
        }
Esempio n. 4
0
        public O2MDbgVariable(PropertyInfo propertyInfo, O2MDbgVariable _parentVariable)
        {
            IsProperty     = true;
            parentVariable = _parentVariable;
            name           = propertyInfo.Name;

            /*try
             * {
             *  value = mdbgValue.GetStringValue(false);
             * }
             * catch (Exception ex)
             * {
             *  DI.log.ex(ex, "in O2MDbgVariable(MDbgValue mdbgValue), while trying to get value for: " + mdbgValue.Name);
             *  value = O2MDbgUtils.getPropertyValue(this);
             * }*/
            //fullName = parentVariableName + ".get_" + propertyInfo.Name;
            //     value = O2MDbgUtils.getPropertyValue(this);
            type = propertyInfo.PropertyType.FullName;

            //complexType = true;
        }
Esempio n. 5
0
 internal List<O2MDbgVariable> getCurrentFrameVariable(O2MDbgVariable o2MDbgVariable)
 {
     var o2MDbgVariables = new List<O2MDbgVariable>();
     try
     {
         MDbgFrame frame = DI.o2MDbg.ActiveProcess.Threads.Active.CurrentFrame;
         MDbgValue mbbgValue = DI.o2MDbg.ActiveProcess.ResolveVariable(o2MDbgVariable.fullName, frame);
         if (mbbgValue != null && mbbgValue.IsComplexType)
         {
             try
             {
                 // add properties
                 var valueType = mbbgValue.TypeName;
                 var valueAssembly = mbbgValue.CorValue.ExactType.Class.Module.Assembly.Name;
                 //var properties2 = DI.reflection.getProperties(DI.reflection.getType(valueAssembly,valueType));
                 var properties = DI.reflection.getProperties(DI.reflection.getType(valueAssembly, valueType));
                 foreach (var property in properties)
                     o2MDbgVariables.Add(new O2MDbgVariable(property, o2MDbgVariable));
             }
             catch (Exception ex)
             {
                 DI.log.ex(ex, "in getCurrentFrameVariable , add properties");
             }
             // add values
             try
             {
                 foreach (MDbgValue mdbgValue in mbbgValue.GetFields())
                     if (mdbgValue != null)
                         o2MDbgVariables.Add(new O2MDbgVariable(mdbgValue, o2MDbgVariable));
             }
             catch (Exception ex)
             {
                 DI.log.ex(ex, "in getCurrentFrameVariable , add values");
             }
         }
     }
     catch (Exception ex)
     {
         DI.log.ex(ex, "in getCurrentFrameVariable");
     }
     return o2MDbgVariables;
 }
Esempio n. 6
0
 public Dictionary<string, O2MDbgVariable> getVariableDictionary(O2MDbgVariable variableToGet)
 {
     var variablesDictionary = new Dictionary<string, O2MDbgVariable>();
     try
     {
         foreach(var variable in getCurrentFrameVariable(variableToGet))
         {
             if (false == variablesDictionary.ContainsKey(variable.name))
                 variablesDictionary[variable.name] = variable;
         }
     }
     catch (Exception ex)
     {
         DI.log.ex(ex, "in getVariableDictionary()");
     }
     return variablesDictionary;
 }
Esempio n. 7
0
 public O2MDbgVariable(MDbgValue mdbgValue, O2MDbgVariable _parentVariable)
     : this(mdbgValue, _parentVariable.parentType, _parentVariable.assemblyName)
 {
     parentVariable = _parentVariable;
 }
        /*lvVariables.invokeOnThread(
                () =>
                    {
        */        

        private void showVariablesDetails(O2MDbgVariable o2MDbgVariable)
        {
            this.invokeOnThread(
                () =>
                {
                    laVariableType.Text = o2MDbgVariable.type;
                    laVariableFullName.Text = o2MDbgVariable.fullName;
                    tbVariableValue.Text = o2MDbgVariable.value;
                });
        }
Esempio n. 9
0
 public O2MDbgVariable(MDbgValue mdbgValue, O2MDbgVariable _parentVariable)
     : this(mdbgValue, _parentVariable.parentType, _parentVariable.assemblyName)
 {
     parentVariable = _parentVariable;
 }
Esempio n. 10
0
        public static string getVariableValue_Thread(O2MDbgVariable o2MDbgVariable)
        {
            String variableValue = "";
            if (o2MDbgVariable.IsProperty)            
                variableValue = getPropertyValue(o2MDbgVariable);
            else
                variableValue = o2MDbgVariable.value;

            if (variableValue != null && variableValue.Length > 0 && variableValue[0] == '"' && variableValue[variableValue.Length - 1] == '"')
            {
                return variableValue.Substring(1, variableValue.Length - 2);
            }
            return variableValue;
        }
Esempio n. 11
0
        public static void showVariableValue(O2MDbgVariable o2MDbgVariable)
        {
            O2Thread.mtaThread(
                () =>
                    {
                        var variableValue = getVariableValue_Thread(o2MDbgVariable);
                        DI.log.info("{0} = {1}", o2MDbgVariable.name, variableValue);
                    });

        }
Esempio n. 12
0
        public static void setVariableValue_Thread(O2MDbgVariable o2MDbgVariable, string newValue)
        {
            if (false == string.IsNullOrEmpty(newValue))
                if (newValue[0] != '"' && newValue[newValue.Length - 1] != '"')
                    newValue = '"' + newValue + '"';
            if (o2MDbgVariable.IsProperty)
            {
                if (o2MDbgVariable.parentVariable != null)
                {
                    var variableType = string.Format("{0}.set_{1}", o2MDbgVariable.parentVariable.type,
                                                     o2MDbgVariable.name);
                    var variableObject = o2MDbgVariable.parentVariable.fullName;
                    var executeString = string.Format("{0} {1} {2}", variableType, variableObject,
                                                      newValue);
                    DI.log.info("executing: {0}", executeString);
                    execute(executeString);
                }
            }
            else
            {    
                
                //var variableFullType = o2MDbgVariable.parentType + "." + o2MDbgVariable.name;
                var variableObject = o2MDbgVariable.fullName;
                var cmdToExecute = string.Format("set {0}={1}" , variableObject,newValue);
                //execute(executeString);
                DI.o2MDbg.execSync(cmdToExecute);
            }

        }
Esempio n. 13
0
 public static void setVariableValue(O2MDbgVariable o2MDbgVariable, string newValue)
 {
     O2Thread.mtaThread( () => setVariableValue_Thread(o2MDbgVariable, newValue));
 }
Esempio n. 14
0
 public static string getPropertyValue(O2MDbgVariable o2MDbgVariable)
 {
     if (o2MDbgVariable.IsProperty)
     {
         if (o2MDbgVariable.parentVariable != null)
         {
             var variableType = string.Format("{0}.get_{1}", o2MDbgVariable.parentVariable.type, o2MDbgVariable.name);
             var variableObject = o2MDbgVariable.parentVariable.fullName;
             var executeString = string.Format("{0} {1}", variableType, variableObject);
             DI.log.info("executing: {0}", executeString);
             var propertyValue = execute(executeString);
             return propertyValue;
         }
     }
     else
     {
         /*  var variableFullType = o2MDbgVariable.parentType + "." + o2MDbgVariable.name;
           var variableObject = o2MDbgVariable.fullName;
           var executeString = string.Format("{0} {1}=\"{2}\"", variableFullType, variableObject, newValue);
           execute(executeString);*/
     }
     return "";
 }