upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/src/main.cpp')
-rw-r--r--runtime/src/main.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp
index 5a9f7c76f..505cd3ea8 100644
--- a/runtime/src/main.cpp
+++ b/runtime/src/main.cpp
@@ -20,6 +20,7 @@
20 20
21#include <cstdio> 21#include <cstdio>
22#include <cstdlib> 22#include <cstdlib>
23#include <exception>
23#include <filesystem> 24#include <filesystem>
24#include <map> 25#include <map>
25#include <string> 26#include <string>
@@ -189,9 +190,15 @@ int wmain(int argc, wchar_t** argv) {
189 r.error); 190 r.error);
190 } 191 }
191 if (run) rt::process::set_command_line(image.filename().wstring(), game_args); 192 if (run) rt::process::set_command_line(image.filename().wstring(), game_args);
193 std::exception_ptr init_failure;
192 if (init || run) { 194 if (init || run) {
193 loader.initialise(); // TLS callbacks, then DllMain(DLL_PROCESS_ATTACH) for DLLs 195 try {
194 std::printf("%zu module(s) initialised\n", loader.modules().size()); 196 loader.initialise(); // TLS callbacks, then DllMain(DLL_PROCESS_ATTACH) for DLLs
197 std::printf("%zu module(s) initialised\n", loader.modules().size());
198 } catch (const std::exception&) {
199 // Keep the mapped modules available for the binding report on an attach failure.
200 init_failure = std::current_exception();
201 }
195 } 202 }
196 int unimplemented = 0, unimplemented_hresult = 0; 203 int unimplemented = 0, unimplemented_hresult = 0;
197 for (auto* m : loader.modules()) { 204 for (auto* m : loader.modules()) {
@@ -215,6 +222,10 @@ int wmain(int argc, wchar_t** argv) {
215 std::printf("%zu module(s) mapped, %d unimplemented import(s)\n", loader.modules().size(), unimplemented); 222 std::printf("%zu module(s) mapped, %d unimplemented import(s)\n", loader.modules().size(), unimplemented);
216 std::printf("unimplemented by return policy: hresult=%d other=%d\n", unimplemented_hresult, 223 std::printf("unimplemented by return policy: hresult=%d other=%d\n", unimplemented_hresult,
217 unimplemented - unimplemented_hresult); 224 unimplemented - unimplemented_hresult);
225 if (init_failure) {
226 std::fflush(stdout);
227 std::rethrow_exception(init_failure);
228 }
218 if (!run) { 229 if (!run) {
219 rt::startup_trace::event("exit", "\"code\":0"); 230 rt::startup_trace::event("exit", "\"code\":0");
220 return 0; 231 return 0;