ayuanx/pal-ddraw

Proxy ddraw.dll not loaded into process on a 2nd start on Win9x

emxd opened this issue · 1 comments

emxd commented

Hello,

as you're probably aware, Win9x (unlike NT) has this peculiar behavior, where certain dlls upon being loaded are registered in memory and the registration persists even when the process is closed (ddraw.dll is one such dll). Then when the process is started for a second time, a LoadLibrary("ddraw.dll") call goes straight for the "registered" system ddraw.dll instead of loading the proxy.dll that resides in the .exe path. On pal-ddraw this can be tested for example with a demo of Fallout (https://archive.org/details/FalloutDemo) and some tool like ProcessExplorer to observe loaded dlls. On the first start, both proxy ddraw and system ddraw are loaded. However after closing the game and restarting, only system dll is loaded, proxy is ignored.

I'm opening this ticket partially for self-serving reasons - I'm writing a win9x ddraw proxy myself and I'm facing this problem :). There aren't that many people that do ddraw proxies for win9x so I was wondering if you have any ideas on how to solve this problem cleanly. The traditional way I think was to patch the .exe to load a different file from ddraw and load the system ddraw from the proxy. (this way, because the proxy has a different name from "ddraw" it doesn't face the registration problem). Other approach (softgpu does this), is to replace the system ddraw library with a proxy switcher, (so you'd have a proxy in the game's folder, a proxy in the \windows\system folder and the renamed real system ddraw in \windows\system). But this is a bit ugly, since you have to change/rename the system ddraw.dll

To sum it up, I'm mostly opening this ticket to poke your brain, specifically:

  1. Do you know the specifics on why Win9x behaves this way as opposed to Windows NT?
  2. Do you think there's some clean solution that doesn't involve changing the .exe or changing the system dll? I.e. I'd like it to be the same it is on NT, just plop the proxy next to the game's .exe without any additional hacking.
ayuanx commented

Yes, I am aware of this issue on Win9x.

Personally I prefer to patch the app/game itself by renaming the dll.
It is clean, permanent, and also makes the app/game itself portable, so that the app/game will work on any machines without further work on both Win9x and WinNT.
You can write a small yet generic patcher to do the job for any app/game that requires the ddraw wrapper.

But that is just my own opinion.