X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/69a1f86cc2ef54163313a2c297585b0628f3fe26..1c3d42bcaee819b8172a9b66d52e50180ef90a98:/windows/window.c diff --git a/windows/window.c b/windows/window.c index 81a28aa4..d58111fd 100644 --- a/windows/window.c +++ b/windows/window.c @@ -836,9 +836,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) sfree(handles); - if (GetMessage(&msg, NULL, 0, 0) != 1) - break; - do { + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) goto finished; /* two-level break */ @@ -852,7 +850,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) */ if (must_close_session) close_session(); - } while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)); + } /* The messages seem unreliable; especially if we're being tricky */ term_set_focus(term, GetForegroundWindow() == hwnd); @@ -1966,11 +1964,11 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; - filemap = CreateFileMapping((HANDLE) 0xFFFFFFFF, + filemap = CreateFileMapping(INVALID_HANDLE_VALUE, &sa, PAGE_READWRITE, 0, sizeof(Config), NULL); - if (filemap) { + if (filemap && filemap != INVALID_HANDLE_VALUE) { p = (Config *) MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, sizeof(Config));