Now this is my first "big" project and im having errors executing this right. What im trying to do is right under "Therorized Algorithm".
Noticable Problems::
1. Doesnt create the file's
2. Offset, Size, Name doesnt show up correctly
I would upload the files but there big. :/
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
using namespace std;
/*
nbyte = null bytes between file infos
FLbyte = Sets pointer at location in the .WAD file
FSbyte = the 4 bytes for settign the buffer size
FNstring = Stores the string name/Path for the file.
IN THAT ORDER, with teh exception of the first.
Therorized Algorithm
Every Label starts with a "\" so if we read into a temp. buffer
until we hit that variable. Then we can go back 8 BYTES and read
FLbyte, FSbyte and end up back at the "/" (Begging of the file's name)
then read that till it hits "0" ( NUll Byte)
Then going into the wad and setting the offset as the one read and
setting the buffer size as the one read. Then creating a new file where
it dumps the memory in that file and givin the name of FNstring.
Repeating this until I hit 0xFFFFFF hence EOF
*/
int main()
{
char* FLbyte;
char* FSbyte;
long Datoff;
long int Datsiz;
char* Data;
char ch,ch2;
int start, end, i, set, x, point;
char* name[MAX_PATH];
ifstream hed ("DATAP.hed", ios::binary|ios::in);
ifstream wad ("DATAP.wad", ios::binary|ios::in);
if(hed.is_open())
{
hed.seekg(0, ios::beg);//set pointer at beggining
while(! hed.eof())
{
hed.read(reinterpret_cast<char*>(&ch), 1);
if(ch = 92)
{
start = hed.tellg();//get start position
while(ch2 != 0)
{
hed.read(reinterpret_cast<char*>(&ch2), 1); //reading until 0
for(x = 0; x < sizeof(name); x++)
{
name[x] = new char[ch2];
}
}
}
end = hed.tellg();//get end position
point = (start - 8);
hed.seekg(point);
FLbyte = new char[4];//setting buffers sizes
FSbyte = new char[4];
hed.read(FLbyte, 4);
hed.read(FSbyte, 4);//reading into buffers
hed.seekg(end);
Datoff = *((long int*)FLbyte);//cast to long's
Datsiz = *((long int*)FSbyte);
cout << "File Offset: "<< Datoff << "\nFile Size: "<<Datsiz <<" bytes\n"<<"Name: "<<name<<endl;
wad.seekg(Datoff);//go to the read offset
Data = new char[Datsiz];//set the buffer size from read size
wad.read(Data, Datsiz);//read from there into that buffer & size
ofstream extract(reinterpret_cast<char*>(&name), ios::binary|ios::out);
if(extract.is_open())
{
extract.write(Data, Datsiz);//new file and write to it
extract.close();
}
}
}
cout << "End Of File...";
cin.ignore();
cin.get();
return 0;
}
There maybe some things in there that have no use, they wereleft over from previous steps.