diff --git a/SHNFileDecryptor/ItemInfoServer.shn b/SHNFileDecryptor/ItemInfoServer.shn new file mode 100644 index 0000000..30f4c7e Binary files /dev/null and b/SHNFileDecryptor/ItemInfoServer.shn differ diff --git a/SHNFileDecryptor/ItemViewInfo.shn b/SHNFileDecryptor/ItemViewInfo.shn new file mode 100644 index 0000000..dae842b Binary files /dev/null and b/SHNFileDecryptor/ItemViewInfo.shn differ diff --git a/SHNFileDecryptor/ItemViewInfo.shn.bak b/SHNFileDecryptor/ItemViewInfo.shn.bak new file mode 100644 index 0000000..2d941c8 Binary files /dev/null and b/SHNFileDecryptor/ItemViewInfo.shn.bak differ diff --git a/SHNFileDecryptor/SHNFileDecryptor.h b/SHNFileDecryptor/SHNFileDecryptor.h index 7280103..f2ab36d 100644 --- a/SHNFileDecryptor/SHNFileDecryptor.h +++ b/SHNFileDecryptor/SHNFileDecryptor.h @@ -11,8 +11,11 @@ typedef char sbyte; class SHNFile{ + SHNFile(const SHNFile&)=delete; + SHNFile(const SHNFile&&)=delete; std::vectorReadBytes(std::ifstream&file); std::vectorReadBytes(std::ifstream&file,int bytes); + void WriteBytes(std::ofstream&file,char*data,int length); void WriteBytes(std::ofstream&file,std::vector&data); int ReadInt32(std::ifstream&file); void Encrypt(); @@ -76,14 +79,15 @@ private: int length=0; }; int marker=0; - std::vectorcryptHeader; - std::vectordata,rawData; + char*cryptHeader=nullptr; + char*data=nullptr,*rawData=nullptr; uint32_t header=0,recordCount=0,defaultRecordLength=0,columnCount=0; std::vectorcolumns; std::vector>contents; std::string filename; std::vectorreadArr; - std::byte*fileMarker=0; + int readAmt=0; + void Cleanup(); public: void Load(std::string file); void Save(); @@ -97,6 +101,7 @@ public: void Write(int row,int col,std::string val); const SHNFile::Data Get(int row,int col)const; SHNFile(); + ~SHNFile(); }; #ifdef OLC_PGEX_SHNFile std::vectorSHNFile::ReadBytes(std::ifstream&file){ @@ -117,6 +122,11 @@ std::vectorSHNFile::ReadBytes(std::ifstream&file,int bytes){ } return byteArr; } +void SHNFile::WriteBytes(std::ofstream&file,char*data,int length){ + for(int i=0;i&data){ for(int i=0;i=0;i--){ - data[i] = std::byte(data[i]^num); + std::byte num = std::byte(readAmt-0x24); + for(int i=readAmt-0x24-1;i>=0;i--){ + data[i] = char(std::byte(data[i])^num); std::byte num3 = std::byte(i); num3 = std::byte(num3&std::byte(15)); num3 = std::byte(int(num3)+0x55); @@ -145,7 +155,9 @@ void SHNFile::Decrypt(){ } std::vector&SHNFile::ReadBytes(int bytes){ readArr.clear(); - std::copy(data.begin()+marker,data.begin()+marker+bytes,std::back_inserter(readArr)); + for(int i=0;itimer=std::chrono::high_resolution_clock::now(); filename=file; + Cleanup(); //FILE OPERATIONS! std::ifstream f(filename,std::ios::binary); //Since we don't just read in the entire file raw, we have to do some additional work here as the header provides us with some basic info on how to decrypt this file. //The backup itself needs all the data from the original file, so we're appending it to rawData as we continue reading it. - cryptHeader=ReadBytes(f,0x20); - int readAmt=ReadInt32(f); - rawData.push_back(std::byte(readAmt&0xFF)); - rawData.push_back(std::byte((readAmt>>8)&0xFF)); - rawData.push_back(std::byte((readAmt>>16)&0xFF)); - rawData.push_back(std::byte((readAmt>>24)&0xFF)); - data=ReadBytes(f,readAmt-0x24); - std::copy(data.begin(),data.end(),std::back_inserter(rawData)); + + cryptHeader=new char[0x20]; + f.read(cryptHeader,0x20); + readAmt=ReadInt32(f); + rawData=new char[readAmt-0x20]; + rawData[0]=char(readAmt&0xFF); + rawData[1]=char((readAmt>>8)&0xFF); + rawData[2]=char((readAmt>>16)&0xFF); + rawData[3]=char((readAmt>>24)&0xFF); + data=new char[readAmt-0x24]; + f.read(data,readAmt-0x24); + for(int i=0;i