private static UnknownStruct7[] _ReadUnknownStruct7Array(byte[] fileBytes, ref int offset, int count) // because Marshal.PtrToStructure IS SO F*****G SLOW { UnknownStruct7[] arr = new UnknownStruct7[count]; for (int i = 0; i < count; i++) { arr[i] = new UnknownStruct7 { UnknownShort1 = StreamTools.ReadInt16(fileBytes, ref offset), UnknownShort2 = StreamTools.ReadInt16(fileBytes, ref offset), UnknownShort3 = StreamTools.ReadInt16(fileBytes, ref offset) }; } return(arr); }
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); }