Skip to content

Commit

Permalink
th175arc: don't decrypt/encrypt game.exe
Browse files Browse the repository at this point in the history
This file isn't encrypted, because, well, Windows need to be able to read it
in order to run the game.
  • Loading branch information
brliron committed Dec 9, 2021
1 parent 824ef05 commit e9170d3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion th175arc/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ uint32_t calc_hash(const char *filename)
{
if (strcmp(filename, "game.exe") == 0) {
// I don't know the filename for this hash, but I need to have one, so I arbitrarily decide it's "game.exe".
return 0x1f47c0c8;
return GAME_EXE_HASH;
}

uint64_t hash = 0x811C9DC5;
Expand Down
4 changes: 3 additions & 1 deletion th175arc/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ int write_dat_file(filenames_cache_t *filenames_cache, const char *out_dir, uint
{
uint8_t *buffer = malloc(size);
memcpy(buffer, data, size);
decrypt(buffer, size, offset_in_file);
if (hash != GAME_EXE_HASH) {
decrypt(buffer, size, offset_in_file);
}

char name_buffer[26];
const char *name = filenames_cache_get(filenames_cache, hash);
Expand Down
1 change: 1 addition & 0 deletions th175arc/th175arc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ typedef struct file_desc_s

int unpack_file(const char *in_file, const char *out_dir);
int repack_file(const char *in_dir, const char *out_file);
#define GAME_EXE_HASH 0x1f47c0c8

uint32_t calc_hash(const char *filename);
void decrypt(uint8_t *buffer, size_t size, size_t offset_in_file);
Expand Down
4 changes: 3 additions & 1 deletion th175arc/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ int repack_file(const char *in_dir, const char *out_file)
desc[i].key = calc_hash(files_list[i] + strlen(in_dir) + strlen("/"));
desc[i].offset = offset;
desc[i].size = size;
decrypt(file, size, offset);
if (desc[i].key != GAME_EXE_HASH) {
decrypt(file, size, offset);
}
offset += size;
fwrite(file, size, 1, out);
free(file);
Expand Down

0 comments on commit e9170d3

Please sign in to comment.