#include "classes.h" // 00a7d2a0 undefined1 KAGE::Sound::ManagerOpenAL::FUN_00a649b0() { char cVar1; int iVar2; void *sources; HMODULE hModule; int *in_ECX; undefined4 *sourceEntry; uint sourceOffset; WCHAR *lpFilename; char *format; DWORD nSize; undefined4 listenerOrientation; undefined4 uStack_24c; undefined1 *puStack_248; undefined4 uStack_244; undefined4 local_240; undefined4 local_23c; undefined4 contextAttribs; undefined4 uStack_234; undefined4 uStack_230; undefined4 uStack_22c; undefined4 local_228; undefined4 local_224; undefined4 local_220; WCHAR dllPath [260]; uint local_14; void *local_10; undefined1 *puStack_c; undefined4 local_8; local_8 = 0xffffffff; puStack_c = &LAB_00b1456a; local_10 = ExceptionList; local_14 = __security_cookie ^ GHIDRA_UINT((dllPath + 0x10c)); ExceptionList = &local_10; iVar2 = alcOpenDevice(0,local_14); in_ECX[0xe] = iVar2; if (iVar2 == 0) { format = "Failed to open OpenAL device\n"; } else { contextAttribs = 0x1991; uStack_234 = 0x1402; uStack_230 = 0x1990; uStack_22c = 0x1501; local_228 = 0x19ac; local_224 = 0x19ae; local_220 = 0; iVar2 = alcCreateContext(iVar2,&contextAttribs); in_ECX[0xd] = iVar2; if (iVar2 == 0) { format = "Failed to create OpenAL context\n"; } else { cVar1 = alcMakeContextCurrent(iVar2); if (cVar1 == '\0') { format = "Failed to make current OpenAL context\n"; } else { alcProcessContext(in_ECX[0xd]); sources = operator_new_tracked(0x300); if (sources == (void *)0x0) { sources = (void *)0x0; } else { iVar2 = 0x40; sourceEntry = GHIDRA_CAST((GHIDRA_INT(sources) + 8)); do { sourceEntry[-2] = 0; sourceEntry[-1] = 0; *sourceEntry = 0; iVar2 = iVar2 + -1; sourceEntry = sourceEntry + 3; } while (iVar2 != 0); } local_8 = 0xffffffff; sourceOffset = 0; in_ECX[0xf] = GHIDRA_INT(sources); do { cVar1 = (**(code **)(*in_ECX + 0x30)) (in_ECX[0xf] + sourceOffset,in_ECX[0xf] + sourceOffset + 4,1); if (cVar1 == '\0') { ExceptionList = local_10; return 0; } sourceOffset = sourceOffset + 0xc; } while (sourceOffset < 0x300); alListener3f(0x1004,0,0,0); listenerOrientation = 0; uStack_24c = 0; puStack_248 = &DAT_bf800000; uStack_244 = 0; local_240 = 0x3f800000; local_23c = 0; alListenerfv(0x100f,&listenerOrientation); cVar1 = (**(code **)(in_ECX[0x10] + 8))(FUN_00a7da80,3,0x1000); if (cVar1 != '\0') { nSize = 0x104; lpFilename = dllPath; hModule = GetModuleHandleW(L"OpenAL32.dll"); GetModuleFileNameW(hModule,lpFilename,nSize); KAGE_LogMessage(1,GHIDRA_CAST("OpenAL DLL loaded from: %ls\n")); alcGetString(in_ECX[0xe],0x1006); alGetString(0xb001); KAGE_LogMessage(1,GHIDRA_CAST("OpenAL AL_VENDOR : %s\n")); alGetString(0xb003); KAGE_LogMessage(1,GHIDRA_CAST("OpenAL AL_RENDERER : %s\n")); alGetString(0xb002); KAGE_LogMessage(1,GHIDRA_CAST("OpenAL AL_VERSION : %s\n")); KAGE_LogMessage(1,GHIDRA_CAST("OpenAL ALC_EXTENSIONS : %s\n")); (**(code **)(in_ECX[4] + 4))(); (**(code **)(in_ECX[10] + 4))(); in_ECX[1] = in_ECX[1] | 1; g_soundReleaseFn = FUN_00a2bb10; ExceptionList = local_10; return 1; } format = "Failed to start up OpenAL processing thread\n"; } } } KAGE_LogMessage(8,GHIDRA_CAST(format)); ExceptionList = local_10; return 0; }