mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-27 00:40:21 +00:00
Merge branch 'fix-6873' into 'master'
Fix #6873: Dynamically obtain pointer to IsHungAppWindow Closes #6873 See merge request OpenMW/openmw!2134
This commit is contained in:
commit
88184fbc79
@ -18,6 +18,28 @@ namespace Crash
|
|||||||
{
|
{
|
||||||
std::unordered_map<HWINEVENTHOOK, CrashMonitor*> CrashMonitor::smEventHookOwners{};
|
std::unordered_map<HWINEVENTHOOK, CrashMonitor*> CrashMonitor::smEventHookOwners{};
|
||||||
|
|
||||||
|
using IsHungAppWindowFn = BOOL(WINAPI*)(HWND hwnd);
|
||||||
|
|
||||||
|
// Obtains the pointer to user32.IsHungAppWindow, this function may be removed in the future.
|
||||||
|
// See: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-ishungappwindow
|
||||||
|
static IsHungAppWindowFn getIsHungAppWindow() noexcept
|
||||||
|
{
|
||||||
|
static IsHungAppWindowFn isHungAppWindow = nullptr;
|
||||||
|
static bool isHungAppWindowInitialized = false;
|
||||||
|
|
||||||
|
if (isHungAppWindowInitialized)
|
||||||
|
return isHungAppWindow;
|
||||||
|
|
||||||
|
auto user32Handle = LoadLibraryA("user32.dll");
|
||||||
|
if (user32Handle == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
isHungAppWindow = reinterpret_cast<IsHungAppWindowFn>(GetProcAddress(user32Handle, "IsHungAppWindow"));
|
||||||
|
isHungAppWindowInitialized = true;
|
||||||
|
|
||||||
|
return isHungAppWindow;
|
||||||
|
}
|
||||||
|
|
||||||
CrashMonitor::CrashMonitor(HANDLE shmHandle)
|
CrashMonitor::CrashMonitor(HANDLE shmHandle)
|
||||||
: mShmHandle(shmHandle)
|
: mShmHandle(shmHandle)
|
||||||
{
|
{
|
||||||
@ -123,8 +145,8 @@ namespace Crash
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IsHungAppWindow)
|
if (auto isHungAppWindow = getIsHungAppWindow(); isHungAppWindow != nullptr)
|
||||||
return IsHungAppWindow(mAppWindowHandle);
|
return isHungAppWindow(mAppWindowHandle);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOL debuggerPresent;
|
BOOL debuggerPresent;
|
||||||
@ -203,7 +225,7 @@ namespace Crash
|
|||||||
signalApp();
|
signalApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring utf8ToUtf16(const std::string& utf8)
|
static std::wstring utf8ToUtf16(const std::string& utf8)
|
||||||
{
|
{
|
||||||
const int nLenWide = MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), utf8.size(), nullptr, 0);
|
const int nLenWide = MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), utf8.size(), nullptr, 0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user