Skip to content

Instantly share code, notes, and snippets.

@berenm berenm/dos2defed.r2
Last active Sep 21, 2018

Embed
What would you like to do?
Radare2 patch for Divinity Original Sin 2: Definitive Edition's black screen (Wine / DXVK)
# cp DefEd/bin/EoCApp.exe DefEd/bin/EoCApp.exe.bak
# r2 -w DefEd/bin/EoCApp.exe -i dos2defed.r2 -q
# sha1sum DefEd/bin/EoCApp.*
# 04c29114a7ca50d414abab399033ac88ca6dd362 DefEd/bin/EoCApp.exe
# e3baf89f0d0d1885eb7d4d718e76da99f304726b DefEd/bin/EoCApp.exe.bak
s 0x140fa0d90
wao nop
s 0x140fa93ba
wao nop
s 0x140fb3431
wao nop
s 0x1410083e9
wa jmp 0x1410083f9
s 0x141185883
wa jmp 0x14118588b
s 0x1411b3bed
wa jmp 0x1411b3bfa
s 0x1411b3d51
wa jmp 0x1411b3db5
s 0x14125ee98
wa jmp 0x14125eea0
@berenm

This comment has been minimized.

Copy link
Owner Author

commented Sep 6, 2018

This patch should help people like me who got stuck with a black screen on game startup.

The reason has nothing to do with DXVK btw, it is related to thread affinity. The game calls SetThreadAffinityMask, which returns 0 for whatever reason which indicates an error, and the game threads don't start.

This patch will overwrite the jump opcodes after the calls to SetThreadAffinityMask to completely ignore the returned result.

@notfood

This comment has been minimized.

Copy link

commented Sep 7, 2018

It seems it needs an update, the sha1sum doesn't match with the current binary.

@berenm

This comment has been minimized.

Copy link
Owner Author

commented Sep 7, 2018

It might be that the Steam version is different. I have it on GOG.

@Kron4ek

This comment has been minimized.

Copy link

commented Sep 7, 2018

On GOG version sha1sum doesn't match too.

bc5f4070791bd554f1d906fbcf3682551ed84ffb

@Rotscha

This comment has been minimized.

Copy link

commented Sep 7, 2018

I can't test this patch, as the game was updated a few days ago.

However, I took a closer look at Wine's SetThreadAffinityMask implementation. I patched it to print all return results. It never returns a zero value. At least not in my case.

Are you sure, it's related to that?

Edit:
After adjusting the addresses to the updated game, I can confirm, this patch works. Thanks very much!
I will now dig deeper into Wine to find out, what exactly causes the problem.

@Kron4ek

This comment has been minimized.

Copy link

commented Sep 7, 2018

@Rotscha, could you please give addresses for updated executable?

@notfood

This comment has been minimized.

Copy link

commented Sep 7, 2018

It'd be nice to have the steps taken to update the .exe, the game updates often and will require patching often.

@lieff

This comment has been minimized.

Copy link

commented Sep 7, 2018

Possibly game tries to set mask for wrong CPU which should fail https://github.com/ValveSoftware/wine/blob/proton_3.7/dlls/kernel32/tests/thread.c#L878
seems real bug not in SetThreadAffinityMask, but where mask is calculated.

@berenm

This comment has been minimized.

Copy link
Owner Author

commented Sep 8, 2018

I investigated a little bit more to see whether this was a wine issue or not, and from the SetThreadAffinityMask documentation, I believe it might be a game bug that has nothing to with wine.

The game first checks whether there is more or less than 6 cpus. If less, it initializes an affinity mask to 0xfffffffe that is then used for the creation of the game threads, and passed as an argument to SetThreadAffinityMask. From the Windows API documentation, I understand that passing a mask that is larger than the process affinity mask (which in turn cannot be larger than the cpu count) is incorrect, and should be treated as an error.

I don't know though if this is also the actual behavior of the Windows implementation, but it looks to me that Wine is implementing the API specification correctly.

@ChaoticShiny

This comment has been minimized.

Copy link

commented Sep 9, 2018

I also would like to know the new addresses.

@berenm

This comment has been minimized.

Copy link
Owner Author

commented Sep 12, 2018

I updated the addresses and sha1sums for the latest GOG version.

Please note however that there's a a Wine patch being worked on by Roger Zoellner, to fix this issue the right way.

@Odelpasso

This comment has been minimized.

Copy link

commented Sep 21, 2018

I don't know if someone will read this message but i have a problem with wine-staging 3.16 and the game.
The game works but when i choose the mod for my game (story mod, exploration mod or other), the loading bar stay empty during very long time. The message popup in the loading screen appears randomly and there is the music so the game has not crashed. It really the loading bar which stay empty and don't load...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.