Speaking of Microsoft, I found an interesting bug in their Desktop Window Manager. If you use PeekMessage in a message loop like this (just a dummy example code to emphasize the point):
- Code: Select all
while (1)
{
if (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE) || PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
DispatchMessage(&msg);
}
Sleep(1);
}
The Desktop Window Manager will consider the app unresponsive 5 seconds after it loses focus and replace its window with a ghost copy that does not respond to user input. DWM may also try replacing the app's window with a ghost window when it does have focus, so one may see a window sort of flash on a 5 second interval.
It does not happen if you do one call to PeekMessage call in a loop with wMsgFilterMin and wMsgFilterMax parameters set to 0, or disable process window ghosting with either NoGhost compatibility shim or a call to DisableProcessWindowsGhosting. It may not happen if some 3rd party window managing utility is running.
I know Surreal Software's games have their message loop written similarly, using the filtering feature of the PeekMessage API and without unofficial patches, they act weird in windowed mode with desktop composition enabled.
But it's not the bug in the games themselves, as long as you eventually call PeekMessage without a filter, you've done it correctly according to API documentation.
The bug exists since Windows Vista and is probably still present on Windows 10, I know it's in the build 15063 and I doubt it's been fixed in today's actual builds.
mirh wrote:My. Program. Is. Made. To. Launch. As. Administrator. Me. Not. Want. Dis. Interference.
Since you mentioned the manifest, I think asInvoker would translate to normal user rights under usual circumstances. highestAvailable should elevate to admin level though, at least if user is admin. It may ask for another user's credentials if he's not, but I'm not 100% certain. Really weird.
Another weird thing comes to mind, one Windows 10 PC at home, I could never reset its desktop icon layout completely (haven't purged the user account, that's no way, even though it might work). There is a key that stores it and deleting it made the system forget the layout, but the bug that creeped in some time ago, preventing from putting any icon in the lower left corner, persists.
I remember reading the funniest thing on PCGamingWiki.
Problem: Low FPS in Wolfenstein: The New Order
1st solution: Run the game as administrator
And this is a newer game that doesn't try to write its settings and saves to restricted locations. I know when it comes to old games, some will try to write some things in registry under HKEY_LOCAL_MACHINE. Microsoft's answer to this so the write doesn't fail when run with normal privileges is file/registry virtualization. But under some circumstances, registry virtualization fails to work properly and game in question fails to read its data back. I think it can happen after a normal shutdown (rather than hybrid one) or reboot, at least I remember it happening long time ago on Windows 8.1. Since then I just patch my games to write to HKEY_CURRENT_USER. A nice thing about keeping everything per-user, if you wipe user profile, all applications' user data should be gone.
Sucks to hear about what kind of support you get from MS. I might put that little program which snippet I've shown above on GitHub, though I don't feel like contacting anyone at MS. I wonder if Raymond Chen can be contacted somehow, he could write a story about that bug on his blog.

I remember reading about another problem with DWM,
someone was trying to get rid of flickering in his program without much success. There used to be the link with the demo program and there was indeed a problem. What's interesting, I found out the flicker could be prevented by applying NoGDIHWAcceleration shim. But that's a workaround rather than a fix. It seems the old Pinball game that was bundled with Windows XP is also affected by DWM's oddities, when the ball is moving at high speed, it looks like as if it disappeared temporarily. NoGDIHWAcceleration seems to help.
OK, after so much off-topic babbling, here's something on-topic: There is DelayAppDllMain shim in Compatibility Administrator, but it doesn't help with our DllMain problem. End of story. Goodbye. The end.
