Skip to content

Commit

Permalink
Merge pull request #13 from Jayveer/feature/native-gui
Browse files Browse the repository at this point in the history
Add Multhithreaded Extract for GUI
  • Loading branch information
Jayveer authored Aug 14, 2020
2 parents fb1521c + bfeca5c commit db94522
Show file tree
Hide file tree
Showing 31 changed files with 45,420 additions and 202 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.vs/
Debug/
Release/
Debug (GUI)/
Release (GUI)/
x64/
DecimaExplorer.vcxproj.filters
Binary file removed DecimaExplorer.aps
Binary file not shown.
71 changes: 0 additions & 71 deletions DecimaExplorer.rc

This file was deleted.

15 changes: 8 additions & 7 deletions DecimaExplorer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (GUI)|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (GUI)|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="decima\common\util.h" />
<ClInclude Include="gui\draw\component\menu\MenuComponent.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
Expand All @@ -365,6 +366,13 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gui\res\res.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="utils\Arrayutils.h" />
<ClInclude Include="utils\Fileutils.h" />
<ClInclude Include="decima\file\DecimaCore.h" />
<ClInclude Include="decima\file\prefetch\CorePrefetch.h" />
Expand Down Expand Up @@ -426,20 +434,13 @@
<ClInclude Include="hash\MurmurHash3.h" />
<ClInclude Include="ooz\Kraken.h" />
<ClInclude Include="ooz\targetver.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="utils\Numutils.h" />
</ItemGroup>
<ItemGroup>
<None Include="LICENSE.md" />
<None Include="ooz\LICENSE.md" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="DecimaExplorer.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="E:\Art\dex.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
22 changes: 9 additions & 13 deletions DecimaExplorer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@
<ClInclude Include="utils\Numutils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="gui\GUI.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand All @@ -176,20 +173,19 @@
<ClInclude Include="gui\draw\component\progress\ProgressComponent.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="gui\res\res.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="utils\Arrayutils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="decima\common\util.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="ooz\LICENSE.md" />
<None Include="LICENSE.md" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="DecimaExplorer.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="E:\Art\dex.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion DecimaExplorer.vcxproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>-l .</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>-e "G:\Games\PC\steamapps\common\Death Stranding\data" ds/models/characters/aml_amelie/core/aml_skirt_demo_cs07_s00350/model/animations/neutral</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug (GUI)|x64'">
Expand Down
Binary file removed RCa06868
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Now includes a GUI version, please note it has a lot less features than the comm

## Usage

There are two flavours of Decima Explorer, one that can be run from the command line and that runs as a Graphical User Interface. The GUI has less features. The command line client has support for movie archive files and binary archive files. Binary archive files can be extracted by their ID or name. If extracting by name it is also possible to enter a directory to search multiple files. A list of game files can also be dumped. Movie archive files can be extracted ID or name if it is known. If the output file isn't specified it will use the 'file to extract' name along with creating its directory structure;
There are two flavours of Decima Explorer, one that can be run from the command line and one that runs as a Graphical User Interface. The GUI has less features. The command line client has support for movie archive files and binary archive files. Binary archive files can be extracted by their ID or name. If extracting by name it is also possible to enter a directory to search multiple files. A list of game files can also be dumped. Movie archive files can be extracted ID or name if it is known. If the output file isn't specified it will use the 'file to extract' name along with creating its directory structure;

```
DecimaExplorer.exe -list "G:\path\to\game\data\files"
Expand Down
14 changes: 3 additions & 11 deletions decima/archive/DecimaArchive.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "DecimaArchive.h"


DecimaArchive::DecimaArchive(std::string filename, std::string extension) {
setFilename(filename);
}
Expand Down Expand Up @@ -79,7 +78,7 @@ void DecimaArchive::movieDecrypt(uint32_t* key, uint8_t* src, int size, int pass
}
}

int DecimaArchive::writeDataToFile(DataBuffer data, std::string filename) {
int DecimaArchive::writeDataToFile(const DataBuffer& data, const std::string& filename) {
FILE* f;
fopen_s(&f, filename.c_str(), "wb");

Expand All @@ -91,13 +90,6 @@ int DecimaArchive::writeDataToFile(DataBuffer data, std::string filename) {
fseek(f, 0, SEEK_END);
fwrite(&data[0], 1, data.size(), f);
fclose(f);
}

uint64_t DecimaArchive::getFileHash(std::string filename) {
uint64_t hash;
uint8_t byte[16];
MurmurHash3_x64_128(filename.c_str(), filename.size() + 1, seed, &byte);
memcpy(&hash, byte, 8);
return hash;
}

return 1;
}
12 changes: 6 additions & 6 deletions decima/archive/DecimaArchive.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#pragma once
#include <thread>

#include "../../ooz/Kraken.h"
#include "../../hash/md5.h"
#include "../../hash/MurmurHash3.h"
#include "../../utils/Fileutils.h"

#include "../../utils/Fileutils.h"
#include "../common/util.h"
#include "DecimaArchiveError.h"

typedef std::vector<uint8_t> DataBuffer;
Expand All @@ -13,16 +15,14 @@ class DecimaArchive {
std::string filename;
std::string extension;

uint8_t seed = 0x2A;
uint32_t saltA[4] = { 0x0FA3A9443, 0x0F41CAB62, 0x0F376811C, 0x0D2A89E3E };
uint32_t saltB[4] = { 0x06C084A37, 0x07E159D95, 0x03D5AF7E8, 0x018AA7D3F };

protected:
bool isEncrypted();
uint64_t getFileHash(std::string filename);
bool isEncrypted();
void decrypt(uint32_t key, uint32_t* src);
void decrypt(uint32_t key, uint32_t key2, uint32_t* src);
int writeDataToFile(DataBuffer data, std::string filename);
int writeDataToFile(const DataBuffer& data, const std::string& filename);
void dataDecrypt(uint32_t* key, uint8_t* src, int size);
void movieDecrypt(uint32_t* key, uint8_t* src, int size, int pass);
void setSaltA(uint32_t* salt);
Expand Down
30 changes: 13 additions & 17 deletions decima/archive/bin/ArchiveBin.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "ArchiveBin.h"

#include <errno.h>

ArchiveBin::ArchiveBin(std::string filename) : DecimaArchive(filename, this->extension) {

Expand Down Expand Up @@ -77,6 +77,12 @@ DataBuffer ArchiveBin::getChunkData(BinChunkEntry chunkEntry) {
FILE* f;

fopen_s(&f, getFilename().c_str(), "rb");

if (!f) {
showError(WRITEFAIL);
return dataBuffer;
}

_fseeki64(f, chunkOffset, SEEK_SET);
fread(&dataBuffer[0], 1, chunkSize, f);

Expand All @@ -85,7 +91,7 @@ DataBuffer ArchiveBin::getChunkData(BinChunkEntry chunkEntry) {
return dataBuffer;
}

void ArchiveBin::decompressChunkData(DataBuffer data, uint64_t decompressedSize, unsigned char* output) {
void ArchiveBin::decompressChunkData(const DataBuffer &data, uint64_t decompressedSize, unsigned char* output) {
int res = Kraken_Decompress(&data[0], data.size(), output, decompressedSize);
if (res == -1) showError(DECOMPRESSFAIL);
}
Expand All @@ -98,7 +104,7 @@ uint32_t ArchiveBin::getFileEntryIndex(int id) {
return -1;
}

uint32_t ArchiveBin::getFileEntryIndex(std::string filename) {
uint32_t ArchiveBin::getFileEntryIndex(const std::string& filename) {
uint64_t hash = getFileHash(filename);
for (int i = 0; i < fileTable.size(); i++) {
if (fileTable[i].hash == hash)
Expand All @@ -122,20 +128,6 @@ int ArchiveBin::findChunkWithOffset(uint64_t offset) {
}
}

int ArchiveBin::writeDataToFile(DataBuffer data, std::string filename) {
FILE* f;
fopen_s(&f, filename.c_str(), "wb");

if (!f) {
showError(WRITEFAIL);
return 0;
}

fseek(f, 0, SEEK_END);
fwrite(&data[0], 1, data.size(), f);
fclose(f);
}

DataBuffer ArchiveBin::extract(BinFileEntry fileEntry) {
uint64_t fileOffset = fileEntry.offset;
uint32_t fileSize = fileEntry.size;
Expand All @@ -152,6 +144,7 @@ DataBuffer ArchiveBin::extract(BinFileEntry fileEntry) {

for (int i = firstChunkRow; i <= lastChunkRow; i++) {
DataBuffer chunkData = getChunkData(chunkTable[i]);

if (isEncrypted()) decryptChunkData(i, &chunkData);
decompressChunkData(chunkData, chunkTable[i].uncompressedSize, &tempBuffer[pos]);
pos += chunkTable[i].uncompressedSize;
Expand Down Expand Up @@ -195,6 +188,8 @@ void ArchiveBin::decryptChunkData(int32_t id, DataBuffer* data) {

int ArchiveBin::open() {
FILE* f;


fopen_s(&f, getFilename().c_str(), "rb");

if (!f) {
Expand All @@ -205,6 +200,7 @@ int ArchiveBin::open() {
parseHeader(f);

if (!checkMagic()) {
fclose(f);
showError(INVALIDMAGIC);
return 0;
}
Expand Down
8 changes: 5 additions & 3 deletions decima/archive/bin/ArchiveBin.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,14 @@ class ArchiveBin : public DecimaArchive {
BinFileEntry getFileEntry(int id);
int findChunkWithOffset(uint64_t offset);
DataBuffer extract(BinFileEntry fileEntry);
uint32_t getFileEntryIndex(std::string filename);
uint32_t getFileEntryIndex(const std::string& filename);
void decryptChunkData(int32_t id, DataBuffer* data);
DataBuffer getChunkData(BinChunkEntry chunkEntry);
int calculateChunkTableOffset(uint64_t fileTableCount);

int writeDataToFile(DataBuffer data, std::string filename);
uint64_t calculateFirstContainingChunk(uint64_t fileOffset, int chunkSize);
uint64_t calculateLastContainingChunk(uint64_t fileOffset, int fileSize, int chunkSize);
void decompressChunkData(DataBuffer data, uint64_t decompressedSize, unsigned char* output);
void decompressChunkData(const DataBuffer& data, uint64_t decompressedSize, unsigned char* output);

protected:
uint32_t getMagic() override;
Expand All @@ -74,4 +73,7 @@ class ArchiveBin : public DecimaArchive {
DataBuffer extractFile(std::string filename);
int extractFile(uint32_t id, std::string output);
int extractFile(std::string filename, std::string output, bool suppressError = 0);

const std::vector<BinFileEntry>& getFileTable() { return fileTable; }

};
16 changes: 16 additions & 0 deletions decima/common/util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include <string>

#include "../../hash/MurmurHash3.h"


const uint8_t seed = 0x2A;

inline
uint64_t getFileHash(const std::string& filename) {
uint64_t hash;
uint8_t byte[16];
MurmurHash3_x64_128(filename.c_str(), filename.size() + 1, seed, &byte);
memcpy(&hash, byte, 8);
return hash;
}
Binary file removed dex.ico
Binary file not shown.
Loading

0 comments on commit db94522

Please sign in to comment.