Example #1
0
        protected DependencyList ReadDependencyBlock(byte[] data, uint offset, out uint size, uint skipOffset = 0x10, uint dataSize = 0x0)
        {
            DependencyList outList         = new DependencyList();
            uint           dependencyCount = ReadUint32(data, offset);
            uint           startOffset     = offset;

            offset += skipOffset;
            for (int j = 0; j < dependencyCount; j++)
            {
                string fileName = ReadString(data, offset, false);
                if (fileName.Length > 0)
                {
                    outList.Add(fileName);
                }

                offset += (uint)fileName.Length + 0x4 + dataSize;
            }

            size = offset - startOffset;

            return(outList);
        }
Example #2
0
        private void ReadDependencies(DependencyList list)
        {
            if (data.Length < 0x14)
            {
                return;
            }

            uint localOffset = (uint)data.Length;

            // Make sure to align the data
            localOffset -= 0xC;
            while (ReadUint32(data, localOffset + 0x8) != 0x7ADB4E5A && localOffset > 0)
            {
                localOffset--;
            }

            if (localOffset > 0x8)
            {
                uint size;
                foreach (string entry in ReadDependencyBlock(data, localOffset, out size, 0x10, 0xC).Objects)
                {
                    list.Add(entry);
                }
            }
            else
            {
                localOffset = (uint)data.Length;
                uint u3 = ReadUint32(data, localOffset - 4);

                if (u3 >= 0x1 && u3 <= 0x7)
                {
                    while (u3 >= 0x1 && u3 <= 0x7)
                    {
                        localOffset -= 0x10;
                        u3           = ReadUint32(data, localOffset - 4);
                    }
                }

                // check if there is a string to read
                uint textOffset = 0;
                while (ReadUint32(data, localOffset - textOffset - 4) != textOffset && localOffset - textOffset > 4)
                {
                    textOffset++;
                }

                bool hasText = localOffset - textOffset > 4;

                if (hasText)
                {
                    int stringCount = 0;
                    while (ReadUint32(data, localOffset - 0x4) != stringCount)
                    {
                        uint stringLength = 0;

                        while (ReadUint32(data, localOffset - stringLength - 0x4) != stringLength)
                        {
                            stringLength++;
                            uint character = ReadByte(data, localOffset - stringLength);
                            if (localOffset - stringLength <= 0x4)
                            {
                                return;
                            }
                        }

                        string dependencyName = ReadString(data, localOffset - stringLength - 0x4, false);

                        list.Add(dependencyName);
                        localOffset -= stringLength + 4;

                        uint prefix = ReadUint32(data, localOffset - 0x4);
                        if (prefix == 0)
                        {
                            localOffset -= 0xC;
                        }
                        else if (prefix == 1 || stringLength == prefix - 8)
                        {
                            break;
                        }

                        stringCount++;
                    }
                }
            }
        }