--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>
333 lines
10 KiB
C++
333 lines
10 KiB
C++
#include "classes.h"
|
|
|
|
// 0041d670
|
|
uint8_t AfterbirthPersistentGameData::check_header(void *stream)
|
|
{
|
|
char isEof;
|
|
uint32_t uVar1;
|
|
int *expectedHeader;
|
|
int *headerPtr;
|
|
void *data;
|
|
uint32_t uVar2;
|
|
bool bVar3;
|
|
uint32_t settingValue;
|
|
uint32_t cutsceneValue;
|
|
uint32_t counter3Value;
|
|
uint32_t counterValue;
|
|
uint32_t storedChecksum;
|
|
int sectionId;
|
|
int sectionCount;
|
|
char specialSeedByte;
|
|
char challengeByte;
|
|
char bossByte;
|
|
char minibossByte;
|
|
char collectibleByte;
|
|
char achievementByte;
|
|
uint32_t sectionSize;
|
|
void *saveData;
|
|
uint32_t entryCount;
|
|
int local_1c [4];
|
|
uint32_t local_c;
|
|
uint8_t auStack_8 [4];
|
|
|
|
local_c = __security_cookie ^ GHIDRA_UINT((auStack_8 + 4));
|
|
saveData = this;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(local_1c,1,0x10);
|
|
expectedHeader = &DAT_00b1b98c;
|
|
headerPtr = local_1c;
|
|
uVar2 = 0xc;
|
|
do {
|
|
if (*expectedHeader != *headerPtr) {
|
|
expectedHeader = &DAT_00b1b9a0;
|
|
headerPtr = local_1c;
|
|
uVar2 = 0xc;
|
|
goto LAB_0041d6d1;
|
|
}
|
|
expectedHeader = expectedHeader + 1;
|
|
headerPtr = headerPtr + 1;
|
|
bVar3 = 3 < uVar2;
|
|
uVar2 = uVar2 - 4;
|
|
} while (bVar3);
|
|
uVar2 = 6;
|
|
sectionCount = 9;
|
|
goto LAB_0041d717;
|
|
LAB_0041d6d1:
|
|
if (*expectedHeader == *headerPtr) goto code_r0x0041d6d7;
|
|
expectedHeader = &DAT_00b1b9b4;
|
|
headerPtr = local_1c;
|
|
uVar2 = 0xc;
|
|
do {
|
|
if (*expectedHeader != *headerPtr) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("AfterbirthPersistentGameData wrong file header (%.16s)\n"));
|
|
return 0;
|
|
}
|
|
expectedHeader = expectedHeader + 1;
|
|
headerPtr = headerPtr + 1;
|
|
bVar3 = 3 < uVar2;
|
|
uVar2 = uVar2 - 4;
|
|
} while (bVar3);
|
|
uVar2 = 8;
|
|
goto LAB_0041d710;
|
|
code_r0x0041d6d7:
|
|
expectedHeader = expectedHeader + 1;
|
|
headerPtr = headerPtr + 1;
|
|
bVar3 = uVar2 < 4;
|
|
uVar2 = uVar2 - 4;
|
|
if (bVar3) goto code_r0x0041d6e2;
|
|
goto LAB_0041d6d1;
|
|
code_r0x0041d6e2:
|
|
uVar2 = 7;
|
|
LAB_0041d710:
|
|
sectionCount = 10;
|
|
LAB_0041d717:
|
|
uVar1 = checksum_stream(stream,0x10,4);
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0xc))(0xfffffffc,2);
|
|
storedChecksum = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&storedChecksum,4,1);
|
|
if ((7 < uVar2) && (storedChecksum != uVar1)) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("[warn] AfterbirthPersistentGameData checksum invalid!\n"));
|
|
return 0;
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0xc))(0x10,0);
|
|
data = saveData;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(GHIDRA_INT(saveData) + 0x6dc,4,1);
|
|
sectionId = 0;
|
|
isEof = (**(code **)(*GHIDRA_CAST<int *>(stream) + 0x10))();
|
|
joined_r0x0041d798:
|
|
if (((isEof != '\0') || (sectionId < 0)) || (sectionCount <= sectionId)) {
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(GHIDRA_INT(data) + 0x6e0,4,1);
|
|
return 1;
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(§ionId,4,1);
|
|
sectionSize = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(§ionSize,4,1);
|
|
if (sectionSize == 0) goto switchD_0041d7f3_default;
|
|
switch(sectionId) {
|
|
case 1:
|
|
entryCount = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&entryCount,4,1);
|
|
bVar3 = entryCount == 0x115;
|
|
if (!bVar3) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Different number of achievements %d/%d\n"));
|
|
bVar3 = entryCount == 0x115;
|
|
}
|
|
if (0x114 < entryCount && !bVar3) {
|
|
entryCount = 0x115;
|
|
}
|
|
uVar2 = 0;
|
|
if (entryCount != 0) {
|
|
do {
|
|
if (sectionSize <= uVar2) break;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&achievementByte,1,1);
|
|
*GHIDRA_CAST<bool *>((GHIDRA_CAST<char *>(data) + uVar2 + 0x38)) = '\0' < achievementByte;
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < entryCount);
|
|
}
|
|
break;
|
|
case 2:
|
|
entryCount = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&entryCount,4,1);
|
|
bVar3 = entryCount == 0xa2;
|
|
if (!bVar3) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Different number of counters %d/%d\n"));
|
|
bVar3 = entryCount == 0xa2;
|
|
}
|
|
if (0xa1 < entryCount && !bVar3) {
|
|
entryCount = 0xa2;
|
|
}
|
|
uVar2 = 0;
|
|
if (entryCount != 0) {
|
|
uVar1 = 0;
|
|
do {
|
|
if (sectionSize <= uVar1) goto LAB_0041dd41;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&counterValue,4,1);
|
|
uVar2 = uVar2 + 1;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(saveData) + uVar1 + 0x150)) = counterValue;
|
|
uVar1 = uVar1 + 4;
|
|
} while (uVar2 < entryCount);
|
|
goto LAB_0041d8fe;
|
|
}
|
|
LAB_0041dd49:
|
|
data = saveData;
|
|
break;
|
|
case 3:
|
|
entryCount = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&entryCount,4,1);
|
|
bVar3 = entryCount == 0xc;
|
|
if (!bVar3) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Different number of counters %d/%d\n"));
|
|
bVar3 = entryCount == 0xc;
|
|
}
|
|
if (0xb < entryCount && !bVar3) {
|
|
entryCount = 0xc;
|
|
}
|
|
uVar2 = 0;
|
|
if (entryCount == 0) goto LAB_0041dd49;
|
|
uVar1 = 0;
|
|
do {
|
|
if (sectionSize <= uVar1) goto LAB_0041dd41;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&counter3Value,4,1);
|
|
uVar2 = uVar2 + 1;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(saveData) + uVar1 + 0x594)) = counter3Value;
|
|
uVar1 = uVar1 + 4;
|
|
} while (uVar2 < entryCount);
|
|
goto LAB_0041d8fe;
|
|
case 4:
|
|
entryCount = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&entryCount,4,1);
|
|
bVar3 = entryCount == 0x1ba;
|
|
if (!bVar3) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Different number of collectibles in collection %d/%d\n"));
|
|
bVar3 = entryCount == 0x1ba;
|
|
}
|
|
if (0x1b9 < entryCount && !bVar3) {
|
|
entryCount = 0x1ba;
|
|
}
|
|
uVar2 = 0;
|
|
if (entryCount != 0) {
|
|
do {
|
|
if (sectionSize <= uVar2) break;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&collectibleByte,1,1);
|
|
*GHIDRA_CAST<bool *>((GHIDRA_CAST<char *>(data) + uVar2 + 0x3d8)) = '\0' < collectibleByte;
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < entryCount);
|
|
}
|
|
break;
|
|
case 5:
|
|
entryCount = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&entryCount,4,1);
|
|
bVar3 = entryCount == 7;
|
|
if (!bVar3) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Different number of minibosses %d/%d\n"));
|
|
bVar3 = entryCount == 7;
|
|
}
|
|
if (6 < entryCount && !bVar3) {
|
|
entryCount = 7;
|
|
}
|
|
uVar2 = 0;
|
|
if (entryCount != 0) {
|
|
do {
|
|
if (sectionSize <= uVar2) break;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&minibossByte,1,1);
|
|
*GHIDRA_CAST<bool *>((GHIDRA_CAST<char *>(data) + uVar2 + 0x5c4)) = '\0' < minibossByte;
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < entryCount);
|
|
}
|
|
break;
|
|
case 6:
|
|
entryCount = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&entryCount,4,1);
|
|
bVar3 = entryCount == 0x43;
|
|
if (!bVar3) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Different number of minibosses %d/%d\n"));
|
|
bVar3 = entryCount == 0x43;
|
|
}
|
|
if (0x42 < entryCount && !bVar3) {
|
|
entryCount = 0x43;
|
|
}
|
|
uVar2 = 0;
|
|
if (entryCount != 0) {
|
|
do {
|
|
if (sectionSize <= uVar2) break;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&bossByte,1,1);
|
|
*GHIDRA_CAST<bool *>((GHIDRA_CAST<char *>(data) + uVar2 + 0x5cb)) = '\0' < bossByte;
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < entryCount);
|
|
}
|
|
break;
|
|
case 7:
|
|
entryCount = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&entryCount,4,1);
|
|
bVar3 = entryCount == 0x1f;
|
|
if (!bVar3) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Different number of challenges %d/%d\n"));
|
|
bVar3 = entryCount == 0x1f;
|
|
}
|
|
if (0x1e < entryCount && !bVar3) {
|
|
entryCount = 0x1f;
|
|
}
|
|
uVar2 = 0;
|
|
if (entryCount != 0) {
|
|
do {
|
|
if (sectionSize <= uVar2) break;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&challengeByte,1,1);
|
|
*GHIDRA_CAST<bool *>((GHIDRA_CAST<char *>(data) + uVar2 + 0x60e)) = '\0' < challengeByte;
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < entryCount);
|
|
}
|
|
break;
|
|
case 8:
|
|
entryCount = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&entryCount,4,1);
|
|
bVar3 = entryCount == 0x16;
|
|
if (!bVar3) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Different number of cutscenes %d/%d\n"));
|
|
bVar3 = entryCount == 0x16;
|
|
}
|
|
if (0x15 < entryCount && !bVar3) {
|
|
entryCount = 0x16;
|
|
}
|
|
uVar2 = 0;
|
|
if (entryCount == 0) goto LAB_0041dd49;
|
|
uVar1 = 0;
|
|
do {
|
|
if (sectionSize <= uVar1) goto LAB_0041dd41;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&cutsceneValue,4,1);
|
|
uVar2 = uVar2 + 1;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(saveData) + uVar1 + 0x630)) = cutsceneValue;
|
|
uVar1 = uVar1 + 4;
|
|
} while (uVar2 < entryCount);
|
|
goto LAB_0041d8fe;
|
|
case 9:
|
|
entryCount = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&entryCount,4,1);
|
|
bVar3 = entryCount == 1;
|
|
if (!bVar3) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Different number of settings %d/%d\n"));
|
|
bVar3 = entryCount == 1;
|
|
}
|
|
if (entryCount != 0 && !bVar3) {
|
|
entryCount = 1;
|
|
}
|
|
uVar2 = 0;
|
|
if (entryCount == 0) goto LAB_0041dd49;
|
|
uVar1 = 0;
|
|
do {
|
|
if (sectionSize <= uVar1) goto LAB_0041dd41;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&settingValue,4,1);
|
|
uVar2 = uVar2 + 1;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(saveData) + uVar1 + 0x688)) = settingValue;
|
|
uVar1 = uVar1 + 4;
|
|
} while (uVar2 < entryCount);
|
|
LAB_0041d8fe:
|
|
data = saveData;
|
|
break;
|
|
case 10:
|
|
entryCount = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&entryCount,4,1);
|
|
bVar3 = entryCount == 0x4d;
|
|
if (!bVar3) {
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("Different number of special seeds %d/%d\n"));
|
|
bVar3 = entryCount == 0x4d;
|
|
}
|
|
if (0x4c < entryCount && !bVar3) {
|
|
entryCount = 0x4d;
|
|
}
|
|
uVar2 = 0;
|
|
if (entryCount != 0) {
|
|
do {
|
|
if (sectionSize <= uVar2) break;
|
|
(**(code **)(*GHIDRA_CAST<int *>(stream) + 0x14))(&specialSeedByte,1,1);
|
|
*GHIDRA_CAST<bool *>((GHIDRA_CAST<char *>(data) + uVar2 + 0x68c)) = '\0' < specialSeedByte;
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < entryCount);
|
|
}
|
|
}
|
|
goto switchD_0041d7f3_default;
|
|
LAB_0041dd41:
|
|
data = saveData;
|
|
switchD_0041d7f3_default:
|
|
isEof = (**(code **)(*GHIDRA_CAST<int *>(stream) + 0x10))();
|
|
goto joined_r0x0041d798;
|
|
}
|