But it can't read the name right now, it either gives no name or invalid characters.
Code:
#include <iostream>
#include <fstream>
using namespace std;
char *data;
int main()
{
char pnt = 0;
char *name;
int x = 0, index, endex = 0,hsize;
long size, offset;
ifstream hed("datap.hed", ios::in | ios::binary);
ifstream wad("datap.wad", ios::in | ios::binary);
hed.seekg(0, ios::end);
hsize = hed.tellg();
hsize = (hsize - 8);
while(endex != hsize)
{
hed.seekg(endex);
while(pnt!=0x5C) hed.read(&pnt, 1);
index = hed.tellg();
while(pnt!=0x00) hed.read(&pnt, 1);
endex = hed.tellg();
if((endex-index) > 4)
{
hed.seekg(index);
name = new char[(endex-index)];
while(pnt!=0x00)
{
hed.read(&pnt, 1);
name[x] = pnt;
x++;
}
hed.seekg(index-9);
hed.read(reinterpret_cast<char*>(&offset), 4);
wad.seekg(offset);
hed.read(reinterpret_cast<char*>(&size), 4);
data = new char[size];
wad.read(data,size);
ofstream extract(name, ios::out | ios::binary);
extract.write(data, size);
extract.close();
delete[] data;
cout << "\nExtracted: " << name <<"(Size: "<<size<<" Offset: 0x"<<hex<<offset<<")";
} else endex++;
delete[] name;
x = 0;
}
cout << "Done";
wad.close();
hed.close();
return 0;
}