Implement restart flag

This commit is contained in:
mkrsym1
2023-08-04 15:35:29 +03:00
parent 970561afb9
commit 4911f8d903
3 changed files with 68 additions and 39 deletions

View File

@ -5,6 +5,7 @@
#include <game.h>
#include <core.h>
#include <utils.h>
#include <msg.h>
#include <main.h>
@ -23,6 +24,19 @@ void unload_ctr_dec() {
}
}
void request_restart() {
HANDLE hRestartFlag = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, "Global\\JadeiteRestartFlag");
int *restartFlag = MapViewOfFile(hRestartFlag, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(int));
if (!restartFlag) {
msg_err_a("Could not map shared memory to set restart flag");
}
*restartFlag = 1;
UnmapViewOfFile(restartFlag);
CloseHandle(hRestartFlag);
}
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) {
// Only listen to attach
if (reason != DLL_PROCESS_ATTACH) {