Если нравится наш проект, пожалуйста, поддержите любой приемлимой суммой чтобы помочь оплачивать хостинг. Спасибо!
Навигация  🇷🇺RU | 🇬🇧EN

Новые комментарии

Последние файлы

Пожертвования
[ Через Yoo.Money ]
(бывшие Яндекс.Деньги) 410011494554572

Contact us if you wish
PayPal or BitCoin donation

Наши друзья

Файловый архив

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>

#ifdef __HAVE_BUILTIN_SETJMP__
#include <setjmp.h>
#undef setjmp
#define setjmp __builtin_setjmp
#undef longjmp
#define longjmp __builtin_longjmp
#endif

/*
To compile this source code you'll need "puff.c" and "puff.h" files from zlib package.
Get this package from official site: http://zlib.net/
Required files can be found in /contrib/puff/ folder inside archive.
*/

#include "puff.h"
#include "puff.c"

#pragma pack(push, 1)
typedef struct {
  uint32_t magic; /* "ezd\xFF" */
  uint32_t count; /* files count */
  uint32_t lsize; /* TOC list size */
  uint32_t fsize; /* file size */
} ezd_head;

typedef struct {
  /* file name [ASCIIZ] */
  /* ???? name [ASCIIZ] */
  uint32_t pack; /* game code: 0 - unpacked, else - zlib */
  uint32_t offs;
  uint32_t unsz;
  uint32_t pksz;
} ezd_item;
#pragma pack(pop)

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);
    }
  }
}

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[]) {
uint8_t *p, *u, *t, *h;
unsigned long ps, us;
ezd_head head;
ezd_item *item;
uint32_t i, sz;
char *s[2];
FILE *fl;
  printf("Nuclear Titbit .EZD unpacker v1.0\n(c) CTPAX-X Team 2025\nhttp://www.CTPAX-X.org/\n\n");
  if (argc != 2) {
    printf("Usage: unpakezd <filename.ezd>\n\n");
    return(1);
  }
  fl = fopen(argv[1], "rb");
  if (!fl) {
    printf("Error: can't open input file.\n\n");
    return(2);
  }
  fseek(fl, 0, SEEK_END);
  sz = ftell(fl);
  fseek(fl, 0, SEEK_SET);
  readdata(fl, &head, sizeof(head));
  if (
    (head.magic != 0xFF647A65) || (head.fsize != sz) ||
    (!head.count) || (head.lsize <= (sizeof(head) + (head.count * (1 + 1 + sizeof(item[0])))))
  ) {
    fclose(fl);
    printf("Error: invalid input file format.\n\n");
    return(3);
  }
  sz = head.lsize - sizeof(head);
  t = (uint8_t *) malloc(sz);
  if (!t) {
    fclose(fl);
    printf("Error: not enough memory for contents table.\n\n");
    return(4);
  }
  readdata(fl, t, sz);
  h = t;
  for (i = 0; i < head.count; i++) {
    s[0] = (char *) h;
    h += strlen(s[0]) + 1;
    s[1] = (char *) h;
    h += strlen(s[1]) + 1;
    item = (ezd_item *) h;
    h += sizeof(item[0]);
    printf("%s\n", s[0]);
    /* reproduce game logic */
    sz = item->pack ? item->pksz : item->unsz;
    /* notice of unknown packing method */
    if ((item->pack != 0) && (item->pack != 2)) {
      printf("Warning: unknown/unsupported packing method - saving file as is.\n");
    }
    p = (uint8_t *) malloc(sz);
    if (p) {
      fseek(fl, item->offs, SEEK_SET);
      readdata(fl, p, sz);
      /* strict check - zlib only for packing method 2 */
      if ((item->pack == 2) && (item->pksz >= 2)) {
        u = (uint8_t *) malloc(item->unsz);
        if (u) {
          us = item->unsz;
          ps = item->pksz - 2;
          memset(u, 0, sz);
          puff(u, &us, &p[2], &ps);
          free(p);
          p = u;
          sz = item->unsz;
        }
      }
      dumpdata(s[0], p, sz);
      free(p);
    }
  }
  free(t);
  fclose(fl);
  printf("\ndone\n\n");
  return(0);
}
    © CTPAX-X 2006-2026 | engine version 2.7
Based on original site design by Blade

 

 

 
При копировании материалов ссылка на сайт WWW.CTPAX-X.ORG обязательна!
Использование материалов влечёт безоговорочное принятие правил сайта.
Количество запросов к БД: 7 | Страница сгенерирована за 0.01202 сек.