Make function linkage use unmangled names
This commit is contained in:
parent
2b945e4406
commit
96ea861c26
|
@ -32,10 +32,12 @@ target_link_libraries(game_re PRIVATE spdlog)
|
|||
|
||||
file(GLOB GH_AUTO_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/gh_auto/*.cxx)
|
||||
file(GLOB GH_FIX_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/gh_fix/*.cxx)
|
||||
file(GLOB GH_STUB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/gh_stub/*.cxx)
|
||||
|
||||
target_sources(game_re PRIVATE
|
||||
${GH_AUTO_SOURCES}
|
||||
${GH_FIX_SOURCES}
|
||||
${GH_STUB_SOURCES}
|
||||
)
|
||||
|
||||
# Ignore -Wformat-security
|
||||
|
|
|
@ -30,6 +30,27 @@ enum R3ModuleId : uint8_t {
|
|||
R3ModId_not_initialized = 0xff,
|
||||
};
|
||||
|
||||
typedef uint32_t cc_type_t;
|
||||
|
||||
template <typename T0, typename T1>
|
||||
inline constexpr cc_type_t CONCAT11(T0 a, T1 b) {
|
||||
return cc_type_t(a) << 8 | cc_type_t(b);
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
inline constexpr cc_type_t CONCAT21(T0 a, T1 b) {
|
||||
return cc_type_t(a) << 8 | cc_type_t(b);
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
inline constexpr cc_type_t CONCAT22(T0 a, T1 b) {
|
||||
return cc_type_t(a) << 16 | cc_type_t(b);
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
inline constexpr cc_type_t CONCAT23(T0 a, T1 b) {
|
||||
return cc_type_t(a) << 24 | cc_type_t(b);
|
||||
}
|
||||
|
||||
// Can not export enums for some reason
|
||||
|
||||
#endif /* A523F6DB_0645_4DEB_8AEB_3792CB732B49 */
|
||||
|
|
|
@ -3,25 +3,27 @@
|
|||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
|
||||
extern undefined r3_initEngine(void); // 00401220 // r3_initEngine
|
||||
extern "C" {
|
||||
undefined r3_initEngine(void); // 00401220 // r3_initEngine
|
||||
extern undefined r3_module0_init(void); // 00401000 // r3_module0_init
|
||||
extern uint32_t r3_containsCmdLine(
|
||||
uint *param_1, char *param_2); // 004028e0 // r3_containsCmdLine
|
||||
extern uint32_t
|
||||
r3_containsCmdLine(uint *param_1,
|
||||
char *param_2); // 004028e0 // r3_containsCmdLine
|
||||
extern undefined FUN_004010b0(void); // 004010b0 // FUN_004010b0
|
||||
extern undefined FUN_004464f0(void); // 004464f0 // FUN_004464f0
|
||||
extern undefined FUN_00503710(void); // 00503710 // FUN_00503710
|
||||
extern undefined r3_setupWindow(
|
||||
HINSTANCE hInstance, undefined4 param_2,
|
||||
undefined4 param_3); // 00402140 // r3_setupWindow
|
||||
extern undefined FUN_00401320(void); // 00401320 // FUN_00401320
|
||||
extern undefined spawnThread(void); // 004477d0 // spawnThread
|
||||
extern undefined FUN_005038e0(void); // 005038e0 // FUN_005038e0
|
||||
extern undefined FUN_004fb300(void); // 004fb300 // FUN_004fb300
|
||||
extern void g_setInitVar0(void); // 00401310 // g_setInitVar0
|
||||
extern undefined
|
||||
r3_setupWindow(HINSTANCE hInstance, undefined4 param_2,
|
||||
undefined4 param_3); // 00402140 // r3_setupWindow
|
||||
extern undefined FUN_00401320(void); // 00401320 // FUN_00401320
|
||||
extern undefined spawnThread(void); // 004477d0 // spawnThread
|
||||
extern undefined FUN_005038e0(void); // 005038e0 // FUN_005038e0
|
||||
extern undefined FUN_004fb300(void); // 004fb300 // FUN_004fb300
|
||||
extern void g_setInitVar0(void); // 00401310 // g_setInitVar0
|
||||
extern void r3_noop(void *p_cTxt1,
|
||||
void *p_cTxt2); // 00401100 // r3_noop
|
||||
void *p_cTxt2); // 00401100 // r3_noop
|
||||
extern undefined r3_checkDisc(void); // 004464f0 // r3_checkDisc
|
||||
extern undefined gfx_init2(void); // 00470be0 // gfx_init2
|
||||
extern undefined gfx_init2(void); // 00470be0 // gfx_init2
|
||||
extern undefined4 __cdecl r3_get_gli_width(
|
||||
void); // 0047baf0 // r3_get_gli_width
|
||||
extern undefined FUN_00472150(void); // 00472150 // FUN_00472150
|
||||
|
@ -413,7 +415,7 @@ LAB_004017ce:
|
|||
sprintf(acStack_810, s_Please_run_the__s_setup__005b63f4, s_windowTitle);
|
||||
sprintf(acStack_508, s__s_not_initialized__005b63e0, s_windowTitle);
|
||||
// FUN_0043e540(acStack_810, acStack_508, 0);
|
||||
MessageBoxA(g_gameHWND, acStack_810, acStack_508,
|
||||
0 | 0x10000);
|
||||
MessageBoxA(g_gameHWND, acStack_810, acStack_508, 0 | 0x10000);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 004010b0
|
||||
// FUN_004010b0
|
||||
extern "C" undefined FUN_004010b0(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: FUN_004010b0");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 00401320
|
||||
// FUN_00401320
|
||||
extern "C" undefined FUN_00401320(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: FUN_00401320");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 00470db0
|
||||
// FUN_00470db0
|
||||
extern "C" undefined FUN_00470db0(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: FUN_00470db0");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 00472150
|
||||
// FUN_00472150
|
||||
extern "C" undefined FUN_00472150(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: FUN_00472150");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 004725a0
|
||||
// FUN_004725a0
|
||||
extern "C" undefined FUN_004725a0(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: FUN_004725a0");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 004fb300
|
||||
// FUN_004fb300
|
||||
extern "C" undefined FUN_004fb300(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: FUN_004fb300");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 00503710
|
||||
// FUN_00503710
|
||||
extern "C" undefined FUN_00503710(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: FUN_00503710");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 005038e0
|
||||
// FUN_005038e0
|
||||
extern "C" undefined FUN_005038e0(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: FUN_005038e0");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 00401310
|
||||
// g_setInitVar0
|
||||
extern "C" void g_setInitVar0(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: g_setInitVar0");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 00470be0
|
||||
// gfx_init2
|
||||
extern "C" undefined gfx_init2(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: gfx_init2");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 004464f0
|
||||
// r3_checkDisc
|
||||
extern "C" undefined r3_checkDisc(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: r3_checkDisc");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 0047bb00
|
||||
// r3_get_gli_height1
|
||||
extern "C" int r3_get_gli_height1(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: r3_get_gli_height1");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 0047baf0
|
||||
// r3_get_gli_width1
|
||||
extern "C" undefined4 r3_get_gli_width1(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: r3_get_gli_width1");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 00401220
|
||||
// r3_initEngine
|
||||
extern "C" undefined r3_initEngine(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: r3_initEngine");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 00401000
|
||||
// r3_module0_init
|
||||
extern "C" undefined r3_module0_init(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: r3_module0_init");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 00402140
|
||||
// r3_setupWindow
|
||||
extern "C" undefined r3_setupWindow(undefined4 hInstance, undefined4 param_2, undefined4 maximizeWindow) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: r3_setupWindow");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 0043e540
|
||||
// r3_wait_for_dvd
|
||||
extern "C" undefined r3_wait_for_dvd(undefined4 param_1, undefined4 param_2, undefined4 param_3) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: r3_wait_for_dvd");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTO-GENERATED FILE!!!!
|
||||
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
|
||||
// with possible manualy fixes
|
||||
|
||||
#include <gh_auto_binder.h>
|
||||
#include "../gh_global.h"
|
||||
#include <stdexcept>
|
||||
|
||||
// 004477d0
|
||||
// spawnThread
|
||||
extern "C" undefined spawnThread(void) {
|
||||
// TODO: Implement this function
|
||||
throw std::runtime_error("Function not implemented: spawnThread");
|
||||
}
|
|
@ -3,8 +3,8 @@
|
|||
#include <stdexcept>
|
||||
#include <stdio.h>
|
||||
|
||||
int r3_main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR *cmdline,
|
||||
int showCmd);
|
||||
extern "C" int r3_main(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPSTR *cmdline, int showCmd);
|
||||
|
||||
extern void gh_init_data_segment();
|
||||
int main() {
|
||||
|
|
|
@ -106,6 +106,13 @@ public class FunctionDumper {
|
|||
String sanitizedFunctionName = Utils.sanitizeIdentifier(function.getName());
|
||||
String fileName = sanitizedFunctionName + ".cxx";
|
||||
|
||||
// Remove the stub file, since we now use the decompiled file
|
||||
File stubFile = new File(RecompileConfig.INSTANCE.dirDecompStub, fileName);
|
||||
if (stubFile.exists()) {
|
||||
script.println("Removing function stub " + stubFile);
|
||||
stubFile.delete();
|
||||
}
|
||||
|
||||
File f0 = new File(RecompileConfig.INSTANCE.dirDecompFix, fileName);
|
||||
if (f0.exists()) {
|
||||
script.println("Func " + function.getName() + " skipped (gh_fix)");
|
||||
|
@ -130,6 +137,7 @@ public class FunctionDumper {
|
|||
writer2.println("#include <gh_auto_binder.h>");
|
||||
writer2.println("#include \"../gh_global.h\"");
|
||||
writer2.println();
|
||||
writer2.println("extern \"C\" {");
|
||||
|
||||
HighFunction highFunction = decompRes.getHighFunction();
|
||||
|
||||
|
@ -216,7 +224,7 @@ public class FunctionDumper {
|
|||
if (calledFunction != null) {
|
||||
if (isValidFunction(calledFunction)) {
|
||||
String proto = calledFunction.getSignature().getPrototypeString(false);
|
||||
headers.add("extern " + proto
|
||||
headers.add("" + proto
|
||||
+ "; // " + calledFunction.getEntryPoint() + " // "
|
||||
+ calledFunction.getName());
|
||||
externalFunctionCalls.add(calledFunction);
|
||||
|
@ -239,16 +247,21 @@ public class FunctionDumper {
|
|||
writer2.println(header);
|
||||
}
|
||||
writer2.println();
|
||||
writer2.println("// " + function.getEntryPoint());
|
||||
writer2.print("// " + function.getEntryPoint());
|
||||
writer2.print(codeWriter.toString());
|
||||
writer2.println("}");
|
||||
writer2.println();
|
||||
}
|
||||
|
||||
// Possibly generate stubs for external functions
|
||||
for (Function externalFunction : externalFunctionCalls) {
|
||||
String sanitizedExtFunctionName = Utils.sanitizeIdentifier(externalFunction.getName());
|
||||
fileName = sanitizedExtFunctionName + ".cxx";
|
||||
File f2 = new File(RecompileConfig.INSTANCE.dirDecompFix, fileName);
|
||||
File f3 = new File(RecompileConfig.INSTANCE.dirDecompAuto, fileName);
|
||||
if (f2.exists() || f3.exists()) {
|
||||
// script.println("Skipping external function: " + externalFunction.getName() +
|
||||
// " - " + externalFunction.getEntryPoint());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -266,7 +279,7 @@ public class FunctionDumper {
|
|||
writer2.println();
|
||||
writer2.println("// " + externalFunction.getEntryPoint());
|
||||
writer2.println("// " + externalFunction.getName());
|
||||
writer2.println(externalFunction.getSignature().getPrototypeString(false) + " {");
|
||||
writer2.println("extern \"C\" " + externalFunction.getSignature().getPrototypeString(false) + " {");
|
||||
writer2.println(" // TODO: Implement this function");
|
||||
writer2
|
||||
.println(" throw std::runtime_error(\"Function not implemented: " + externalFunction.getName() + "\");");
|
||||
|
|
Loading…
Reference in New Issue