Esempio n. 1
0
        public void LoadRpkgFileStructure(RpkgBinaryReader reader)
        {
            var hashes     = new List <string>(); //File.ReadAllLines(@"Hitman_Hashes.txt");
            var dictionary = new Dictionary <UInt64, string>();

            foreach (var hash in hashes)
            {
                var parts      = hash.Split(' ');
                var hashedName = UInt64.Parse(parts[0]);
                var name       = parts[1];
                dictionary.Add(hashedName, name);
            }

            Archive = reader.ReadHeader();

            for (int i = 0; i < Archive.NumberOfFiles; i++)
            {
                var entry = reader.ReadEntry();
                Archive.Entries.Add(entry);

                if (dictionary.ContainsKey(entry.Hash))
                {
                    entry.Name = dictionary[entry.Hash];
                }
            }

            for (int i = 0; i < Archive.NumberOfFiles; i++)
            {
                Archive.Entries[i].Info = reader.ReadEntryInfo();
            }
        }
Esempio n. 2
0
        public void Write(RpkgFileStructure header)
        {
            Write(header.Signature);
            Write(header.NumberOfFiles);
            Write(header.ResourceTableOffset);
            Write(header.ResourceTableSize);

            if (myVersion == 0)
            {
                if (header.BaseVersionZero)
                {
                    Write((UInt32)0);
                }
            }
            else if (myVersion == 1)
            {
                Write(header.PatchUnknownValues.Count);
                foreach (ulong patchUnknownValue in header.PatchUnknownValues)
                {
                    Write(patchUnknownValue);
                }
            }
        }
        public RpkgFileStructure ReadHeader()
        {
            var rpkgFile = new RpkgFileStructure();

            rpkgFile.Signature           = new string(ReadChars(4));
            rpkgFile.NumberOfFiles       = ReadUInt32();
            rpkgFile.ResourceTableOffset = ReadUInt32();
            rpkgFile.ResourceTableSize   = ReadUInt32();

            if (rpkgFile.NumberOfFiles == 0)
            {
                return(rpkgFile);
            }

            if (myVersion == 0)
            {
                UInt32 zero = ReadUInt32();
                if (zero == 0)
                {
                    rpkgFile.BaseVersionZero = true;
                }
                else
                {
                    BaseStream.Seek(-4, SeekOrigin.Current);
                }
            }
            else if (myVersion == 1)
            {
                uint numberOfLongs = ReadUInt32();
                for (int i = 0; i < numberOfLongs; i++)
                {
                    rpkgFile.PatchUnknownValues.Add(ReadUInt64());
                }
            }

            return(rpkgFile);
        }