diff --git a/libraries/config/templates/stratosphere.mk b/libraries/config/templates/stratosphere.mk index 39e83bc16..d0bbf3f85 100644 --- a/libraries/config/templates/stratosphere.mk +++ b/libraries/config/templates/stratosphere.mk @@ -58,7 +58,7 @@ export CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \ -Wl,--wrap,exit else ifeq ($(ATMOSPHERE_BOARD),generic_windows) export CXXREQUIRED := -export CXXWRAPS := -Wl,--wrap,__p__acmdln +export CXXWRAPS := -Wl,--wrap,__p__acmdln -Wl,--wrap,_set_invalid_parameter_handler else export CXXREQUIRED := export CXXWRAPS := diff --git a/libraries/libstratosphere/source/ams/ams_environment_weak.os.windows.cpp b/libraries/libstratosphere/source/ams/ams_environment_weak.os.windows.cpp index 5162e1b24..c672270c5 100644 --- a/libraries/libstratosphere/source/ams/ams_environment_weak.os.windows.cpp +++ b/libraries/libstratosphere/source/ams/ams_environment_weak.os.windows.cpp @@ -16,6 +16,7 @@ #include extern "C" char **__real___p__acmdln(void); +extern "C" _invalid_parameter_handler __real__set_invalid_parameter_handler(_invalid_parameter_handler); namespace ams { @@ -65,4 +66,11 @@ extern "C" { return __real___p__acmdln(); } + /* On some mingw gcc versions, acmdln isn't used, so we need to hook a different part of crt init. */ + _invalid_parameter_handler __wrap__set_invalid_parameter_handler(_invalid_parameter_handler handler) { + ::ams::os::Initialize(); + return __real__set_invalid_parameter_handler(handler); + + } + }