当前位置: 首页>>代码示例>>C#>>正文


C# Debugger.GetMemoryValues方法代码示例

本文整理汇总了C#中Debugger.GetMemoryValues方法的典型用法代码示例。如果您正苦于以下问题:C# Debugger.GetMemoryValues方法的具体用法?C# Debugger.GetMemoryValues怎么用?C# Debugger.GetMemoryValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Debugger的用法示例。


在下文中一共展示了Debugger.GetMemoryValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessFields

        private void ProcessFields(Debugger TheDebugger, uint ProcessId, uint BaseAddress, List<FieldInfo> FieldsToProcess)
        {
            foreach (FieldInfo AFieldInfo in FieldsToProcess)
            {
                if (!AFieldInfo.IsStatic)
                {
                    uint FieldAddress = (uint)(BaseAddress + AFieldInfo.OffsetInBytes);
                    TypeInfo FieldTypeInfo = TheDebugger.GetTypeInfo(AFieldInfo.TypeID);

                    if (FieldTypeInfo.SizeOnHeapInBytes > 0)
                    {
                        string FieldValueStr = TheDebugger.GetMemoryValues(ProcessId, FieldAddress, FieldTypeInfo.IsValueType ? FieldTypeInfo.SizeOnHeapInBytes : FieldTypeInfo.SizeOnStackInBytes, 1);
                        byte[] FieldValueArr = FieldValueStr.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(x => byte.Parse(x.Substring(2), System.Globalization.NumberStyles.HexNumber)).ToArray();
                        Fields.Add(new VariableData()
                        {
                            Address = FieldAddress,
                            Info = FieldTypeInfo,
                            OffsetFromParent = AFieldInfo.OffsetInBytes,
                            Value = FieldValueArr,
                            Name = AFieldInfo.Name
                        });
                    }
                }
            }
        }
开发者ID:rmhasan,项目名称:FlingOS,代码行数:25,代码来源:MainForm.cs

示例2: LoadFields

        public void LoadFields(Debugger TheDebugger, uint ProcessId, int Depth)
        {
            if (Depth == 1)
            {
                if (Info != null &&
                    !Info.IsPointer &&
                    !Info.IsValueType &&
                    Value.Length == 4)
                {
                    uint AddressFromValue = BitConverter.ToUInt32(Value, 0);

                    if (AddressFromValue != 0)
                    {
                        string BaseTypeID = Info.BaseTypeID;
                        while (BaseTypeID != null)
                        {
                            TypeInfo BaseInfo = TheDebugger.GetTypeInfo(BaseTypeID);

                            ProcessFields(TheDebugger, ProcessId, AddressFromValue, BaseInfo.Fields.Values.ToList());

                            BaseTypeID = BaseInfo.BaseTypeID;
                        }

                        ProcessFields(TheDebugger, ProcessId, AddressFromValue, Info.Fields.Values.ToList());

                        if (Info.ID == "type_Kernel_FOS_System_String")
                        {
                            // Special treatment

                            // Find the length field
                            int length = 0;
                            bool found = false;
                            foreach(VariableData AField in Fields)
                            {
                                if (AField.Name == "length")
                                {
                                    found = true;
                                    length = BitConverter.ToInt32(AField.Value, 0);
                                    break;
                                }
                            }

                            // Load string bytes
                            //                                                              +8 for bytes for string fields
                            //                                                                                      *2 - 2 bytes/char
                            string StringBytesStr = TheDebugger.GetMemoryValues(ProcessId, AddressFromValue + 8, length*2, 1);
                            byte[] StringBytesArr = StringBytesStr.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(x => byte.Parse(x.Substring(2), System.Globalization.NumberStyles.HexNumber)).ToArray();
                            string StringVal = Encoding.Unicode.GetString(StringBytesArr);
                            Fields.Add(new VariableData()
                            {
                                Address = AddressFromValue+8,
                                Info = null,
                                OffsetFromParent = 8,
                                Value = new byte[0],
                                Name = "\"" + StringVal + "\""
                            });
                        }
                    }
                }
            }

            if (Depth > 1)
            {
                foreach (VariableData Field in Fields)
                {
                    Field.LoadFields(TheDebugger, ProcessId, Depth - 1);
                }
            }
        }
开发者ID:rmhasan,项目名称:FlingOS,代码行数:69,代码来源:MainForm.cs


注:本文中的Debugger.GetMemoryValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。