mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-18 03:28:07 -05:00
Windows Pageant: deal with PeekMessageW failing on legacy Windows.
This makes Pageant run on Win95 again. Previously (after fixing the startup-time failures due to missing security APIs) it would go into an uninterruptible CPU-consuming spin in the message loop when every attempt to retrieve its messages failed because PeekMessageW doesn't work at all on the 95 series.
This commit is contained in:
parent
a2b376af96
commit
3f76a86c13
@ -1382,6 +1382,23 @@ static NORETURN void opt_error(const char *fmt, ...)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LEGACY_WINDOWS
|
||||||
|
BOOL sw_PeekMessage(LPMSG msg, HWND hwnd, UINT min, UINT max, UINT remove)
|
||||||
|
{
|
||||||
|
static bool unicode_unavailable = false;
|
||||||
|
if (!unicode_unavailable) {
|
||||||
|
BOOL ret = PeekMessageW(msg, hwnd, min, max, remove);
|
||||||
|
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
||||||
|
unicode_unavailable = true; /* don't try again */
|
||||||
|
else
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return PeekMessageA(msg, hwnd, min, max, remove);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define sw_PeekMessage PeekMessageW
|
||||||
|
#endif
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
@ -1732,7 +1749,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
|||||||
handle_wait_activate(hwl, n - WAIT_OBJECT_0);
|
handle_wait_activate(hwl, n - WAIT_OBJECT_0);
|
||||||
handle_wait_list_free(hwl);
|
handle_wait_list_free(hwl);
|
||||||
|
|
||||||
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
|
while (sw_PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||||
if (msg.message == WM_QUIT)
|
if (msg.message == WM_QUIT)
|
||||||
goto finished; /* two-level break */
|
goto finished; /* two-level break */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user