samp-re/uncompress.c

70 lines
1.1 KiB
C
Raw Normal View History

/* vim: set filetype=c ts=8 noexpandtab: */
#define COMPRESS_PRINT
#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;
}