2020-04-02 23:46:27 +02:00
|
|
|
|
|
|
|
/* vim: set filetype=c ts=8 noexpandtab: */
|
|
|
|
|
2020-04-05 21:10:03 +02:00
|
|
|
//#define COMPRESS_PRINT
|
2020-04-02 23:46:27 +02:00
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "uncompress.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
static unsigned char *currentPort = (unsigned char*) 0x4F4E78;
|
|
|
|
|
|
|
|
static
|
|
|
|
__declspec(naked) int sub_46A6F0(
|
|
|
|
int a, unsigned char portStuff, char *dest, int length)
|
|
|
|
{
|
|
|
|
_asm {
|
|
|
|
mov eax, 0x46A6F0
|
|
|
|
jmp eax
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
__declspec(naked) int sub_46A6C0(char *dest, int length)
|
|
|
|
{
|
|
|
|
_asm {
|
|
|
|
mov eax, 0x46A6C0
|
|
|
|
jmp eax
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int uncompress_main(char *dest, char *source, int *length)
|
|
|
|
{
|
|
|
|
unsigned char res;
|
|
|
|
|
|
|
|
#ifdef COMPRESS_PRINT
|
|
|
|
int i;
|
|
|
|
|
|
|
|
printf("IN ");
|
|
|
|
for (i = 0; i < *length; i++) {
|
|
|
|
printf("%02X ", (unsigned char) source[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
(*length)--;
|
|
|
|
memcpy(dest, source + 1, *length);
|
|
|
|
|
|
|
|
sub_46A6F0(0, *currentPort, dest, *length);
|
|
|
|
res = sub_46A6C0(dest, *length);
|
|
|
|
|
|
|
|
#ifdef COMPRESS_PRINT
|
|
|
|
printf("OUT ");
|
|
|
|
for (i = 0; i < *length; i++) {
|
|
|
|
printf("%02X ", (unsigned char) dest[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
res -= source[0];
|
|
|
|
res = -res;
|
|
|
|
// sbb eax, eax
|
|
|
|
// inc eax*/
|
|
|
|
/*always accept for now I suppose...*/
|
|
|
|
return 1;
|
|
|
|
}
|