Files
isaac-port/generated-src/file_system.cpp
T
shweetandClaude Opus 5.5 9d4d4f5c64 Build 29: zero-length placeholder structs, generated-src with standard types
--check: 938/3256 method bodies compile for x86_64 (28.8%), 32-bit layout asserts hold; boot path 3/626 curated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:41:34 -05:00

598 lines
21 KiB
C++

#include "classes.h"
// 00a16060
void * FileSystem::GetMountPrefixes(void *outPrefixes)
{
int mountIndex;
uint32_t prefix;
uint32_t local_14;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
int mount;
uint32_t *prefixesEnd;
local_10 = ExceptionList;
puStack_c = &LAB_00b10e6e;
ExceptionList = &local_10;
*GHIDRA_CAST<uint32_t *>(outPrefixes) = 0;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(outPrefixes) + 4)) = 0;
*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((mount + 0xc));
prefixesEnd = *GHIDRA_CAST<uint32_t **>((GHIDRA_CAST<char *>(outPrefixes) + 4));
if (prefixesEnd == *GHIDRA_CAST<uint32_t **>((GHIDRA_CAST<char *>(outPrefixes) + 8))) {
msvc::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()
{
uint8_t isOpened;
char isMatch;
uint32_t uVar1;
int *piVar2;
uint8_t *pbVar3;
int bytesRead;
int iVar4;
uint32_t *puVar5;
uint64_t *allocCounter;
uint32_t i;
void *pvVar6;
code *freeFn;
int *piVar7;
int *piVar8;
uint8_t *mountPath;
uint32_t local_3c;
uint32_t *mountPointMem;
uint8_t *local_34;
void *self;
uint32_t *local_2c;
uint32_t *entryLength;
int nameLength;
uint8_t *local_20;
void *entries;
uint32_t entryCount;
int *file;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
uint64_t allocatedBytes;
uint32_t blockSize;
uint32_t *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<uint8_t *>("kage_mount_points.dat"),GHIDRA_CAST<int *>(0x0));
file = piVar2;
if (piVar2 == GHIDRA_CAST<int *>(0x0)) {
piVar7 = piVar2;
piVar8 = piVar2;
pbVar3 = GHIDRA_CAST<uint8_t *>((**(code **)(*GHIDRA_CAST<int *>(this) + 0x10))(0,0,uVar1));
pbVar3 = path_join(GHIDRA_CAST<uint8_t *>("kage_mount_points.dat"),pbVar3,(uint8_t)piVar7,(uint8_t)piVar8);
if ((pbVar3 == GHIDRA_CAST<uint8_t *>(0x0)) || (*pbVar3 == 0)) {
file = piVar2;
if (pbVar3 == GHIDRA_CAST<uint8_t *>(0x0)) {
ExceptionList = local_10;
return;
}
}
else {
local_34 = operator_new(0x10);
if (local_34 == GHIDRA_CAST<uint8_t *>(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<uint8_t ***>(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<uint8_t *>(0x0);
(**(code **)(*piVar2 + 0x14))(&local_20,4,1);
local_34 = local_20;
do {
if (local_34 == GHIDRA_CAST<uint8_t *>(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(((uint64_t)entryCount * 4 >> 0x20)) != 0)) |
GHIDRA_UINT(((uint64_t)entryCount * 4)));
i = 0;
if (uVar1 != 0) {
do {
pvVar6 = (void *)0x0;
entryLength = GHIDRA_CAST<uint32_t *>(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<uint32_t *>((**(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<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 4;
mountPointMem = puVar5;
if (puVar5 == GHIDRA_CAST<uint32_t *>(0x0)) {
local_2c = GHIDRA_CAST<uint32_t *>(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<uint16_t *>((GHIDRA_CAST<char *>(pvVar6) + 0xc)) = 0x101;
*mapTree = pvVar6;
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 5;
*puVar5 = KAGE::Filesys::ContentManagerBase::ContentMountPoint::vftable;
FUN_00a15b90(&mountPath);
pvVar6 = entries;
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 6;
FUN_00a68590(entries,entryCount);
local_2c = puVar5;
}
local_8 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),3);
puVar5 = *GHIDRA_CAST<uint32_t **>((GHIDRA_CAST<char *>(self) + 0x18));
if (puVar5 == *GHIDRA_CAST<uint32_t **>((GHIDRA_CAST<char *>(self) + 0x1c))) {
msvc::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<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
blockSize = *GHIDRA_CAST<uint32_t *>((iVar4 + -4));
allocatedBytes = *allocCounter;
*GHIDRA_CAST<uint32_t *>(allocCounter) = GHIDRA_UINT(*allocCounter) - blockSize;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < blockSize));
free((void *)(iVar4 + -4));
*GHIDRA_CAST<uint32_t *>((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<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
uVar1 = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(pvVar6) + -4));
allocatedBytes = *allocCounter;
*GHIDRA_CAST<uint32_t *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar1;
freeFn = free_exref;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < uVar1));
free((void *)(GHIDRA_INT(pvVar6) + -4));
}
local_8 = 0xffffffff;
if (mountPath != GHIDRA_CAST<uint8_t *>(0x0)) {
if (g_mainHeap == (void *)0x0) {
allocCounter = &g_allocatedBytesNoHeap;
}
else {
allocCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
uVar1 = *GHIDRA_CAST<uint32_t *>((mountPath + -4));
allocatedBytes = *allocCounter;
*GHIDRA_CAST<uint32_t *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar1;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < uVar1));
(*freeFn)(mountPath + -4);
mountPath = GHIDRA_CAST<uint8_t *>(0x0);
}
local_8 = 0xffffffff;
local_3c = 0xffffffff;
if (local_20 != GHIDRA_CAST<uint8_t *>(0x0)) {
if (g_mainHeap == (void *)0x0) {
allocCounter = &g_allocatedBytesNoHeap;
}
else {
allocCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
uVar1 = *GHIDRA_CAST<uint32_t *>((local_20 + -4));
allocatedBytes = *allocCounter;
*GHIDRA_CAST<uint32_t *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar1;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
*GHIDRA_CAST<uint32_t *>((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<uint8_t *>(0x0)) {
local_8 = 1;
tracked_alloc(1,pbVar3,0);
local_8 = 0xffffffff;
}
}
local_34 = local_34 + -1;
} while( true );
}
// 00a16c60
uint32_t FileSystem::find_mount(uint8_t *param_1, uint8_t *param_2)
{
int iVar1;
uint64_t qVar2;
uint8_t bVar3;
uint8_t *normalizedPath;
uint8_t *archivePath;
int *entry;
int in_ECX;
uint64_t *allocatedBytes;
int mountIndex;
uint8_t hashIter [8];
int hashNode;
int fileSystem;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
uint32_t blockSize;
local_8 = 0xffffffff;
puStack_c = &LAB_00b10fa0;
local_10 = ExceptionList;
ExceptionList = &local_10;
fileSystem = in_ECX;
normalizedPath = path_join(param_1,GHIDRA_CAST<uint8_t *>(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<uint8_t **>((*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<uint8_t *>(CONCAT13(bVar3,(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(param_1)) + 0x0)))));
if (archivePath != GHIDRA_CAST<uint8_t *>(0x0)) {
operator_delete(archivePath,1);
bVar3 = (*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(param_1)) + 0x3)));
}
if (bVar3 != 0) {
iVar1 = *GHIDRA_CAST<int *>((fileSystem + 8));
*param_2 = 1;
ExceptionList = local_10;
return *GHIDRA_CAST<uint32_t *>((iVar1 + mountIndex * 4));
}
in_ECX = fileSystem;
}
iVar1 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((in_ECX + 8)) + mountIndex * 4));
param_1 = GHIDRA_CAST<uint8_t *>(KAGE_Filesys_FileManager)::GetPrimaryFilePathHash(normalizedPath);
_Find_lower_bound<>(hashIter,&param_1);
if (((*GHIDRA_CAST<char *>((hashNode + 0xd)) == '\0') && (*GHIDRA_CAST<uint8_t **>((hashNode + 0x10)) <= param_1)) &&
(hashNode != *GHIDRA_CAST<int *>((iVar1 + 4)))) {
entry = map_find_value((void *)(iVar1 + 4),GHIDRA_UINT(&param_1));
if (*entry != 0) {
if (normalizedPath != GHIDRA_CAST<uint8_t *>(0x0)) {
local_8 = 0;
tracked_alloc(1,normalizedPath,0);
}
*param_2 = 0;
ExceptionList = local_10;
return *GHIDRA_CAST<uint32_t *>((*GHIDRA_CAST<int *>((fileSystem + 8)) + mountIndex * 4));
}
}
mountIndex = mountIndex + -1;
if (mountIndex < 0) break;
in_ECX = fileSystem;
}
}
if (normalizedPath != GHIDRA_CAST<uint8_t *>(0x0)) {
if (g_mainHeap == (void *)0x0) {
allocatedBytes = &g_allocatedBytesNoHeap;
}
else {
allocatedBytes = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
blockSize = *GHIDRA_CAST<uint32_t *>((normalizedPath + -4));
qVar2 = *allocatedBytes;
*GHIDRA_CAST<uint32_t *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - blockSize;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < blockSize));
free(normalizedPath + -4);
}
ExceptionList = local_10;
return 0;
}
// 00a17180
uint8_t * FileSystem::ResolvePath(uint8_t *path)
{
uint8_t isExists;
uint8_t *pbVar1;
int mount;
uint8_t *pbVar2;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
pbVar1 = path;
local_8 = 0xffffffff;
puStack_c = &LAB_00b10fc0;
local_10 = ExceptionList;
ExceptionList = &local_10;
if (path != GHIDRA_CAST<uint8_t *>(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<uint8_t *>(0x0),0,0);
isExists = file_exists(pbVar1);
if ((isExists == 0) && (pbVar1 != GHIDRA_CAST<uint8_t *>(0x0))) {
local_8 = 0;
tracked_alloc(1,pbVar1,0);
pbVar1 = GHIDRA_CAST<uint8_t *>(0x0);
}
ExceptionList = local_10;
return pbVar1;
}
}
path = GHIDRA_CAST<uint8_t *>((GHIDRA_UINT(path) & 0xffffff));
mount = find_mount(pbVar1,GHIDRA_INT(&path) + 3);
if (mount == 0) {
ExceptionList = local_10;
return GHIDRA_CAST<uint8_t *>(0x0);
}
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(path)) + 0x3))) != '\0') {
pbVar1 = path_join(pbVar1,*GHIDRA_CAST<uint8_t **>((mount + 0xc)),0,0);
ExceptionList = local_10;
return pbVar1;
}
pbVar1 = path_join(pbVar1,GHIDRA_CAST<uint8_t *>(0x0),0,0);
pbVar2 = GHIDRA_CAST<uint8_t *>(FUN_00a68790(pbVar1));
if (pbVar1 != GHIDRA_CAST<uint8_t *>(0x0)) {
local_8 = 1;
tracked_alloc(1,pbVar1,0);
local_8 = 0xffffffff;
}
pbVar1 = path_join(pbVar2,*GHIDRA_CAST<uint8_t **>((mount + 0xc)),0,0);
ExceptionList = local_10;
return pbVar1;
}
// 00a178d0
void * FileSystem::Open(uint8_t *path, int *outResolvedPath)
{
uint8_t *resolvedPath;
void *this_00;
void *local_10;
uint8_t *puStack_c;
int *local_8;
resolvedPath = path;
local_8 = GHIDRA_CAST<int *>(0xffffffff);
puStack_c = &LAB_00af0b60;
local_10 = ExceptionList;
if ((path == GHIDRA_CAST<uint8_t *>(0x0)) || (*path == 0)) {
return (void *)0x0;
}
path = GHIDRA_CAST<uint8_t *>(0x0);
ExceptionList = &local_10;
resolvedPath = ResolvePath(resolvedPath);
open_archive_file(this,resolvedPath,&path);
if (path == GHIDRA_CAST<uint8_t *>(0x0)) {
open_disk_file(this_00,resolvedPath,&path);
if (outResolvedPath == GHIDRA_CAST<int *>(0x0)) {
if (resolvedPath == GHIDRA_CAST<uint8_t *>(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<uint8_t *>(0x0)) {
ExceptionList = local_10;
return path;
}
local_8 = outResolvedPath;
goto LAB_00a1795c;
}
*outResolvedPath = GHIDRA_INT(resolvedPath);
ExceptionList = local_10;
return path;
}
// 00a17ea0
uint8_t FileSystem::open_disk_file(uint8_t *path, void **outFile)
{
uint8_t isExisting;
int *this_00;
if ((path == GHIDRA_CAST<uint8_t *>(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
uint8_t FileSystem::open_archive_file(uint8_t *path, void **outFile)
{
uint32_t uVar1;
uint32_t pathHash;
int secondaryHash;
void *archiveFile;
uint32_t extraout_ECX;
uint32_t probeCount;
uint32_t slot;
int iVar2;
void *local_10;
uint8_t *puStack_c;
uint32_t 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<uint8_t *>(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<uint32_t *>((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<uint32_t *>((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;
}