本文整理汇总了C#中Marshaller.SetGetPos方法的典型用法代码示例。如果您正苦于以下问题:C# Marshaller.SetGetPos方法的具体用法?C# Marshaller.SetGetPos怎么用?C# Marshaller.SetGetPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Marshaller
的用法示例。
在下文中一共展示了Marshaller.SetGetPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SplitResponse
public static void SplitResponse(
byte[] response,
uint numHandles,
out TpmSt tag,
out uint paramSize,
out TpmRc responseCode,
out TpmHandle[] handles,
out SessionOut[] sessions,
out byte[] responseParmsNoHandles,
out byte[] responseParmsWithHandles)
{
var m = new Marshaller(response);
tag = m.Get<TpmSt>();
paramSize = m.Get<uint>();
responseCode = m.Get<TpmRc>();
// If error we only get the header
if (responseCode != TpmRc.Success)
{
handles = new TpmHandle[0];
sessions = new SessionOut[0];
responseParmsNoHandles = new byte[0];
responseParmsWithHandles = new byte[0];
return;
}
handles = new TpmHandle[numHandles];
for (int j = 0; j < numHandles; j++)
{
handles[j] = m.Get<TpmHandle>();
}
uint parmsEnd = m.GetValidLength();
if (tag == TpmSt.Sessions)
{
var sessionOffset = m.Get<uint>();
uint startOfParmsX = m.GetGetPos();
parmsEnd = startOfParmsX + sessionOffset;
m.SetGetPos(parmsEnd);
var sessX = new List<SessionOut>();
while (m.GetGetPos() < m.GetValidLength())
{
var s = m.Get<SessionOut>();
sessX.Add(s);
}
sessions = sessX.ToArray();
m.SetGetPos(startOfParmsX);
}
else
{
sessions = new SessionOut[0];
}
uint startOfParms = m.GetGetPos();
uint parmsLength = parmsEnd - m.GetGetPos();
// Get the response buf with no handles
responseParmsNoHandles = new byte[parmsLength];
Array.Copy(response, (int)startOfParms, responseParmsNoHandles, 0, (int)parmsLength);
// Get the response buf with handles
responseParmsWithHandles = new byte[parmsLength + numHandles * 4];
Array.Copy(response, 10, responseParmsWithHandles, 0, (int)numHandles * 4);
Array.Copy(response, (int)startOfParms, responseParmsWithHandles, (int)numHandles * 4, (int)parmsLength);
}