Reconstruction layout: generated-src/ (generated) and src/ (curated), CMake, the first takeover: RNG
The decompiled C++ tree moves to generated-src/ (classes.h, C++20); src/ is for code written by hand. A curated function defines the generated declaration and starts its comment with its address, and source_tree.py stops emitting that body. src/rng.cpp takes over RNG (SetSeed, the constructor, Next, RandomInt, RandomFloat, Shuffle) with the shift table read from the exe as a constexpr array; src/log.h names KAGE_LogMessage's levels (1 INFO, 2 NET, 4 WARN, 8 ERROR, 16 ASSERT, from its prefix jump table). CMakeLists.txt builds src/*.cpp against generated-src/classes.h (clean with -Wall -Wextra). structs.hpp and headers.py are retired: scripts/merge_fields.py writes the merged field list, classes.h checks the layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2ff2d5d87f
commit
3ce74c6e2d
331 files changed
+485
-7835
No files matched your search
@@ -0,0 +1,597 @@
|
||||
#include "classes.h"
|
||||
|
||||
// 00a16060
|
||||
void * FileSystem::GetMountPrefixes(void *outPrefixes)
|
||||
{
|
||||
int mountIndex;
|
||||
undefined4 prefix;
|
||||
undefined4 local_14;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
undefined4 local_8;
|
||||
int mount;
|
||||
undefined4 *prefixesEnd;
|
||||
|
||||
local_10 = ExceptionList;
|
||||
puStack_c = &LAB_00b10e6e;
|
||||
ExceptionList = &local_10;
|
||||
*GHIDRA_CAST<undefined4 *>(outPrefixes) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(outPrefixes) + 4)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(outPrefixes) + 8)) = 0;
|
||||
local_8 = 0;
|
||||
mountIndex = DAT_00c379ec - DAT_00c379e8 >> 2;
|
||||
local_14 = 1;
|
||||
while (mountIndex = mountIndex + -1, -1 < mountIndex) {
|
||||
mount = *GHIDRA_CAST<int *>((DAT_00c379e8 + mountIndex * 4));
|
||||
strncmp(*GHIDRA_CAST<char **>((mount + 0xc)),GHIDRA_CAST<char *>(&s_empty),0);
|
||||
prefix = *GHIDRA_CAST<undefined4 *>((mount + 0xc));
|
||||
prefixesEnd = *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(outPrefixes) + 4));
|
||||
if (prefixesEnd == *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(outPrefixes) + 8))) {
|
||||
std::vector<unsigned_int>::_Emplace_reallocate(prefixesEnd,&prefix);
|
||||
}
|
||||
else {
|
||||
*prefixesEnd = prefix;
|
||||
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outPrefixes) + 4)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outPrefixes) + 4)) + 4;
|
||||
}
|
||||
}
|
||||
ExceptionList = local_10;
|
||||
return outPrefixes;
|
||||
}
|
||||
|
||||
// 00a167d0
|
||||
void FileSystem::load_mount_points()
|
||||
{
|
||||
byte isOpened;
|
||||
char isMatch;
|
||||
uint uVar1;
|
||||
int *piVar2;
|
||||
byte *pbVar3;
|
||||
int bytesRead;
|
||||
int iVar4;
|
||||
undefined4 *puVar5;
|
||||
qword *allocCounter;
|
||||
uint i;
|
||||
void *pvVar6;
|
||||
code *freeFn;
|
||||
int *piVar7;
|
||||
int *piVar8;
|
||||
byte *mountPath;
|
||||
undefined4 local_3c;
|
||||
undefined4 *mountPointMem;
|
||||
byte *local_34;
|
||||
void *self;
|
||||
undefined4 *local_2c;
|
||||
undefined4 *entryLength;
|
||||
int nameLength;
|
||||
byte *local_20;
|
||||
void *entries;
|
||||
uint entryCount;
|
||||
int *file;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
undefined4 local_8;
|
||||
qword allocatedBytes;
|
||||
uint blockSize;
|
||||
undefined4 *mapTree;
|
||||
|
||||
local_8 = 0xffffffff;
|
||||
puStack_c = &LAB_00b10f7f;
|
||||
local_10 = ExceptionList;
|
||||
uVar1 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
||||
ExceptionList = &local_10;
|
||||
self = this;
|
||||
piVar2 = Open(&PTR_vftable_00c37a10,GHIDRA_CAST<byte *>("kage_mount_points.dat"),GHIDRA_CAST<int *>(0x0));
|
||||
file = piVar2;
|
||||
if (piVar2 == GHIDRA_CAST<int *>(0x0)) {
|
||||
piVar7 = piVar2;
|
||||
piVar8 = piVar2;
|
||||
pbVar3 = GHIDRA_CAST<byte *>((**(code **)(*GHIDRA_CAST<int *>(this) + 0x10))(0,0,uVar1));
|
||||
pbVar3 = path_join(GHIDRA_CAST<byte *>("kage_mount_points.dat"),pbVar3,(byte)piVar7,(byte)piVar8);
|
||||
if ((pbVar3 == GHIDRA_CAST<byte *>(0x0)) || (*pbVar3 == 0)) {
|
||||
file = piVar2;
|
||||
if (pbVar3 == GHIDRA_CAST<byte *>(0x0)) {
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
local_34 = operator_new(0x10);
|
||||
if (local_34 == GHIDRA_CAST<byte *>(0x0)) {
|
||||
file = GHIDRA_CAST<int *>(0x0);
|
||||
}
|
||||
else {
|
||||
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_34) + 4)) = 2;
|
||||
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_34) + 8)) = 0;
|
||||
*GHIDRA_CAST<undefined ***>(local_34) = KAGE::Filesys::File::vftable;
|
||||
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_34) + 0xc)) = 0;
|
||||
file = GHIDRA_CAST<int *>(local_34);
|
||||
}
|
||||
piVar2 = file;
|
||||
if (*(code **)(*file + 0x24) == KAGE::Filesys::File::open) {
|
||||
isOpened = (GHIDRA_CAST<KAGE::Filesys::File *>((file)))->KAGE::Filesys::File::open(pbVar3);
|
||||
}
|
||||
else {
|
||||
isOpened = (**(code **)(*file + 0x24))();
|
||||
}
|
||||
if (isOpened == 0) {
|
||||
(**(code **)*piVar2)(1);
|
||||
piVar2 = GHIDRA_CAST<int *>(0x0);
|
||||
file = GHIDRA_CAST<int *>(0x0);
|
||||
}
|
||||
}
|
||||
local_8 = 0;
|
||||
tracked_alloc(1,pbVar3,0);
|
||||
local_8 = 0xffffffff;
|
||||
if (piVar2 == GHIDRA_CAST<int *>(0x0)) {
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
}
|
||||
local_20 = GHIDRA_CAST<byte *>(0x0);
|
||||
(**(code **)(*piVar2 + 0x14))(&local_20,4,1);
|
||||
local_34 = local_20;
|
||||
do {
|
||||
if (local_34 == GHIDRA_CAST<byte *>(0x0)) {
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
nameLength = 0;
|
||||
bytesRead = (**(code **)(*piVar2 + 0x14))(&nameLength,4,1);
|
||||
iVar4 = nameLength;
|
||||
if (bytesRead == 4) {
|
||||
uVar1 = nameLength + 1;
|
||||
pbVar3 = operator_new_tracked(uVar1);
|
||||
local_20 = pbVar3;
|
||||
memset(pbVar3,0,uVar1);
|
||||
bytesRead = (**(code **)(*piVar2 + 0x14))(pbVar3,1,iVar4);
|
||||
if (bytesRead == iVar4) {
|
||||
entryCount = 0;
|
||||
(**(code **)(*piVar2 + 0x14))(&entryCount,4,1);
|
||||
uVar1 = entryCount;
|
||||
entries = operator_new_tracked
|
||||
(-GHIDRA_UINT((GHIDRA_INT(((ulonglong)entryCount * 4 >> 0x20)) != 0)) |
|
||||
GHIDRA_UINT(((ulonglong)entryCount * 4)));
|
||||
i = 0;
|
||||
if (uVar1 != 0) {
|
||||
do {
|
||||
pvVar6 = (void *)0x0;
|
||||
entryLength = GHIDRA_CAST<undefined4 *>(0x0);
|
||||
iVar4 = (**(code **)(*piVar2 + 0x14))(&entryLength,4,1);
|
||||
local_2c = entryLength;
|
||||
if (iVar4 == 4) {
|
||||
uVar1 = GHIDRA_INT(entryLength) + 1;
|
||||
pvVar6 = operator_new_tracked(uVar1);
|
||||
memset(pvVar6,0,uVar1);
|
||||
piVar2 = file;
|
||||
puVar5 = GHIDRA_CAST<undefined4 *>((**(code **)(*file + 0x14))(pvVar6,1,local_2c));
|
||||
if ((puVar5 != local_2c) && (pvVar6 != (void *)0x0)) {
|
||||
local_8 = 2;
|
||||
tracked_alloc(1,pvVar6,0);
|
||||
local_8 = 0xffffffff;
|
||||
pvVar6 = (void *)0x0;
|
||||
}
|
||||
}
|
||||
*(void **)(GHIDRA_CAST<char *>(entries) + i * 4) = pvVar6;
|
||||
i = i + 1;
|
||||
} while (i < entryCount);
|
||||
}
|
||||
local_3c = 0xffffffff;
|
||||
mountPath = path_join(local_20,&s_empty,0,1);
|
||||
local_8 = 3;
|
||||
piVar7 = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(self) + 0x18));
|
||||
for (piVar2 = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(self) + 0x14)); piVar2 != piVar7; piVar2 = piVar2 + 1) {
|
||||
piVar8 = GHIDRA_CAST<int *>(*piVar2);
|
||||
if ((piVar8[4] == -1) && (isMatch = FUN_00a5a940(), pvVar6 = entries, isMatch != '\0')) {
|
||||
if (piVar8 != GHIDRA_CAST<int *>(0x0)) {
|
||||
(**(code **)(*piVar8 + 4))(entries,entryCount);
|
||||
goto LAB_00a16b36;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
puVar5 = operator_new(0x14);
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 4;
|
||||
mountPointMem = puVar5;
|
||||
if (puVar5 == GHIDRA_CAST<undefined4 *>(0x0)) {
|
||||
local_2c = GHIDRA_CAST<undefined4 *>(0x0);
|
||||
pvVar6 = entries;
|
||||
}
|
||||
else {
|
||||
mapTree = puVar5 + 1;
|
||||
*puVar5 = KAGE::Filesys::FileMap::vftable;
|
||||
*mapTree = 0;
|
||||
puVar5[2] = 0;
|
||||
local_2c = mapTree;
|
||||
pvVar6 = operator_new(0x18);
|
||||
*(void **)pvVar6 = pvVar6;
|
||||
*(void **)(GHIDRA_CAST<char *>(pvVar6) + 4) = pvVar6;
|
||||
*(void **)(GHIDRA_CAST<char *>(pvVar6) + 8) = pvVar6;
|
||||
*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(pvVar6) + 0xc)) = 0x101;
|
||||
*mapTree = pvVar6;
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 5;
|
||||
*puVar5 = KAGE::Filesys::ContentManagerBase::ContentMountPoint::vftable;
|
||||
FUN_00a15b90(&mountPath);
|
||||
pvVar6 = entries;
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 6;
|
||||
FUN_00a68590(entries,entryCount);
|
||||
local_2c = puVar5;
|
||||
}
|
||||
local_8 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),3);
|
||||
puVar5 = *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(self) + 0x18));
|
||||
if (puVar5 == *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(self) + 0x1c))) {
|
||||
std::vector<4byte>::_Emplace_reallocate(puVar5,&local_2c);
|
||||
}
|
||||
else {
|
||||
*puVar5 = local_2c;
|
||||
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(self) + 0x18)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(self) + 0x18)) + 4;
|
||||
}
|
||||
LAB_00a16b36:
|
||||
uVar1 = entryCount;
|
||||
i = 0;
|
||||
if (entryCount != 0) {
|
||||
do {
|
||||
iVar4 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar6) + i * 4));
|
||||
if (iVar4 != 0) {
|
||||
if (g_mainHeap == (void *)0x0) {
|
||||
allocCounter = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
else {
|
||||
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
||||
}
|
||||
blockSize = *GHIDRA_CAST<uint *>((iVar4 + -4));
|
||||
allocatedBytes = *allocCounter;
|
||||
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - blockSize;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < blockSize));
|
||||
free((void *)(iVar4 + -4));
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(pvVar6) + i * 4)) = 0;
|
||||
}
|
||||
i = i + 1;
|
||||
} while (i < uVar1);
|
||||
}
|
||||
if (pvVar6 == (void *)0x0) {
|
||||
freeFn = free_exref;
|
||||
}
|
||||
else {
|
||||
if (g_mainHeap == (void *)0x0) {
|
||||
allocCounter = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
else {
|
||||
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
||||
}
|
||||
uVar1 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(pvVar6) + -4));
|
||||
allocatedBytes = *allocCounter;
|
||||
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar1;
|
||||
freeFn = free_exref;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < uVar1));
|
||||
free((void *)(GHIDRA_INT(pvVar6) + -4));
|
||||
}
|
||||
local_8 = 0xffffffff;
|
||||
if (mountPath != GHIDRA_CAST<byte *>(0x0)) {
|
||||
if (g_mainHeap == (void *)0x0) {
|
||||
allocCounter = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
else {
|
||||
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
||||
}
|
||||
uVar1 = *GHIDRA_CAST<uint *>((mountPath + -4));
|
||||
allocatedBytes = *allocCounter;
|
||||
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar1;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < uVar1));
|
||||
(*freeFn)(mountPath + -4);
|
||||
mountPath = GHIDRA_CAST<byte *>(0x0);
|
||||
}
|
||||
local_8 = 0xffffffff;
|
||||
local_3c = 0xffffffff;
|
||||
if (local_20 != GHIDRA_CAST<byte *>(0x0)) {
|
||||
if (g_mainHeap == (void *)0x0) {
|
||||
allocCounter = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
else {
|
||||
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
||||
}
|
||||
uVar1 = *GHIDRA_CAST<uint *>((local_20 + -4));
|
||||
allocatedBytes = *allocCounter;
|
||||
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar1;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < uVar1));
|
||||
(*freeFn)(local_20 + -4);
|
||||
}
|
||||
local_8 = 0xffffffff;
|
||||
piVar2 = file;
|
||||
}
|
||||
else if (pbVar3 != GHIDRA_CAST<byte *>(0x0)) {
|
||||
local_8 = 1;
|
||||
tracked_alloc(1,pbVar3,0);
|
||||
local_8 = 0xffffffff;
|
||||
}
|
||||
}
|
||||
local_34 = local_34 + -1;
|
||||
} while( true );
|
||||
}
|
||||
|
||||
// 00a16c60
|
||||
undefined4 FileSystem::find_mount(byte *param_1, undefined1 *param_2)
|
||||
{
|
||||
int iVar1;
|
||||
qword qVar2;
|
||||
byte bVar3;
|
||||
byte *normalizedPath;
|
||||
byte *archivePath;
|
||||
int *entry;
|
||||
int in_ECX;
|
||||
qword *allocatedBytes;
|
||||
int mountIndex;
|
||||
undefined1 hashIter [8];
|
||||
int hashNode;
|
||||
int fileSystem;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
undefined4 local_8;
|
||||
uint blockSize;
|
||||
|
||||
local_8 = 0xffffffff;
|
||||
puStack_c = &LAB_00b10fa0;
|
||||
local_10 = ExceptionList;
|
||||
ExceptionList = &local_10;
|
||||
fileSystem = in_ECX;
|
||||
normalizedPath = path_join(param_1,GHIDRA_CAST<byte *>(0x0),0,0);
|
||||
mountIndex = (*GHIDRA_CAST<int *>((in_ECX + 0xc)) - *GHIDRA_CAST<int *>((in_ECX + 8)) >> 2) + -1;
|
||||
if (-1 < mountIndex) {
|
||||
while( true ) {
|
||||
if (DAT_00c37b14 != 0) {
|
||||
archivePath = path_join(normalizedPath,
|
||||
*GHIDRA_CAST<byte **>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((in_ECX + 8)) + mountIndex * 4)) + 0xc)),0,
|
||||
0);
|
||||
bVar3 = open_archive_file(&PTR_vftable_00c37a10,archivePath,(void **)0x0);
|
||||
param_1 = GHIDRA_CAST<byte *>(CONCAT13(bVar3,(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(param_1)) + 0x0)))));
|
||||
if (archivePath != GHIDRA_CAST<byte *>(0x0)) {
|
||||
operator_delete(archivePath,1);
|
||||
bVar3 = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(param_1)) + 0x3)));
|
||||
}
|
||||
if (bVar3 != 0) {
|
||||
iVar1 = *GHIDRA_CAST<int *>((fileSystem + 8));
|
||||
*param_2 = 1;
|
||||
ExceptionList = local_10;
|
||||
return *GHIDRA_CAST<undefined4 *>((iVar1 + mountIndex * 4));
|
||||
}
|
||||
in_ECX = fileSystem;
|
||||
}
|
||||
iVar1 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((in_ECX + 8)) + mountIndex * 4));
|
||||
param_1 = GHIDRA_CAST<byte *>(KAGE_Filesys_FileManager)::GetPrimaryFilePathHash(normalizedPath);
|
||||
_Find_lower_bound<>(hashIter,¶m_1);
|
||||
if (((*GHIDRA_CAST<char *>((hashNode + 0xd)) == '\0') && (*GHIDRA_CAST<byte **>((hashNode + 0x10)) <= param_1)) &&
|
||||
(hashNode != *GHIDRA_CAST<int *>((iVar1 + 4)))) {
|
||||
entry = map_find_value((void *)(iVar1 + 4),GHIDRA_UINT(¶m_1));
|
||||
if (*entry != 0) {
|
||||
if (normalizedPath != GHIDRA_CAST<byte *>(0x0)) {
|
||||
local_8 = 0;
|
||||
tracked_alloc(1,normalizedPath,0);
|
||||
}
|
||||
*param_2 = 0;
|
||||
ExceptionList = local_10;
|
||||
return *GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((fileSystem + 8)) + mountIndex * 4));
|
||||
}
|
||||
}
|
||||
mountIndex = mountIndex + -1;
|
||||
if (mountIndex < 0) break;
|
||||
in_ECX = fileSystem;
|
||||
}
|
||||
}
|
||||
if (normalizedPath != GHIDRA_CAST<byte *>(0x0)) {
|
||||
if (g_mainHeap == (void *)0x0) {
|
||||
allocatedBytes = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
else {
|
||||
allocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
||||
}
|
||||
blockSize = *GHIDRA_CAST<uint *>((normalizedPath + -4));
|
||||
qVar2 = *allocatedBytes;
|
||||
*GHIDRA_CAST<uint *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - blockSize;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < blockSize));
|
||||
free(normalizedPath + -4);
|
||||
}
|
||||
ExceptionList = local_10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 00a17180
|
||||
byte * FileSystem::ResolvePath(byte *path)
|
||||
{
|
||||
byte isExists;
|
||||
byte *pbVar1;
|
||||
int mount;
|
||||
byte *pbVar2;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
undefined4 local_8;
|
||||
|
||||
pbVar1 = path;
|
||||
local_8 = 0xffffffff;
|
||||
puStack_c = &LAB_00b10fc0;
|
||||
local_10 = ExceptionList;
|
||||
ExceptionList = &local_10;
|
||||
if (path != GHIDRA_CAST<byte *>(0x0)) {
|
||||
pbVar2 = path;
|
||||
do {
|
||||
isExists = *pbVar2;
|
||||
pbVar2 = pbVar2 + 1;
|
||||
} while (isExists != 0);
|
||||
if (((2 < GHIDRA_UINT((GHIDRA_INT(pbVar2) - GHIDRA_INT((path + 1))))) && (path[1] == 0x3a)) &&
|
||||
((path[2] == 0x5c || (path[2] == 0x2f)))) {
|
||||
pbVar1 = path_join(path,GHIDRA_CAST<byte *>(0x0),0,0);
|
||||
isExists = file_exists(pbVar1);
|
||||
if ((isExists == 0) && (pbVar1 != GHIDRA_CAST<byte *>(0x0))) {
|
||||
local_8 = 0;
|
||||
tracked_alloc(1,pbVar1,0);
|
||||
pbVar1 = GHIDRA_CAST<byte *>(0x0);
|
||||
}
|
||||
ExceptionList = local_10;
|
||||
return pbVar1;
|
||||
}
|
||||
}
|
||||
path = GHIDRA_CAST<byte *>((GHIDRA_UINT(path) & 0xffffff));
|
||||
mount = find_mount(pbVar1,GHIDRA_INT(&path) + 3);
|
||||
if (mount == 0) {
|
||||
ExceptionList = local_10;
|
||||
return GHIDRA_CAST<byte *>(0x0);
|
||||
}
|
||||
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(path)) + 0x3))) != '\0') {
|
||||
pbVar1 = path_join(pbVar1,*GHIDRA_CAST<byte **>((mount + 0xc)),0,0);
|
||||
ExceptionList = local_10;
|
||||
return pbVar1;
|
||||
}
|
||||
pbVar1 = path_join(pbVar1,GHIDRA_CAST<byte *>(0x0),0,0);
|
||||
pbVar2 = GHIDRA_CAST<byte *>(FUN_00a68790(pbVar1));
|
||||
if (pbVar1 != GHIDRA_CAST<byte *>(0x0)) {
|
||||
local_8 = 1;
|
||||
tracked_alloc(1,pbVar1,0);
|
||||
local_8 = 0xffffffff;
|
||||
}
|
||||
pbVar1 = path_join(pbVar2,*GHIDRA_CAST<byte **>((mount + 0xc)),0,0);
|
||||
ExceptionList = local_10;
|
||||
return pbVar1;
|
||||
}
|
||||
|
||||
// 00a178d0
|
||||
void * FileSystem::Open(byte *path, int *outResolvedPath)
|
||||
{
|
||||
byte *resolvedPath;
|
||||
void *this_00;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
int *local_8;
|
||||
|
||||
resolvedPath = path;
|
||||
local_8 = GHIDRA_CAST<int *>(0xffffffff);
|
||||
puStack_c = &LAB_00af0b60;
|
||||
local_10 = ExceptionList;
|
||||
if ((path == GHIDRA_CAST<byte *>(0x0)) || (*path == 0)) {
|
||||
return (void *)0x0;
|
||||
}
|
||||
path = GHIDRA_CAST<byte *>(0x0);
|
||||
ExceptionList = &local_10;
|
||||
resolvedPath = ResolvePath(resolvedPath);
|
||||
open_archive_file(this,resolvedPath,&path);
|
||||
if (path == GHIDRA_CAST<byte *>(0x0)) {
|
||||
open_disk_file(this_00,resolvedPath,&path);
|
||||
if (outResolvedPath == GHIDRA_CAST<int *>(0x0)) {
|
||||
if (resolvedPath == GHIDRA_CAST<byte *>(0x0)) {
|
||||
ExceptionList = local_10;
|
||||
return path;
|
||||
}
|
||||
local_8 = GHIDRA_CAST<int *>(0x1);
|
||||
LAB_00a1795c:
|
||||
tracked_alloc(1,resolvedPath,0);
|
||||
ExceptionList = local_10;
|
||||
return path;
|
||||
}
|
||||
}
|
||||
else if (outResolvedPath == GHIDRA_CAST<int *>(0x0)) {
|
||||
if (resolvedPath == GHIDRA_CAST<byte *>(0x0)) {
|
||||
ExceptionList = local_10;
|
||||
return path;
|
||||
}
|
||||
local_8 = outResolvedPath;
|
||||
goto LAB_00a1795c;
|
||||
}
|
||||
*outResolvedPath = GHIDRA_INT(resolvedPath);
|
||||
ExceptionList = local_10;
|
||||
return path;
|
||||
}
|
||||
|
||||
// 00a17ea0
|
||||
byte FileSystem::open_disk_file(byte *path, void **outFile)
|
||||
{
|
||||
byte isExisting;
|
||||
int *this_00;
|
||||
|
||||
if ((path == GHIDRA_CAST<byte *>(0x0)) || (*path == 0)) {
|
||||
return 0;
|
||||
}
|
||||
if (outFile == (void **)0x0) {
|
||||
isExisting = file_exists(path);
|
||||
return isExisting;
|
||||
}
|
||||
this_00 = operator_new(0x10);
|
||||
if (this_00 == GHIDRA_CAST<int *>(0x0)) {
|
||||
this_00 = GHIDRA_CAST<int *>(0x0);
|
||||
}
|
||||
else {
|
||||
this_00[1] = 2;
|
||||
this_00[2] = 0;
|
||||
*this_00 = GHIDRA_INT(KAGE)::Filesys::File::vftable;
|
||||
this_00[3] = 0;
|
||||
}
|
||||
if (*(code **)(*this_00 + 0x24) == KAGE::Filesys::File::open) {
|
||||
isExisting = (GHIDRA_CAST<KAGE::Filesys::File *>((this_00)))->KAGE::Filesys::File::open(path);
|
||||
}
|
||||
else {
|
||||
isExisting = (**(code **)(*this_00 + 0x24))();
|
||||
}
|
||||
if (isExisting == 0) {
|
||||
(**(code **)*this_00)(1);
|
||||
this_00 = GHIDRA_CAST<int *>(0x0);
|
||||
}
|
||||
*outFile = this_00;
|
||||
return this_00 != GHIDRA_CAST<int *>(0x0);
|
||||
}
|
||||
|
||||
// 00a17f40
|
||||
byte FileSystem::open_archive_file(byte *path, void **outFile)
|
||||
{
|
||||
uint uVar1;
|
||||
uint pathHash;
|
||||
int secondaryHash;
|
||||
void *archiveFile;
|
||||
undefined4 extraout_ECX;
|
||||
uint probeCount;
|
||||
uint slot;
|
||||
int iVar2;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
undefined4 local_8;
|
||||
|
||||
local_8 = 0xffffffff;
|
||||
puStack_c = &LAB_00b11067;
|
||||
local_10 = ExceptionList;
|
||||
uVar1 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
||||
ExceptionList = &local_10;
|
||||
if ((path != GHIDRA_CAST<byte *>(0x0)) && (*path != 0)) {
|
||||
pathHash = KAGE_Filesys_FileManager::GetPrimaryFilePathHash(path);
|
||||
slot = pathHash & 0x7fff;
|
||||
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + slot * 4 + 0x108));
|
||||
if (iVar2 != 0) {
|
||||
secondaryHash = FUN_00a15ab0(extraout_ECX,uVar1);
|
||||
uVar1 = 0;
|
||||
do {
|
||||
if (((*GHIDRA_CAST<uint *>((iVar2 + 4)) == pathHash) &&
|
||||
(probeCount = uVar1, *GHIDRA_CAST<int *>((iVar2 + 8)) == secondaryHash)) ||
|
||||
(probeCount = uVar1 + 1, 0x7fff < uVar1)) break;
|
||||
slot = slot + 1 & 0x7fff;
|
||||
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + slot * 4 + 0x108));
|
||||
uVar1 = probeCount;
|
||||
} while (iVar2 != 0);
|
||||
if ((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + slot * 4 + 0x108)) != 0) && (probeCount < 0x8000)) {
|
||||
if (outFile != (void **)0x0) {
|
||||
archiveFile = operator_new(0xc2c);
|
||||
local_8 = 0;
|
||||
if (archiveFile != (void *)0x0) {
|
||||
archiveFile = (void *)FUN_00a68a50(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + slot * 4 + 0x108)));
|
||||
*outFile = archiveFile;
|
||||
ExceptionList = local_10;
|
||||
return 1;
|
||||
}
|
||||
*outFile = (void *)0x0;
|
||||
}
|
||||
ExceptionList = local_10;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
ExceptionList = local_10;
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user