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


C# Marshaller.PushLength方法代码示例

本文整理汇总了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();
        }
开发者ID:vishalishere,项目名称:TSS.MSR,代码行数:29,代码来源:Tpm2.cs

示例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();
        }
开发者ID:vishalishere,项目名称:TSS.MSR,代码行数:43,代码来源:Tpm2.cs


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