Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
HNIdesu authored Sep 7, 2023
1 parent 997d510 commit b519cdf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
9 changes: 8 additions & 1 deletion DSRTArchiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ unsigned int DSRTArchiver::ExtractEntry(DSRTEntry entry,unsigned char* buffer,co

DSRTArchiver::DSRTArchiver(const wchar_t* filepath){
#define BUFFERSIZE 32768
DSRTEntry entry;
file_path=filepath;
HANDLE hFile=CreateFileW(filepath,GENERIC_READ,FILE_SHARE_READ,nullptr,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,nullptr);
if(!hFile)
Expand All @@ -78,6 +79,12 @@ DSRTArchiver::DSRTArchiver(const wchar_t* filepath){
DWORD bytesRead;
entries=new std::vector<DSRTEntry>();
ReadFile(hFile,buffer,24,nullptr,nullptr);
{
entry.entry_name=L"Project.srpgs";
entry.offset=*((uint32_t*)(buffer+20))+168;
entry.length=GetFileSize(hFile,nullptr)-entry.offset;
entries->push_back(entry);
}
if(!BufferEquals(buffer,DSRTSignature,4))
throw L"Signature error";
is_encrypted=*((UINT*)(buffer+4))==1;
Expand All @@ -97,6 +104,7 @@ DSRTArchiver::DSRTArchiver(const wchar_t* filepath){
SetFilePointer(hFile,curFrag->position,nullptr,FILE_BEGIN);
ReadFile(hFile,buffer,4,nullptr,nullptr);
UINT resource_group_count=*((UINT*)buffer);
if(curFrag->length==0)continue;
UINT info_length=(resource_group_count)*4;
UINT offset=0;

Expand Down Expand Up @@ -137,7 +145,6 @@ DSRTArchiver::DSRTArchiver(const wchar_t* filepath){

ReadFile(hFile,buffer,info_length,nullptr,nullptr);
for(int k=0;k<file_count;k++){
DSRTEntry entry;
entry.entry_name=curFrag->entry_name;
entry.entry_name+=L'/';
if(k>0){
Expand Down
12 changes: 6 additions & 6 deletions DSRTArchiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ class DSRTEntry{
public:
friend class DSRTArchiver;
const std::wstring GetEntryName();
unsigned int GetLength();
uint32_t GetLength();

private:
std::wstring entry_name;
unsigned int offset;
unsigned length;
uint32_t offset;
uint32_t length;
};

class DSRTArchiver
{
private:
std::vector<DSRTEntry>* entries;
const unsigned char DSRTSignature[4]={0x53,0x44,0x54,0x53};
const uint8_t DSRTSignature[4]={0x53,0x44,0x54,0x53};
bool is_encrypted;
unsigned int version;
uint32_t version;
wstring file_path;
public:
const std::vector<DSRTEntry> GetEntries();
unsigned int ExtractEntry(DSRTEntry entry,unsigned char* buffer,const unsigned char* key,unsigned int keylength);
uint32_t ExtractEntry(DSRTEntry entry,unsigned char* buffer,const unsigned char* key,unsigned int keylength);
DSRTArchiver(const wchar_t* filename);
~DSRTArchiver();
};
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "Utility.h"
#include <iostream>

#define TARGETPATH L".\\data.dts"
#define TARGETPATH L"E:\\Games\\冒险游戏\\戦姫ルルカver1.1\\data.dts"
#define DECRYPT_KEY_LENGTH 6
const wchar_t DecryptKey[DECRYPT_KEY_LENGTH]={L'k',L'e',L'y',L's',L'e',L't'};

Expand Down

0 comments on commit b519cdf

Please sign in to comment.