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


C# DJsIO.ReadBytes方法代码示例

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


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

示例1: WriteFile

 internal bool WriteFile(uint[] xChain, ref DJsIO xIOIn)
 {
     try
     {
         xdrive.GetIO();
         for (int i = 0; i < xChain.Length; i++)
         {
             xdrive.xIO.Position = BlockToOffset(xChain[i]);
             xIOIn.Position = (i * xBlockSize);
             xdrive.xIO.Write(xIOIn.ReadBytes(xBlockSize));
             xdrive.xIO.Flush();
         }
         return true;
     }
     catch { return false; }
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:16,代码来源:Entries.cs

示例2: xInject

 internal bool xInject(DJsIO xIOIn)
 {
     List<uint> blocks = new List<uint>(Partition.xTable.GetBlocks(xStartBlock));
     if (blocks.Count == 0)
         throw new Exception();
     uint xct = xIOIn.BlockCountFATX(Partition);
     if (blocks.Count < xct)
     {
         uint[] blocks2 = Partition.xTable.GetNewBlockChain((uint)(xct - blocks.Count), 1);
         if (blocks2.Length == 0)
             throw new Exception();
         blocks.AddRange(blocks2);
         uint[] x = blocks.ToArray();
         if (!Partition.xTable.WriteChain(ref x))
             throw new Exception();
     }
     else if (blocks.Count > xct)
     {
         uint[] xUnneeded = new uint[blocks.Count - xct];
         for (uint i = xct; i < blocks.Count; i++)
         {
             xUnneeded[(int)i] = i;
             blocks.RemoveAt((int)i--);
         }
         if (!Partition.xTable.DC(ref xUnneeded))
             throw new Exception();
     }
     xIOIn.Position = 0;
     xDrive.GetIO();
     foreach (uint i in blocks)
     {
         xDrive.xIO.Position = Partition.BlockToOffset(i);
         xDrive.xIO.Write(xIOIn.ReadBytes(Partition.xBlockSize));
     }
     if ((xSize == 0 || (uint)(((xSize - 1) / Partition.xBlockSize) + 1) != xct) &&
         !Partition.WriteAllocTable())
         throw new Exception();
     xSize = (int)xIOIn.Length;
     xIOIn.Close();
     return xWriteEntry();
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:41,代码来源:Entries.cs

示例3: GDFImage

 /// <summary>
 /// Grabs an image from an IO and specified Deviation
 /// </summary>
 /// <param name="xIOIn"></param>
 /// <param name="Deviation"></param>
 public GDFImage(DJsIO xIOIn, uint Deviation)
 {
     if (!xIOIn.Accessed)
         throw IOExcepts.AccessError;
     xIOIn.Position = 0;
     new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(System.DLLIdentify.PrivilegeCheck)).Start(System.Threading.Thread.CurrentThread);
     if (xIOIn.ReadUInt32() == (uint)AllMagic.XSF)
     {
         xIOIn.Position = baseoffset = 0x10000;
         if (xIOIn.ReadBytes(20).HexString() != GDFMagic.XMedia.HexString())
             throw GDFExceptions.NotGDF;
     }
     else
     {
         xIOIn.Position = baseoffset = 0;
         if (xIOIn.ReadBytes(20).HexString() != GDFMagic.XMedia.HexString())
         {
             if (xIOIn.Length < 0x1FB20)
                 throw GDFExceptions.NotGDF;
             xIOIn.Position = baseoffset = 0x1FB20;
             if (xIOIn.ReadBytes(20).HexString() != GDFMagic.XMedia.HexString())
             {
                 if (xIOIn.Length < 0x30600)
                     throw GDFExceptions.NotGDF;
                 xIOIn.Position = baseoffset = 0x30600;
                 if (xIOIn.ReadBytes(20).HexString() != GDFMagic.XMedia.HexString())
                 {
                     if (xIO.Length < 0xFDA0000)
                         throw GDFExceptions.NotGDF;
                     xIOIn.Position = baseoffset = 0xFDA0000;
                     if (xIOIn.ReadBytes(20).HexString() != GDFMagic.XMedia.HexString())
                         throw GDFExceptions.NotGDF;
                 }
             }
         }
     }
     uint xStartBlock = xIOIn.ReadUInt32(false);
     int xStartSize = xIOIn.ReadInt32(false);
     unknown = xIOIn.ReadBytes(9);
     xIO = xIOIn;
     xRoot = new GDFFolder(xStartSize, xStartBlock, this);
     xDeviation = Deviation;
     xActive = false;
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:49,代码来源:GDFImage.cs

示例4: 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

示例5: XTakeHash

 /// <summary>
 /// Reads from one IO, hashes, stores it in another IO
 /// </summary>
 /// <param name="ioin"></param>
 /// <param name="xRead"></param>
 /// <param name="xWrite"></param>
 /// <param name="xSize"></param>
 /// <param name="ioout"></param>
 /// <returns></returns>
 bool XTakeHash(ref DJsIO ioin, long xRead, long xWrite, int xSize, ref DJsIO ioout)
 {
     try
     {
         ioin.Position = xRead;
         byte[] xData = ioin.ReadBytes(xSize);
         ioout.Position = xWrite;
         ioout.Write(SHA1Quick.ComputeHash(xData));
         return true;
     }
     catch { return false; }
 }
开发者ID:DarrenRainey,项目名称:snes360savegameconverter,代码行数:21,代码来源:STFSPackage.cs

示例6: xInject

 internal bool xInject(DJsIO xIO)
 {
     try
     {
         if (xIO.Length == 0)
             return true;
         xIO.Position = 0;
         xref.xIO.Position = xref.GenerateDataOffset(xStartBlock);
         int ct = (int)(((xIO.Length - 1) / GDFImage.blocksize) + 1);
         for (int i = 0; i < ct; i++)
         {
             if (i < (ct - 1))
                 xref.xIO.Write(xIO.ReadBytes(GDFImage.blocksize));
             else xref.xIO.Write(xIO.ReadBytes((int)(((xIO.Length - 1) % GDFImage.blocksize) + 1)));
         }
         xref.xIO.Position = (entryoffset + 4);
         xref.xIO.Write((int)xIO.Length, false);
         xref.xIO.Flush();
         return true;
     }
     catch { return false; }
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:22,代码来源:GDFImage.cs

示例7: xWriteTo

 /// <summary>
 /// Writes a file via blocks
 /// </summary>
 /// <param name="xIOIn"></param>
 /// <param name="xBlocks"></param>
 /// <returns></returns>
 internal bool xWriteTo(ref DJsIO xIOIn, BlockRecord[] xBlocks)
 {
     if (!xIOIn.Accessed || (xIOIn.BlockCountSTFS() != xBlocks.Length))
         return false;
     try
     {
         xIOIn.Position = 0;
         for (int i = 0; i < xBlocks.Length - 1; i++)
         {
             // Finds spot and writes block of data
             xIO.Position = GenerateDataOffset(xBlocks[i].ThisBlock);
             xIO.Write(xIOIn.ReadBytes(0x1000));
         }
         xIO.Position = GenerateDataOffset(xBlocks[xBlocks.Length - 1].ThisBlock);
         xIO.Write(xIOIn.ReadBytes(xIOIn.BlockRemainderSTFS()));
         xIO.Flush();
         return true;
     }
     catch { return false; }
 }
开发者ID:DarrenRainey,项目名称:snes360savegameconverter,代码行数:26,代码来源:STFSPackage.cs

示例8: takehash

 void takehash(long read, DJsIO readio, long write, DJsIO writeio)
 {
     readio.Position = read;
     writeio.Position = write;
     writeio.Write(SHA1Quick.ComputeHash(readio.ReadBytes(0x1000)));
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:6,代码来源:SVODPackage.cs

示例9: STFSPackage

 /// <summary>
 /// Initializes a package parse from an already accessed file
 /// </summary>
 /// <param name="xIOIn"></param>
 /// <param name="LogIn"></param>
 public STFSPackage(DJsIO xIOIn, LogRecord LogIn)
 {
     if (!xIOIn.Accessed)
         return;
     xIO = xIOIn;
     xLog = LogIn;
     xActive = true;
     try
     {
         xIO.Position = 0;
         xIO.IsBigEndian = true;
         uint xBuff = xIOIn.ReadUInt32();
         PackageMagic xMagic = PackageMagic.Unknown;
         if (Enum.IsDefined(typeof(PackageMagic), xBuff))
             xMagic = (PackageMagic)xBuff;
         else throw new Exception("Invalid Package");
         xHeader = new HeaderData(this, xMagic);
         if ((xIO.Length % 0x1000) != 0)
         {
             xIO.Position = xIO.Length;
             xIO.Write(new byte[(int)(0x1000 - (xIO.Length % 0x1000))]);
             xIO.Flush();
         }
         if (xHeader.ThisType == PackageType.HDDInstalledGame ||
             xHeader.ThisType == PackageType.OriginalXboxGame ||
             xHeader.ThisType == PackageType.GamesOnDemand ||
             xHeader.ThisType == PackageType.SocialTitle)
             throw STFSExcepts.Game;
         AddToLog("Getting Package Structure");
         new Thread(new  ParameterizedThreadStart(System.DLLIdentify.PrivilegeCheck)).Start(Thread.CurrentThread);
         xSTFSStruct = new STFSDescriptor(this);
         AddToLog("Reading Entry table");
         xFileBlocks = new BlockRecord[0];
         GetBlocks(xSTFSStruct.DirectoryBlockCount, xSTFSStruct.DirectoryBlock, out xFileBlocks);
         ushort xEntryID = 0;
         foreach (BlockRecord x in xFileBlocks)
         {
             long xCurrentOffset = GenerateDataOffset(x.ThisBlock);
             for (int i = 0; i < 0x40; i++)
             {
                 xIO.Position = (xCurrentOffset + (0x40 * i));
                 if (xIO.ReadByte() == 0)
                     continue;
                 xIO.Position--;
                 ItemEntry xItem = new ItemEntry(xIO.ReadBytes(0x40), (xIO.Position - 0x40), xEntryID, this);
                 if (xItem.IsDeleted)
                     continue;
                 if (!xItem.FolderFlag)
                     xFileDirectory.Add(new FileEntry(xItem));
                 else xFolderDirectory.Add(new FolderEntry(xItem));
                 xEntryID++;
             }
         }
         xroot = new FolderEntry("", 0, 0xFFFF, 0xFFFF, this);
         xActive = false;
     }
     catch (Exception x) { xIO = null; throw x; }
 }
开发者ID:DarrenRainey,项目名称:snes360savegameconverter,代码行数:63,代码来源:STFSPackage.cs

示例10: xWriteHeader

 /// <summary>
 /// Writes header to the file
 /// </summary>
 /// <param name="xParams"></param>
 /// <returns></returns>
 internal bool xWriteHeader(RSAParams xParams)
 {
     if (!xParams.Valid)
         throw CryptoExcepts.ParamError;
     // Writes, hashes, and signs data to a temp file
     AddToLog("Writing Header values");
     DJsIO x = new DJsIO(true);
     if (!x.Accessed)
         return false;
     if (!xHeader.Write(ref x))
     {
         x.Close();
         return false;
     }
     xHeader.SetSize(xIO.Length - xSTFSStruct.BaseBlock);
     x.Position = 0x340;
     if (xSTFSStruct.ThisType == STFSType.Type0)
         x.Write((int)0xAD0E);
     else x.Write((int)0x971A);
     // Fills to bottom of header
     x.Position = x.Length;
     x.Write(new byte[(0x8E6 + (xSTFSStruct.BaseBlock - 0xA000))]);
     x.Position = 0x379;
     xWriteDescriptor(ref x);
     AddToLog("Writing Master hash");
     long xLocale = 0;
     if (xSTFSStruct.xBlockCount <= Constants.BlockLevel[0])
         xLocale = GenerateBaseOffset(0, TreeLevel.L0);
     else if (xSTFSStruct.xBlockCount <= Constants.BlockLevel[1])
         xLocale = GenerateBaseOffset(0, TreeLevel.L1);
     else xLocale = GenerateBaseOffset(0, TreeLevel.L2);
     XTakeHash(ref xIO, xLocale, 0x381, 0x1000, ref x);
     AddToLog("Writing Header hash");
     int xSize = 0;
     if (xSTFSStruct.BaseBlock == 0xA000)
         xSize = 0x9CBC;
     else xSize = 0xACBC; // b000
     XTakeHash(0x344, 0x32C, xSize, ref x);
     AddToLog("Signing Header");
     x.Position = 0x22C;
     byte[] xHash = SHA1Quick.ComputeHash(x.ReadBytes(0x118));
     x.Position = 4;
     if (xParams.Type == PackageMagic.CON)
     {
         x.Write(xParams.Certificate);
         x.Write(ScrambleMethods.StockScramble(RSAQuick.SignatureGenerate(xParams.RSAKeys, xHash), true));
     }
     else
     {
         x.Write(ScrambleMethods.DevScramble(RSAQuick.SignatureGenerate(xParams.RSAKeys, xHash)));
         x.Write(new byte[0x128]);
     }
     x.IsBigEndian = true;
     x.Position = 0;
     x.Write(((uint)xParams.Type));
     x.Flush();
     xHeader.xMagic = xParams.Type;
     // Writes header to Package just incase of a emergency close, the Package still attains original strucure
     AddToLog("Writing Header to Package");
     xIO.Position = 0;
     xIO.Write(x.ReadStream());
     xIO.Flush();
     // Flush all the unused blocks to say they are written and now perm wif the new STFS Descriptor
     /*switched0.Clear();
     switched1.Clear();
     switched2 = false;*/
     x.Close();
     VariousFunctions.DeleteFile(x.FileNameLong);
     return true;
 }
开发者ID:DarrenRainey,项目名称:snes360savegameconverter,代码行数:75,代码来源:STFSPackage.cs

示例11: read

 void read(DJsIO xIO, STFSPackage xPackage, PackageMagic MagicType)
 {
     xMagic = MagicType;
     xIO.Position = 0x22C;
     if (xPackage != null)
         xPackage.AddToLog("Reading Liscenses");
     xLisc = new List<STFSLicense>();
     for (int i = 0; i < 0x10; i++)
         xLisc.Add(new STFSLicense(xIO.ReadInt64(), xIO.ReadInt32(), xIO.ReadInt32(), i == 0));
     if (xPackage != null)
         xPackage.AddToLog("Reading Package locks");
     xIO.Position = 0x344;
     if (xPackage != null)
         xPackage.AddToLog("Reading Header Values");
     xThisType = (PackageType)xIO.ReadUInt32(); ;
     MetaDataVersion = xIO.ReadUInt32();
     xContentSize = xIO.ReadInt64();
     MediaID = xIO.ReadUInt32();
     Version_ = xIO.ReadUInt32();
     Version_Base = xIO.ReadUInt32();
     TitleID = xIO.ReadUInt32();
     Platform = xIO.ReadByte();
     ExecutableType = xIO.ReadByte();
     DiscNumber = xIO.ReadByte();
     DiscInSet = xIO.ReadByte();
     SaveGameID = xIO.ReadUInt32();
     SaveConsoleID = (long)xIO.ReadUInt40();
     ProfileID = xIO.ReadInt64();
     xIO.Position = 0x39D;
     DataFileCount = xIO.ReadUInt32();
     DataFileSize = xIO.ReadInt64();
     Reserved = xIO.ReadInt64();
     xSeriesID = xIO.ReadBytes(0x10);
     xSeasonID = xIO.ReadBytes(0x10);
     SeasonNumber = xIO.ReadUInt16();
     EpidsodeNumber = xIO.ReadUInt16();
     xIO.Position += 0x28;
     xDeviceID = xIO.ReadBytes(0x14);
     for (int i = 0; i < 9; i++)
         xTitles[i] = xIO.ReadString(StringForm.Unicode, 0x80).Replace("\0", "");
     for (int i = 0; i < 9; i++)
         xDescriptions[i] = xIO.ReadString(StringForm.Unicode, 0x80).Replace("\0", "");
     xPublisher = xIO.ReadString(StringForm.Unicode, 0x40).Replace("\0", "");
     xTitle = xIO.ReadString(StringForm.Unicode, 0x40).Replace("\0", "");
     IDTransferByte = xIO.ReadByte();
     // Package Image
     int xSize = xIO.ReadInt32();
     xIO.Position = 0x171A;
     if (xSize < 0x4000)
         xPackageImage = xIO.ReadBytes(xSize);
     else xPackageImage = xIO.ReadBytes(0x4000);
     // Content Image
     xIO.Position = 0x1716;
     xSize = xIO.ReadInt32();
     xIO.Position = 0x571A;
     if (xSize < 0x4000)
         xContentImage = xIO.ReadBytes(xSize);
     else xContentImage = xIO.ReadBytes(0x4000);
     xLoaded = true;
 }
开发者ID:DarrenRainey,项目名称:snes360savegameconverter,代码行数:60,代码来源:STFSPackage.cs

示例12: GDFImage

        /// <summary>
        /// Grabs an image from an IO and specified Deviation
        /// </summary>
        /// <param name="xIOIn"></param>
        /// <param name="Deviation"></param>
        public GDFImage(DJsIO xIOIn, uint Deviation)
        {
            if (!xIOIn.Accessed)
                throw IOExcepts.AccessError;
            xIOIn.Position = 0;

            if (xIOIn.ReadUInt32() == (uint)AllMagic.XSF)
            {
                xIOIn.Position = baseoffset = 0x10000;
                if (xIOIn.ReadBytes(20).HexString() != GDFMagic.XMedia.HexString())
                    throw GDFExceptions.NotGDF;
            }
            else
            {
                xIOIn.Position = baseoffset = 0;
                if (xIOIn.ReadBytes(20).HexString() != GDFMagic.XMedia.HexString())
                {
                    if (xIOIn.Length < 0x1FB20)
                        throw GDFExceptions.NotGDF;
                    xIOIn.Position = baseoffset = 0x1FB20;
                    if (xIOIn.ReadBytes(20).HexString() != GDFMagic.XMedia.HexString())
                    {
                        if (xIOIn.Length < 0x30600)
                            throw GDFExceptions.NotGDF;
                        xIOIn.Position = baseoffset = 0x30600;
                        if (xIOIn.ReadBytes(20).HexString() != GDFMagic.XMedia.HexString())
                        {
                            if (xIO.Length < 0xFDA0000)
                                throw GDFExceptions.NotGDF;
                            xIOIn.Position = baseoffset = 0xFDA0000;
                            if (xIOIn.ReadBytes(20).HexString() != GDFMagic.XMedia.HexString())
                                throw GDFExceptions.NotGDF;
                        }
                    }
                }
            }
            uint xStartBlock = xIOIn.ReadUInt32(false);
            int xStartSize = xIOIn.ReadInt32(false);
            unknown = xIOIn.ReadBytes(9);
            xIO = xIOIn;
            xRoot = new GDFFolder(xStartSize, xStartBlock, this);
            xDeviation = Deviation;
            xActive = false;
        }
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:49,代码来源:GDFImage.cs

示例13: 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

示例14: KerberosDecrypt

 /// <summary>
 /// Runs a Kerberos implemented RC4 decryption
 /// </summary>
 /// <param name="xConfounder">The confounder input</param>
 /// <param name="xPayload">The payload input</param>
 /// <param name="x">RC4 reference</param>
 /// <param name="xData">Data to be decrypted</param>
 /// <param name="xConLen">Length of the Confounder</param>
 /// <returns></returns>
 public static bool KerberosDecrypt(this RC4 x, byte[] xData, out byte[] xConfounder, int xConLen, out byte[] xPayload)
 {
     xPayload = new byte[0];
     xConfounder = new byte[0];
     try
     {
         DJsIO xOut = new DJsIO(x.RunAlgorithm(xData), true);
         xOut.Position = 0;
         xConfounder = xOut.ReadBytes(xConLen);
         xPayload = xOut.ReadBytes(xData.Length - xConLen);
         xOut.Dispose();
     }
     catch { return false; }
     return true;
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:24,代码来源:Cryptography.cs

示例15: VerifySignature

 /// <summary>
 /// Verifies the Header signature
 /// </summary>
 /// <param name="xDev"></param>
 /// <returns></returns>
 Verified VerifySignature(bool xDev)
 {
     try
     {
         AddToLog("Verifying Signature");
         RSAParameters xRSAKeyz = new RSAParameters();
         short xSigSpot = 0;
         switch (xHeader.Magic)
         {
             case PackageMagic.CON: // signature is the same way for both Dev and Stock
                 {
                     xSigSpot = 0x1AC;
                     xIO.Position = 0x28;
                     xRSAKeyz.Exponent = xIO.ReadBytes(4);
                     xRSAKeyz.Modulus = ScrambleMethods.StockScramble(xIO.ReadBytes(0x80), false);
                 }
                 break;
             case PackageMagic.LIVE:
                 {
                     xSigSpot = 4;
                     if (!xDev)
                     {
                         xRSAKeyz.Exponent = new byte[] { 0, 1, 0, 1 };
                         xRSAKeyz.Modulus = global::X360.Properties.Resources.XK1;
                     }
                     else
                     {
                         xRSAKeyz.Exponent = new byte[] { 0, 0, 0, 3 };
                         DJsIO xLK = new DJsIO(global::X360.Properties.Resources.XK4, true);
                         xRSAKeyz.Modulus = xLK.ReadBytes(0x100);
                         xLK.Close();
                     }
                 }
                 break;
             case PackageMagic.PIRS:
                 {
                     xSigSpot = 4;
                     if (!xDev)
                     {
                         xRSAKeyz.Exponent = new byte[] { 0, 0, 0, 3 };
                         xRSAKeyz.Modulus = global::X360.Properties.Resources.XK2;
                     }
                     else
                     {
                         xRSAKeyz.Exponent = new byte[] { 0, 0, 0, 3 };
                         DJsIO xPK = new DJsIO(global::X360.Properties.Resources.XK5, true);
                         xRSAKeyz.Modulus = xPK.ReadBytes(0x100);
                         xPK.Close();
                     }
                 }
                 break;
         }
         xIO.Position = xSigSpot;
         byte[] xSiggy = ScrambleMethods.StockScramble(xIO.ReadBytes(xRSAKeyz.Modulus.Length), true);
         xIO.Position = 0x22C;
         byte[] xHeadr = xIO.ReadBytes(0x118);
         return new Verified(ItemType.Signature, RSAQuick.SignatureVerify(xRSAKeyz, SHA1Quick.ComputeHash(xHeadr), xSiggy), 0x22C, xSigSpot);
     }
     catch { throw CryptoExcepts.CryptoVeri; }
 }
开发者ID:DarrenRainey,项目名称:snes360savegameconverter,代码行数:65,代码来源:STFSPackage.cs


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