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


C# DJsIO.Write方法代码示例

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


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

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

示例2: xExtract

 internal bool xExtract(DJsIO xIOOut)
 {
     if (!Opened && !ReadBlocks())
         return false;
     try
     {
         // Gets data and writes it
         xIOOut.Position = 0;
         for (uint i = 0; i < xBlockCount; i++)
         {
             xPackage.xIO.Position = xPackage.GenerateDataOffset(xBlocks[i].ThisBlock);
             if (i < (xBlockCount - 1))
                 xIOOut.Write(xPackage.xIO.ReadBytes(0x1000));
             else xIOOut.Write(xPackage.xIO.ReadBytes((((Size - 1) % 0x1000) + 1)));
         }
         xIOOut.Flush();
         ClearBlocks();
         return true;
     }
     catch
     {
         ClearBlocks();
         return false;
     }
 }
开发者ID:DarrenRainey,项目名称:snes360savegameconverter,代码行数:25,代码来源:STFSPackage.cs

示例3: UserAccount

 /// <summary>
 /// Initializes an instance
 /// </summary>
 /// <param name="xAcc"></param>
 /// <param name="xType"></param>
 /// <param name="CreateBackup"></param>
 public UserAccount(DJsIO xAcc, AccountType xType, bool CreateBackup)
 {
     if (xAcc.Length != 404 || !Enum.IsDefined(typeof(AccountType), xType))
         return;
     IO = xAcc;
     xHS = new HMACSHA1();
     ThisType = xType;
     DJsIO xfill;
     if (xDecrypt(out xfill))
     {
         if (CreateBackup)
         {
             xBackup = new DJsIO(true);
             xBackup.Position = 0;
             xBackup.Write(IO.ReadStream());
         }
         xfill.Position = 0;
         if (((xfill.ReadByte() >> 5) & 1) == 1)
         {
             xIsLive = true;
             xfill.Position = 0x28;
             xXUID = xfill.ReadUInt64();
         }
         xSuccess = true;
     }
 }
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:32,代码来源:ProfileTools.cs

示例4: STFSPackage

 /// <summary>
 /// Create an STFS Package
 /// </summary>
 /// <param name="xSession"></param>
 /// <param name="xSigning"></param>
 /// <param name="xOutPath"></param>
 /// <param name="LogIn"></param>
 public STFSPackage(CreateSTFS xSession, RSAParams xSigning, string xOutPath, LogRecord LogIn)
 {
     xActive = true;
     if (!xSigning.Valid)
         throw CryptoExcepts.ParamError;
     if (xSession.xFileDirectory.Count == 0)
         throw new Exception();
     try
     {
         AddToLog("Setting Package variables");
         new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(System.DLLIdentify.PrivilegeCheck)).Start(System.Threading.Thread.CurrentThread);
         xroot = new FolderEntry("", 0, 0xFFFF, 0xFFFF, this);
         if (xSession.HeaderData.ThisType == PackageType.ThematicSkin)
         {
             DJsIO x1 = new DJsIO(true);
             DJsIO x2 = new DJsIO(true);
             x1.Write((int)xSession.ThemeSettings.StyleType);
             x1.Flush();
             x1.Close();
             if (!xSession.AddFile(x1.FileNameLong, "DashStyle"))
                 throw STFSExcepts.ThemeError;
             x2.Write("SphereColor=" + ((byte)xSession.ThemeSettings.Sphere).ToString().PadRight(2, '\0'));
             x2.Write(new byte[] { 0xD, 0xA });
             x2.Write("AvatarLightingDirectional=" +
                 xSession.ThemeSettings.AvatarLightingDirectional0.ToString("#0.0") + "," +
                 xSession.ThemeSettings.AvatarLightingDirectional1.ToString("#0.0000") + "," +
                 xSession.ThemeSettings.AvatarLightingDirectional2.ToString("#0.0") + ",0x" +
                 xSession.ThemeSettings.AvatarLightingDirectional3.ToString("X"));
             x2.Write(new byte[] { 0xD, 0xA });
             x2.Write("AvatarLightingAmbient=0x" + xSession.ThemeSettings.AvatarLightingAmbient.ToString("X"));
             x2.Write(new byte[] { 0xD, 0xA });
             x2.Flush();
             x2.Close();
             if (!xSession.AddFile(x2.FileNameLong, "parameters.ini"))
                 throw STFSExcepts.ThemeError;
         }
         else if (xSession.HeaderData.ThisType == PackageType.GamesOnDemand ||
             xSession.HeaderData.ThisType == PackageType.HDDInstalledGame ||
             xSession.HeaderData.ThisType == PackageType.OriginalXboxGame ||
             xSession.HeaderData.ThisType == PackageType.SocialTitle)
             throw STFSExcepts.Game;
         xLog = LogIn;
         xHeader = xSession.HeaderData;
         xSTFSStruct = new STFSDescriptor(xSession.STFSType, 0);
         xIO = new DJsIO(true);
         List<BlockRecord> DirectoryBlockz = new List<BlockRecord>();
         // switched2 = true;
         uint xcurblock = 0;
         for (ushort i = 0; i < xSession.GetDirectoryCount; i++)
         {
             DirectoryBlockz.Add(new BlockRecord());
             DirectoryBlockz[DirectoryBlockz.Count - 1].ThisBlock = xcurblock++;
             /*if (!switched0.Contains((int)(xcurblock / Constants.BlockLevel[0])))
                 switched0.Add((int)(xcurblock / Constants.BlockLevel[0]));
             if (!switched1.Contains((int)(xcurblock / Constants.BlockLevel[1])))
                 switched1.Add((int)(xcurblock / Constants.BlockLevel[1]));*/
         }
         xFileBlocks = DirectoryBlockz.ToArray();
         xWriteChain(xFileBlocks);
         xSTFSStruct.xDirectoryBlockCount = (ushort)xFileBlocks.Length;
         ushort xCurID = 0;
         xSession.xFolderDirectory.Sort(new Comparison<CFolderEntry>(sortpathct));
         foreach (CFolderEntry x in xSession.xFolderDirectory)
         {
             ushort pointer = 0xFFFF;
             if (x.xthispath.xPathCount() > 1)
                 pointer = xGetParentFolder(x.Path).EntryID;
             xFolderDirectory.Add(new FolderEntry(x.Name, 0, xCurID++, pointer, this));
             xFolderDirectory[xFolderDirectory.Count - 1].xFixOffset();
         }
         foreach (CFileEntry x in xSession.xFileDirectory)
         {
             ushort pointer = 0xFFFF;
             if (x.xthispath.xPathCount() > 1)
                 pointer = xGetParentFolder(x.Path).EntryID;
             xFileDirectory.Add(new FileEntry(x.Name, (int)x.GetLength(), false,xCurID++, pointer, this));
             List<BlockRecord> xAlloc = new List<BlockRecord>();
             for (uint i = 0; i < x.BlockCount(); i++)
             {
                 xAlloc.Add(new BlockRecord());
                 xAlloc[xAlloc.Count - 1].ThisBlock = xcurblock++;
                 /*if (!switched0.Contains((int)(xcurblock / Constants.BlockLevel[0])))
                     switched0.Add((int)(xcurblock / Constants.BlockLevel[0]));
                 if (!switched1.Contains((int)(xcurblock / Constants.BlockLevel[1])))
                     switched1.Add((int)(xcurblock / Constants.BlockLevel[1]));*/
             }
             xFileDirectory[xFileDirectory.Count - 1].xBlockCount = (uint)xAlloc.Count;
             xFileDirectory[xFileDirectory.Count - 1].xStartBlock = xAlloc[0].ThisBlock;
             xFileDirectory[xFileDirectory.Count - 1].xPackage = this;
             xFileDirectory[xFileDirectory.Count - 1].xFixOffset();
             xWriteChain(xAlloc.ToArray());
         }
         AddToLog("Writing Entry Table");
//.........这里部分代码省略.........
开发者ID:DarrenRainey,项目名称:snes360savegameconverter,代码行数:101,代码来源:STFSPackage.cs

示例5: xExtract

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

示例6: xExtract

 void xExtract(ref DJsIO xIOOut)
 {
     xIOOut.Position = 0;
     IO.Position = 0xD08;
     /* Self Note:
      * not in 0x1000 blocks, just decided to write them
      * in those size to avoid memory conflicts
      * */
     while (IO.Position < IO.Length)
         xIOOut.Write(IO.ReadBytes(0x1000));
     xIOOut.Flush();
 }
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:12,代码来源:Music.cs

示例7: xUpdate

 internal bool xUpdate()
 {
     try
     {
         int xsize = xpairs.Count * 0x10;
         if (Size > xsize)
         {
             new FreeSpaceEntry(xRef, xOffset + xsize, Size - xsize);
             xRef.PatchFree();
         }
         else if (Size < xsize)
         {
             int off = xRef.AllocateData(xsize);
             if (off == -1)
                 return false;
             new FreeSpaceEntry(xRef, xOffset, Size);
             xRef.PatchFree();
             xOffset = off;
         }
         DJsIO xbuff = new DJsIO(new byte[xsize], true);
         xbuff.Position = 0;
         foreach (SyncPair x in xpairs)
         {
             xbuff.Write(x.ID);
             xbuff.Write(x.Sync);
         }
         xbuff.Flush();
         xRef.xIO.Position = Offset;
         xRef.xIO.Write(xbuff.ReadStream());
         xRef.xIO.Flush();
         if (xsize > xSize)
             xRef.UpdateHeader();
         xSize = xsize;
         return true;
     }
     catch { return false; }
 }
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:37,代码来源:GPD.cs

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

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

示例10: xWriteDescriptor

        /// <summary>
        /// Writes the STFS Descriptor to make perm. changes
        /// </summary>
        /// <returns></returns>
        bool xWriteDescriptor(ref DJsIO io)
        {
            //AddToLog("Writing new Descriptor");
            io.Position = 0x379;
            xSTFSStruct.xDirectoryBlockCount = (ushort)xCurEntBlckCnt;
            io.Write(xSTFSStruct.GetData());
            io.Flush();

            return true;
        }
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:14,代码来源:STFSPackage.cs

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

示例12: ExtractData

 /// <summary>
 /// Extract the data of the package
 /// </summary>
 /// <param name="xIOOut"></param>
 /// <returns></returns>
 public bool ExtractData(DJsIO xIOOut)
 {
     if (!dataloaded || xIOOut == null || !xIOOut.Accessed || !ActiveCheck())
         return false;
     try
     {
         xIOOut.Position = 0;
         for (uint i = 0; i < xBlockCount; i++)
         {
             xDataFiles[(int)(i / Constants.SVODBL[1])].Position = GenerateDataOffset(i);
             xIOOut.Write(xDataFiles[(int)(i / Constants.SVODBL[1])].ReadBytes(0x1000));
         }
         xIOOut.Flush();
         return !(xActive = false);
     }
     catch { return (xActive = false); }
 }
开发者ID:VictorOverX,项目名称:X360,代码行数:22,代码来源:SVODPackage.cs

示例13: xEncrypt

 bool xEncrypt(ref DJsIO xNewPayload)
 {
     try
     {
         if (!xSuccess)
             return false;
         if (xIsLive)
         {
             byte[] xService = (ThisType == AccountType.Stock ?
                 new byte[] { 0x50, 0x52, 0x4F, 0x44 } : // PROD
                 new byte[] { 0x50, 0x41, 0x53, 0x54 }); // PART
             xNewPayload.Position = 0x34;
             xNewPayload.Write(xService);
             xNewPayload.Flush();
         }
         List<byte> xReturn = new List<byte>();
         byte[] xConfounder = xRC4.NewConfounder(8);
         byte[] NewPay = xNewPayload.ReadStream();
         xNewPayload.Dispose();
         byte[] xHeaderKey = xComputeHeaderKey(xConfounder, NewPay);
         xRC4.KeyBinary = xComputeRC4Key(xHeaderKey);
         xReturn.AddRange(xHeaderKey);
         xReturn.AddRange(xRC4.KerberosEncrypt(ref xConfounder, ref NewPay));
         IO.Position = 0;
         IO.Write(xReturn.ToArray());
         IO.Flush();
         return true;
     }
     catch { return false; }
 }
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:30,代码来源:ProfileTools.cs

示例14: xEntriesToFile

 /// <summary>
 /// Produces a file via entries
 /// </summary>
 /// <param name="xFile"></param>
 /// <returns></returns>
 bool xEntriesToFile(out DJsIO xFile)
 {
     xFile = null;
     try
     {
         // Not much explaination is needed, just writes entries into a file
         xFile = new DJsIO(true);
         ushort xCurEnt = 0;
         foreach (FolderEntry v in xFolderDirectory)
         {
             if (v.IsDeleted)
                 continue;
             xFile.Position = 0x40 * xCurEnt;
             // Reorders the folders to current entry
             // Note: Don't have to do this, but I think it's sexy to handle folders at top of directory
             foreach (FolderEntry y in xFolderDirectory)
             {
                 if (y.xFolderPointer == v.EntryID)
                     y.xFolderPointer = xCurEnt;
             }
             foreach (FileEntry y in xFileDirectory)
             {
                 if (y.xFolderPointer == v.EntryID)
                     y.xFolderPointer = xCurEnt;
             }
             // Sets current entry
             v.xEntryID = xCurEnt;
             // Writes
             xFile.Write(v.GetEntryData());
             xCurEnt++;
         }
         for (int i = 0; i < xFolderDirectory.Count; i++)
         {
             // Write new folder pointer
             xFile.Position = (0x40 * i) + 0x32;
             xFile.Write(xFolderDirectory[i].xFolderPointer);
         }
         foreach (FileEntry y in xFileDirectory)
         {
             if (y.IsDeleted)
                 continue;
             // Sets
             y.xEntryID = xCurEnt;
             xFile.Position = 0x40 * xCurEnt;
             // Writes
             xFile.Write(y.GetEntryData());
             xCurEnt++;
         }
         xFile.Flush();
         return true;
     }
     catch { return false; }
 }
开发者ID:DarrenRainey,项目名称:snes360savegameconverter,代码行数:58,代码来源:STFSPackage.cs

示例15: IncreaseXDBFCount

 internal bool IncreaseXDBFCount()
 {
     DJsIO xtemp = new DJsIO(true);
     try
     {
         xtemp.Position = (HeaderSize + (0xFF * 0x12));
         xIO.Position = HeaderSize;
         int len = (int)(xIO.Length - xIO.Position);
         for (int i = 0; i < len; i++)
             xtemp.Write(xIO.ReadByte());
         xtemp.Position = 0;
         xtemp.Write((uint)AllMagic.XDBF);
         xtemp.Write((int)0x10000);
         xEntryMax += 0xFF;
         xtemp.Write((int)xEntryMax);
         xtemp.Write((int)xEntryCurrent);
         xtemp.Write((int)xFreeCurrent);
         xtemp.Write((int)xFreeMax);
         List<XDBFEntry> xEntries = GetEntries();
         foreach (XDBFEntry x in xEntries)
         {
             xtemp.Write((ushort)x.NS);
             xtemp.Write(x.ID);
             xtemp.Write(x.xOffset);
             xtemp.Write(x.Size);
         }
         xtemp.Write(new byte[0x12 * (xEntryMax - xEntries.Count)]);
         foreach (FreeSpaceEntry x in xFreeEnts)
         {
             if (x.Size != 0)
             {
                 xtemp.Write(x.offset);
                 xtemp.Write(x.Size);
             }
         }
         int xdatasize = (int)(xtemp.Length - HeaderSize);
         xtemp.Write(xdatasize);
         xtemp.Write((int)(((-1) - xdatasize)));
         xtemp.Write(new byte[0x8 * (xFreeMax - (xFreeEnts.Count + 1))]);
         xtemp.Flush();
         xtemp.Close();
         xIO.Close();
         VariousFunctions.MoveFile(xtemp.FileNameLong, xIO.FileNameLong);
         xIO = new DJsIO(xIO.FileNameLong, DJFileMode.Open, true);
         return true;
     }
     catch { xtemp.Dispose(true); return false; }
 }
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:48,代码来源:GPD.cs


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