Norbyte / ositools

Advanced scripting and mod support for Divinity Original Sin 2
MIT License
376 stars 30 forks source link

[Linux] DLL does not seem to be loaded with Proton #7

Open keraldi opened 4 years ago

keraldi commented 4 years ago

It seems that when playing D:OS2 on Linux via Proton on Steam, the DLL is not being loaded.

Using Proton, the game is launched via EoCApp.exe after applying the following workaround:

mv ./bin ./bin.bak && ln -s DefEd/bin bin && cd bin && mv ./SupportTool.exe ./SupportTool.bak && ln -s EoCApp.exe SupportTool.exe

(create a backup of folder 'bin', make a symlink 'bin' that points to 'DefEd/bin', change directory to 'bin', create backup of file 'SupportTool.exe', make a symlink 'SupportTool.exe' that points to 'EoCApp.exe')

Essentially launching 'EoCApp.exe' directly via Steam. Mods subscribed to in the Steam workshop show up normally in the game. Mods that require ositools cause an error that the story could not be created. Mods that do not require ositools work fine.

Linux version: openSUSE Tumbleweed x86_64 running Kernel 5.5.7-1-vanilla. Proton version: Proton 5.0-4 Game version: v3.6.58.1306

If any further information or help is required, I'll try to assist to the best of my abilities.

Norbyte commented 4 years ago

The DLL looks for the main exe using GetModuleHandleW(L"EoCApp.exe") and GetModuleHandleW(L"DivinityEngine2.exe"), to ensure that it doesn't get loaded for other apps that run from the bin directory (like ReCon, SFG compiler, launcher, etc.).

Since your EoCApp.exe is not EoCApp.exe anymore, the DLL may load but it won't do anything.

keraldi commented 4 years ago

I tried starting EoCApp.exe directly by setting the game's launch options to "/home/tobias/.local/share/Steam/steamapps/common/Divinity Original Sin 2/DefEd/EoCApp.exe"; %command% > /dev/null

(launches original EoCApp.exe, sends Steam's original launch command to /dev/null, once the game exits)

I did it like that since creating a custom launcher for D:OS2 doesn't work. The game launches normally, the DLL seems to not work still.

I would be grateful if you could send me a resource to try to compile it myself, that's what I would look into next. I'll also search for wine/proton specific information about loading DLLs like that.

If possible, I'd like to try the DLL without the GetModuleHandleW(L"*") restriction if you could provide it for me to test.

Norbyte commented 4 years ago

DXGI-Spec.zip

I've built a launcher version that always loads independently of filename (see above).

keraldi commented 4 years ago

Doesn't seem to work still, neither with the workaround, nor with launching EoCApp.exe directly. Here's the proton log of launching it with the workaround, it has a couple occurrences of DXGI but I don't know whether they're important.

steam-435150.log

Norbyte commented 4 years ago

DXGI-Spec2.zip

This one has a debug console, can you check its output?

keraldi commented 4 years ago

If the console is supposed to appear in game, it didn't. Are there any other logs I should look out for? Here's the proton log with DXGI-Spec, DXGI-Spec2 and a diff view of the logs.

steam-435150.log steam-435150.debug_console.log steam-435150.diff.log

Zerraphous commented 4 years ago

I'm also having the same issues I'll post a log based off Spec2 and there was nothing that appeared in game and I also created a .json like an older issue you had but I don't see the console anywhere. I tried checking for any new type of files it might've created as well but didn't find any in /steam or /DSO2 and below

steam-435150.log

chicken42 commented 4 years ago

Launching via the bink2w64.dll wrapper included in "Achievements -Definitive Edition" loads the DLL and launches with the Debug console on the desktop. The debug console logs a (probably unrelated) message "Unable to read VR Path Registry from ... Local Settings\Application Data\orpenvr\openvrpaths.vrpath", but seemingly continues to load, then tries to update OsirisExtender.

Updating OsirisExtender fails after successfully downloading the Update.zip file with a popup dialog "Unable to extract Script Extender update package. IShellDispatch::NameSpace() call failed on zip file ...\Update.zip"

Enabling trace on shell and seh results in the following log (exception occurs around line 15,000)

steam-435150.fail.log

Norbyte commented 4 years ago

Interesting ... looks like shell32 in Proton doesn't support reading Zip files as COM Folders, so it is unable to extract the zip. You can bypass the update step by extracting Update.zip directly to the folder it is located in (i.e. Local Settings\Application Data\OsirisExtender\).

chicken42 commented 4 years ago

After the manual extraction, everything appears to be working correctly. The DLL loading failure is probably due to Proton's DXVK overriding of DXGI.dll (in addition to the main exec check). It looks like the proton developers may be working on the DXGI issue: https://github.com/ValveSoftware/Proton/issues/2992 .

Norbyte commented 4 years ago

Looks like I'll bake a Zip library into the updater in newer versions, as there are too many issues with the shell API, i.e. it sometimes decides not to work even on Windows if people installed something that happens to interfere with it.

Not sure what can be done about DXGI.dll having a special override in Proton. I don't want to use any filename that ships with the game as game updates will wipe the extender entirely, and the other DLLs that the game imports have way too many exports so wrapping each one of them is not an option. I could add a launcher exe that injects the extender into the game, but then you'd have to use a separate launcher instead of just using the game exe.

keraldi commented 4 years ago

If it is not too much work for you, injecting it would probably the most quality of life solution for the end user. Alternatively, I'd suggest a step by step for linux users by those who made it work would be more appropriate as a native solution is not possible anyways.

Norbyte commented 4 years ago

If there is an LD_PRELOAD equivalent in Wine/Proton that would also be helpful

keraldi commented 4 years ago

I don't know about that but any command can be executed before the game is launched through Steam launch options. So if environmental variables need to be set, all that could be done via a script that is launched beforehand. But my Linux knowledge (and Proton, especially) is lacking severely.

Marenz commented 4 years ago

The closest there is to LD_PRELOAD would be WINEDLLOVERRIDES but that doesn't really help here.

Norbyte commented 4 years ago

Does launching the game exe directly work with Proton? i.e. does it redirect you to the Steam launcher or does it work without involving Steam? If it doesn't work directly, then launching via a custom injector could be similarly problematic.

keraldi commented 4 years ago

The way to launch it suggested i ProtonDB is the one I described with replacing SupportTool.exe with EoCApp.exe. As on linux, a shell script is executed when launching a game, any other executable can be launched simply by pointing at the executable that should be launched and discarding the original command.

To answer your question: Proton is used automatically by Steam to launch windows executables. Launching EoCApp.exe with WINE (not using Steam's Proton (which is a modified WINE), the game launches as well.

Although people would have to add some things to WINE themselves (patches that are in Proton), otherwise it's not playable on its own (because it doesn't utilize DXVK/Vulkan, for example, resulting in atrocious performance).

lo4952 commented 4 years ago

Stumbled upon this thread trying to install the Script Extender on Proton, curious if there has been an update or if anyone has figured out any steps to get it installed?

EDIT - WORKING Steps to set up, in order:

  1. Get zip from github and place DLL in /DefED/bin
  2. Use winetricks or protontricks to add a DLL overwrite
  3. Select "dxgi" with the source as "native"
  4. First run will give the "Could not unzip Update.ZIP" error. Go to the folder, extract the individual files within the Update folder into /Application Data/OsirisExtender
Hark0nnen commented 4 years ago

while override dxgi to native does work, it causes game to routinely crash (there are reasons wine has its own dxgi.dll). Norbyte, can you make an injector or alternate dll hook? (like bink2w64 for example)?

ngoonee commented 4 years ago

Thanks @lo4952 for the steps. I had to do native,builtin for dxgi, as 'native only' failed to start the game. Plus side is, after doing the unzipping manually it works!

longmind commented 4 years ago

i did everything as instructed. However, i did not find a Update.ZIP folder in Local Settings/Application Data. Is there anyway to fix or get around this?

Norbyte commented 4 years ago

You can get it from https://d1ov7wr93ghrd7.cloudfront.net/Release/Latest.zip

caysilou commented 4 years ago

I'm not sure if I'm doing it wrong but following the above steps stopped the game from even running for me (both native and native,builtin) I would also be interested in Linux compatibility for this tool if possible. Is there anything that we can do to help, beyond just testing?

Norbyte commented 4 years ago

I rewrote quite a bit of the updater which should resolve some compatibility issues. In particular, it no longer uses WinHTTP or the Shell API for Zip extraction, so it should work properly under Wine now.

Test version: DXGI-curltest.zip

folknor commented 4 years ago

So, I came here to write a new issue ticket asking Norbyte to tell Proton users in the release notes how to make this work using WINE, because it's really easy.

All you need to do is launch WINE/Proton using WINEDLLOVERRIDES="DXGI.dll=n,b" after following the other install instructions.

So, for Steam+Proton,

  1. Right-click the game in the games library in Steam
  2. Click Properties...
  3. Click SET LAUNCH OPTIONS... button
  4. Enter WINEDLLOVERRIDES="DXGI.dll=n,b" PROTON_NO_ESYNC=1 %command%

Close and launch, enjoy script-extended mods.

Norbyte commented 4 years ago

Thanks for the info, I've amended the instructions on the release list

otakutyrant commented 3 years ago

@folknor I have done as you said, but it still cannot seem to load the dll successfully.

otakutyrant commented 3 years ago

@folknor Could you clarify "the other install instructions" more clear please? Are they just only mv ./bin ./bin.bak && ln -s DefEd/bin bin && cd bin && mv ./SupportTool.exe ./SupportTool.bak && ln -s EoCApp.exe SupportTool.exe?

otakutyrant commented 3 years ago

I have found out that actually I pasted the command WINEDLLOVERRIDES="DXGI.dll=n,b" PROTON_NO_ESYNC=1 %command% in the launch option for two times, because after the first paste, the launch option still seems empty, showing only the end of the paste actually, so I had to paste again, resulted in an invalid launch option. After fixing this, the extended script finally works!

jn64 commented 3 years ago

Thanks for this. Using WINEDLLOVERRIDES="DXGI.dll=n,b" %command% is enough with Proton-5.9-GE-8-ST. Confirmed I got achievements with several Gift Bag features enabled.

(Proton GE also has a built-in launch fix so none of the other steps with the moving and linking files are needed. Just install, choose Proton version, add the launch option and done.)

freddiehaddad commented 1 year ago

Got it! There is a section in the configuration options for the game: https://ibb.co/QJGLrqG

In there I added:

WINEDLLOVERRIDES="version.dll=n,b" %command%

It's working!