This software and its source code (if available) are licensed under the Apache-2.0 license (unless otherwise specified) which DOES NOT APPLY to any third-party code (such as zlib for example) and borrowed Assembler code (ripped code from other software executable files).
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#pragma pack(push, 1)
typedef struct {
uint32_t magic; /* "EPFS" */
uint32_t toffs; /* TOC offset */
uint8_t flags; /* unused/unknown */
uint16_t count; /* files count */
} epfshead;
typedef struct {
char flname[13]; /* ASCIIZ filename */
uint8_t flflag; /* non-zero if LZW packed */
uint32_t pksize; /* packed size */
uint32_t unsize; /* unpacked size if LZW packed */
} epfsitem;
#pragma pack(pop)
#include "epfunlzw.c"
static void dumpdata(char *name, void *data, uint32_t size) {
FILE *f;
if (name) {
f = fopen(name, "wb");
if (f) {
if (data && size) {
fwrite(data, size, 1, f);
}
fclose(f);
}
}
}
static void readdata(FILE *fl, void *data, uint32_t size) {
if (data && size) {
memset(data, 0, size);
if (fl) {
fread(data, size, 1, fl);
}
}
}
int main(int argc, char *argv[]) {
epfshead head;
epfsitem *list;
uint8_t *p, *u;
uint32_t i;
FILE *fl;
printf(
"East Point Software .EPF file unpacker v1.2\n"
"(c) Lumis 2026\n"
"(c) CTPAX-X Team 2010,2018\n"
"http://www.CTPAX-X.org/\n\n"
);
if (argc != 2) {
printf("Usage: unepfs <filename.epf>\n\n");
return(1);
}
fl = fopen(argv[1], "rb");
if (!fl) {
printf("Error: can't open input file.\n\n");
return(2);
}
/* read head */
readdata(fl, &head, sizeof(head));
if ((head.magic != 0x53465045) || (!head.count) || (head.toffs < sizeof(head))) {
fclose(fl);
printf("Error: invalid input file format.\n\n");
return(3);
}
/* allocate memory */
i = head.count * sizeof(list[0]);
list = (epfsitem *) malloc(i);
if (!list) {
fclose(fl);
printf("Error: not enough memory for contents table.\n\n");
return(4);
}
fseek(fl, head.toffs, SEEK_SET);
readdata(fl, list, i);
fseek(fl, sizeof(head), SEEK_SET);
for (i = 0; i < head.count; i++) {
printf("%s", list[i].flname);
p = (uint8_t *) malloc(list[i].pksize);
if (p) {
readdata(fl, p, list[i].pksize);
/* packed */
if (list[i].flflag) {
u = (uint8_t *) malloc(list[i].unsize);
if (u) {
/* this for files like "4X44.MAP" from "Overdrive"
which corrupted and stops unpack earlier than it should
so we fill output buffer with zeros */
memset(u, 0, list[i].unsize);
/* and this for files like "4X43.MAP" from "Overdrive"
which corrupted and failed to unpack at all
we must warn about it, but write what we can unpack anyway */
if (epfs_unlzw(p, list[i].pksize, u, list[i].unsize)) {
printf(" - fatal error, code depth too great.");
}
list[i].pksize = list[i].unsize;
free(p);
p = u;
}
}
/* dump file to disk */
dumpdata(list[i].flname, p, list[i].pksize);
free(p);
} else {
/* skip file */
printf(" - not enough memory, skipping file.");
fseek(fl, ftell(fl) + list[i].pksize, SEEK_SET);
}
printf("\n");
}
free(list);
fclose(fl);
printf("\ndone\n\n");
return(0);
}