#include "classes.h" // 00835c90 void KeyConfigs::apply_to_device(int deviceId) { int iVar1; char cVar2; uint uVar3; int iVar4; byte *deviceNameChar; char *pcVar5; char *pcVar6; char *pcVar7; undefined4 *puVar8; char **newEntryWord; byte *configNameChar; bool isLess; uint actionOffset; int targetDevice; int *targetDeviceRef; int *local_124; int *deviceRef; uint actionId; char *newEntry [65]; uint local_14; void *local_10; undefined1 *puStack_c; char *local_8; undefined4 binding; byte ch; local_8 = GHIDRA_CAST(0xffffffff); puStack_c = &LAB_00b0235b; local_10 = ExceptionList; uVar3 = __security_cookie ^ GHIDRA_UINT((newEntry + 0x45)); ExceptionList = &local_10; local_14 = uVar3; (GHIDRA_CAST((&PTR_vftable_00c57b18)))->InputManager::get_device(&local_124,deviceId); local_8 = GHIDRA_CAST(0x0); if (local_124 != GHIDRA_CAST(0x0)) { iVar4 = __RTDynamicCast(local_124,0,&KAGE::Input::InputDeviceBase::RTTI_Type_Descriptor, &IsaacRepentancePlus::NetInputDevice::RTTI_Type_Descriptor,0,uVar3); if (iVar4 == 0) { puVar8 = *GHIDRA_CAST(this); if (puVar8 != *GHIDRA_CAST((GHIDRA_CAST(this) + 4))) { do { configNameChar = GHIDRA_CAST(*puVar8); deviceNameChar = GHIDRA_CAST((**(code **)(*local_124 + 0xc))()); do { ch = *deviceNameChar; isLess = ch < *configNameChar; if (ch != *configNameChar) { LAB_00835d40: uVar3 = -GHIDRA_UINT(isLess) | 1; goto LAB_00835d45; } if (ch == 0) break; ch = deviceNameChar[1]; isLess = ch < configNameChar[1]; if (ch != configNameChar[1]) goto LAB_00835d40; deviceNameChar = deviceNameChar + 2; configNameChar = configNameChar + 2; } while (ch != 0); uVar3 = 0; LAB_00835d45: if (uVar3 == 0) { (GHIDRA_CAST((&PTR_vftable_00c57b18)))->InputManager::get_device(&targetDevice,deviceId); local_8 = GHIDRA_CAST(CONCAT31((*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x1))),1)); if (targetDevice == 0) { local_8 = GHIDRA_CAST(CONCAT31((*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x1))),2)); if (targetDeviceRef != GHIDRA_CAST(0x0)) { cVar2 = (**(code **)(*targetDeviceRef + 0xc))(); if ((cVar2 != '\0') && (g_inputDeviceRelease != (void *)0x0)) { (*g_inputDeviceRelease)(&targetDevice); } } } else { actionId = 0; actionOffset = 0; puVar8 = puVar8 + 1; do { uVar3 = 0; do { iVar1 = targetDevice; binding = *puVar8; iVar4 = *GHIDRA_CAST((targetDevice + 0x10)); if (GHIDRA_UINT((*GHIDRA_CAST((targetDevice + 0x14)) - iVar4 >> 4)) <= actionId) { KAGE_LogMessage(0x10,GHIDRA_CAST("ActionId is out of range\n")); iVar4 = *GHIDRA_CAST((iVar1 + 0x10)); } puVar8 = puVar8 + 1; *GHIDRA_CAST((actionOffset + iVar4 + uVar3)) = binding; uVar3 = uVar3 + 4; } while (uVar3 < 8); actionId = actionId + 1; actionOffset = actionOffset + 0x10; } while (actionOffset < 0x200); local_8 = GHIDRA_CAST(CONCAT31((*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x1))),3)); if (targetDeviceRef != GHIDRA_CAST(0x0)) { cVar2 = (**(code **)(*targetDeviceRef + 0xc))(); if ((cVar2 != '\0') && (g_inputDeviceRelease != (void *)0x0)) { (*g_inputDeviceRelease)(&targetDevice); } } } goto LAB_00835f18; } puVar8 = puVar8 + 0x41; } while (puVar8 != *GHIDRA_CAST((GHIDRA_CAST(this) + 4))); } newEntryWord = newEntry; for (iVar4 = 0x40; newEntryWord = newEntryWord + 1, iVar4 != 0; iVar4 = iVar4 + -1) { *newEntryWord = GHIDRA_CAST(0xffffffff); } pcVar5 = GHIDRA_CAST((**(code **)(*local_124 + 0xc))()); pcVar7 = pcVar5 + 1; do { cVar2 = *pcVar5; pcVar5 = pcVar5 + 1; } while (cVar2 != '\0'); pcVar5 = operator_new_tracked(GHIDRA_UINT((pcVar5 + (1 - GHIDRA_INT(pcVar7))))); newEntry[0] = pcVar5; pcVar6 = GHIDRA_CAST((**(code **)(*local_124 + 0xc))()); pcVar7 = pcVar6 + 1; do { cVar2 = *pcVar6; pcVar6 = pcVar6 + 1; } while (cVar2 != '\0'); pcVar6 = pcVar6 + (1 - GHIDRA_INT(pcVar7)); pcVar7 = GHIDRA_CAST((**(code **)(*local_124 + 0xc))()); strncpy(pcVar5,pcVar7,(size_t)pcVar6); FUN_00835ba0(deviceId); puVar8 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); if (puVar8 == *GHIDRA_CAST((GHIDRA_CAST(this) + 8))) { FUN_008367e0(puVar8,newEntry); } else { newEntryWord = newEntry; for (iVar4 = 0x41; iVar4 != 0; iVar4 = iVar4 + -1) { *puVar8 = *newEntryWord; newEntryWord = newEntryWord + 1; puVar8 = puVar8 + 1; } *GHIDRA_CAST((GHIDRA_CAST(this) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0x104; } } } LAB_00835f18: local_8 = GHIDRA_CAST(0x4); if (deviceRef != GHIDRA_CAST(0x0)) { cVar2 = (**(code **)(*deviceRef + 0xc))(); if ((cVar2 != '\0') && (g_inputDeviceRelease != (void *)0x0)) { (*g_inputDeviceRelease)(&local_124); } } ExceptionList = local_10; return; }