Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(DirectDraw) Programmatically disable the 8- and 16-bit compatibility shim #33

Open
nmlgc opened this issue Dec 30, 2022 · 0 comments
Open
Labels
Vintage Only necessary to keep the game working on the old Windows 9x systems that it originally targeted. ~≤0.33 pushes Projected number of pushes needed. Might turn out to get more expensive!

Comments

@nmlgc
Copy link
Owner

nmlgc commented Dec 30, 2022

While #3 implemented a proper 32-bit mode, DirectDraw's DWM8And16BitMitigation might still be active from running a previous version of a Shuusou Gyoku binary from the same path. This mitigation provides the emulated 8- and 16-bit modes even on modern Windows systems that don't support them, and are what causes the infamous slowdown in the first place. Ideally, we would remove this mitigation programmatically and not even offer players the option to select an actually unsupported, emulated video mode.

Doing that is not trivial hough:

  • Removing the mitigation's registry keys manually requires admin rights, since they might be set system-wide under HKEY_LOCAL_MACHINE, in addition to HKEY_CURRENT_USER.
  • Even if we did delete both keys programmatically, they wouldn't apply to the currently running process. DirectDraw checks for the state of the mitigation by calling DWM8And16Bit_IsShimApplied_CallOut() from apphelp.dll. This DLL is loaded into the game process at startup, and the flag read by the above function call is set on its DLL entry point, before any of our code gets to run.

That only leaves IAT patching as the most reliable method to override this flag, which is also what DDrawCompat arrived at:
https://github.com/narzoul/DDrawCompat/blob/7a59458d585fbf7eb1b243fc133c091bbdf561ce/DDrawCompat/Win32/DisplayMode.cpp#L276

Too complicated to handle within the same push as #3.

@nmlgc nmlgc added Enhancement New feature or request ~≤0.33 pushes Projected number of pushes needed. Might turn out to get more expensive! labels Dec 30, 2022
@nmlgc nmlgc changed the title Programmatically disable DirectDraw's 8- and 16-bit compatibility shim (DirectDraw) Programmatically disable the 8- and 16-bit compatibility shim Jul 19, 2023
@nmlgc nmlgc added the Vintage Only necessary to keep the game working on the old Windows 9x systems that it originally targeted. label Jul 19, 2023
@nmlgc nmlgc removed the Enhancement New feature or request label Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Vintage Only necessary to keep the game working on the old Windows 9x systems that it originally targeted. ~≤0.33 pushes Projected number of pushes needed. Might turn out to get more expensive!
Projects
None yet
Development

No branches or pull requests

1 participant