本文整理汇总了C#中IDebugMemoryContext2.GetInfo方法的典型用法代码示例。如果您正苦于以下问题:C# IDebugMemoryContext2.GetInfo方法的具体用法?C# IDebugMemoryContext2.GetInfo怎么用?C# IDebugMemoryContext2.GetInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDebugMemoryContext2
的用法示例。
在下文中一共展示了IDebugMemoryContext2.GetInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadAt
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public int ReadAt (IDebugMemoryContext2 pStartContext, uint dwCount, byte [] rgbMemory, out uint pdwRead, ref uint pdwUnreadable)
{
//
// Reads a sequence of bytes, starting at a given location.
//
LoggingUtils.PrintFunction ();
try
{
CONTEXT_INFO [] contextInfoArray = new CONTEXT_INFO [1];
LoggingUtils.RequireOk (pStartContext.GetInfo (enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE, contextInfoArray));
string command = string.Format ("-data-read-memory-bytes {0} {1}", contextInfoArray [0].bstrAddressAbsolute, dwCount);
MiResultRecord resultRecord = m_debugger.GdbClient.SendSyncCommand (command);
MiResultRecord.RequireOk (resultRecord, command);
MiResultValueList memoryStreamList = (MiResultValueList) resultRecord ["memory"] [0];
for (int s = 0; s < memoryStreamList.Values.Count; ++s)
{
if (!memoryStreamList [s].HasField ("contents"))
{
throw new InvalidOperationException ("-data-read-memory-bytes result missing 'contents' field");
}
string hexValue = memoryStreamList [s] ["contents"] [0].GetString ();
if ((hexValue.Length / 2) != dwCount)
{
throw new InvalidOperationException ();
}
for (int i = 0; i < dwCount; ++i)
{
rgbMemory [i] = byte.Parse (hexValue.Substring (i * 2, 2), NumberStyles.HexNumber);
}
}
pdwRead = dwCount;
pdwUnreadable = 0;
return Constants.S_OK;
}
catch (Exception e)
{
LoggingUtils.HandleException (e);
pdwRead = 0;
pdwUnreadable = dwCount;
return Constants.E_FAIL;
}
}
示例2: WriteAt
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public int WriteAt (IDebugMemoryContext2 pStartContext, uint dwCount, byte [] rgbMemory)
{
//
// Writes the specified number of bytes of memory, starting at the specified address.
//
LoggingUtils.PrintFunction ();
try
{
CONTEXT_INFO [] contextInfoArray = new CONTEXT_INFO [1];
LoggingUtils.RequireOk (pStartContext.GetInfo (enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE, contextInfoArray));
StringBuilder stringBuilder = new StringBuilder ((int)dwCount * 2);
for (uint i = 0; i < dwCount; ++i)
{
stringBuilder.Append (rgbMemory [i].ToString ("x"));
}
string command = string.Format ("-data-write-memory-bytes {0} {1} {2}", contextInfoArray [0].bstrAddressAbsolute, stringBuilder.ToString (), dwCount);
MiResultRecord resultRecord = m_debugger.GdbClient.SendSyncCommand (command);
MiResultRecord.RequireOk (resultRecord, command);
return Constants.S_OK;
}
catch (Exception e)
{
LoggingUtils.HandleException (e);
return Constants.E_FAIL;
}
}