narzoul / DDrawCompat

DirectDraw and Direct3D 1-7 compatibility, performance and visual enhancements for Windows Vista, 7, 8, 10 and 11
BSD Zero Clause License
952 stars 70 forks source link

Exclusive Mode issue with Star Trek Armada 1 & 2 #36

Closed elishacloud closed 4 years ago

elishacloud commented 5 years ago

A while ago I was troubleshooting an issue with Star Trek Armada 1 and found a bug in Microsoft's implementation of ddraw. Apparently it was introduced in Windows 8.0, and still exists in the latest version of Windows 10.

The issue happens when an application calls SetCooperativeLevel and sets the exclusive flag on a particular window and then later closes that window without releasing the exclusive flag. In ddraw the exclusive flag remains set on the closed window. At this point any other call to make another window exclusive will fail, since ddraw still sees the first window as exclusive. However since the first window no longer exists there is no way to clear the exclusive flag. This issue happens with both Star Trek Armada 1 and 2. The result is that both games crash on launch.

I put a fix for this in my code see here. Basically I set a window hook and look for when the window is closing. Then before the window closes I remove the exclusive flag.

I thought maybe you would want to put a fix in DDrawCompat for this issue. I checked the latest experimental version and it is not able to fix this issue.

narzoul commented 4 years ago

I can't reproduce this with the latest experimental release on Windows 8.1, using the Armada 1 demo version. On Windows 10, the game crashes before even loading ddraw.dll. Can you still reproduce this issue? If yes, please attach the debug logs also.

elishacloud commented 4 years ago

It looks like this is fixed in the latest experimental release. Thanks.

BTW: You need to update the game to version 1.3 for it to work. The demo version won't work on Windows 10 for some reason and I don't think you can apply the 1.3 patch on the demo version.