Пример #1
0
        private static UnknownStruct1[] _ReadUnknownStruct1Array(byte[] fileBytes, ref int offset, int count) // because Marshal.PtrToStructure IS SO F*****G SLOW
        {
            UnknownStruct1[] arr = new UnknownStruct1[count];

            for (int i = 0; i < count; i++)
            {
                arr[i] = new UnknownStruct1
                {
                    UnknownFloat1 = StreamTools.ReadFloat(fileBytes, ref offset),
                    UnknownFloat2 = StreamTools.ReadFloat(fileBytes, ref offset),
                    UnknownFloat3 = StreamTools.ReadFloat(fileBytes, ref offset),
                    Index         = StreamTools.ReadInt32(fileBytes, ref offset)
                };
            }

            return(arr);
        }
Пример #2
0
        private void _ParsePatchType(byte[] buffer)
        {
            int offset = 0;

            /* This reading/parsing stores all date merely to make it clear of the file structure.
             * Given we're not going to be using this much at all, this will do for now until we know
             * what all the unknown fields are.
             */

            // header
            PatchFileHeader fileHeader = FileTools.ByteArrayToStructure <PatchFileHeader>(buffer, ref offset);

            if (fileHeader.EndToken != Token.PatchSect)
            {
                throw new Exceptions.UnexpectedTokenException("Expected PatchSect token but got 0x" + fileHeader.EndToken.ToString("X8"));
            }

            // file searches?
            List <PatchSearch> searchSegments = new List <PatchSearch>();

            while (true)
            {
                bool isPresent = (StreamTools.ReadInt32(buffer, ref offset) != 0);
                if (!isPresent)
                {
                    break;
                }

                int characterCount = StreamTools.ReadInt32(buffer, ref offset);

                PatchSearch searchSegment = new PatchSearch
                {
                    IsPresent      = true,
                    CharacterCount = characterCount,
                    FileSearch     = StreamTools.ReadStringUnicode(buffer, ref offset, characterCount, false)
                };

                searchSegments.Add(searchSegment);
            }

            // files
            List <PatchEntryStruct> entries = new List <PatchEntryStruct>();

            while (true)
            {
                int characterCount = StreamTools.ReadInt32(buffer, ref offset);

                PatchEntryStruct entrySegment = new PatchEntryStruct
                {
                    CharacterCount = characterCount,
                    FileName       = StreamTools.ReadStringUnicode(buffer, ref offset, characterCount, false),
                    UsedInX86      = (StreamTools.ReadInt32(buffer, ref offset) != 0),
                    UsedInX64      = (StreamTools.ReadInt32(buffer, ref offset) != 0),
                    Localization   = StreamTools.ReadInt16(buffer, ref offset),
                    FileSize       = StreamTools.ReadInt64(buffer, ref offset),
                    DatOffset      = StreamTools.ReadInt64(buffer, ref offset),
                    Hash           = StreamTools.ReadInt32(buffer, ref offset),
                    HasMoreEntries = StreamTools.ReadInt32(buffer, ref offset),
                };

                entries.Add(entrySegment);

                if (entrySegment.HasMoreEntries == -1)
                {
                    break;
                }
            }

            // add files to file list (could be done in above loop, but as mentioned earlier, this parsing method is almost enitrely out of random interest
            foreach (PatchEntryStruct entry in entries)
            {
                PackFileEntry fileEntry = new PatchFileEntry(entry)
                {
                    Pack = this
                };

                Files.Add(fileEntry);
            }

            HasIntegrity = (offset == buffer.Length);
        }