本文整理汇总了C#中Marshaller.PushLength方法的典型用法代码示例。如果您正苦于以下问题:C# Marshaller.PushLength方法的具体用法?C# Marshaller.PushLength怎么用?C# Marshaller.PushLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Marshaller
的用法示例。
在下文中一共展示了Marshaller.PushLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateResponse
public static byte[] CreateResponse(
TpmRc responseCode,
TpmHandle[] handles,
SessionOut[] sessions,
byte[] responseParmsNoHandles)
{
var m = new Marshaller();
TpmSt tag = sessions.Length == 0 ? TpmSt.NoSessions : TpmSt.Sessions;
m.Put(tag, "tag");
m.PushLength(4);
m.Put(responseCode, "responseCode");
foreach (TpmHandle h in handles)
{
m.Put(h, "handle");
}
if (tag == TpmSt.Sessions)
{
m.Put((uint)responseParmsNoHandles.Length, "parmsLenght");
}
m.Put(responseParmsNoHandles, "parms");
foreach (SessionOut s in sessions)
m.Put(s, "session");
m.PopAndSetLengthToTotalLength();
return m.GetBytes();
}
示例2: CreateCommand
/// <summary>
/// Create a TPM command byte stream from constituent components
/// </summary>
/// <param name="commandCode"></param>
/// <param name="handles"></param>
/// <param name="sessions"></param>
/// <param name="parmsWithoutHandles"></param>
/// <returns></returns>
public static byte[] CreateCommand(
TpmCc commandCode,
TpmHandle[] handles,
SessionIn[] sessions,
byte[] parmsWithoutHandles)
{
// ReSharper disable once UnusedVariable
CommandInfo commandInfo = Tpm2.CommandInfoFromCommandCode(commandCode);
var m = new Marshaller();
TpmSt tag = sessions.Length == 0 ? TpmSt.NoSessions : TpmSt.Sessions;
m.Put(tag, "tag");
m.PushLength(4);
m.Put(commandCode, "commandCode");
foreach (TpmHandle h in handles)
{
m.Put(h, "handle");
}
if (tag == TpmSt.Sessions)
{
var m2 = new Marshaller();
foreach (SessionIn s in sessions)
{
m2.Put(s, "session");
}
m.PutUintPrependedArray(m2.GetBytes(), "sessions");
}
m.Put(parmsWithoutHandles, "parms");
m.PopAndSetLengthToTotalLength();
return m.GetBytes();
}