ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.72k stars 376 forks source link

SDL1 Installer and executable doesn't work under Windows XP #6002

Closed GeorgeK1ng closed 1 year ago

GeorgeK1ng commented 2 years ago

Preliminary checks

Platform

Windows

Describe the bug

SDL1 Installer doesn't work under XP, even with modified MajorSubsystemVersion to 5 under Optional Header using CFF Explorer and recalculated checksum. Another error apper then.

When I downloaded SDL1 ZIP package and tried running fheroes2.exe it can't be launched. Because it's not valid Win32 executable. But when I mod MajorSubsystemVersion to 5, I can finaly play under Windows XP SP3.

Can you change needed MajorSubsystemVersion in SDL1 compilation to be able to run under Windows XP? No issues detected, game works. I tried it only few minutes with success.

SDL2 ZIP version is not suitable to apply same hack.

I have no idea where should I look for changing MajorSubsystemVersion from Vista (6.0) to XP (5.1) in published code.

Extracted SDL1 ZIP image

Extracted SDL1 ZIP with fixed fheroes2.exe image

image

Testing was done on Windows XP SP3+ (+ means all updates and additions until 04-2019 when MS released last updated). Of course testing image was build using my XP2ESD project which help users to run XP on modern systems.

I hope you can change SDL1 to be fully supported under XP from next version. Otherwise I can provide small HEX patch for already compiled EXE.

Save file

No save file

Additional info

No response

zenseii commented 2 years ago

Hi @GeorgeK1ng.

We already have this issue posted with regards to XP support: https://github.com/ihhub/fheroes2/issues/5327

Since these are the same I suggest to close this one and move the points you have made here over to that one.

BTW on a different note, you seem to not have pushed your latest changes to your current PR https://github.com/ihhub/fheroes2/pull/5999 and so there is nothing to review there.

GeorgeK1ng commented 2 years ago

Hi @zenseii, I have checked that ticket. It's similar issue. I have checked all files with Depency Walker and only smpeg.dll have missing imports and can cause problems.

image

If I understand correctly, here is solution how to compile it without needs of LIBSTDC++-+.DLL https://stackoverflow.com/questions/6404636/libstdc-6-dll-not-found

I see nothing happends to support fheroes2.exe natively. I can upload small "toolkit" that will use two command line apps. bbe + modifype. Script will find automaticaly HEX patter in EXE, modify 6 to 5 and recalc checksum. Then it can be distributed in ZIP as start of XP support in SDL1.

I see nobody solved that issues for now

zenseii commented 2 years ago

I have checked that ticket. It's similar issue.

Yes, then to avoid having duplicate issues, I suggest we move your points to that issue so that the people who participated in that will be notified. Also we do not want to have duplicate issues here because that becomes very untidy. I hope you can understand.

I see nothing happends to support fheroes2.exe natively. I can upload small "toolkit" that will use two command line apps. bbe + modifype. Script will find automaticaly HEX patter in EXE, modify 6 to 5 and recalc checksum. Then it can be distributed in ZIP as start of XP support in SDL1.

Yes, it has not been decided whether to add XP support yet or not. However, it seems if we do then, according to the previous issue's discussion, we will want to build it as part of our pipeline and not have to add many extra downloadables and tools. I think this would be much easier for an end user.

I see nobody solved that issues for now

Yes, so since that issue wasn't closed then I think the best thing is to close this new one and move over to the previous issue.

GeorgeK1ng commented 2 years ago

@zenseii Feel free to move it to previous ticket. I was meaning toolset for Devs, one single batch that can fix EXE after compiling before uploading ZIP

GeorgeK1ng commented 2 years ago

Here is MajorVersion fix "toolkit" for compiled file. Download and extract somewhere. https://www.mediafire.com/file/311099je6el18us/FIXFHEROES2.7z/file

Then run it like this from script or CMD.

FixFHEROES2MajoverVer.cmd F:\SDL1\fheroes2.exe

Result is F:\SDL1\fheroes2_fixed.exe which can run under Windows XP. To fully support XP, only SMPEG.DLL depency to LIBSTDC++-6.DLL must be solved. Of course if someone find solution for code instead of post compile hack, it would be much better.

oleg-derevenetz commented 2 years ago

Reclassifying this as a request for improvement with no milestone, because currently we have no plans to support Windows XP (as well as Windows 2000 and Windows 95).

GeorgeK1ng commented 2 years ago

Missing imports can be solved by adding these files libstdc++-6.dll libgcc_s_dw2-1.dll https://github.com/ihhub/fheroes2/issues/6007#issuecomment-1285530898

So only HeroesMajorVer FIX is needed to fully support Windows XP in SDL1 https://github.com/ihhub/fheroes2/issues/6002#issuecomment-1284672698

ihhub commented 1 year ago

Hi @GeorgeK1ng , if you still insist on Windows XP support I have an alternative: if you have time try to create a batch script, let's call it fix_windows_xp_support.bat which will include the code for HeroesMajorVer fix and to download missing libraries. After this you can create a pull request.

GeorgeK1ng commented 1 year ago

Hi @ihhub, batch (CMD) set for fix executable is already here.

https://github.com/ihhub/fheroes2/issues/6002#issuecomment-1284672698

And here are needed files to fix missing depencies on SMPEG.dll https://github.com/ihhub/fheroes2/issues/6007#issuecomment-1285530898

oleg-derevenetz commented 1 year ago

Hi @ihhub what do you think about dropping the SDL1 support entirely (not now, but after 1.0 maybe)?

ihhub commented 1 year ago

Hi @oleg-derevenetz , I am for dropping SDL1 in the future. Right now the only advantage SDL1 has is support of 8-bit palette based images which SDL2 somehow doesn't have.

Gerwin2k commented 1 year ago

@GeorgeK1ng Two quotes from you below. Oct 19, 2022 - "SDL2 ZIP version is not suitable to apply same hack." Oct 20, 2022 - "SDL2 can't be launched under Windows XP" No intention to get involved, but I wonder what you mean... Since I just downloaded latest FHeroes2 nightly SDL2, changed a single byte 6 -> 5, and then it runs on Windows XP. SDL2 in itself is XP compatible, only release SDL2 2.24 regressed that, and 2.24.1 fixed it again.

zenseii commented 1 year ago

All of the points @oleg-derevenetz made above

SDL2 in itself is XP compatible

only advantage SDL1 has is support of 8-bit palette based images

So the SDL1 question is about 8-bit image support rather than supported systems.

It'd also be great to drop SDL1 support because this has been more the rule than the exception as of late:

image

Not to mention users being confused about which one to get because obviously most people have no idea what SDL1 and 2 are. Why wouldn't 1 be better if it's number 1 :P Looking at the amount of monthly downloads I'm surprised there are so many for SDL1 on Windows, this might explain it. I'm still curious about SDL1 64-bit for Windows and what sort of setup necessitates that. It's obviously not Win XP 64-bit because we just got proof it supports SDL2.

ihhub commented 1 year ago

I'm really thinking then not to include SDL1 into 1.0 release. I'll check within few days what we're loosing not including it anymore.

GeorgeK1ng commented 1 year ago

I just checked current SDL2. It can be launched on XP using same hack. But not all binaries works. When I launched fixed EXE it show me error about ws2_32.dll.

image

Then I decided to check all files depencies again using Depency Walker. Here is file list that have missing imports. Most of them are shared between files. Is there any chance to adapt code to full XP support please?

GIO-2.0-0.dll

IPHLPAPI.DLL


NotifyRouteChange2 if_nametoindex GetIpForwardTable2 CancelMibChangeNotify2

WS2_32.DLL


inet_ntop inet_pton

KERNEL32.DLL


AcquireSRWLockExclusive AcquireSRWLockShared GetFileInformationByHandleEx InitializeConditionVariable InitializeSRWLock ReleaseSRWLockExclusive ReleaseSRWLockShared SleepConditionVariableSRW TryAcquireSRWLockExclusive TryAcquireSRWLockShared WakeAllConditionVariable WakeConditionVariable

SHELL32.DLL


SHGetKnownFolderPath

ADVAPI32.DLL


RegLoadMUIStringW

GLIB-2.0-0.dll

KERNEL32.DLL


AcquireSRWLockExclusive AcquireSRWLockShared GetFileInformationByHandleEx InitializeConditionVariable InitializeSRWLock ReleaseSRWLockExclusive ReleaseSRWLockShared SleepConditionVariableSRW TryAcquireSRWLockExclusive TryAcquireSRWLockShared WakeAllConditionVariable WakeConditionVariable

SHELL32.DLL


SHGetKnownFolderPath

ADVAPI32.DLL


RegLoadMUIStringW

GMODULE-2.0-0.DLL

KERNEL32.DLL


SetThreadErrorMode

LIBFLUIDSYNTH-3.DLL

WS2_32.DLL


inet_ntop

This test was performed on Windows XP SP3+ x86. Test on Windows XP SP2+ x64 will be done in few hours too.

oleg-derevenetz commented 1 year ago

@ihhub

I'm really thinking then not to include SDL1 into 1.0 release. I'll check within few days what we're loosing not including it anymore.

I suggest we wait with that and do this after 1.0. There will be a lot of cleanups, we can accidentally break something.

GeorgeK1ng commented 1 year ago

According to x64 test under XP. Reported depencies from previous post are mostly same. Only EXE have new additional missing depencies. I think good start is to try adapt current SDL2 missing imports on x86 and then we can continue to x64 as only EXE depencies will remain probably.

Gerwin2k commented 1 year ago

I just checked current SDL2. It can be launched on XP using same hack. But not all binaries works. When I launched fixed EXE it show me error about ws2_32.dll.

For FHeroes2 nightly Windows XP usage you can remove all dll-files except these four: SDL2.dll SDL2_image.dll SDL2_mixer.dll zlib1.dll

The absence of the other dlls will not give any errors, as they are optionally loaded. This way, you cannot use the included Fluidsynth music option for one. libfluidsynth-3.dll introduces runtime dependencies on the GCC side. Whilst the core of the game is MSVC runtime. Though you can still use any Windows Midi music device through midi mapper (including the official Fluidsynth XP package in server mode).

Edit: scratch the "on the GCC side".

oleg-derevenetz commented 1 year ago

@Gerwin2k

libfluidsynth-3.dll introduces runtime dependencies on the GCC side.

How could it be if FluidSynth as well as other SDL2-related libs are built with MSVC as well? Something is definitely wrong with your analysis.

oleg-derevenetz commented 1 year ago

When I launched fixed EXE it show me error about ws2_32.dll.

This is the standard Winsock2 DLL. I don't remember whether is was available for WinXP, probably not.

Gerwin2k commented 1 year ago

@Gerwin2k

libfluidsynth-3.dll introduces runtime dependencies on the GCC side.

How could it be if FluidSynth as well as other SDL2-related libs are built with MSVC as well? Something is definitely wrong with your analysis.

Yeah, I stand corrected on that part. Sorry. The dlls starting with "libg" in their name reminded me of GNU dlls, as glib2 is a common GCC package.

Gerwin2k commented 1 year ago

When I launched fixed EXE it show me error about ws2_32.dll.

This is the standard Winsock2 DLL. I don't remember whether is was available for WinXP, probably not.

It is there in XP, but only the call "inet_ntop" is not. This is Fluidsynth again.

ihhub commented 1 year ago

@ihhub

I'm really thinking then not to include SDL1 into 1.0 release. I'll check within few days what we're loosing not including it anymore.

I suggest we wait with that and do this after 1.0. There will be a lot of cleanups, we can accidentally break something.

Hi @oleg-derevenetz , by removing I meant to just not including binaries in the release on GitHub while retaining the code for it.

GeorgeK1ng commented 1 year ago

I have tried current branch to target for XP with SDL2. So I changed project toolset to v141_xp and compiled it. No errors at all during compilation. But when I tried it under XP. I got error and EXE can't be launched due missing imports. When compiling using XP toolset, there is no need to hack EXE after compiling.

This first issue can be solved by extracting all DLLs from fluidsynth XP package to game root https://github.com/FluidSynth/fluidsynth/releases

But after then there are still 4 missing imports from kernel32.dll in SDL2.dll.

CreateSymbolicLinkW Can be probably replaced with https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-iocreatesymboliclink

GetFinalPathNameByHandleW

GetFileInformationByHandleEx SetFileInformationByHandle

Last two seems possible to fix with this code. http://space-for-all.blogspot.com/2009/01/fileextdlib-for-xp2003.html

I hope someone can have a look on this issue

NOTE, I can't find usage of these function is source.

Any idea how to solve these few problems to fully support XP in SDL2?

EDIT: I tried now both SDL1 and SDL2 and they have exactly same issue with kernel32.dll imports. SDL1 directly from EXE. SDL2 from DLL. I ques between 1.0.1 and 1.0.2 was added something that breaks this compatibility?

GeorgeK1ng commented 1 year ago

There also exist XP "mod", see readme inside archive. http://www.gb-homepage.nl/download/backports/FHeroes2_XPmod.zip

Seems like there was no changes to source, just prepared special build environment. Maybe you can add support for XP using this mechanism?