Seven agents took over LuaEngine (the mod API registration deferred), the rest of Manager (LoadConfigs, fonts, render surfaces, Update/Render), MusicManager/SFXManager, MenuManager with the title/save/game menus, Cutscene/NightmareScene/ Backdrop, RoomConfig (src/rooms ported and retired) with ItemPool, and PersistentGameData (the original binary save format) with InfoDisplay. An integration pass moved call sites to the new APIs, declared the taken-over free functions, fixed two data.cpp crashes (an empty children array, null attribute strings), and made the generator keep a header's own name where a prototype names another address. Clean build (0 warnings with -Wall -Wextra). build/isaac runs the game's Lua scripts (without the mod API yet) and stops at reload_resource_paths. 901 functions taken over, boot path 204/615. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
657 lines
26 KiB
C++
657 lines
26 KiB
C++
#include "classes.h"
|
|
|
|
// 009015b0
|
|
NetInputDevice::NetInputDevice(void *userProfile)
|
|
{
|
|
void *historyMap = this;
|
|
void *pvVar1;
|
|
uint32_t *containerProxy;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
uint32_t *containerProxySlot;
|
|
uint32_t *historyMap;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00b082e1;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
FUN_00a1e050(__security_cookie ^ GHIDRA_INT(register0x00000010) - 4U);
|
|
*GHIDRA_CAST<uint8_t ***>(historyMap) = IsaacRepentancePlus::NetInputDevice::vftable;
|
|
*GHIDRA_CAST<uint8_t ***>((GHIDRA_CAST<char *>(historyMap) + 0x370)) = KAGE::System::UserProfileBase::vftable;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x374)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(userProfile) + 4));
|
|
*GHIDRA_CAST<uint8_t ***>((GHIDRA_CAST<char *>(historyMap) + 0x370)) = KAGE::System::UserProfile::vftable;
|
|
local_8 = 1;
|
|
KAGE::SmartPointer<InputDeviceBase>::SmartPointer(GHIDRA_INT(historyMap) + 0x378);
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 2;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x394)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x390)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x39c)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x398)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3a0)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3a4)) = 0;
|
|
pvVar1 = operator_new(0x24);
|
|
*(void **)pvVar1 = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(pvVar1) + 4) = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(pvVar1) + 8) = pvVar1;
|
|
*GHIDRA_CAST<uint16_t *>((GHIDRA_CAST<char *>(pvVar1) + 0xc)) = 0x101;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3a0)) = pvVar1;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3a8)) = 0xffff;
|
|
historyMap = GHIDRA_CAST<uint32_t *>((GHIDRA_INT(historyMap) + 0x3ac));
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 3;
|
|
*historyMap = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3b0)) = 0;
|
|
pvVar1 = operator_new(0x24);
|
|
*(void **)pvVar1 = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(pvVar1) + 4) = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(pvVar1) + 8) = pvVar1;
|
|
*GHIDRA_CAST<uint16_t *>((GHIDRA_CAST<char *>(pvVar1) + 0xc)) = 0x101;
|
|
*historyMap = pvVar1;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3b4)) = 0xffff;
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 4;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3bc)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3c0)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3c8)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3cc)) = 0;
|
|
pvVar1 = operator_new(0x10);
|
|
*(void **)pvVar1 = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(pvVar1) + 4) = pvVar1;
|
|
*(void **)(GHIDRA_CAST<char *>(historyMap) + 0x3c8) = pvVar1;
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3d4)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3d8)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3dc)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3e0)) = 0;
|
|
local_8 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),6);
|
|
containerProxySlot = GHIDRA_CAST<uint32_t *>((GHIDRA_INT(historyMap) + 0x3e4));
|
|
*containerProxySlot = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 1000)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3ec)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3f0)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3f4)) = 0;
|
|
containerProxy = operator_new(8);
|
|
containerProxy[1] = 0;
|
|
*containerProxySlot = containerProxy;
|
|
*containerProxy = containerProxySlot;
|
|
FUN_00901b70();
|
|
*GHIDRA_CAST<uint16_t *>((GHIDRA_CAST<char *>(historyMap) + 8)) = *GHIDRA_CAST<uint16_t *>((GHIDRA_CAST<char *>(historyMap) + 8)) | 1;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3b4)) = 0x3c;
|
|
if (0x3c < *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3b0))) {
|
|
do {
|
|
pvVar1 = (GHIDRA_CAST<msvc::_Tree *>((historyMap)))->msvc::_Tree::_Extract(*(void **)*historyMap);
|
|
operator_delete(pvVar1,0x24);
|
|
} while (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3b4)) < *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(historyMap) + 0x3b0)));
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 00901cb0
|
|
uint8_t NetInputDevice::is_input_ready(uint8_t param_1, int *param_2)
|
|
{
|
|
int iVar1;
|
|
char cVar2;
|
|
int *piVar3;
|
|
Entity_Player *player;
|
|
int *node;
|
|
int iVar4;
|
|
int in_ECX;
|
|
uint32_t uVar5;
|
|
Manager *pMVar6;
|
|
uint8_t isReady;
|
|
int iVar7;
|
|
uint64_t uVar8;
|
|
void *in_stack_ffffffb4;
|
|
void *deviceRefCount;
|
|
int frame;
|
|
uint32_t local_2c;
|
|
int *local_28;
|
|
uint32_t local_24;
|
|
uint8_t local_20 [4];
|
|
int *connectionRefCount;
|
|
uint64_t local_18;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
uint32_t *tail;
|
|
|
|
puStack_c = &LAB_00b083b5;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
local_8 = 0;
|
|
if ((*GHIDRA_CAST<uint8_t *>((in_ECX + 8)) & 1) == 0) {
|
|
isReady = 1;
|
|
goto LAB_00901fc3;
|
|
}
|
|
cVar2 = (**(code **)(*GHIDRA_CAST<int *>((in_ECX + 0x370)) + 0x14))
|
|
(__security_cookie ^ GHIDRA_UINT((local_20 + 0x1c)));
|
|
if (cVar2 == '\0') {
|
|
piVar3 = GHIDRA_CAST<int *>(FUN_00a29fd0(local_20,in_ECX + 0x370));
|
|
iVar4 = *piVar3;
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 1;
|
|
if (((connectionRefCount != GHIDRA_CAST<int *>(0x0)) &&
|
|
(cVar2 = (**(code **)(*connectionRefCount + 0xc))(), cVar2 != '\0')) &&
|
|
(g_connectionReleaseFn != (void *)0x0)) {
|
|
(*g_connectionReleaseFn)(local_20);
|
|
}
|
|
local_8 = (*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(GHIDRA_UINT(local_8))) + 0x1))) << 8;
|
|
if (iVar4 != 0) {
|
|
piVar3 = GHIDRA_CAST<int *>((in_ECX + 0x3c8));
|
|
local_18 = FUN_00a58670();
|
|
iVar4 = *piVar3;
|
|
if (*GHIDRA_CAST<int *>((in_ECX + 0x3cc)) == 0xfffffff) {
|
|
/* WARNING: Subroutine does not return */
|
|
msvc::_Xlength_error("list too long");
|
|
}
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 2;
|
|
local_24 = 0;
|
|
local_28 = piVar3;
|
|
node = operator_new(0x10);
|
|
*GHIDRA_CAST<uint64_t *>((node + 2)) = local_18;
|
|
local_8 = (*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(GHIDRA_UINT(local_8))) + 0x1))) << 8;
|
|
*GHIDRA_CAST<int *>((in_ECX + 0x3cc)) = *GHIDRA_CAST<int *>((in_ECX + 0x3cc)) + 1;
|
|
tail = *GHIDRA_CAST<uint32_t **>((iVar4 + 4));
|
|
*node = iVar4;
|
|
node[1] = GHIDRA_INT(tail);
|
|
*GHIDRA_CAST<int **>((iVar4 + 4)) = node;
|
|
*tail = node;
|
|
uVar5 = *GHIDRA_CAST<uint32_t *>((in_ECX + 0x3cc));
|
|
while (0x1e < uVar5) {
|
|
node = *GHIDRA_CAST<int **>(*piVar3);
|
|
iVar4 = *node;
|
|
*GHIDRA_CAST<int *>((in_ECX + 0x3cc)) = *GHIDRA_CAST<int *>((in_ECX + 0x3cc)) + -1;
|
|
*GHIDRA_CAST<int *>(node[1]) = iVar4;
|
|
*GHIDRA_CAST<int *>((iVar4 + 4)) = node[1];
|
|
operator_delete(node,0x10);
|
|
uVar5 = *GHIDRA_CAST<uint32_t *>((in_ECX + 0x3cc));
|
|
}
|
|
}
|
|
LAB_00901f19:
|
|
pMVar6 = g_manager;
|
|
}
|
|
else {
|
|
iVar4 = *GHIDRA_CAST<int *>((in_ECX + 0x3a4));
|
|
if (iVar4 == 0) {
|
|
uVar5 = *GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1])) + 0x8))));
|
|
pMVar6 = g_manager;
|
|
}
|
|
else {
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))) = *GHIDRA_CAST<uint32_t *>((in_ECX + 0x3a0));
|
|
uVar8 = FUN_009012b0();
|
|
uVar5 = *GHIDRA_CAST<int *>(uVar8) + 1;
|
|
pMVar6 = GHIDRA_CAST<Manager *>(((uint64_t)uVar8 >> 0x20));
|
|
}
|
|
local_18 = CONCAT44((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))),(uint32_t)local_18);
|
|
if (uVar5 <= GHIDRA_UINT((pMVar6[1]._previousState + *GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pMVar6[1])) + 0x8))))))) {
|
|
local_18 = CONCAT44((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))),(uint32_t)local_18);
|
|
if (g_game != GHIDRA_CAST<Game *>(0x0)) {
|
|
iVar7 = *GHIDRA_CAST<int *>((in_ECX + 0x378));
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))) = 0x3c;
|
|
if (iVar7 != 0) {
|
|
iVar1 = *GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pMVar6[1]._gamestate)) + 0x92c))));
|
|
if (iVar1 == 0x3c) {
|
|
if ((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pMVar6[1]._gamestate)) + 0x290)))) != 0) ||
|
|
(0 < *GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pMVar6[1]._gamestate)) + 0x2d8)))))) {
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))) = 0x15;
|
|
}
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pMVar6[1]._gamestate)) + 0x92c)))) = 0x3c;
|
|
iVar4 = *GHIDRA_CAST<int *>((in_ECX + 0x3a4));
|
|
iVar7 = *GHIDRA_CAST<int *>((in_ECX + 0x378));
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_18)) + 0x4))) = iVar1;
|
|
}
|
|
}
|
|
if (iVar4 == 0) {
|
|
frame = *GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pMVar6[1])) + 0x8))));
|
|
}
|
|
else {
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_18)) + 0x0))) = *GHIDRA_CAST<uint32_t *>((in_ECX + 0x3a0));
|
|
piVar3 = GHIDRA_CAST<int *>(FUN_009012b0());
|
|
frame = *piVar3 + 1;
|
|
}
|
|
local_2c = 0x7fff0000;
|
|
local_28 = GHIDRA_CAST<int *>(0x7fff7fff);
|
|
local_24 = GHIDRA_UINT(CONCAT12((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&((char)local_18)) + 0x4))),0x7fff));
|
|
if (iVar7 != 0) {
|
|
deviceRefCount = (void *)0x901dfa;
|
|
player = GHIDRA_CAST<Entity_Player *>(FUN_004253d0());
|
|
FUN_00902d60(in_ECX + 0x378);
|
|
net_input_frame_capture(&frame,player,in_stack_ffffffb4,deviceRefCount);
|
|
}
|
|
iVar4 = frame;
|
|
FUN_00901070(&frame);
|
|
FUN_00901070(&frame);
|
|
broadcast_frame_input(iVar4);
|
|
goto LAB_00901f19;
|
|
}
|
|
}
|
|
}
|
|
FUN_00901030(*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pMVar6[1])) + 0x8)))));
|
|
FUN_00901030(*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1])) + 0x8)))) + -5);
|
|
if (*GHIDRA_CAST<char *>(&g_manager[1]._persistentGameData) == '\0') {
|
|
iVar4 = 0;
|
|
}
|
|
else {
|
|
iVar4 = g_manager[1]._previousState;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((in_ECX + 0x3a4)) == 0) {
|
|
uVar5 = *GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1])) + 0x8))));
|
|
pMVar6 = g_manager;
|
|
}
|
|
else {
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_18)) + 0x0))) = *GHIDRA_CAST<uint32_t *>((in_ECX + 0x3a0));
|
|
uVar8 = FUN_009012b0();
|
|
uVar5 = *GHIDRA_CAST<int *>(uVar8) + 1;
|
|
pMVar6 = GHIDRA_CAST<Manager *>(((uint64_t)uVar8 >> 0x20));
|
|
}
|
|
if (GHIDRA_UINT((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pMVar6[1])) + 0x8)))) + iVar4)) < uVar5) {
|
|
iVar4 = FUN_00901190(*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pMVar6[1])) + 0x8)))));
|
|
if (((iVar4 != 0) &&
|
|
(((*GHIDRA_CAST<uint16_t *>((iVar4 + 4)) & 0x4000) == 0 || (*GHIDRA_CAST<int *>((in_ECX + 0x3f4)) != 0)))) &&
|
|
(iVar4 != 0)) {
|
|
isReady = 1;
|
|
goto LAB_00901fc3;
|
|
}
|
|
}
|
|
isReady = 0;
|
|
LAB_00901fc3:
|
|
local_8 = 3;
|
|
if (param_2 != GHIDRA_CAST<int *>(0x0)) {
|
|
cVar2 = (**(code **)(*param_2 + 0xc))();
|
|
if ((cVar2 != '\0') && (g_connectionReleaseFn != (void *)0x0)) {
|
|
(*g_connectionReleaseFn)(¶m_1);
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return isReady;
|
|
}
|
|
|
|
// 00902010
|
|
uint8_t NetInputDevice::ProcessInputMessage(void *message, void *messageRefCount)
|
|
{
|
|
void *pvVar1;
|
|
char isLastRef;
|
|
uint32_t uVar2;
|
|
void *pvVar3;
|
|
uint8_t isAccepted;
|
|
int iVar4;
|
|
char *format;
|
|
uint8_t **stream;
|
|
int local_64;
|
|
int local_60;
|
|
void *streamBufBegin;
|
|
void *streamBufEnd;
|
|
int streamBufCapacity;
|
|
int payload;
|
|
uint32_t local_4c;
|
|
uint32_t local_48;
|
|
uint32_t local_44;
|
|
uint8_t **streamVtable;
|
|
int checksum;
|
|
uint8_t local_38;
|
|
uint32_t local_34;
|
|
int local_30;
|
|
uint32_t inputFrame;
|
|
uint32_t local_28;
|
|
uint32_t local_24;
|
|
uint32_t local_20;
|
|
uint32_t receivedChecksum;
|
|
uint32_t readValue;
|
|
uint8_t readByte;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
|
|
puStack_c = &LAB_00b083f5;
|
|
local_10 = ExceptionList;
|
|
uVar2 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
ExceptionList = &local_10;
|
|
local_8 = 0;
|
|
if (*GHIDRA_CAST<char *>((*GHIDRA_CAST<int *>((**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(message) + 8)) + 0x14)) + 5)) != '\x01') {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Specified message is not an input message"));
|
|
}
|
|
pvVar3 = message;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(message) + 0xc)) != 1) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("This function should only be called on consolidated messages"));
|
|
}
|
|
pvVar1 = message;
|
|
iVar4 = *GHIDRA_CAST<int *>((**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(pvVar3) + 8)) + 0x18)) + -8;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(message) + 0xc)) != 1) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("This function should only be called on consolidated messages"));
|
|
}
|
|
payload = *GHIDRA_CAST<int *>((**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(pvVar1) + 8)) + 0x14)) + 8;
|
|
streamBufBegin = (void *)0x0;
|
|
streamBufCapacity = 0;
|
|
local_44 = 0;
|
|
local_48 = 0;
|
|
local_4c = 0;
|
|
streamBufEnd = (void *)0x0;
|
|
stream = KAGE::Filesys::BufferedStream::vftable;
|
|
streamVtable = KAGE::Filesys::BufferedStream::vftable;
|
|
local_8 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),1);
|
|
local_30 = 1;
|
|
checksum = 0;
|
|
local_38 = 0;
|
|
local_34 = 0xfedcba76;
|
|
receivedChecksum = 0;
|
|
local_64 = iVar4;
|
|
local_60 = iVar4;
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&receivedChecksum,4,1);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,4,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue,4,1,uVar2);
|
|
}
|
|
local_28 = readValue;
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,4,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
uVar2 = readValue;
|
|
local_24 = readValue;
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,4,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_20 = readValue;
|
|
if (uVar2 != 0) {
|
|
FUN_0090d4a0(&local_28);
|
|
}
|
|
Checksum::Update(&checksum,GHIDRA_CAST<uint8_t *>(&local_28),0xc);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,4,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
uVar2 = readValue;
|
|
inputFrame = readValue;
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,2,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_28 = CONCAT22((*GHIDRA_CAST<uint16_t *>((GHIDRA_CAST<char *>(&(local_28)) + 0x2))),(uint16_t)readValue);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,2,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_28 = CONCAT22((uint16_t)readValue,(uint16_t)local_28);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,2,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_24 = CONCAT22((*GHIDRA_CAST<uint16_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x2))),(uint16_t)readValue);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,2,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_24 = CONCAT22((uint16_t)readValue,(uint16_t)local_24);
|
|
readValue = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readValue,2,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readValue);
|
|
}
|
|
local_20 = CONCAT22((*GHIDRA_CAST<uint16_t *>((GHIDRA_CAST<char *>(&(local_20)) + 0x2))),(uint16_t)readValue);
|
|
readByte = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readByte,1,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readByte);
|
|
}
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_20)) + 0x0))) = CONCAT12(readByte,(uint16_t)local_20);
|
|
readByte = 0;
|
|
if ((code *)streamVtable[5] == memory_stream_read) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((&stream)))->KAGE::Filesys::BufferedStream::read(&readByte,1,1);
|
|
}
|
|
else {
|
|
(*(code *)streamVtable[5])(&readByte);
|
|
}
|
|
local_20 = CONCAT13(readByte,(undefined3)local_20);
|
|
Checksum::Update(&checksum,GHIDRA_CAST<uint8_t *>(&inputFrame),0x10);
|
|
if (uVar2 < *GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1])) + 0x8))))) {
|
|
format =
|
|
"NetInputDevice::ProcessInputMessage - Dropping input packet outside of match scope. Received Frame: %d, Current Frame: %d\n"
|
|
;
|
|
LAB_0090244d:
|
|
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>(format));
|
|
}
|
|
else {
|
|
iVar4 = FUN_00901190(uVar2);
|
|
if (iVar4 == 0) {
|
|
if ((local_30 == 0) && (local_38 != 0)) {
|
|
if (local_38 < 4) {
|
|
memset((void *)(GHIDRA_INT(&checksum) + GHIDRA_UINT(local_38)),0,GHIDRA_UINT((uint8_t)(4 - local_38)));
|
|
}
|
|
uVar2 = local_34 * -0x80000000 + (local_34 >> 1) + checksum;
|
|
}
|
|
else {
|
|
uVar2 = local_34;
|
|
}
|
|
if (uVar2 == receivedChecksum) {
|
|
FUN_00901070(&inputFrame);
|
|
FUN_00901070(&inputFrame);
|
|
isAccepted = 1;
|
|
goto LAB_00902459;
|
|
}
|
|
format =
|
|
"NetInputDevice::ProcessInputMessage - CHECKSUM MISMATCH! Expected: %08x, Received: %08x\n";
|
|
goto LAB_0090244d;
|
|
}
|
|
KAGE_LogMessage(1,(uint8_t *)
|
|
"NetInputDevice::ProcessInputMessage - Dropping input packet for frame we already have. Frame: %d\n"
|
|
);
|
|
}
|
|
isAccepted = 0;
|
|
LAB_00902459:
|
|
local_8 = local_8 & 0xffffff00;
|
|
streamVtable = KAGE::Filesys::StreamBase::vftable;
|
|
stream = KAGE::Filesys::BufferedStreamBase::vftable;
|
|
local_64 = 0;
|
|
local_60 = 0;
|
|
streamBufEnd = streamBufBegin;
|
|
payload = 0;
|
|
local_4c = 0;
|
|
local_48 = 0;
|
|
local_44 = 0;
|
|
if (streamBufBegin != (void *)0x0) {
|
|
uVar2 = streamBufCapacity - GHIDRA_INT(streamBufBegin);
|
|
pvVar3 = streamBufBegin;
|
|
if (0xfff < uVar2) {
|
|
pvVar3 = *(void **)(GHIDRA_CAST<char *>(streamBufBegin) + -4);
|
|
uVar2 = uVar2 + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(streamBufBegin) + (-4 - GHIDRA_INT(pvVar3))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(pvVar3,uVar2);
|
|
streamBufEnd = (void *)0x0;
|
|
streamBufCapacity = 0;
|
|
}
|
|
local_8 = 2;
|
|
if (messageRefCount != (void *)0x0) {
|
|
streamBufBegin = streamBufEnd;
|
|
isLastRef = (**(code **)(*GHIDRA_CAST<int *>(messageRefCount) + 0xc))();
|
|
if ((isLastRef != '\0') && (g_multiplayerRelease != (void *)0x0)) {
|
|
(*g_multiplayerRelease)(&message);
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return isAccepted;
|
|
}
|
|
|
|
// 00902950
|
|
void NetInputDevice::broadcast_frame_input(uint32_t param_1)
|
|
{
|
|
uint64_t uVar1;
|
|
uint8_t *data;
|
|
char cVar2;
|
|
int in_ECX;
|
|
void *this;
|
|
int extraout_ECX;
|
|
uint32_t *streamData;
|
|
uint32_t checksum;
|
|
uint32_t checksumTail;
|
|
uint32_t checksumHigh;
|
|
void *messageRefCount;
|
|
uint8_t stream [4];
|
|
void *streamSize;
|
|
uint32_t *local_74;
|
|
uint32_t *local_68;
|
|
int local_58;
|
|
int checksumState;
|
|
uint8_t local_50;
|
|
uint32_t checksumAcc;
|
|
int local_48;
|
|
uint64_t frameChecksum;
|
|
uint32_t local_3c;
|
|
uint8_t inputMessage [4];
|
|
int *inputMessageRefCount;
|
|
uint8_t *local_2c;
|
|
uint32_t tmpDword;
|
|
uint8_t tmpByte;
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
uint32_t local_14;
|
|
uint64_t *checksumEntry;
|
|
Manager *manager;
|
|
|
|
puStack_20 = inputMessage + 0x34;
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00b08455;
|
|
local_1c = ExceptionList;
|
|
ExceptionList = &local_1c;
|
|
cVar2 = (**(code **)(*GHIDRA_CAST<int *>((in_ECX + 0x370)) + 0x14))
|
|
(__security_cookie ^ GHIDRA_UINT((inputMessage + 0x28)));
|
|
if (cVar2 == '\0') {
|
|
KAGE_LogMessage(0x10,(uint8_t *)
|
|
"NetInputDevice::broadcast_frame_input should only be called on the local player"
|
|
);
|
|
}
|
|
if (*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x20)))) != 0) {
|
|
local_2c = GHIDRA_CAST<uint8_t *>((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x20)))) +
|
|
*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x1c))))));
|
|
if (*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1])) + 0x8)))) - 1U <=
|
|
**GHIDRA_CAST<uint32_t **>((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x14)))) +
|
|
(*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x18)))) - 1U &
|
|
GHIDRA_UINT((local_2c + -1))) * 4))) {
|
|
checksumEntry =
|
|
*(uint64_t **)
|
|
(*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x14)))) +
|
|
(*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(g_manager[1]._persistentGameData)) + 0x18)))) - 1U & GHIDRA_UINT((local_2c + -1))) * 4)
|
|
;
|
|
uVar1 = *checksumEntry;
|
|
checksumTail = *GHIDRA_CAST<uint32_t *>((checksumEntry + 1));
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(frameChecksum)) + 0x4))) = (uint32_t)((uint64_t)uVar1 >> 0x20);
|
|
checksumHigh = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(frameChecksum)) + 0x4)));
|
|
frameChecksum = uVar1;
|
|
goto LAB_00902a25;
|
|
}
|
|
}
|
|
checksumHigh = 0;
|
|
frameChecksum = 0;
|
|
checksumTail = 0;
|
|
LAB_00902a25:
|
|
local_3c = checksumTail;
|
|
local_2c = GHIDRA_CAST<uint8_t *>(FUN_00901190(param_1));
|
|
if (local_2c != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
(GHIDRA_CAST<KAGE::Filesys::BufferedStream *>((stream)))->KAGE::Filesys::BufferedStream::BufferedStream(0);
|
|
local_14 = 0;
|
|
local_48 = 1;
|
|
checksumState = 0;
|
|
local_50 = 0;
|
|
checksumAcc = 0xfedcba76;
|
|
tmpDword = 0;
|
|
(**(code **)(local_58 + 0x1c))(&tmpDword,4,1);
|
|
tmpDword = (uint32_t)frameChecksum;
|
|
(**(code **)(local_58 + 0x1c))(&tmpDword,4,1);
|
|
tmpDword = checksumHigh;
|
|
(**(code **)(local_58 + 0x1c))(&tmpDword,4,1);
|
|
tmpDword = checksumTail;
|
|
(**(code **)(local_58 + 0x1c))(&tmpDword,4,1);
|
|
data = local_2c;
|
|
local_2c = *GHIDRA_CAST<uint8_t **>(local_2c);
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,4,1);
|
|
local_2c = GHIDRA_CAST<uint8_t *>(GHIDRA_UINT(*GHIDRA_CAST<uint16_t *>((data + 4))));
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,2,1);
|
|
local_2c = GHIDRA_CAST<uint8_t *>(GHIDRA_UINT(*GHIDRA_CAST<uint16_t *>((data + 6))));
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,2,1);
|
|
local_2c = GHIDRA_CAST<uint8_t *>(GHIDRA_UINT(*GHIDRA_CAST<uint16_t *>((data + 8))));
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,2,1);
|
|
local_2c = GHIDRA_CAST<uint8_t *>(GHIDRA_UINT(*GHIDRA_CAST<uint16_t *>((data + 10))));
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,2,1);
|
|
local_2c = GHIDRA_CAST<uint8_t *>(GHIDRA_UINT(*GHIDRA_CAST<uint16_t *>((data + 0xc))));
|
|
(**(code **)(local_58 + 0x1c))(&local_2c,2,1);
|
|
tmpByte = data[0xe];
|
|
(**(code **)(local_58 + 0x1c))(&tmpByte,1,1);
|
|
tmpByte = data[0xf];
|
|
(**(code **)(local_58 + 0x1c))(&tmpByte,1,1);
|
|
Checksum::Update(&checksumState,GHIDRA_CAST<uint8_t *>(&frameChecksum),0xc);
|
|
Checksum::Update(this,data,0x10);
|
|
if ((local_48 == 0) && (local_50 != 0)) {
|
|
if (local_50 < 4) {
|
|
memset((void *)(extraout_ECX + GHIDRA_UINT(local_50)),0,GHIDRA_UINT((uint8_t)(4 - local_50)));
|
|
}
|
|
checksum = checksumAcc * -0x80000000 + (checksumAcc >> 1) + checksumState;
|
|
}
|
|
else {
|
|
checksum = checksumAcc;
|
|
}
|
|
streamData = local_74;
|
|
if (local_68 != GHIDRA_CAST<uint32_t *>(0x0)) {
|
|
streamData = local_68;
|
|
}
|
|
*streamData = checksum;
|
|
streamData = local_74;
|
|
if (local_68 != GHIDRA_CAST<uint32_t *>(0x0)) {
|
|
streamData = local_68;
|
|
}
|
|
if (g_multiplayerService == (void *)0x0) {
|
|
KAGE_LogMessage(0x10,(uint8_t *)
|
|
"Attempting to create a message when there is no multiplayer service\n");
|
|
}
|
|
messageRefCount = (void *)0x1;
|
|
NetConnection::send_message(g_multiplayerService,inputMessage,1,streamData,GHIDRA_UINT(streamSize),1);
|
|
manager = g_manager;
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 1;
|
|
FUN_008ef1d0(inputMessage);
|
|
NetplayManager::send_message
|
|
(GHIDRA_CAST<NetplayManager *>(&manager->_netplayManager),8,streamSize,messageRefCount);
|
|
local_14 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_14)) + 0x1))),2);
|
|
if (inputMessageRefCount != GHIDRA_CAST<int *>(0x0)) {
|
|
cVar2 = (**(code **)(*inputMessageRefCount + 0xc))();
|
|
if ((cVar2 != '\0') && (g_multiplayerRelease != (void *)0x0)) {
|
|
(*g_multiplayerRelease)(inputMessage);
|
|
}
|
|
}
|
|
FUN_00a58200();
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|