|
|
@ -219,7 +219,7 @@ class SHNFile{ |
|
|
|
} |
|
|
|
} |
|
|
|
int marker=0; |
|
|
|
int marker=0; |
|
|
|
std::vector<byte>cryptHeader; |
|
|
|
std::vector<byte>cryptHeader; |
|
|
|
std::vector<byte>data; |
|
|
|
std::vector<byte>data,rawData; |
|
|
|
uint32_t header=0,recordCount=0,defaultRecordLength=0,columnCount=0; |
|
|
|
uint32_t header=0,recordCount=0,defaultRecordLength=0,columnCount=0; |
|
|
|
std::vector<Column>columns; |
|
|
|
std::vector<Column>columns; |
|
|
|
std::vector<std::vector<Data>>contents; |
|
|
|
std::vector<std::vector<Data>>contents; |
|
|
@ -231,12 +231,23 @@ public: |
|
|
|
header=recordCount=defaultRecordLength=columnCount=0; |
|
|
|
header=recordCount=defaultRecordLength=columnCount=0; |
|
|
|
columns.clear(); |
|
|
|
columns.clear(); |
|
|
|
contents.clear(); |
|
|
|
contents.clear(); |
|
|
|
|
|
|
|
rawData.clear(); |
|
|
|
marker=0; |
|
|
|
marker=0; |
|
|
|
std::chrono::time_point<std::chrono::high_resolution_clock>timer=std::chrono::high_resolution_clock::now(); |
|
|
|
std::chrono::time_point<std::chrono::high_resolution_clock>timer=std::chrono::high_resolution_clock::now(); |
|
|
|
filename=file; |
|
|
|
filename=file; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//FILE OPERATIONS!
|
|
|
|
std::ifstream f(filename,std::ios::binary); |
|
|
|
std::ifstream f(filename,std::ios::binary); |
|
|
|
cryptHeader=ReadBytes(f,0x20); |
|
|
|
cryptHeader=ReadBytes(f,0x20); |
|
|
|
data=ReadBytes(f,ReadInt32(f)-0x24); |
|
|
|
std::copy(cryptHeader.begin(),cryptHeader.end(),std::back_inserter(rawData)); |
|
|
|
|
|
|
|
int readAmt=ReadInt32(f); |
|
|
|
|
|
|
|
rawData.push_back(byte(readAmt&0xFF)); |
|
|
|
|
|
|
|
rawData.push_back(byte((readAmt>>8)&0xFF)); |
|
|
|
|
|
|
|
rawData.push_back(byte((readAmt>>16)&0xFF)); |
|
|
|
|
|
|
|
rawData.push_back(byte((readAmt>>24)&0xFF)); |
|
|
|
|
|
|
|
data=ReadBytes(f,readAmt-0x24); |
|
|
|
|
|
|
|
std::copy(data.begin(),data.end(),std::back_inserter(rawData)); |
|
|
|
|
|
|
|
|
|
|
|
Decrypt(); |
|
|
|
Decrypt(); |
|
|
|
header=ReadUInt32(); |
|
|
|
header=ReadUInt32(); |
|
|
|
recordCount=ReadUInt32(); |
|
|
|
recordCount=ReadUInt32(); |
|
|
@ -302,8 +313,8 @@ public: |
|
|
|
void Save(){ |
|
|
|
void Save(){ |
|
|
|
std::ofstream fBackup(filename+".bak",std::ios::binary); |
|
|
|
std::ofstream fBackup(filename+".bak",std::ios::binary); |
|
|
|
std::cout<<"Saving a backup to "<<filename+".bak"<<std::endl; |
|
|
|
std::cout<<"Saving a backup to "<<filename+".bak"<<std::endl; |
|
|
|
for(int i=0;i<data.size();i++){ |
|
|
|
for(int i=0;i<rawData.size();i++){ |
|
|
|
fBackup<<unsigned char(data[i]); |
|
|
|
fBackup<<unsigned char(rawData[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
std::cout<<"Saving new file..."<<std::endl; |
|
|
|
std::cout<<"Saving new file..."<<std::endl; |
|
|
|
//std::ofstream f("save_"+filename,std::ios::binary);
|
|
|
|
//std::ofstream f("save_"+filename,std::ios::binary);
|
|
|
|