示例#1
0
 private void addFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog();
     ofd.Multiselect = true;
     ofd.Title = "Open Xbox Live Packages";
     ofd.Filter = "";
     if (ofd.ShowDialog() != DialogResult.OK)
         return;
     menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = false;
     progressBarX1.Value = 0;
     progressBarX1.Maximum = ofd.FileNames.Length;
     foreach (string x in ofd.FileNames)
     {
         DJsIO y = null;
         try { y = new DJsIO(x, DJFileMode.Open, true); }
         catch { progressBarX1.Value++; continue; }
         if (!y.Accessed)
         {
             progressBarX1.Value++;
             continue;
         }
         y.Position = 0;
         if (y.ReadUInt32() == (uint)AllMagic.CON)
             listBox1.Items.Add(x);
         y.Dispose();
         if (checkBoxX3.Checked)
             fix(listBox1.Items.Count - 1);
         progressBarX1.Value++;
     }
     menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = true;
 }
        /// <summary>
        /// Determins if a Drive is FATX format
        /// </summary>
        /// <param name="xIO">Stream to check</param>
        /// <param name="xType">Grabs the type of drive</param>
        /// <returns></returns>
        public static bool IsFATX(ref DJsIO xIO, out DriveTypes xType)
        {
            // Tries to read the offsets of Xbox 360 drives to see if the magic's match
            xType = DriveTypes.Unknown;

            try
            {
                if (xIO.IOType != DataType.Drive || ((DriveIO)xIO).xDrive.Type != DeviceType.LogicalDrive)
                    throw new Exception();
                string dat0 = ((DriveIO)xIO).xDrive.DeviceName + @"\Xbox360\Data0000";
                if (!File.Exists(dat0))
                    throw new Exception();

                var fa = File.GetAttributes(dat0);
                if ((fa & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                {
                    return false;
                }
                DJsIO xio = new DJsIO(dat0, DJFileMode.Open, true);
                if (!xio.Accessed)
                    throw new Exception();
                xio.Position = (long)USB.Partition1;
                try
                {
                    if (xio.ReadUInt32() == (uint)AllMagic.FATX)
                    {
                        xType = DriveTypes.USBFlashDrive;
                        xio.Dispose();
                        return true;
                    }
                }
                catch { }
                xio.Dispose();
            }
            catch { }

            try
            {
                xIO.Position = (long)MU.Partition2;
                if (xIO.ReadUInt32() == (uint)AllMagic.FATX)
                {
                    xType = DriveTypes.MemoryUnit;
                    return true;
                }
            }
            catch { }
            try
            {
                xIO.Position = (long)HDD.Partition5;
                if (xIO.ReadUInt32() == (uint)AllMagic.FATX)
                {
                    xType = DriveTypes.HardDrive;
                    return true;
                }
            }
            catch { }
            try
            {
                xIO.Position = 8;
                xIO.Position = (xIO.ReadUInt32() * 0x200);
                if (xIO.ReadUInt32() == (uint)AllMagic.FATX)
                {
                    xType = DriveTypes.DevHardDrive;
                    return true;
                }
            }
            catch { }
            return false;
        }
 /// <summary>
 /// Initializes this object
 /// </summary>
 /// <param name="FileLocale"></param>
 public MusicFile(string FileLocale)
 {
     xActive = true;
     DJsIO xIO = new DJsIO(FileLocale, DJFileMode.Open, true);
     if (!xIO.Accessed)
         throw STFSExcepts.ParseError;
     try
     {
         xIO.Position = 0;
         xIO.IsBigEndian = true;
         if (xIO.ReadUInt32() != 0x464D494D)
             throw MusicExcepts.NotMusic;
         xIO.Position = 0xC;
         so = xIO.ReadString(StringForm.Unicode, 0x100);
         al = xIO.ReadString(StringForm.Unicode, 0x100);
         ar = xIO.ReadString(StringForm.Unicode, 0x100);
         xIO.Position += 0x200;
         ge = xIO.ReadString(StringForm.Unicode, 0x100);
         IO = xIO;
         xActive = false;
     }
     catch { xIO.Dispose(); throw STFSExcepts.ParseError; }
 }
示例#4
0
 private void listBox1_DragDrop(object sender, DragEventArgs e)
 {
     menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = false;
     string[] xfiles = (string[])e.Data.GetData(DataFormats.FileDrop);
     foreach (string x in xfiles)
     {
         DJsIO y = null;
         try { y = new DJsIO(x, DJFileMode.Open, true); }
         catch { continue; }
         if (!y.Accessed)
             continue;
         y.Position = 0;
         if (y.ReadUInt32() == (uint)AllMagic.CON)
             listBox1.Items.Add(x);
         y.Dispose();
         listBox1.SelectedIndex = listBox1.Items.Count - 1;
         Application.DoEvents();
         if (checkBoxX3.Checked)
             fix(listBox1.Items.Count - 1);
     }
     menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = true;
 }
 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; }
 }
示例#6
0
 /// <summary>
 /// Overwrite the file
 /// </summary>
 /// <param name="FileLocale"></param>
 /// <returns></returns>
 public bool Inject(string FileLocale)
 {
     if (!xref.ActiveCheck())
         return false;
     DJsIO xIO = null;
     bool success = false;
     try
     {
         xIO = new DJsIO(FileLocale, DJFileMode.Open, true);
         if (!xIO.Accessed)
             throw new Exception();
         success = xInject(xIO);
     }
     catch { success = false; }
     if (xIO != null)
         xIO.Dispose();
     return (success & !(xref.xActive = false));
 }
 /// <summary>
 /// Replace the file via File Location
 /// </summary>
 /// <param name="FileIn"></param>
 /// <returns></returns>
 public bool Replace(string FileIn)
 {
     DJsIO xIO = null;
     try
     {
         xIO = new DJsIO(FileIn, DJFileMode.Open, true);
         bool Success = Replace(xIO);
         xIO.Dispose();
         return Success;
     }
     catch
     {
         if (xIO != null)
             xIO.Dispose();
         return xPackage.xActive = false;
     }
 }
示例#8
0
 /// <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;
 }
 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; }
 }
 /// <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");
         DJsIO xent;
         if (!xEntriesToFile(out xent))
             throw new Exception();
         xWriteTo(ref xent, xFileBlocks);
         xent.Close();
         VariousFunctions.DeleteFile(xent.FileNameLong);
         AddToLog("Writing Files");
         uint curblck = xSession.GetDirectoryCount;
         foreach (CFileEntry z in xSession.xFileDirectory)
         {
             List<BlockRecord> w = new List<BlockRecord>();
             uint ct = z.BlockCount();
             for (uint y = 0; y < ct; y++)
             {
                 w.Add(new BlockRecord());
                 w[w.Count - 1].ThisBlock = curblck++;
             }
             DJsIO x = null;
             try
             {
                 x = new DJsIO(z.FileLocale, DJFileMode.Open, true);
                 xWriteTo(ref x, w.ToArray());
             }
             catch { }
             if (x != null)
                 x.Dispose();
         }
         xWriteTables();
         xWriteHeader(xSigning);
         xIO.Close();
         VariousFunctions.MoveFile(xIO.FileNameLong, xOutPath);
         xIO = new DJsIO(xOutPath, DJFileMode.Open, true);
         xActive = false;
     }
     catch (Exception x) { xFileDirectory = null; xFolderDirectory = null; xIO.Dispose(); throw x; }
 }
 /// <summary>
 /// Overwrites the data from a file location
 /// </summary>
 /// <param name="FileIn"></param>
 /// <returns></returns>
 public bool Inject(string FileIn)
 {
     DJsIO xIO = null;
     //try
     {
         xIO = new DJsIO(FileIn, DJFileMode.Open, true);
         bool Success = Inject(xIO);
         xIO.Dispose();
         return Success;
     }
     //catch
     //{
     //  if (xIO != null)
     //    xIO.Dispose();
     //return xPackage.xActive = false;
     //}
 }
        /// <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, out byte[] ret, LogRecord LogIn)
        {
            ret = null;
            xActive = true;
            if (!xSigning.Valid)
                throw CryptoExcepts.ParamError;
            if (xSession.xFileDirectory.Count == 0)
                throw new Exception();
            ////try
            {
                //AddToLog("Setting Package variables");

                xroot = new FolderEntry("", 0, 0xFFFF, 0xFFFF, this);
                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();
                var 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++;

                }
                xFileBlocks = DirectoryBlockz.ToArray();
                xWriteChain(xFileBlocks);
                xSTFSStruct.xDirectoryBlockCount = (ushort)xFileBlocks.Length;
                ushort xCurID = 0;
                xSession.xFolderDirectory.Sort(new Comparison<CFolderEntry>(sortpathct));
                foreach (var 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));

                    var xAlloc = new List<BlockRecord>();
                    for (uint i = 0; i < x.BlockCount(); i++)
                    {
                        xAlloc.Add(new BlockRecord());
                        xAlloc[xAlloc.Count - 1].ThisBlock = xcurblock++;

                    }
                    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");
                DJsIO xent;
                if (!xEntriesToFile(out xent))
                    throw new Exception();
                xWriteTo(ref xent, xFileBlocks);
                xent.Close();
                //VariousFunctions.DeleteFile(xent.FileNameLong);
                //AddToLog("Writing Files");
                uint curblck = xSession.GetDirectoryCount;
                foreach (var z in xSession.xFileDirectory)
                {
                    var w = new List<BlockRecord>();
                    uint ct = z.BlockCount();
                    for (uint y = 0; y < ct; y++)
                    {
                        w.Add(new BlockRecord());
                        w[w.Count - 1].ThisBlock = curblck++;
                    }
                    DJsIO x = null;
                    //try
                    {
                        x = new DJsIO(z.FileData, true);
                        xWriteTo(ref x, w.ToArray());
                    }
                    //catch { }
                    if (x != null)
                        x.Dispose();
                }
                xWriteTables();
                xWriteHeader(xSigning);
                ret = xIO.GetBytes();
                xIO.Close();
                //VariousFunctions.MoveFile(xIO.FileNameLong, xOutPath);

                xActive = false;
            }
            ////catch (Exception x) { xFileDirectory = null; xFolderDirectory = null; xIO.Dispose(); throw x; }
        }
示例#13
0
 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; }
 }
 /// <summary>
 /// Extracts the image via a file location
 /// </summary>
 /// <param name="fileOut"></param>
 /// <returns></returns>
 public bool ExtractImage(string fileOut)
 {
     if (ActiveCheck())
         return false;
     DJsIO xIOOut = null;
     try { xIOOut = new DJsIO(fileOut, DJFileMode.Create, true); }
     catch { return xactive = false; }
     if (!xIOOut.Accessed)
         return xactive = false;
     bool result = extractimg(xIOOut);
     xIOOut.Dispose();
     return result;
 }
 /// <summary>
 /// Extracts via out locale
 /// </summary>
 /// <param name="xOutLocale"></param>
 /// <param name="xIncludeSubItems"></param>
 /// <param name="xIncludeHeader"></param>
 /// <returns></returns>
 bool xExtractPayload(string xOutLocale, bool xIncludeSubItems, bool xIncludeHeader)
 {
     try
     {
         AddToLog("Checking Directory");
         xOutLocale.Replace("\\", "/");
         if (xOutLocale[xOutLocale.Length - 1] == '/')
             xOutLocale = xOutLocale.Substring(0, xOutLocale.Length - 1);
         if (!VariousFunctions.xCheckDirectory(xOutLocale))
         {
             AddToLog("Directory error");
             return false;
         }
         if (xIncludeHeader)
         {
             // Records the meta data
             AddToLog("Noting Header Information");
             DJsIO xhead = new DJsIO(VariousFunctions.xGetUnusedFile(xOutLocale + "/" + dlcname() + ".txt")
                 , DJFileMode.Create, true);
             xHeader.WriteText(ref xhead);
             xhead.Dispose();
             xhead = new DJsIO(VariousFunctions.xGetUnusedFile(xOutLocale + "/Content Image.png")
                 , DJFileMode.Create, true);
             xhead.Position = 0;
             xhead.Write(xHeader.ContentImageBinary);
             xhead.Dispose();
             xhead = new DJsIO(VariousFunctions.xGetUnusedFile(xOutLocale + "/Package Image.png")
                 , DJFileMode.Create, true);
             xhead.Position = 0;
             xhead.Write(xHeader.PackageImageBinary);
             xhead.Dispose();
         }
         xOutLocale += "/Root";
         if (!VariousFunctions.xCheckDirectory(xOutLocale))
             return (xActive = false);
         // Runs a regular folder extract
         AddToLog("Extracting payload");
         RootDirectory.folderextract(xIncludeSubItems, xOutLocale);
         AddToLog("Package Extracted");
         return !(xActive = false);
     }
     catch { return (xActive = false); }
 }
示例#16
0
 bool xExtract(string xOut, bool Sub)
 {
     if (!VariousFunctions.xCheckDirectory(xOut))
         return false;
     FATXReadContents xread = xRead();
     if (xread == null)
         return false;
     foreach (FATXFileEntry x in xread.Files)
     {
         DJsIO xIOOut = new DJsIO(xOut + "/" + x.Name, DJFileMode.Create, true);
         if (!xIOOut.Accessed)
             continue;
         x.xExtract(ref xIOOut);
         xIOOut.Dispose();
     }
     if (!Sub)
         return true;
     foreach (FATXFolderEntry x in xread.Folders)
         x.xExtract(xOut + "/" + x.Name, Sub);
     return true;
 }
 internal bool folderextract(bool xInclude, string xOut)
 {
     try
     {
         if (!VariousFunctions.xCheckDirectory(xOut))
             return false;
         foreach (FileEntry x in xPackage.xFileDirectory)
         {
             if (x.FolderPointer != xEntryID)
                 continue;
             DJsIO xIO = new DJsIO(VariousFunctions.xGetUnusedFile(xOut + "/" + x.Name), DJFileMode.Create, true);
             if (xIO.Accessed)
             {
                 x.xExtract(xIO);
                 xIO.Dispose();
             }
         }
         foreach (FolderEntry z in xPackage.xFolderDirectory)
         {
             if (z.FolderPointer == EntryID)
                 z.folderextract(xInclude, xOut + "/" + z.Name);
         }
         xPackage.AddToLog(Name + " Extracted");
         return true;
     }
     catch { return false; }
 }
示例#18
0
文件: Other.cs 项目: VictorOverX/X360
        /// <summary>
        /// Attempts to find the type of the file
        /// </summary>
        /// <param name="FileLocale"></param>
        /// <returns></returns>
        public static XboxFileType ReadFileType(string FileLocale)
        {
            /* ADD FATX SUPPORT */
            DJsIO xIO = new DJsIO(FileLocale, DJFileMode.Open, true);
            try
            {
                XboxFileType xReturn = XboxFileType.None;
                xIO.Position = 0;
                uint sig = xIO.ReadUInt32();
                switch (sig)
                {
                    case (uint)AllMagic.CON:
                    case (uint)AllMagic.LIVE:
                    case (uint)AllMagic.PIRS:
                        {
                            if (xIO.Length < 0x37C)
                                break;
                            xIO.Position = 0x379;
                            byte[] desc = xIO.ReadBytes(3);
                            if (desc[0] == 0x24 && desc[1] == 0 &&
                                (desc[2] == 0 || desc[2] == 1 || desc[2] == 2))
                                xReturn = XboxFileType.STFS;
                            else if (desc[0] == 0x24 && desc[1] == 5 &&
                                desc[2] == 5)
                                xReturn = XboxFileType.SVOD;
                        }
                        break;

                    case (uint)AllMagic.Music: { xReturn = XboxFileType.Music; } break;

                    case (uint)AllMagic.XDBF: { xReturn = XboxFileType.GPD; } break;

                    case 0:
                        {
                            if (xIO.Length < 0x130EB0004)
                                break;
                            xIO.Position = 0x130EB0000;
                            if (xIO.ReadUInt32() != (uint)AllMagic.FATX)
                                break;
                            xReturn = XboxFileType.FATX;
                        }
                        break;

                    case (uint)AllMagic.XSF: { xReturn = XboxFileType.GDF; } break;

                    default: break;
                }
                if (xReturn == XboxFileType.None)
                {
                    try
                    {
                        xIO.Position = 0;
                        if (xIO.ReadBytes(20).HexString() != GDFX.GDFMagic.XMedia.HexString())
                        {
                            xIO.Position = 0x1FB20;
                            if (xIO.ReadBytes(20).HexString() != GDFX.GDFMagic.XMedia.HexString())
                            {
                                xIO.Position = 0x30600;
                                if (xIO.ReadBytes(20).HexString() != GDFX.GDFMagic.XMedia.HexString())
                                {
                                    xIO.Position = 0x7FF000;
                                    if (xIO.ReadUInt32() != (uint)AllMagic.FATX)
                                    {
                                        xIO.Position = 0xFDA0000;
                                        if (xIO.ReadBytes(20).HexString() != GDFX.GDFMagic.XMedia.HexString())
                                        {
                                            xIO.Position = 0x130EB0000;
                                            if (xIO.ReadUInt32() == (uint)AllMagic.FATX)
                                                xReturn = XboxFileType.FATX;
                                        }
                                        else xReturn = XboxFileType.GDF;
                                    }
                                    else xReturn = XboxFileType.FATX;
                                }
                                else xReturn = XboxFileType.GDF;
                            }
                            else xReturn = XboxFileType.GDF;
                        }
                        else xReturn = XboxFileType.GDF;
                    }
                    catch { }
                }
                xIO.Dispose();
                return xReturn;
            }
            catch (Exception x) { xIO.Close(); throw x; }
        }
示例#19
0
文件: About.cs 项目: VictorOverX/X360
 /// <summary>
 /// Writes the legal documentation to a local location
 /// </summary>
 public static void WriteLegalLocally()
 {
     DJsIO xIO = new DJsIO(Application.StartupPath + "/" + "X360 READ ME.txt", DJFileMode.Create, true);
     if (!xIO.Accessed)
         return;
     xIO.Position = 0;
     xIO.Write("------------ Legal Info ------------" + Environment.NewLine);
     xIO.Write(Legal + Environment.NewLine);
     xIO.Write("------------------------------------" + Environment.NewLine);
     xIO.Write("------- Terms and Conditions -------" + Environment.NewLine);
     xIO.Write(GNUProtected + Environment.NewLine);
     xIO.Write("------------------------------------" + Environment.NewLine);
     xIO.Write("----------- GNU License ------------" + Environment.NewLine);
     xIO.Write(PublicResources.GPL + Environment.NewLine);
     xIO.Write("------------------------------------");
     xIO.Flush();
     xIO.Dispose();
 }