@@ -42,6 +42,7 @@ namespace {
4242 namespace kb = koalabox;
4343
4444 void * steamapi_handle = nullptr ;
45+ const kb::dll_monitor::callback_context_t * dll_monitor_context = nullptr ;
4546
4647 std::set<std::string> find_steamclient_versions () {
4748 if (!steamapi_handle) {
@@ -93,11 +94,18 @@ namespace {
9394
9495 KB_HOOK_DETOUR_MODULE (CreateInterface, steamclient_handle);
9596
97+ // TODO: There is an implicit lifetime dependency here and potential for leaks.
98+ // This mechanism requires rework.
99+ // DLL monitor will have destroyed it.
100+ dll_monitor_context = nullptr ;
101+
96102 return true ;
97103 }
98104
99105 void start_dll_listener () {
100- kb::dll_monitor::init_listener ({{STEAMCLIENT_DLL, on_steamclient_loaded}});
106+ dll_monitor_context = kb::dll_monitor::init_listener (
107+ {{STEAMCLIENT_DLL, on_steamclient_loaded}}
108+ );
101109 }
102110}
103111
@@ -153,14 +161,13 @@ namespace smoke_api {
153161 steamapi_handle = nullptr ;
154162 }
155163
156- kb::dll_monitor::shutdown_listener (nullptr );
164+ kb::dll_monitor::shutdown_listener (dll_monitor_context );
157165
158166 // TODO: Unhook everything
159167
160168 LOG_INFO (" Shutdown complete" );
161169 } catch (const std::exception& e) {
162- const auto msg = std::format (" Shutdown error: {}" , e.what ());
163- LOG_ERROR (msg);
170+ LOG_ERROR (" Shutdown error: {}" , e.what ());
164171 }
165172
166173 kb::logger::shutdown ();
0 commit comments