private void Parse() { _r.Seek(0); if (_r.PeekFor(() => _r.ReadWZStringBlock(true)) == "Property") { _encrypted = true; } else if (_r.PeekFor(() => _r.ReadWZStringBlock(false)) == "Property") { _encrypted = false; } else { WZUtil.Die("Failed to determine image encryption!"); } _r.SkipWZStringBlock(); if (_r.ReadUInt16() != 0) { WZUtil.Die("WZImage with invalid header (no zero UInt16!)"); } foreach (WZObject child in WZExtendedParser.ParsePropertyList(_r, this, this, _encrypted)) { Add(child); } _parsed = true; }
private void Parse(WZBinaryReader wzbr, long offset) { wzbr.Seek(offset); int entryCount = wzbr.ReadWZInt(); for (int i = 0; i < entryCount; ++i) { byte type = wzbr.ReadByte(); string name = null; switch (type) { case 2: int x = wzbr.ReadInt32(); wzbr.PeekFor(() => { wzbr.Seek(x + File._fstart); type = wzbr.ReadByte(); name = wzbr.ReadWZString(File._encrypted); }); break; case 3: case 4: name = wzbr.ReadWZString(File._encrypted); break; case 1: // wzbr.Skip(10); // continue; default: WZUtil.Die($"Unknown object type {type} in WzDirectory."); break; } if (name == null) { WZUtil.Die("Failed to read WZDirectory entry name."); } int size = wzbr.ReadWZInt(); wzbr.ReadWZInt(); uint woffset = wzbr.ReadWZOffset(File._fstart); switch (type) { case 3: Add(new WZDirectory(name, this, File, wzbr.Clone(), woffset)); break; case 4: Add(new WZImage(name, this, File, File.GetSubstream(woffset, size))); break; } } }
private void Parse(WZBinaryReader wzbr, long offset) { wzbr.Seek(offset); int entryCount = wzbr.ReadWZInt(); for (int i = 0; i < entryCount; ++i) { byte type = wzbr.ReadByte(); string name = null; switch (type) { case 2: int x = wzbr.ReadInt32(); wzbr.PeekFor(() => { wzbr.Seek(x + File._fstart); type = wzbr.ReadByte(); name = wzbr.ReadWZString(File._encrypted); }); break; case 3: case 4: name = wzbr.ReadWZString(File._encrypted); break; case 1: // wzbr.Skip(10); // continue; default: WZUtil.Die($"Unknown object type {type} in WzDirectory."); break; } if (name == null) { WZUtil.Die("Failed to read WZDirectory entry name."); } int size = wzbr.ReadWZInt(); wzbr.ReadWZInt(); uint woffset = wzbr.ReadWZOffset(File._fstart); switch (type) { case 3: Add(new WZDirectory(name, this, File, wzbr.Clone(), woffset)); break; case 4: Add(new WZImage(name, this, File, File.GetSubstream(woffset, size))); break; } } }