Go Back   FileForums > Game Backup > PC Games > PC Games - CD/DVD Conversions > Conversion Tutorials

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 21-12-2018, 13:26
Golden-Mask
Guest
 
Posts: n/a
The decompression for the program is as follows:

int srcPos; /* start at the end of the packed exe, because the unpacker works downwards */
int dstPos;
int commandByte, lengthWord, fillByte;

/* skip all 0xff bytes (they're just padding to make the packed exe's size a multiple of 16 */
while (*srcPos == 0xff) {
srcPos--;
}

/* unpack */
do {
commandByte = *(srcPos--);

switch (commandByte & 0xFE) {
/* (byte)value (word)length (byte)0xb0 */
/* writes a run of <length> bytes with a value of <value> */
case 0xb0:
lengthWord = (*(srcPos--))*0x100;
lengthWord += *(srcPos--);
fillByte = *(srcPos--);
for (i = 0; i < lengthWord; i++) {
*(dstPos--) = fillByte;
}
break;
/* (word)length (byte)0xb2 */
/* copies the next <length> bytes */
case 0xb2:
lengthWord = (*(srcPos--))*0x100;
lengthWord += *(srcPos--);
for (i = 0; i < lengthWord; i++) {
*(dstPos--) = *(srcPos--);
}
break;
/* unknown command */
default:
printf("Unknown command %x at position %x\n", commandByte, srcPos);
exit(1);
break;
}
} while ((commandByte & 1) != 1); /* lowest bit set => last block */
Reply With Quote
The Following User Says Thank You to For This Useful Post:
Jiva newstone (22-12-2018)
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -7. The time now is 14:14.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com