1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 13:53:53 +00:00
openmw/components/crashcatcher/windows_crashmonitor.hpp

64 lines
1.3 KiB
C++
Raw Normal View History

#ifndef WINDOWS_CRASHMONITOR_HPP
#define WINDOWS_CRASHMONITOR_HPP
#include <components/misc/windows.hpp>
#include <atomic>
2022-01-13 20:46:00 +00:00
#include <unordered_map>
namespace Crash
{
2022-09-22 18:26:05 +00:00
struct CrashSHM;
2022-09-22 18:26:05 +00:00
class CrashMonitor final
{
public:
CrashMonitor(HANDLE shmHandle);
2022-09-22 18:26:05 +00:00
~CrashMonitor();
2022-09-22 18:26:05 +00:00
void run();
2022-09-22 18:26:05 +00:00
private:
HANDLE mAppProcessHandle = nullptr;
DWORD mAppMainThreadId = 0;
HWND mAppWindowHandle = nullptr;
2022-09-22 18:26:05 +00:00
// triggered when the monitor process wants to wake the parent process (received via SHM)
HANDLE mSignalAppEvent = nullptr;
// triggered when the application wants to wake the monitor process (received via SHM)
HANDLE mSignalMonitorEvent = nullptr;
2022-09-22 18:26:05 +00:00
CrashSHM* mShm = nullptr;
HANDLE mShmHandle = nullptr;
HANDLE mShmMutex = nullptr;
2022-09-22 18:26:05 +00:00
DWORD mFreezeMessageBoxThreadId = 0;
std::atomic_bool mFreezeAbort;
2022-09-22 18:26:05 +00:00
static std::unordered_map<HWINEVENTHOOK, CrashMonitor*> smEventHookOwners;
2022-09-22 18:26:05 +00:00
void signalApp() const;
2022-09-22 18:26:05 +00:00
bool waitApp() const;
2022-09-22 18:26:05 +00:00
bool isAppAlive() const;
2022-09-22 18:26:05 +00:00
bool isAppFrozen();
2021-12-18 21:34:15 +00:00
2022-09-22 18:26:05 +00:00
void shmLock();
2022-09-22 18:26:05 +00:00
void shmUnlock();
void handleCrash(bool isFreeze);
2022-09-22 18:26:05 +00:00
void showFreezeMessageBox();
2022-09-22 18:26:05 +00:00
void hideFreezeMessageBox();
};
} // namespace Crash
#endif // WINDOWS_CRASHMONITOR_HPP