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


C# DJsIO.SetLength方法代码示例

本文整理汇总了C#中X360.IO.DJsIO.SetLength方法的典型用法代码示例。如果您正苦于以下问题:C# DJsIO.SetLength方法的具体用法?C# DJsIO.SetLength怎么用?C# DJsIO.SetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在X360.IO.DJsIO的用法示例。


在下文中一共展示了DJsIO.SetLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

 /// <summary>
 /// Builds the package
 /// </summary>
 /// <param name="xParams"></param>
 /// <param name="ContentType"></param>
 /// <returns></returns>
 public bool Create(RSAParams xParams, PackageType ContentType)
 {
     if (BaseImage == null)
         throw new Exception("No image");
     if (!xParams.Valid)
         throw CryptoExcepts.ParamError;
     if (ContentType != PackageType.HDDInstalledGame &&
         ContentType != PackageType.OriginalXboxGame &&
         ContentType != PackageType.GamesOnDemand &&
         ContentType != PackageType.SocialTitle)
         return false;
     if (xActive)
         return false;
     xActive = true;
     DJsIO x = null;
     DJsIO h = null;
     try
     {
         string outlocale = OutLocation.Replace('\\', '/');
         if (outlocale[outlocale.Length - 1] == '/')
             outlocale = outlocale.Substring(0, outlocale.Length - 1);
         outlocale += '/' + ((uint)ContentType).ToString("X8");
         string DataFolder = outlocale + "/" + xHeader.TitleID.ToString("X8") + ".data";
         if (!VariousFunctions.xCheckDirectory(OutLocation))
             throw IOExcepts.CreateError;
         if (!VariousFunctions.xCheckDirectory(DataFolder))
             throw IOExcepts.CreateError;
         uint xBlockCount = 0;
         uint xDataFileCount = 0;
         long xDataLength = 0;
         BaseImage.xIO.Position = BaseImage.baseoffset;
         while (BaseImage.xIO.Position < BaseImage.xIO.Length)
         {
             if ((xBlockCount % Constants.SVODBL[1]) == 0)
             {
                 if (x != null)
                 {
                     for (int i = 0; i < 0xCB; i++)
                     {
                         x.Position = SVODFuncs.GenerateHashOffset((uint)(i * Constants.SVODBL[0]), 0);
                         byte[] Data1 = SHA1Quick.ComputeHash(x.ReadBytes(0x1000));
                         x.Position = SVODFuncs.GenerateHashOffset((uint)(i * Constants.SVODBL[0]), 1);
                         x.Write(Data1);
                     }
                     x.Flush();
                     xDataLength += x.Length;
                     x.Close();
                 }
                 x = new DJsIO(DataFolder + SVODFuncs.formatstring(xDataFileCount), DJFileMode.Create, true);
                 xDataFileCount++;
             }
             x.Position = SVODFuncs.GenerateDataOffset(xBlockCount);
             byte[] Data = BaseImage.xIO.ReadBytes(0x1000);
             x.Write(Data);
             x.Position = SVODFuncs.GenerateHashOffset(xBlockCount, 0);
             x.Write(SHA1Quick.ComputeHash(Data));
             xBlockCount++;
         }
         if (xBlockCount == 0)
         {
             x.Close();
             return (xActive = false);
         }
         x.Flush();
         xDataLength += x.Length;
         int lvlct = (int)((((xBlockCount % Constants.SVODBL[1]) - 1) / Constants.SVODBL[0]) + 1);
         for (int i = 0; i < lvlct; i++)
         {
             x.Position = SVODFuncs.GenerateHashOffset((uint)(i * Constants.SVODBL[0]), 0);
             byte[] Data1 = SHA1Quick.ComputeHash(x.ReadBytes(0x1000));
             x.Position = SVODFuncs.GenerateHashOffset((uint)(i * Constants.SVODBL[0]), 1);
             x.Write(Data1);
         }
         x.Flush();
         x.Close();
         byte[] Hash = null;
         for (int i = (int)(xDataFileCount - 1); i >= 0; i--)
         {
             x = new DJsIO(DataFolder + SVODFuncs.formatstring((uint)i), DJFileMode.Open, true);
             if (Hash != null)
             {
                 x.Position = 0xFF0;
                 x.Write(Hash);
                 x.Flush();
             }
             x.Position = 0;
             Hash = SHA1Quick.ComputeHash(x.ReadBytes(0x1000));
         }
         xHeader.DataFileSize = xDataLength;
         xHeader.DataFileCount = xDataFileCount;
         xHeader.xThisType = ContentType;
         h = new DJsIO(outlocale + "/" + xHeader.TitleID.ToString("X8"), DJFileMode.Create, true);
         xHeader.Write(ref h);
         h.SetLength(0xB000);
//.........这里部分代码省略.........
开发者ID:VictorOverX,项目名称:X360,代码行数:101,代码来源:Create.cs

示例2: xWriteHeader

 bool xWriteHeader(RSAParams xParams)
 {
     try
     {
         DJsIO xio = new DJsIO(true);
         xHeaderData.Write(ref xio);
         xio.SetLength(0xB000);
         xio.Position = 0x340;
         xio.Write((uint)0xAD0E);
         xio.Position = 0x379;
         xio.Write(new byte[] { 0x24, 5, 5, 0x11 });
         IO.Position = 0x37D;
         xio.Write(IO.ReadBytes(20));
         xio.Write((byte)((xIsShifted ? 1 : 0) << 6));
         xio.WriteUInt24(xBlockCount);
         xio.Write(xDeviation);
         xio.Flush();
         xio.Position = 0x344;
         byte[] xHash = SHA1Quick.ComputeHash(xio.ReadBytes((int)(xio.Length - 0x344)));
         xio.Position = 0x32C;
         xio.Write(xHash);
         xio.Flush();
         xio.Position = 0x22C;
         xHash = SHA1Quick.ComputeHash(xio.ReadBytes(0x118));
         xio.Position = 4;
         if (xParams.Type == PackageMagic.CON)
         {
             xio.Write(xParams.Certificate);
             xio.Write(ScrambleMethods.StockScramble(RSAQuick.SignatureGenerate(xParams.RSAKeys, xHash), true));
         }
         else
         {
             xio.Write(ScrambleMethods.DevScramble(RSAQuick.SignatureGenerate(xParams.RSAKeys, xHash)));
             xio.Write(new byte[0x128]);
         }
         xio.IsBigEndian = true;
         xio.Position = 0;
         xio.Write(((uint)xParams.Type));
         xio.Flush();
         xHeaderData.xMagic = xParams.Type;
         IO.Position = 0;
         IO.Write(xio.ReadStream());
         IO.Flush();
         xio.Dispose();
         return true;
     }
     catch { return false; }
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:48,代码来源:SVODPackage.cs


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