Fix nullptr problems (#878)

This commit is contained in:
kizer 2022-06-04 20:45:22 +09:00 committed by GitHub
parent 74966fc4ef
commit 71f3680388
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 161 additions and 84 deletions

View file

@ -488,3 +488,24 @@ std::filesystem::path utils::get_module_path(HMODULE hModule) {
buf.resize(buf.size() * 2);
}
}
HWND utils::try_find_game_window() {
HWND hwnd = nullptr;
while ((hwnd = FindWindowExW(nullptr, hwnd, L"FFXIVGAME", nullptr))) {
DWORD pid;
GetWindowThreadProcessId(hwnd, &pid);
if (pid == GetCurrentProcessId() && IsWindowVisible(hwnd))
break;
}
return hwnd;
}
void utils::wait_for_game_window() {
HWND game_window;
while (!(game_window = try_find_game_window())) {
WaitForInputIdle(GetCurrentProcess(), INFINITE);
Sleep(100);
};
SendMessageW(game_window, WM_NULL, 0, 0);
}