コード例 #1
0
ファイル: EntryTypes.cs プロジェクト: XboxChaos/Liberty
 public string GetPackageName()
 {
     // If the STFS info was already loaded...
     if (IsSTFSPackage && STFSInformation.Magic != null)
     {
         // Return it.
         return(STFSInformation.ContentName);
     }
     // If the file appears to match the requirements for an STFS package...
     else if (Size >= 0xB000 && !Name.ToLower().Contains(".xex") && !Name.ToLower().Contains(".xbe"))
     {
         byte[] Magic = new STFS.STFSInfo(this).Magic();
         byte[] CON   = Encoding.ASCII.GetBytes("CON ");
         byte[] LIVE  = Encoding.ASCII.GetBytes("LIVE");
         byte[] PIRS  = Encoding.ASCII.GetBytes("PIRS");
         if (ArrayComparer(Magic, CON) | ArrayComparer(Magic, LIVE) | ArrayComparer(Magic, PIRS))
         {
             // Get the IO
             IOReader io = new IOReader(GetStream());
             io.BaseStream.Position = (long)STFS.STFSInfo.Offsets.DisplayName;
             string ss = "";
             for (int i = 0; i < 0x80; i += 2)
             {
                 char c = (char)io.ReadUInt16(true);
                 if (c != '\0')
                 {
                     ss += c;
                 }
             }
             io.Close();
             return(ss);
         }
     }
     return("");
 }
コード例 #2
0
ファイル: Misc.cs プロジェクト: NicmeisteR/Liberty
        public string GetFATXPath(string PackagePath)
        {
            // Check the header...
            IOReader io = new IOReader(new System.IO.FileStream(PackagePath, System.IO.FileMode.Open));

            if (io.BaseStream.Length > 4)
            {
                uint header = io.ReadUInt32(true);
                if (header == 0x434F4E20 || header == 0x4C495645 || header == 0x50495253)
                {
                    // Get the type
                    io.BaseStream.Position = 0x344;
                    byte[] Type = io.ReadBytes(0x4);

                    // Get the profile ID
                    io.BaseStream.Position = 0x371;
                    byte[] ID = io.ReadBytes(0x8);

                    // Get the title ID
                    io.BaseStream.Position = 0x360;
                    byte[] TitleID = io.ReadBytes(0x4);

                    // NOW LET'S DO THIS SHIT
                    return(string.Format("Content\\{0}\\{1}\\{2}", ID.ToHexString(), TitleID.ToHexString(), Type.ToHexString()));
                }
            }

            throw new Exception("Not a valid package!");
        }
コード例 #3
0
ファイル: Misc.cs プロジェクト: NicmeisteR/Liberty
        /// <summary>
        /// Used for quickly reading bytes for a length that is not a multiple of 0x200
        /// </summary>
        internal byte[] ReadBytes(ref FATX.IOReader br, long length)
        {
            Misc m = new Misc();

            byte[]      buffer = br.ReadBytes((int)m.UpToNearest200(length));
            List <byte> b      = buffer.ToList <byte>();

            b.RemoveRange((int)length, buffer.Length - (int)length);
            buffer = b.ToArray();
            return(buffer);
        }
コード例 #4
0
        public bool ExtractSS(string outFile)
        {
            if (DriveType != Info.DriveType.HDD)
            {
                throw new Exception("Drive is not a hard drive");
            }
            //Create our io for the drive
            IOReader io = GetIO();

            //Go to the location of the security sector
            io.BaseStream.Position = 0x2000;
            //Create our ref io for the file
            IOWriter bw = new IOWriter(new System.IO.FileStream(outFile, System.IO.FileMode.Create));

            //Read the sector.  The size is an estimation, since I have no idea how big it really is
            bw.Write(io.ReadBytes(0xE00));
            //Close our io's
            io.Close();
            bw.Close();
            return(true);
        }
コード例 #5
0
ファイル: Misc.cs プロジェクト: NicmeisteR/Liberty
 /// <summary>
 /// ReadInt32 (big endian)
 /// </summary>
 public int ReadInt32(ref FATX.IOReader br)
 {
     byte[] bytes = br.ReadBytes(0x4);
     Array.Reverse(bytes);
     return(BitConverter.ToInt32(bytes, 0x0));
 }
コード例 #6
0
ファイル: Misc.cs プロジェクト: NicmeisteR/Liberty
 public ushort ReadUInt16(ref FATX.IOReader br)
 {
     byte[] bytes = br.ReadBytes(0x2);
     Array.Reverse(bytes);
     return(BitConverter.ToUInt16(bytes, 0x0));
 }