summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xToD/Makefile17
-rw-r--r--ToD/c_dumper.cpp140
2 files changed, 157 insertions, 0 deletions
diff --git a/ToD/Makefile b/ToD/Makefile
new file mode 100755
index 0000000..12f5a46
--- /dev/null
+++ b/ToD/Makefile
@@ -0,0 +1,17 @@
+#!/usr/bin/make -f
+
+CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror -I../includes
+CXX=g++
+LIBS=-lz
+LDFLAGS=${LIBS}
+
+TARGET = c_dumper
+
+all: ${TARGET}
+
+c_dumper: c_dumper.o ../includes/generic.h Makefile
+ ${CXX} ${LDFLAGS} c_dumper.o ../generic/generic.a -o unarc
+
+clean:
+ rm -f *.o ${TARGET} compil.c
+
diff --git a/ToD/c_dumper.cpp b/ToD/c_dumper.cpp
new file mode 100644
index 0000000..edbd8df
--- /dev/null
+++ b/ToD/c_dumper.cpp
@@ -0,0 +1,140 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "generic.h"
+#include "Main.h"
+#include "Input.h"
+#include "Output.h"
+
+CODE_BEGINS
+int startup() throw (GeneralException)
+{
+ long valpos = 0;
+ long valpos2 = 0;
+ long valposnext = 0;
+ long valtaille = 0;
+ char doublon[8];
+ char doublon2[8];
+ unsigned char pos[3];
+ unsigned char taille[3];
+ int index = 0;
+
+ Byte segment[257];
+
+ Input * handleindex = new Input("M.B");
+ Input * handlearchi = new Input("M.DAT");
+
+ while(index!=1315) {
+ Output * outfile;
+ String nom_fichier;
+
+ valposnext = valpos + valtaille;
+
+ handleindex->seek(1, SEEK_CUR); // on saute le premier octet
+ handleindex->read(pos, 3);
+ valpos = pos[0] + (pos[1] << 8) + (pos[2] << 16);
+
+ handleindex->seek(1, SEEK_CUR); // on saute le premier octet
+ handleindex->read(taille, 3);
+ valtaille = taille[0] + (taille[1] << 8) + (taille[2] << 16);
+
+ valpos2 = handleindex->tell(); // sauve la position
+ doublon[0] = 0;
+ doublon[1] = pos[0];
+ doublon[2] = pos[1];
+ doublon[3] = pos[2];
+ doublon[4] = 0;
+ doublon[5] = taille[0];
+ doublon[6] = taille[1];
+ doublon[7] = taille[2]; // on construit la chaine contenant le pointeur
+ handleindex->seek(0);
+ for(int i = 0; i < (valpos2 - 8); i += 8) {
+ handleindex->read(doublon2, 8);
+ if(memcmp(doublon, doublon2, 8) == 0) {
+ printm(M_BARE, "\nIgnore fichier d'index %d\n", index);
+ index++;
+ break;
+ }
+ }
+ handleindex->seek(valpos2); // on remet la position au bon endroit
+
+ if (memcmp(doublon, doublon2, 8) == 0) {
+ continue;
+ }
+
+ handlearchi->seek(valpos << 8);
+
+ nom_fichier.set("extract\\tod_%04d.out", index);
+
+ /////////////////////
+ // A decommenter si les fichiers sont déjà extrait du .DAT
+ /////////////////////
+
+ // outfile = fopen(nom_fichier,"rb"); // unarc
+
+ ////////////////////
+ // Commenter à partir de là jusqu'à la fin du FOR si on a déjà extrait les fichiers du .DAT
+ ////////////////////
+
+ outfile = new Output(nom_fichier);
+
+ for (int i = 0; i < valtaille; i++) {
+ handlearchi->read(segment, 256);
+ outfile->write(segment, 256);
+ }
+ ////////////////////
+
+ printm(M_BARE, "\rFichier dumpé : %d",index);
+ //unarc(outfile,index);
+ delete outfile;
+ index++;
+
+ }
+ delete handleindex;
+ delete handlearchi;
+
+ printm(M_BARE, "\nNombre de fichiers dumpés : %d",index - 1);
+ return 0;
+}
+
+void unarc(Input * fichier, int num)
+{
+ int quantite;
+ int *pos;
+ long taille;
+ char *buf;
+ String nomarchive;
+ String nomfichier;
+ Output *fichierout;
+
+ taille = fichier->GetSize();
+
+ fichier->read(&quantite, 4);
+ pos = (int *) malloc(4 * quantite);
+ fichier->read(pos, 4 * quantite);
+ nomarchive.set("%04d", num);
+ MKDIR(nomarchive.to_charp());
+
+ for (int i = 0; i < quantite - 1; i++) {
+ buf=(char *) malloc(pos[i+1]-pos[i]);
+ fichier->read(buf, pos[i + 1] - pos[i]);
+ nomarchive.set("%04d", i);
+
+ fichierout = new Output(nomarchive + nomfichier);
+ fichierout->write(buf, pos[i + 1] - pos[i]);
+ delete fichierout;
+ }
+
+ buf = (char *) malloc(taille - pos[quantite - 1]);
+ fichier->read(buf, taille - pos[quantite - 1]);
+ nomfichier.set("%04d", quantite - 1);
+
+ fichierout = new Output(nomarchive + nomfichier);
+ fichierout->write(buf, taille - pos[quantite - 1]);
+ delete fichierout;
+}
+
+int Analyse_table() {
+ return 1;
+}
+CODE_ENDS