Live++ integration
Live++ is a generic hot reload solution for C++ applications. D0 requires the following integration to work correctly:1. Copy & paste this code anywhere in your application with the
#include "LPP_API_x64_CPP.h"
include present (note: you may need to include Windows.h
if it is not already).
void GlobalHotReloadEnd(lpp::LppGlobalHotReloadEndHookId)
{
char eventName[32];
if (snprintf(eventName, sizeof(eventName), "D0_GlobalHotReload_%i", GetCurrentProcessId()) < 0) {
return;
}
HANDLE ev = OpenEventA(EVENT_MODIFY_STATE, FALSE, eventName);
if (ev) {
SetEvent(ev);
CloseHandle(ev);
}
}
LPP_GLOBAL_HOTRELOAD_END_HOOK(GlobalHotReloadEnd);
2. Locate your call to the
LppCreateDefaultAgent
function and replace it with LppCreateDefaultAgentWithPreferences
like this:
lpp::LppProjectPreferences prefs = lpp::LppCreateDefaultProjectPreferences();
prefs.exceptionHandler.isEnabled = false;
lpp::LppDefaultAgent agent = lpp::LppCreateDefaultAgentWithPreferences(..., ..., &prefs);
Essentially passing the additional
LppProjectPreferences
object to disable the exception handler.
Why is this required?
- Live++ will catch exceptions that need to be handled by D0 first. This is fixed by disabling the exception handler.
- When Live++ recompiles a module, it will load the new module with the new code compiled. D0 processes notifications about the module being loaded, but it does not know when Live++ finishes patching the application code, which is why the global reload hook is installed. Setting the named event notifies D0 that the patching is done and it may apply its own instrumentation.
If you have any issues with D0 or the integration, you can talk to me directly on Discord: