本文整理汇总了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
});
}
}
}
}
示例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);
}
}
}