File tree 1 file changed +26
-6
lines changed
1 file changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -319,18 +319,33 @@ void ExtractGobStk::extractChunks(Common::Filename &outpath, Common::File &stk)
319
319
byte *ExtractGobStk::unpackData (byte *src, uint32 &size) {
320
320
uint32 counter;
321
321
uint16 cmd;
322
- byte tmpBuf[4114 ];
322
+ byte tmpBuf[4370 ]; // 4096 + (256 + 18) = 4096 + (max string length)
323
323
int16 off;
324
- byte len;
324
+ int16 len;
325
325
uint16 tmpIndex;
326
326
327
327
counter = size = READ_LE_UINT32 (src);
328
+ src += 4 ;
329
+ uint16 magic1 = READ_LE_UINT16 (src);
330
+ src += 2 ;
331
+ uint16 magic2 = READ_LE_UINT16 (src);
332
+ src += 2 ;
328
333
329
- for (int i = 0 ; i < 4078 ; i++)
330
- tmpBuf[i] = 0x20 ;
331
- tmpIndex = 4078 ;
334
+ int16 extendedLenCmd;
335
+ if ((magic1 == 0x1234 ) && (magic2 == 0x5678 )) {
336
+ // Extended format allowing to copy larger strings
337
+ // from the window (up to 256 + 18 = 274 bytes).
338
+ extendedLenCmd = 18 ;
339
+ tmpIndex = 273 ;
340
+ } else {
341
+ // Standard format allowing to copy short strings
342
+ // (up to 18 bytes) from the window.
343
+ extendedLenCmd = 100 ; // Cannot be matched
344
+ tmpIndex = 4078 ;
345
+ src -= 4 ;
346
+ }
332
347
333
- src += 4 ;
348
+ memset (tmpBuf, 0x20 , tmpIndex); // Fill initial window with spaces
334
349
335
350
byte *unpacked = new byte[size];
336
351
byte *dest = unpacked;
@@ -358,6 +373,11 @@ byte *ExtractGobStk::unpackData(byte *src, uint32 &size) {
358
373
len = (*src & 0x0F ) + 3 ;
359
374
src++;
360
375
376
+ if (len == extendedLenCmd) {
377
+ len = *src + 18 ;
378
+ src++;
379
+ }
380
+
361
381
for (int i = 0 ; i < len; i++) {
362
382
*dest++ = tmpBuf[(off + i) % 4096 ];
363
383
if (--counter == 0 )
You can’t perform that action at this time.
0 commit comments