mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-12-31 00:10:26 -06:00
319 lines
11 KiB
C++
319 lines
11 KiB
C++
#include "stdafx.h"
|
|
#include <kernel/function.h>
|
|
|
|
// TODO: Multiplatform support
|
|
void CriErrNotify1(const char* message)
|
|
{
|
|
OutputDebugStringA(message);
|
|
OutputDebugStringA("\n");
|
|
}
|
|
|
|
void CriErrNotify2(uint32_t category, const char* message)
|
|
{
|
|
OutputDebugStringA(message);
|
|
OutputDebugStringA("\n");
|
|
}
|
|
|
|
BOOL QueryPerformanceCounterImpl(LARGE_INTEGER* lpPerformanceCount)
|
|
{
|
|
BOOL result = QueryPerformanceCounter(lpPerformanceCount);
|
|
ByteSwap(lpPerformanceCount->QuadPart);
|
|
return result;
|
|
}
|
|
|
|
BOOL QueryPerformanceFrequencyImpl(LARGE_INTEGER* lpFrequency)
|
|
{
|
|
BOOL result = QueryPerformanceFrequency(lpFrequency);
|
|
ByteSwap(lpFrequency->QuadPart);
|
|
return result;
|
|
}
|
|
|
|
// https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-memorystatus
|
|
typedef struct _XMEMORYSTATUS {
|
|
XDWORD dwLength;
|
|
XDWORD dwMemoryLoad;
|
|
XDWORD dwTotalPhys;
|
|
XDWORD dwAvailPhys;
|
|
XDWORD dwTotalPageFile;
|
|
XDWORD dwAvailPageFile;
|
|
XDWORD dwTotalVirtual;
|
|
XDWORD dwAvailVirtual;
|
|
} XMEMORYSTATUS, *XLPMEMORYSTATUS;
|
|
|
|
void GlobalMemoryStatusImpl(XLPMEMORYSTATUS lpMemoryStatus)
|
|
{
|
|
lpMemoryStatus->dwLength = sizeof(XMEMORYSTATUS);
|
|
lpMemoryStatus->dwMemoryLoad = 0;
|
|
lpMemoryStatus->dwTotalPhys = 0x20000000;
|
|
lpMemoryStatus->dwAvailPhys = 0x20000000;
|
|
lpMemoryStatus->dwTotalPageFile = 0x20000000;
|
|
lpMemoryStatus->dwAvailPageFile = 0x20000000;
|
|
lpMemoryStatus->dwTotalVirtual = 0x20000000;
|
|
lpMemoryStatus->dwAvailVirtual = 0x20000000;
|
|
}
|
|
|
|
GUEST_FUNCTION_HOOK(sub_831B0ED0, memcpy);
|
|
GUEST_FUNCTION_HOOK(sub_831CCB98, memcpy);
|
|
GUEST_FUNCTION_HOOK(sub_831CEAE0, memcpy);
|
|
GUEST_FUNCTION_HOOK(sub_831CEE04, memcpy);
|
|
GUEST_FUNCTION_HOOK(sub_831CF2D0, memcpy);
|
|
GUEST_FUNCTION_HOOK(sub_831CF660, memcpy);
|
|
GUEST_FUNCTION_HOOK(sub_831B1358, memcpy);
|
|
GUEST_FUNCTION_HOOK(sub_831B5E00, memmove);
|
|
GUEST_FUNCTION_HOOK(sub_831B0BA0, memset);
|
|
GUEST_FUNCTION_HOOK(sub_831CCAA0, memset);
|
|
|
|
GUEST_FUNCTION_HOOK(sub_82BD4CA8, OutputDebugStringA);
|
|
|
|
#ifdef _DEBUG
|
|
GUEST_FUNCTION_HOOK(sub_8312EB48, CriErrNotify1);
|
|
GUEST_FUNCTION_HOOK(sub_83185B00, CriErrNotify1);
|
|
GUEST_FUNCTION_HOOK(sub_831683E0, CriErrNotify2);
|
|
#endif
|
|
|
|
GUEST_FUNCTION_HOOK(sub_82BD4AC8, QueryPerformanceCounterImpl);
|
|
GUEST_FUNCTION_HOOK(sub_831CD040, QueryPerformanceFrequencyImpl);
|
|
|
|
GUEST_FUNCTION_HOOK(sub_82BD4BC0, GlobalMemoryStatusImpl);
|
|
|
|
#if defined(PPC_CONFIG_NON_VOLATILE_AS_LOCAL) && defined(PPC_CONFIG_NON_ARGUMENT_AS_LOCAL)
|
|
|
|
GUEST_FUNCTION_STUB(sub_831B1400);
|
|
GUEST_FUNCTION_STUB(__savefpr_15);
|
|
GUEST_FUNCTION_STUB(__savefpr_16);
|
|
GUEST_FUNCTION_STUB(__savefpr_17);
|
|
GUEST_FUNCTION_STUB(__savefpr_18);
|
|
GUEST_FUNCTION_STUB(__savefpr_19);
|
|
GUEST_FUNCTION_STUB(__savefpr_20);
|
|
GUEST_FUNCTION_STUB(__savefpr_21);
|
|
GUEST_FUNCTION_STUB(__savefpr_22);
|
|
GUEST_FUNCTION_STUB(__savefpr_23);
|
|
GUEST_FUNCTION_STUB(__savefpr_24);
|
|
GUEST_FUNCTION_STUB(__savefpr_25);
|
|
GUEST_FUNCTION_STUB(__savefpr_26);
|
|
GUEST_FUNCTION_STUB(__savefpr_27);
|
|
GUEST_FUNCTION_STUB(__savefpr_28);
|
|
GUEST_FUNCTION_STUB(__savefpr_29);
|
|
GUEST_FUNCTION_STUB(__savefpr_30);
|
|
GUEST_FUNCTION_STUB(__savefpr_31);
|
|
GUEST_FUNCTION_STUB(sub_831B144C);
|
|
GUEST_FUNCTION_STUB(__restfpr_15);
|
|
GUEST_FUNCTION_STUB(__restfpr_16);
|
|
GUEST_FUNCTION_STUB(__restfpr_17);
|
|
GUEST_FUNCTION_STUB(__restfpr_18);
|
|
GUEST_FUNCTION_STUB(__restfpr_19);
|
|
GUEST_FUNCTION_STUB(__restfpr_20);
|
|
GUEST_FUNCTION_STUB(__restfpr_21);
|
|
GUEST_FUNCTION_STUB(__restfpr_22);
|
|
GUEST_FUNCTION_STUB(__restfpr_23);
|
|
GUEST_FUNCTION_STUB(__restfpr_24);
|
|
GUEST_FUNCTION_STUB(__restfpr_25);
|
|
GUEST_FUNCTION_STUB(__restfpr_26);
|
|
GUEST_FUNCTION_STUB(__restfpr_27);
|
|
GUEST_FUNCTION_STUB(__restfpr_28);
|
|
GUEST_FUNCTION_STUB(__restfpr_29);
|
|
GUEST_FUNCTION_STUB(__restfpr_30);
|
|
GUEST_FUNCTION_STUB(__restfpr_31);
|
|
GUEST_FUNCTION_STUB(sub_831B0AF0);
|
|
GUEST_FUNCTION_STUB(__savegprlr_15);
|
|
GUEST_FUNCTION_STUB(__savegprlr_16);
|
|
GUEST_FUNCTION_STUB(__savegprlr_17);
|
|
GUEST_FUNCTION_STUB(__savegprlr_18);
|
|
GUEST_FUNCTION_STUB(__savegprlr_19);
|
|
GUEST_FUNCTION_STUB(__savegprlr_20);
|
|
GUEST_FUNCTION_STUB(__savegprlr_21);
|
|
GUEST_FUNCTION_STUB(__savegprlr_22);
|
|
GUEST_FUNCTION_STUB(__savegprlr_23);
|
|
GUEST_FUNCTION_STUB(__savegprlr_24);
|
|
GUEST_FUNCTION_STUB(__savegprlr_25);
|
|
GUEST_FUNCTION_STUB(__savegprlr_26);
|
|
GUEST_FUNCTION_STUB(__savegprlr_27);
|
|
GUEST_FUNCTION_STUB(__savegprlr_28);
|
|
GUEST_FUNCTION_STUB(__savegprlr_29);
|
|
GUEST_FUNCTION_STUB(__savegprlr_30);
|
|
GUEST_FUNCTION_STUB(__savegprlr_31);
|
|
GUEST_FUNCTION_STUB(sub_831B0B40);
|
|
GUEST_FUNCTION_STUB(__restgprlr_15);
|
|
GUEST_FUNCTION_STUB(__restgprlr_16);
|
|
GUEST_FUNCTION_STUB(__restgprlr_17);
|
|
GUEST_FUNCTION_STUB(__restgprlr_18);
|
|
GUEST_FUNCTION_STUB(__restgprlr_19);
|
|
GUEST_FUNCTION_STUB(__restgprlr_20);
|
|
GUEST_FUNCTION_STUB(__restgprlr_21);
|
|
GUEST_FUNCTION_STUB(__restgprlr_22);
|
|
GUEST_FUNCTION_STUB(__restgprlr_23);
|
|
GUEST_FUNCTION_STUB(__restgprlr_24);
|
|
GUEST_FUNCTION_STUB(__restgprlr_25);
|
|
GUEST_FUNCTION_STUB(__restgprlr_26);
|
|
GUEST_FUNCTION_STUB(__restgprlr_27);
|
|
GUEST_FUNCTION_STUB(__restgprlr_28);
|
|
GUEST_FUNCTION_STUB(__restgprlr_29);
|
|
GUEST_FUNCTION_STUB(__restgprlr_30);
|
|
GUEST_FUNCTION_STUB(__restgprlr_31);
|
|
GUEST_FUNCTION_STUB(sub_831B3450);
|
|
GUEST_FUNCTION_STUB(__savevmx_15);
|
|
GUEST_FUNCTION_STUB(__savevmx_16);
|
|
GUEST_FUNCTION_STUB(__savevmx_17);
|
|
GUEST_FUNCTION_STUB(__savevmx_18);
|
|
GUEST_FUNCTION_STUB(__savevmx_19);
|
|
GUEST_FUNCTION_STUB(__savevmx_20);
|
|
GUEST_FUNCTION_STUB(__savevmx_21);
|
|
GUEST_FUNCTION_STUB(__savevmx_22);
|
|
GUEST_FUNCTION_STUB(__savevmx_23);
|
|
GUEST_FUNCTION_STUB(__savevmx_24);
|
|
GUEST_FUNCTION_STUB(__savevmx_25);
|
|
GUEST_FUNCTION_STUB(__savevmx_26);
|
|
GUEST_FUNCTION_STUB(__savevmx_27);
|
|
GUEST_FUNCTION_STUB(__savevmx_28);
|
|
GUEST_FUNCTION_STUB(__savevmx_29);
|
|
GUEST_FUNCTION_STUB(__savevmx_30);
|
|
GUEST_FUNCTION_STUB(__savevmx_31);
|
|
GUEST_FUNCTION_STUB(__savevmx_64);
|
|
GUEST_FUNCTION_STUB(__savevmx_65);
|
|
GUEST_FUNCTION_STUB(__savevmx_66);
|
|
GUEST_FUNCTION_STUB(__savevmx_67);
|
|
GUEST_FUNCTION_STUB(__savevmx_68);
|
|
GUEST_FUNCTION_STUB(__savevmx_69);
|
|
GUEST_FUNCTION_STUB(__savevmx_70);
|
|
GUEST_FUNCTION_STUB(__savevmx_71);
|
|
GUEST_FUNCTION_STUB(__savevmx_72);
|
|
GUEST_FUNCTION_STUB(__savevmx_73);
|
|
GUEST_FUNCTION_STUB(__savevmx_74);
|
|
GUEST_FUNCTION_STUB(__savevmx_75);
|
|
GUEST_FUNCTION_STUB(__savevmx_76);
|
|
GUEST_FUNCTION_STUB(__savevmx_77);
|
|
GUEST_FUNCTION_STUB(__savevmx_78);
|
|
GUEST_FUNCTION_STUB(__savevmx_79);
|
|
GUEST_FUNCTION_STUB(__savevmx_80);
|
|
GUEST_FUNCTION_STUB(__savevmx_81);
|
|
GUEST_FUNCTION_STUB(__savevmx_82);
|
|
GUEST_FUNCTION_STUB(__savevmx_83);
|
|
GUEST_FUNCTION_STUB(__savevmx_84);
|
|
GUEST_FUNCTION_STUB(__savevmx_85);
|
|
GUEST_FUNCTION_STUB(__savevmx_86);
|
|
GUEST_FUNCTION_STUB(__savevmx_87);
|
|
GUEST_FUNCTION_STUB(__savevmx_88);
|
|
GUEST_FUNCTION_STUB(__savevmx_89);
|
|
GUEST_FUNCTION_STUB(__savevmx_90);
|
|
GUEST_FUNCTION_STUB(__savevmx_91);
|
|
GUEST_FUNCTION_STUB(__savevmx_92);
|
|
GUEST_FUNCTION_STUB(__savevmx_93);
|
|
GUEST_FUNCTION_STUB(__savevmx_94);
|
|
GUEST_FUNCTION_STUB(__savevmx_95);
|
|
GUEST_FUNCTION_STUB(__savevmx_96);
|
|
GUEST_FUNCTION_STUB(__savevmx_97);
|
|
GUEST_FUNCTION_STUB(__savevmx_98);
|
|
GUEST_FUNCTION_STUB(__savevmx_99);
|
|
GUEST_FUNCTION_STUB(__savevmx_100);
|
|
GUEST_FUNCTION_STUB(__savevmx_101);
|
|
GUEST_FUNCTION_STUB(__savevmx_102);
|
|
GUEST_FUNCTION_STUB(__savevmx_103);
|
|
GUEST_FUNCTION_STUB(__savevmx_104);
|
|
GUEST_FUNCTION_STUB(__savevmx_105);
|
|
GUEST_FUNCTION_STUB(__savevmx_106);
|
|
GUEST_FUNCTION_STUB(__savevmx_107);
|
|
GUEST_FUNCTION_STUB(__savevmx_108);
|
|
GUEST_FUNCTION_STUB(__savevmx_109);
|
|
GUEST_FUNCTION_STUB(__savevmx_110);
|
|
GUEST_FUNCTION_STUB(__savevmx_111);
|
|
GUEST_FUNCTION_STUB(__savevmx_112);
|
|
GUEST_FUNCTION_STUB(__savevmx_113);
|
|
GUEST_FUNCTION_STUB(__savevmx_114);
|
|
GUEST_FUNCTION_STUB(__savevmx_115);
|
|
GUEST_FUNCTION_STUB(__savevmx_116);
|
|
GUEST_FUNCTION_STUB(__savevmx_117);
|
|
GUEST_FUNCTION_STUB(__savevmx_118);
|
|
GUEST_FUNCTION_STUB(__savevmx_119);
|
|
GUEST_FUNCTION_STUB(__savevmx_120);
|
|
GUEST_FUNCTION_STUB(__savevmx_121);
|
|
GUEST_FUNCTION_STUB(__savevmx_122);
|
|
GUEST_FUNCTION_STUB(__savevmx_123);
|
|
GUEST_FUNCTION_STUB(__savevmx_124);
|
|
GUEST_FUNCTION_STUB(__savevmx_125);
|
|
GUEST_FUNCTION_STUB(__savevmx_126);
|
|
GUEST_FUNCTION_STUB(__savevmx_127);
|
|
GUEST_FUNCTION_STUB(sub_831B36E8);
|
|
GUEST_FUNCTION_STUB(__restvmx_15);
|
|
GUEST_FUNCTION_STUB(__restvmx_16);
|
|
GUEST_FUNCTION_STUB(__restvmx_17);
|
|
GUEST_FUNCTION_STUB(__restvmx_18);
|
|
GUEST_FUNCTION_STUB(__restvmx_19);
|
|
GUEST_FUNCTION_STUB(__restvmx_20);
|
|
GUEST_FUNCTION_STUB(__restvmx_21);
|
|
GUEST_FUNCTION_STUB(__restvmx_22);
|
|
GUEST_FUNCTION_STUB(__restvmx_23);
|
|
GUEST_FUNCTION_STUB(__restvmx_24);
|
|
GUEST_FUNCTION_STUB(__restvmx_25);
|
|
GUEST_FUNCTION_STUB(__restvmx_26);
|
|
GUEST_FUNCTION_STUB(__restvmx_27);
|
|
GUEST_FUNCTION_STUB(__restvmx_28);
|
|
GUEST_FUNCTION_STUB(__restvmx_29);
|
|
GUEST_FUNCTION_STUB(__restvmx_30);
|
|
GUEST_FUNCTION_STUB(__restvmx_31);
|
|
GUEST_FUNCTION_STUB(__restvmx_64);
|
|
GUEST_FUNCTION_STUB(__restvmx_65);
|
|
GUEST_FUNCTION_STUB(__restvmx_66);
|
|
GUEST_FUNCTION_STUB(__restvmx_67);
|
|
GUEST_FUNCTION_STUB(__restvmx_68);
|
|
GUEST_FUNCTION_STUB(__restvmx_69);
|
|
GUEST_FUNCTION_STUB(__restvmx_70);
|
|
GUEST_FUNCTION_STUB(__restvmx_71);
|
|
GUEST_FUNCTION_STUB(__restvmx_72);
|
|
GUEST_FUNCTION_STUB(__restvmx_73);
|
|
GUEST_FUNCTION_STUB(__restvmx_74);
|
|
GUEST_FUNCTION_STUB(__restvmx_75);
|
|
GUEST_FUNCTION_STUB(__restvmx_76);
|
|
GUEST_FUNCTION_STUB(__restvmx_77);
|
|
GUEST_FUNCTION_STUB(__restvmx_78);
|
|
GUEST_FUNCTION_STUB(__restvmx_79);
|
|
GUEST_FUNCTION_STUB(__restvmx_80);
|
|
GUEST_FUNCTION_STUB(__restvmx_81);
|
|
GUEST_FUNCTION_STUB(__restvmx_82);
|
|
GUEST_FUNCTION_STUB(__restvmx_83);
|
|
GUEST_FUNCTION_STUB(__restvmx_84);
|
|
GUEST_FUNCTION_STUB(__restvmx_85);
|
|
GUEST_FUNCTION_STUB(__restvmx_86);
|
|
GUEST_FUNCTION_STUB(__restvmx_87);
|
|
GUEST_FUNCTION_STUB(__restvmx_88);
|
|
GUEST_FUNCTION_STUB(__restvmx_89);
|
|
GUEST_FUNCTION_STUB(__restvmx_90);
|
|
GUEST_FUNCTION_STUB(__restvmx_91);
|
|
GUEST_FUNCTION_STUB(__restvmx_92);
|
|
GUEST_FUNCTION_STUB(__restvmx_93);
|
|
GUEST_FUNCTION_STUB(__restvmx_94);
|
|
GUEST_FUNCTION_STUB(__restvmx_95);
|
|
GUEST_FUNCTION_STUB(__restvmx_96);
|
|
GUEST_FUNCTION_STUB(__restvmx_97);
|
|
GUEST_FUNCTION_STUB(__restvmx_98);
|
|
GUEST_FUNCTION_STUB(__restvmx_99);
|
|
GUEST_FUNCTION_STUB(__restvmx_100);
|
|
GUEST_FUNCTION_STUB(__restvmx_101);
|
|
GUEST_FUNCTION_STUB(__restvmx_102);
|
|
GUEST_FUNCTION_STUB(__restvmx_103);
|
|
GUEST_FUNCTION_STUB(__restvmx_104);
|
|
GUEST_FUNCTION_STUB(__restvmx_105);
|
|
GUEST_FUNCTION_STUB(__restvmx_106);
|
|
GUEST_FUNCTION_STUB(__restvmx_107);
|
|
GUEST_FUNCTION_STUB(__restvmx_108);
|
|
GUEST_FUNCTION_STUB(__restvmx_109);
|
|
GUEST_FUNCTION_STUB(__restvmx_110);
|
|
GUEST_FUNCTION_STUB(__restvmx_111);
|
|
GUEST_FUNCTION_STUB(__restvmx_112);
|
|
GUEST_FUNCTION_STUB(__restvmx_113);
|
|
GUEST_FUNCTION_STUB(__restvmx_114);
|
|
GUEST_FUNCTION_STUB(__restvmx_115);
|
|
GUEST_FUNCTION_STUB(__restvmx_116);
|
|
GUEST_FUNCTION_STUB(__restvmx_117);
|
|
GUEST_FUNCTION_STUB(__restvmx_118);
|
|
GUEST_FUNCTION_STUB(__restvmx_119);
|
|
GUEST_FUNCTION_STUB(__restvmx_120);
|
|
GUEST_FUNCTION_STUB(__restvmx_121);
|
|
GUEST_FUNCTION_STUB(__restvmx_122);
|
|
GUEST_FUNCTION_STUB(__restvmx_123);
|
|
GUEST_FUNCTION_STUB(__restvmx_124);
|
|
GUEST_FUNCTION_STUB(__restvmx_125);
|
|
GUEST_FUNCTION_STUB(__restvmx_126);
|
|
GUEST_FUNCTION_STUB(__restvmx_127);
|
|
|
|
#endif
|