Exemple #1
0
 internal FATXEntry(long Pos, byte[] xData, ref FATXDrive xdrive)
 {
     xDrive = xdrive;
     xOffset = Pos;
     try
     {
         DJsIO xIO = new DJsIO(xData, true);
         xNLen = xIO.ReadByte();
         if (xNLen == 0xE5 || xNLen == 0xFF || xNLen == 0 || xNLen > 0x2A)
             return;
         byte xatt = (byte)((xIO.ReadByte() >> 4) & 1);
         byte xLen = (byte)(xNLen & 0x3F);
         xName = xIO.ReadString(StringForm.ASCII, xLen);
         xName.IsValidXboxName();
         xIO.Position = 0x2C;
         xStartBlock = xIO.ReadUInt32();
         if (xStartBlock == Constants.FATX32End)
             return;
         xSize = xIO.ReadInt32();
         xT1 = xIO.ReadInt32();
         xT2 = xIO.ReadInt32();
         xT3 = xIO.ReadInt32();
         if (xatt == 1)
             xIsFolder = true;
         else if (xSize == 0)
             return;
         xIsValid = true;
     }
     catch { xIsValid = false; }
 }
 /// <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; }
 }
 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;
 }
 internal ItemEntry(byte[] xDataIn, long DirectOffset, ushort xID, STFSPackage xPackageIn)
 {
     try
     {
         xPackage = xPackageIn;
         DJsIO xFileIO = new DJsIO(xDataIn, true);
         xFileIO.Position = 0;
         xEntryID = xID;
         xFileIO.Position = 0x28;
         xFlag = xFileIO.ReadByte();
         if (xNameLength > 0x28)
             xNameLength = 0x28;
         xFileIO.Position = 0;
         if (xNameLength == 0)
             return;
         xName = xFileIO.ReadString(StringForm.ASCII, xNameLength);
         xName.IsValidXboxName();
         xFileIO.Position = 0x2F;
         xStartBlock = xFileIO.ReadUInt24(false);
         xFolderPointer = xFileIO.ReadUInt16();
         xSize = xFileIO.ReadInt32();
         xBlockCount = (uint)(((xSize - 1) / 0x1000) + 1);
         xCreated = xFileIO.ReadInt32();
         xAccessed = xFileIO.ReadInt32();
         xDirectoryOffset = DirectOffset;
     }
     catch { xNameLength = 0; }
 }
Exemple #5
0
 /// <summary>Initialize the package via header info
 /// <param name="xHeaderIO">Stream to header information</param>
 /// <param name="xDataPath">Path of data files, null if you want to want to load header only</param>
 /// </summary>
 public SVODPackage(DJsIO xHeaderIO, string xDataPath)
 {
     xActive = true;
     if (xDataPath != null && xDataPath != "")
     {
         xDataPath = xDataPath.Replace('\\', '/');
         if (xDataPath[xDataPath.Length - 1] == '/')
             xDataPath = xDataPath.Substring(0, xDataPath.Length - 1);
     }
     new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(System.DLLIdentify.PrivilegeCheck)).Start(System.Threading.Thread.CurrentThread);
     IO = xHeaderIO;
     xHeaderIO.Position = 0;
     xHeaderIO.IsBigEndian = true;
     uint xBuff = xHeaderIO.ReadUInt32();
     if (!Enum.IsDefined(typeof(PackageMagic), xBuff) || (PackageMagic)xBuff == PackageMagic.Unknown)
         return;
     xHeaderIO.Position = 0x379;
     if (xHeaderIO.ReadByte() != 0x24 && xHeaderIO.ReadByte() != 5 &&
         xHeaderIO.ReadByte() != 5 && xHeaderIO.ReadByte() != 0x11)
         return;
     xHeaderData = new HeaderData(xHeaderIO, (PackageMagic)xBuff);
     xHeaderIO.Position = 0x391;
     xIsShifted = (((xHeaderIO.ReadByte() >> 6) & 1) == 1);
     xBlockCount = xHeaderIO.ReadUInt24();
     if (xIsShifted)
         xDeviation = xHeaderIO.ReadUInt32(false);
     if (xDataPath == null || xDataPath == "")
     {
         xActive = false;
         return;
     }
     try { xDataFiles = new DJsIO[(int)xHeaderData.DataFileCount]; }
     catch { throw SVODExcepts.Unknown; }
     if (xDataFiles.Length > 9999 || xDataFiles.Length == 0)
         throw SVODExcepts.Count;
     for (uint i = 0; i < xDataFiles.Length; i++)
     {
         xDataFiles[i] = new DJsIO(xDataPath + SVODFuncs.formatstring((uint)i), DJFileMode.Open, true);
         if (!xDataFiles[i].Accessed) { throw SVODExcepts.Access; }
     }
     xActive = false;
 }