sigonasr2 1 year ago
parent d0cc51f224
commit f8814bec65
  1. BIN
      SHNFileDecryptor/ItemInfo.shn
  2. 14
      SHNFileDecryptor/SHNFileDecryptor.h
  3. 4
      SHNFileDecryptor/SHNFileDecryptor.vcxproj
  4. 6
      SHNFileDecryptor/SHNFile_example.cpp

Binary file not shown.

@ -5,6 +5,7 @@
#include <iostream>
#include <string>
#include <chrono>
#include <sstream>
//typedef std::std::byte std::byte;
typedef char sbyte;
@ -16,7 +17,7 @@ class SHNFile{
int ReadInt32(std::ifstream&file);
void Encrypt();
void Decrypt();
std::vector<std::byte>ReadBytes(int bytes);
std::vector<std::byte>&ReadBytes(int bytes);
std::byte ReadByte();
void WriteByte(std::ofstream&f,std::byte b);
void WriteSByte(std::ofstream&f,sbyte b);
@ -146,13 +147,13 @@ std::vector<std::byte>&SHNFile::ReadBytes(int bytes){
readArr.clear();
for(int i=0;i<bytes;i++){
if(marker<data.size()){
byteArr.push_back(data[marker]);
readArr.push_back(data[marker]);
marker++;
} else {
break;
}
}
return byteArr;
return readArr;
}
std::byte SHNFile::ReadByte(){
std::vector<std::byte>&b=ReadBytes(1);
@ -341,8 +342,6 @@ std::string SHNFile::Data::GetDisplayText(){
}
}
void SHNFile::Load(std::string file){
cryptHeader.clear();
data.clear();
header=recordCount=defaultRecordLength=columnCount=0;
columns.clear();
contents.clear();
@ -356,7 +355,6 @@ void SHNFile::Load(std::string file){
//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);
std::copy(cryptHeader.begin(),cryptHeader.end(),std::back_inserter(rawData));
int readAmt=ReadInt32(f);
rawData.push_back(std::byte(readAmt&0xFF));
rawData.push_back(std::byte((readAmt>>8)&0xFF));
@ -537,5 +535,7 @@ void SHNFile::Write(int row,int col,float val){
void SHNFile::Write(int row,int col,std::string val){
contents[row][col].Set<std::string>(val);
}
SHNFile::SHNFile(){}
SHNFile::SHNFile(){
readArr.reserve(64000);
}
#endif

@ -76,7 +76,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -106,7 +106,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

@ -7,9 +7,5 @@
int main(){
SHNFile shn;
shn.Load("AbState.shn");
SHNFile::Data dat=shn.Get(3,6);
std::cout<<dat<<std::endl;
shn.Write(1,1,"Noodles");
shn.Save();
shn.Load("ItemInfo.shn");
}
Loading…
Cancel
Save