elishacloud / dxwrapper

Fixes compatibility issues with older games running on Windows 10/11 by wrapping DirectX dlls. Also allows loading custom libraries with the file extension .asi into game processes.
zlib License
1.16k stars 83 forks source link

Help with Sonic Mania Plus #50

Closed Storm3000 closed 1 year ago

Storm3000 commented 4 years ago

Hi!

I've been trying to integrate WineD3D to Sonic Mania Plus because apparently fixes the random missing background music and the FMV sequence on Intel graphic cards, but if I use WineD3D, it won't work the Sonic Mania Mod Loader (a program wich allow you to use any mod on Sonic Mania). I've tried to use the d3d8.dll file from Silent Hill 2: Enhanced Edition on Sonic Mania Plus and works awesome, but again, the Mod Loader won't work. This Mod Loader generates a d3d9.dll file that allows the program to work correctly.

My question is: Is it possibly to add the fixes from WineD3D or the d3d8.dll file from SH2:ED into the d3d9.dll file generated by Sonic Mania Mod Loader?

This is the original file generated by Sonic Mania Mod Loader: https://www34.zippyshare.com/v/j4hJVIrw/file.html

elishacloud commented 4 years ago

Without the source code for the Sonic Mania Mod Loader it would be difficult to add on to it. However, I did make a project that allows you to use WineD3D with other wrappers. It is called LoadWineD3D-ASI. I already created a package that should work for this.

Steps:

  1. Delete the existing WineD3D and Sonic Mania Mod Loader files from the Sonic Mania Plus game.
  2. Download this and unzip all files in the Sonic Mania Plus folder: dxwrapper.zip
  3. Copy the WineD3D files into the scripts folder that was created in step 2 above.
  4. Run the game.

A few notes:

Storm3000 commented 4 years ago

Thank you, elishacloud.

Sadly, it doesn't work. The background music is still missing randomly, just like it used to happen with Silent Hill 2.

I can notice if the WineD3D file is working or not 'cause at the moment that I press Alt+Tab, the music stops, then plays again once I go back into the game. When I'm not using WineD3D, the music keeps playing even on the Desktop screen.

elishacloud commented 4 years ago

Can you attach the dxwrapper and LoadWineD3D-ASI log files? Note: the LoadWineD3D-ASI log file will be in the scripts folder.

Storm3000 commented 4 years ago

dxwrapper-sonicmania

4240 22:38:35.288 Starting DxWrapper v1.0.6342.21 4240 22:38:35.288 Gigabyte Technology Co., Ltd. M68MT-S2P (Desktop) 4240 22:38:35.288 Gigabyte Technology Co., Ltd. M68MT-S2P (Desktop) 4240 22:38:35.288 NVIDIA GeForce GT 520 4240 22:38:35.289 Windows 7 64-bit (6.1.7601) Service Pack 1 4240 22:38:35.289 "SonicMania.exe" (PID:5572) 4240 22:38:35.289 Steam game detected! 4240 22:38:35.290 Disabling High DPI Scaling... 4240 22:38:35.290 Loaded library: user32.dll 4240 22:38:35.290 Loading ASI Plugins 4240 22:38:35.303 Loaded library: C:\Program Files (x86)\Sonic Mania\scripts\LoadWineD3D.asi 4240 22:38:35.304 DxWrapper loaded! 4240 22:43:20.148 Quiting DxWrapper 4240 22:43:20.148 Unloading libraries... 4240 22:43:20.148 Reseting screen resolution 4240 22:43:20.228 Reseting font smoothing 4240 22:43:20.233 DxWrapper terminated!

LoadWineD3D

4240 22:38:35.293 Starting Load WineD3D! v0.1.206.1 4240 22:38:35.293 Checking "C:\Program Files (x86)\Sonic Mania\scripts\d3d8.dll" 4240 22:38:35.298 Checking "C:\Program Files (x86)\Sonic Mania\scripts\d3d9.dll" 4240 22:38:35.298 Found "d3d9.dll"! 4240 22:38:35.303 "C:\Windows\system32\d3d9.dll" addr=00AD0000 4240 22:38:35.303 Checking Direct3DCreate9 ... 4240 22:38:35.303 Hooked Direct3DCreate9 count 1 addr=00B30A62 4240 22:38:35.303 Checking Direct3DCreate9Ex ... 4240 22:38:35.303 Hooked Direct3DCreate9Ex count 2 addr=00ADCCD5 4240 22:38:35.303 Checking D3DPERF_BeginEvent ... 4240 22:38:35.303 Hooked D3DPERF_BeginEvent count 3 addr=00B771DB 4240 22:38:35.303 Checking D3DPERF_EndEvent ... 4240 22:38:35.303 Hooked D3DPERF_EndEvent count 4 addr=00B77249 4240 22:38:35.303 Checking D3DPERF_QueryRepeatFrame ... 4240 22:38:35.303 Hooked D3DPERF_QueryRepeatFrame count 5 addr=00B7738D 4240 22:38:35.303 Checking D3DPERF_SetMarker ... 4240 22:38:35.303 Hooked D3DPERF_SetMarker count 6 addr=00B772B5 4240 22:38:35.303 Checking D3DPERF_SetOptions ... 4240 22:38:35.303 Hooked D3DPERF_SetOptions count 7 addr=00B77402 4240 22:38:35.303 Checking D3DPERF_SetRegion ... 4240 22:38:35.303 Hooked D3DPERF_SetRegion count 8 addr=00B77321 4240 22:38:35.303 Checking D3DPERF_GetStatus ... 4240 22:38:35.303 Hooked D3DPERF_GetStatus count 9 addr=00B7746D 4240 22:38:35.303 Checking Direct3DShaderValidatorCreate9 ... 4240 22:38:35.303 Hooked Direct3DShaderValidatorCreate9 count 10 addr=00B0F5AF 4240 22:38:35.303 Checking "C:\Program Files (x86)\Sonic Mania\scripts\d3d10.dll" 4240 22:38:35.303 Checking "C:\Program Files (x86)\Sonic Mania\scripts\d3d10core.dll" 4240 22:38:35.303 Checking "C:\Program Files (x86)\Sonic Mania\scripts\d3d11.dll" 4240 22:38:35.303 Checking "C:\Program Files (x86)\Sonic Mania\scripts\ddraw.dll" 4240 22:38:35.303 Checking "C:\Program Files (x86)\Sonic Mania\scripts\dxgi.dll" 4240 22:43:20.147 Unhooking procs... 4240 22:43:20.147 Unloading dlls... 4240 22:43:20.147 Quiting LoadWineD3D

Storm3000 commented 4 years ago

I've been investigating, and maybe the problem isn't the game itself. I think the Mod Loader has changed something into the game. So I think that WineD3D is not neccesary. I contacted the mod's creator to apply his mod without the Mod Loader program and he told me this:

"Sorry I currently don't support the use of WINE with my mods. It requires the modloader to work. So your best bet is to either get the modloader to work with it or just inject the DLL and call the Init function with the path to the directory containing the DLL pushed into the stack."

I didn't understand the last thing he meant. How can I inject the dll?

The mod contains three files: config.ini, mod.ini and Dll4.dll.

elishacloud commented 4 years ago

I didn't understand the last thing he meant. How can I inject the dll?

Injecting the dll is easy. Do this:

  1. Ensure Dll.dll, config.ini and mod.ini files all exist in the game folder.
  2. Delete the current d3d9.dll file.
  3. Move all the WineD3D files out of the scripts folder and into the game folder.
  4. Delete the scripts folder and everything left in it.
  5. Modify the dxwrapper.ini file as seen below:
LoadCustomDllPath          = Dll.dll

Edit: fixed the steps to use the actual mod rather than the d3d9.dll

elishacloud commented 4 years ago

I just realized that you probably still need to use the d3d9.dll in order to load Dll.dll properly. So instead you can rename the d3d9.dll to DllLoader.dll and copy it to the Game folder. Then change the dxwrapper.ini file like this:

LoadCustomDllPath          = DllLoader.dll
.dll

To make this simple I created package for you: dxwrapper.zip

  1. Delete the script folder if it still exists.
  2. Extract these files into the game folder.
  3. Copy the WineD3D files into the game folder.
  4. Copy the three mod files Dll.dll, config.ini and mod.ini into the game folder, if they don't already exist there.
  5. Run the game.
Storm3000 commented 4 years ago

Sadly, it doesn't work.

I played yesterday and I realized that apparently isn't necessary the WineD3D files after all, at least not for now. I think the Mod Loader program is provoking the missing music bug. So, my best bet is to get rid of the Mod Loader program and use directly the Dll4.dll, config.ini and mod.ini directly into the game's directory. But I don't know how to make it work without the Mod Loader program.

The game itself doesn't include a d3d9.dll file. In order to work, the Mod Loader program installs a d3d9.dll file into the game's directory. So the Mod Loader program needs to read that specific d3d9.dll file. It won't work if I change the name or I try to replace the file by another one. It has to be that specific d3d9.dll file in order to make Mod Loader work. The problem is that I can use WineD3D, but the Mod Loader program (and thus, the mods) won't work, because the game will use another d3d9.dll. In the other hand, if I use the d3d9.dll file created by the Mod Loader program it won't fix the missing audio bug and I can't use WineD3D or any other dll file.

It would be possible to load the mod files (Dll4.dll, mod.ini and config.ini) directly into the game's directory without installing the Mod Loader program? The creator of the mod sent me that message I pasted above.

Storm3000 commented 4 years ago

@elishacloud Sorry to bother you again.

Do you know how to inject a DLL file (in this case, Dll4.dll) into the game's directory and call the Init function with the path directory containing the DLL file?

elishacloud commented 4 years ago

Yes. From the comment, it looks like there are two steps to load dll4.dll into the game:

  1. Push the folder path onto the stack.
  2. Call the Init() function of the dll.

I do not have the game, but if you can give me a copy of the Mod I can try and make a custom build of my stub that will load this Mod correctly.

Storm3000 commented 4 years ago

Yes, sure. Here you have: https://www29.zippyshare.com/v/IYnDzqKP/file.html

Originally, the TinyManiaPatches folder goes into another folder called "mods", that way the Mod Loader can load any mod added into the folder from there.

The exe for the game is called SonicMania.exe

Thank you. :)

Storm3000 commented 4 years ago

Hi, @elishacloud

I received a message from the mod's creator after asking him again how to apply the DLL into the game. He wrote this:

"You will need to call the Init function after you inject it into the game. The function is exported."

I still don't know what does it mean.

elishacloud commented 3 years ago

@Storm3000, with the latest release I will call the "InitializeASI" function after loading each ASI, if that function exists. If that is the name of the Init function that is used for this mod then you should be able to load it as an ASI with dxwrapper. If it is using a different name you can change this line to have it load a different function name.

elishacloud commented 1 year ago

Closing this out. It should be completed.