https://bugs.winehq.org/show_bug.cgi?id=3930
--- Comment #87 from Damjan Jovanovic damjan.jov@gmail.com --- (In reply to Dmitry Timoshkov from comment #86)
Created attachment 78138 [details] patch
Something like this may work.
That doesn't work, because GetCurrentThread() only returns a pseudo handle, "a special constant that is interpreted as the current thread handle" (MSDN). I think we have to compare the globally unique thread IDs to be sure:
---snip--- if (GetCurrentThreadId() == GetThreadId(thread) && (GetVersion() & 0x80000000)) return 0; ---snip---
That fixes all the tests, but doesn't fully fix the game: it no longer deadlocks and even plays music (it was silently frozen before), but shows badly corrupted video (bottom ~2/3 of the screen are black, and the top 1/3 has randomly colored pixels), which makes it completely unplayable. Running it with "wine HEROES.EXE /s0" (which disables all sound) gets the graphics fully functional. This however, seems to be a separate issue, probably a regression as this WINMM fix was enough in earlier Wine versions, but now isn't.