WIP setup CRT
This commit is contained in:
89
game_re/gh_fix/entry.cxx
Normal file
89
game_re/gh_fix/entry.cxx
Normal file
@@ -0,0 +1,89 @@
|
||||
// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!!
|
||||
|
||||
#include <r3/binders/auto.h>
|
||||
#include <r3/binders/stub.h>
|
||||
#include <gh_global.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
extern "C" {
|
||||
undefined4 crt_createProgramHeap(undefined4 param_1) {
|
||||
return gh_stub_impl_cdecl<undefined4>((void *)0x00404902, param_1);
|
||||
}
|
||||
undefined4 ioinit(void) {
|
||||
return gh_stub_impl_cdecl<undefined4>((void *)0x004046bf);
|
||||
}
|
||||
void crt_initConsole(void) {
|
||||
return gh_stub_impl_cdecl<void>((void *)0x00404503);
|
||||
}
|
||||
LPSTR crt_setupEnv(void) {
|
||||
return gh_stub_impl_cdecl<LPSTR>((void *)0x004043d1);
|
||||
}
|
||||
undefined4 crt_main2(void) {
|
||||
return gh_stub_impl_cdecl<undefined4>((void *)0x00404184);
|
||||
}
|
||||
undefined4 crt_main1(void) {
|
||||
return gh_stub_impl_cdecl<undefined4>((void *)0x004040cb);
|
||||
}
|
||||
void c_static_init(void) {
|
||||
return gh_stub_impl_cdecl<void>((void *)0x004027be);
|
||||
}
|
||||
|
||||
char* crt_0(void) {
|
||||
return gh_stub_impl_cdecl<char*>((void *)0x00404073);
|
||||
}
|
||||
|
||||
void gh_pre_main(void) {
|
||||
DWORD DVar1;
|
||||
int iVar2;
|
||||
LPSTR *cmdline;
|
||||
uint showCmd;
|
||||
HMODULE hInstance;
|
||||
HINSTANCE hPrevInstance;
|
||||
_STARTUPINFOA local_60;
|
||||
undefined1 *local_1c;
|
||||
void *pvStack_14;
|
||||
undefined1 *puStack_10;
|
||||
undefined *puStack_c;
|
||||
undefined4 local_8;
|
||||
|
||||
local_8 = 0xffffffff;
|
||||
// This sets up the unhandled exception handler i think?
|
||||
// puStack_c = &DAT_00597ca0;
|
||||
// puStack_10 = &LAB_00404a58;
|
||||
// pvStack_14 = ExceptionList;
|
||||
// local_1c = &stack0xffffff88;
|
||||
// ExceptionList = &pvStack_14;
|
||||
DVar1 = GetVersion();
|
||||
DWORD_005cf980 = DVar1 >> 8 & 0xff;
|
||||
DWORD_005cf97c = DVar1 & 0xff;
|
||||
DWORD_005cf978 = DWORD_005cf97c * 0x100 + DWORD_005cf980;
|
||||
DWORD_005cf974 = DVar1 >> 0x10;
|
||||
iVar2 = crt_createProgramHeap(1);
|
||||
if (iVar2 == 0) {
|
||||
SPDLOG_ERROR("crt_createProgramHeap failed");
|
||||
exit(0);
|
||||
}
|
||||
iVar2 = ioinit();
|
||||
if (iVar2 == 0) {
|
||||
SPDLOG_ERROR("_ioinit failed");
|
||||
exit(0);
|
||||
}
|
||||
local_8 = 0;
|
||||
crt_initConsole();
|
||||
g_crt_cmdLine = GetCommandLineA();
|
||||
PTR_005cf9b4 = crt_setupEnv();
|
||||
crt_main2();
|
||||
crt_main1();
|
||||
c_static_init();
|
||||
local_60.dwFlags = 0;
|
||||
GetStartupInfoA(&local_60);
|
||||
cmdline = (LPSTR *)crt_0();
|
||||
if ((local_60.dwFlags & 1) == 0) {
|
||||
showCmd = 10;
|
||||
} else {
|
||||
showCmd = (uint)local_60.wShowWindow;
|
||||
}
|
||||
hPrevInstance = (HINSTANCE)0x0;
|
||||
hInstance = GetModuleHandleA((LPCSTR)0x0);
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,8 @@ int r3_main(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR *cmdline,int showC
|
||||
LPRECT lpRect;
|
||||
LPHANDLE lpTargetHandle;
|
||||
undefined4 uVar22;
|
||||
|
||||
|
||||
#if RE_AUTHENTIC == 0
|
||||
lpBuffer = pathToUbi_ini;
|
||||
uiParam = 0x104;
|
||||
/* Append windows dir / ubi.ini */
|
||||
@@ -111,17 +112,17 @@ int r3_main(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR *cmdline,int showC
|
||||
pcVar4[(int)(tStack_820 + iVar13)] = cVar1;
|
||||
pcVar4 = pcVar4 + 1;
|
||||
} while (cVar1 != '\0');
|
||||
pcVar4 = strrchr(tStack_820,0x5c);
|
||||
pcVar4 = strrchr(tStack_820,0x5c); // Get the exe path
|
||||
if (pcVar4 == (char *)0x0) {
|
||||
/* Read from ubi.ini */
|
||||
GetPrivateProfileStringA
|
||||
(lpAppName_005b68f0,s_Directory_005b68f8,s_None,tStack_820,0xff,acStack_61c);
|
||||
iVar13 = strcmpi(tStack_820,s_None);
|
||||
}
|
||||
else {
|
||||
else { // We have the .exe path
|
||||
pcVar4 = strrchr(tStack_820,0x5c);
|
||||
*pcVar4 = '\0';
|
||||
iVar13 = chdir(tStack_820);
|
||||
*pcVar4 = '\0'; // Split into the binary path (strip .exe)
|
||||
iVar13 = chdir(tStack_820); // Change into the binary path
|
||||
if (iVar13 != -1) goto LAB_00401765;
|
||||
/* Read from ubi.ini */
|
||||
GetPrivateProfileStringA
|
||||
@@ -244,7 +245,7 @@ LAB_004017ce:
|
||||
/* Setup localized quiting/restoring strings */
|
||||
iVar13 = strcmpi(aCStack_71c,s_French_005b6828);
|
||||
if (iVar13 == 0) {
|
||||
sprintf(s_windowTitleRestoring,s_Restauration_fmt,s_windowTitle);
|
||||
sprintf(g_windowTitleRestoring,s_Restauration_fmt,s_windowTitle);
|
||||
chars = s_QUITTER + Field<4, 4>();
|
||||
pcVar4 = s_ou_appuyez_sur_Echap_pour_quitte_005b67d0;
|
||||
pcVar17 = s_quitting1;
|
||||
@@ -279,7 +280,7 @@ LAB_004017ce:
|
||||
else {
|
||||
iVar13 = strcmpi(aCStack_71c,s_Spanish_005b67a0);
|
||||
if (iVar13 == 0) {
|
||||
sprintf(s_windowTitleRestoring,s__s___Restablecer_datos____005b6784,s_windowTitle);
|
||||
sprintf(g_windowTitleRestoring,s__s___Restablecer_datos____005b6784,s_windowTitle);
|
||||
uVar2 = s_SALIR_005b675c + Field<4, 2>();
|
||||
pcVar4 = s_Pulsa_ESC_para_salir_Rayman_3__005b6764;
|
||||
pcVar17 = s_quitting1;
|
||||
@@ -319,7 +320,7 @@ LAB_004017ce:
|
||||
else {
|
||||
iVar13 = strcmpi(aCStack_71c,s_Italian_005b6730);
|
||||
if (iVar13 == 0) {
|
||||
sprintf(s_windowTitleRestoring,s__s___Ripristino_dati____005b6718,s_windowTitle);
|
||||
sprintf(g_windowTitleRestoring,s__s___Ripristino_dati____005b6718,s_windowTitle);
|
||||
uVar2 = s_USCIRE_005b66ec + Field<4, 2>();
|
||||
pcVar4 = s_Premi_ESC_per_uscire_da_Rayman_3_005b66f4;
|
||||
pcVar17 = s_quitting1;
|
||||
@@ -360,7 +361,7 @@ LAB_004017ce:
|
||||
else {
|
||||
iVar13 = strcmpi(aCStack_71c,s_German_005b66c4);
|
||||
if (iVar13 == 0) {
|
||||
sprintf(s_windowTitleRestoring,s__s___Daten_Reparatur____005b66ac,s_windowTitle);
|
||||
sprintf(g_windowTitleRestoring,s__s___Daten_Reparatur____005b66ac,s_windowTitle);
|
||||
chars = s_BEENDIGEN_005b6678 + Field<0, 4>();
|
||||
pcVar4 = &CHAR_E_005b6684;
|
||||
pcVar17 = s_quitting1;
|
||||
@@ -420,7 +421,7 @@ LAB_004017ce:
|
||||
s_wndStrRestoring[0x12] = s_Daten_Reparatur____005b6664[0x12];
|
||||
}
|
||||
else {
|
||||
sprintf(s_windowTitleRestoring,s__s___Restoring_data____005b664c,s_windowTitle);
|
||||
sprintf(g_windowTitleRestoring,s__s___Restoring_data____005b664c,s_windowTitle);
|
||||
chars = s_QUIT + Field<0, 4>();
|
||||
pcVar4 = s_or_press_ESC_to_quit_Rayman_3__005b662c;
|
||||
pcVar17 = s_quitting1;
|
||||
@@ -462,6 +463,13 @@ LAB_004017ce:
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
strcpy(g_windowTitle, "Reman3");
|
||||
strcpy(g_windowTitle1, "Reman3 - Paused");
|
||||
strcpy(g_windowTitleRestoring, "Restoring data");
|
||||
|
||||
|
||||
#endif
|
||||
/* Create draw semaphore
|
||||
Initial count = 1
|
||||
Maximum count = 1 */
|
||||
|
||||
Reference in New Issue
Block a user