some fixes.

This commit is contained in:
morkt
2015-05-01 23:32:04 +04:00
parent 888718e900
commit ca01b2c13b

View File

@@ -85,7 +85,7 @@ namespace GameRes.Formats.FVP
return new MemoryStream (decoder.Output, false); return new MemoryStream (decoder.Output, false);
} }
} }
return new ArcView.ArcStream (input); return new ArcView.ArcStream (input, entry_offset, entry.Size);
} }
catch catch
{ {
@@ -116,6 +116,7 @@ namespace GameRes.Formats.FVP
int dst = 0; int dst = 0;
int bits = 0; int bits = 0;
var buf = new int[0x8c00]; var buf = new int[0x8c00];
uint dst_left = m_dst_size;
uint L0 = 0x800000; uint L0 = 0x800000;
uint edx = 0x102; uint edx = 0x102;
for (;;) for (;;)
@@ -159,7 +160,7 @@ namespace GameRes.Formats.FVP
buf[edx] = dst; buf[edx] = dst;
if (0 == (eax & 0xff00)) if (0 == (eax & 0xff00))
{ {
if (0 == m_dst_size--) if (0 == dst_left--)
throw new EndOfStreamException ("Invalid compressed stream"); throw new EndOfStreamException ("Invalid compressed stream");
m_output[dst++] = (byte)(eax & 0xff); m_output[dst++] = (byte)(eax & 0xff);
} }
@@ -169,9 +170,9 @@ namespace GameRes.Formats.FVP
throw new EndOfStreamException ("Invalid compressed stream"); throw new EndOfStreamException ("Invalid compressed stream");
int src = buf[eax]; int src = buf[eax];
int count = buf[eax+1] - src + 1; int count = buf[eax+1] - src + 1;
if (m_dst_size < count) if (dst_left < count)
throw new EndOfStreamException ("Invalid compressed stream"); throw new EndOfStreamException ("Invalid compressed stream");
m_dst_size -= (uint)count; dst_left -= (uint)count;
Binary.CopyOverlapped (m_output, src, dst, count); Binary.CopyOverlapped (m_output, src, dst, count);
dst += count; dst += count;
} }