Exemplo n.º 1
0
        private void InitFields()
        {
            

            if (_Fields!=null)
            {
                return;
            }

            

            _Fields = new Dictionary<string, CLRObject>(_properties.Length);

            //chose to do string split instead of regular expressions.
            //this may be faster than regular expressions
            //regular expression has lot of edge cases when i comes to matching geneic's notation
            //containing special charcters
            

            //name can be populated from the feild property.so this is not necessary
            if (string.IsNullOrEmpty(Name)&&_properties[0].Contains("Name:"))
                Name = _properties[0].Substring(13);
            //getting the method table from the substring.
            if (string.IsNullOrEmpty(this.MT)&&_properties[1].Contains("MethodTable:"))
                MT = _properties[1].Substring(13);
            if (_properties[2].Contains("EEClass:"))
                EEclass = _properties[2].Substring(13);

            Debugger.Current.OutputDebugInfo("Initializing fields of CLR Object Name:{0} and Type {1}\n", Name, Type);
            EmitParentInfo();

            Debugger.Current.OutputDebugInfo("MT \t\t Type \t\t valueType \t\t Name\n");
            for (int i = 7; i < _properties.Length; i++)
            {
                var strCurrentLine = _properties[i];
                //only if the filed contains instance,try to parse it.
                //we are skipping shared and static variable instances.
                if (strCurrentLine.Contains("instance"))
                {
                    string[] arrFields = strCurrentLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    //saw that some times the type field is empty string
                    //we are skipping that field as well b taking more thn or equal to 8 strings.
                    //0-MT
                    //1-Field
                    //2-offset
                    //3-Type
                    //4-VT
                    //5-Attr
                    //6-Value
                    //7 =>Name
                    if (arrFields.Length >= 8)
                    {
                       
                        CLRObject ObjCLR;
                        //indexing from back to avoid problems when the type contains spaces.
                        //if type contains spaces,it will cause length to be changed
                        if (arrFields[arrFields.Length - 4].Trim() == "1")
                        {
                            
                            //instantiaing value type.
                            //no need to check for address and values.
                            ObjCLR = new CLRObject(true, arrFields[3].Trim(), arrFields[arrFields.Length - 2].Trim());
                            ObjCLR.Name = arrFields[arrFields.Length-1];
                            ObjCLR.Parent = this;
                            ObjCLR.MT = arrFields[0].Trim();
                            ObjCLR.Type = arrFields[3].Trim();
                           
                        }
                        else
                        {
                            string fieldAddress = new Address(_address.ToHex(), arrFields[2]).ToHex();
                            //var pointer = Debugger.Current.ReadPointer(fieldAddress);
                            ObjCLR = new CLRObject(true, fieldAddress);
                            ObjCLR.Name = arrFields[arrFields.Length - 1];
                            ObjCLR.Parent = this;
                            //ObjCLR.MT = arrFields[0];
                            ObjCLR.MT = arrFields[0].Trim();
                            ObjCLR.Type = arrFields[3].Trim();


                        }
                        Debugger.Current.OutputDebugInfo("{0} \t\t {1} \t\t {2} \t\t {3} \n", ObjCLR.MT, ObjCLR.Type, ObjCLR.IsValueType, ObjCLR.Name);
                        _Fields.Add(arrFields[arrFields.Length-1].Trim().ToUpperInvariant(), ObjCLR);
                    }
                }

            }
        }
Exemplo n.º 2
0
        private void InitFields()
        {
            if (_Fields != null)
            {
                return;
            }



            _Fields = new Dictionary <string, CLRObject>(_properties.Length);

            //chose to do string split instead of regular expressions.
            //this may be faster than regular expressions
            //regular expression has lot of edge cases when i comes to matching geneic's notation
            //containing special charcters


            //name can be populated from the feild property.so this is not necessary
            if (string.IsNullOrEmpty(Name) && _properties[0].Contains("Name:"))
            {
                Name = _properties[0].Substring(13);
            }
            //getting the method table from the substring.
            if (string.IsNullOrEmpty(this.MT) && _properties[1].Contains("MethodTable:"))
            {
                MT = _properties[1].Substring(13);
            }
            if (_properties[2].Contains("EEClass:"))
            {
                EEclass = _properties[2].Substring(13);
            }

            Debugger.Current.OutputDebugInfo("Initializing fields of CLR Object Name:{0} and Type {1}\n", Name, Type);
            EmitParentInfo();

            Debugger.Current.OutputDebugInfo("MT \t\t Type \t\t valueType \t\t Name\n");
            for (int i = 7; i < _properties.Length; i++)
            {
                var strCurrentLine = _properties[i];
                //only if the filed contains instance,try to parse it.
                //we are skipping shared and static variable instances.
                if (strCurrentLine.Contains("instance"))
                {
                    string[] arrFields = strCurrentLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    //saw that some times the type field is empty string
                    //we are skipping that field as well b taking more thn or equal to 8 strings.
                    //0-MT
                    //1-Field
                    //2-offset
                    //3-Type
                    //4-VT
                    //5-Attr
                    //6-Value
                    //7 =>Name
                    if (arrFields.Length >= 8)
                    {
                        CLRObject ObjCLR;
                        //indexing from back to avoid problems when the type contains spaces.
                        //if type contains spaces,it will cause length to be changed
                        if (arrFields[arrFields.Length - 4].Trim() == "1")
                        {
                            //instantiaing value type.
                            //no need to check for address and values.
                            ObjCLR        = new CLRObject(true, arrFields[3].Trim(), arrFields[arrFields.Length - 2].Trim());
                            ObjCLR.Name   = arrFields[arrFields.Length - 1];
                            ObjCLR.Parent = this;
                            ObjCLR.MT     = arrFields[0].Trim();
                            ObjCLR.Type   = arrFields[3].Trim();
                        }
                        else
                        {
                            string fieldAddress = new Address(_address.ToHex(), arrFields[2]).ToHex();
                            //var pointer = Debugger.Current.ReadPointer(fieldAddress);
                            ObjCLR        = new CLRObject(true, fieldAddress);
                            ObjCLR.Name   = arrFields[arrFields.Length - 1];
                            ObjCLR.Parent = this;
                            //ObjCLR.MT = arrFields[0];
                            ObjCLR.MT   = arrFields[0].Trim();
                            ObjCLR.Type = arrFields[3].Trim();
                        }
                        Debugger.Current.OutputDebugInfo("{0} \t\t {1} \t\t {2} \t\t {3} \n", ObjCLR.MT, ObjCLR.Type, ObjCLR.IsValueType, ObjCLR.Name);
                        _Fields.Add(arrFields[arrFields.Length - 1].Trim().ToUpperInvariant(), ObjCLR);
                    }
                }
            }
        }