Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent users from using the wrong game path (again) #1355

Closed
PhilipJFryFAF opened this issue Jul 21, 2019 · 18 comments · Fixed by #1595
Closed

prevent users from using the wrong game path (again) #1355

PhilipJFryFAF opened this issue Jul 21, 2019 · 18 comments · Fixed by #1595

Comments

@PhilipJFryFAF
Copy link
Collaborator

had a user this week on discord who couldn't run the game
he managed to select vanilla supcom for the base game install instead of forged alliance

please don't allow users to select the vanilla supcom install directory (tested myself and the client doesn't throw an error when trying to do so in 0.10.7)

@Geosearchef
Copy link
Member

How can we distinguish the two? Currently the client just looks for the bin folder.

@Brutus5000
Copy link
Member

Vanilla has a SupremeCommander.exe in bin and FA has a ForgedAlliance.exe in bin.
You could even tell the user: hey looks like you selected Supreme Commander vanilla, not Forged Alliance

@Katharsas
Copy link
Collaborator

Katharsas commented Jul 21, 2019

Duplicate of #1100
Since the steam files are static, we could just check that some files have expected hashes? This way we also would notice if the steam install is modded / patched.

@1-alex98
Copy link
Member

1-alex98 commented Mar 4, 2020

@PhilipJFryFAF @speed2CZ is there a use case where u select the vanilla game for coop??? I need to know because otherwise I can quickly do this here

@1-alex98
Copy link
Member

1-alex98 commented Mar 4, 2020

Ok so I checked @Brutus5000 and

Vanilla has a SupremeCommander.exe in bin and FA has a ForgedAlliance.exe

is wrong my FA game has an EXE called SupremeCommander.exe

@1-alex98
Copy link
Member

1-alex98 commented Mar 4, 2020

So how do I detect somebody selects the vanilla game. I don't have the vanilla game some somebody needs to tell me preferably I would like to check for the existence of a file that is not there is the noral FA installation.

@Slothologist
Copy link
Contributor

Good candidates would be the "Microsoft.VC80.CRT.manifest" or the "LuaPlus.exe" file of the vanilla bin folder. Both are not present in the FA bin folder.
The "steam_api.dll" and "steam_appid.txt" on the other hand are not present in the vanilla folder.

@1-alex98
Copy link
Member

1-alex98 commented Mar 4, 2020

Well there are also valid not steam version of the game so those files are probably a bad idea

@1-alex98
Copy link
Member

1-alex98 commented Mar 4, 2020

Or maybe use the hash of the vanilla exe.... not sure if that's a good idea. There are probably different version of the game

@Slothologist
Copy link
Contributor

Isn't a steam version of the game required nowadays, due to the multiacc issue? If not, you are of course right.

Super low effort solution would be to just check the path given by the user itself. If the user did not manually rename the folders, they should be
some/path/where/you/install/your/games/Supreme Commander/bin
versus
some/path/where/you/install/your/games/Supreme Commander Forged Alliance/bin
So if your path ends with "Forged Alliance/bin" you are almost certainly in the right folder.

You could also check files in the movies folder, these are (almost?) entirely different.
The file size of the SupremeCommander.exe also seems vastly different, 0.5 MB (vanilla) versus 13MB (FA).

Hashing sure is the way to go if you also want to ensure an unaltered game (or want to remind the user he has a altered game which will not work). Would you then just hash the main .exe or the whole game folder, which could take a while (especially on HDD's)? Afaik most if not all normal mods were/are installed to the supcom/mods folder, so I don't think that they have an impact on FAF at all.
One should consider that updates to old games on steam are super rare, but not unheard of (see e.g. https://steamcommunity.com/discussions/forum/0/1780513643846438019/ ), so if a given hash is hard-coded in, a steam update could break this overnight.
Still, hashing looks like the way to go, especially if you want to combat #1100 as well, as @Katharsas pointed out. False negatives could either way be mitigated by just warning the user instead of absolutely disallowing them to use a "modified" game folder.

@1-alex98
Copy link
Member

1-alex98 commented Mar 5, 2020

Well yes the folder name is probably a good indicator as well and no steam version is not required, steam lining is required! There is a difference. Users are not forced to install via steam they just need to own it in steam

@1-alex98
Copy link
Member

1-alex98 commented Mar 5, 2020

@Slothologist so u own the vanilla game on steam? Can you provide me the SHA-2 hash of it? Like only the exe

@Geosearchef
Copy link
Member

Geosearchef commented Mar 5, 2020

SupCom
CRC-32: 715FBE24 (We do not need the one way property of a hash function and CRC should be way faster)
SHA256: 1AFBCD0CA85546470660FA8AC09B230E870EC65C8D1B33FEB6731BB5D4C366C5

@1-alex98
Copy link
Member

1-alex98 commented Mar 5, 2020

CRC32 does not prevent collisions by design which is probably not bad since there are only a few files that we will ever run the chec on but I think SHA is at least in theory more fitting.

@Geosearchef
Copy link
Member

Geosearchef commented Mar 5, 2020

CRC is built to detect bit errors, so yes, we don't have single bits, go for a longer checksum/hashfnct.

1-alex98 added a commit that referenced this issue Mar 5, 2020
@1-alex98
Copy link
Member

1-alex98 commented Mar 5, 2020

@Geosearchef @Slothologist go test the PR ;) I included the hash from Geosearched but we could also include further hashes

@1-alex98
Copy link
Member

1-alex98 commented Mar 5, 2020

I also avoided that the user selects the faf ProgrammData one because I also had reports about users selecting that one

@1-alex98 1-alex98 linked a pull request Mar 5, 2020 that will close this issue
@Slothologist
Copy link
Contributor

Slothologist commented Mar 5, 2020

Sadly this does not work (at least on linux).
The hashes created by the function differ from the actual hashes. Note that sha256sum gives the same hash value @Geosearchef has provided (via command line).
Because of that I never run into the "vanilla exe detected" case.

Edit: I fixed that in bugfix/#1594-ask-for-game...Slothologist:bugfix/#1594-ask-for-game

1-alex98 added a commit that referenced this issue Mar 11, 2020
Fixes #1594

Fixes #1355

Fixes #1100

Fixes #1614  

* fixed hash function for supcom.exe (#1614)

Co-authored-by: Slothologist <rfeldh@gmail.com>
@1-alex98 1-alex98 added this to the v1.1.4 milestone Mar 11, 2020
mrchris2000 pushed a commit to mrchris2000/downlords-faf-client that referenced this issue Apr 15, 2022
Fixes FAForever#1594

Fixes FAForever#1355

Fixes FAForever#1100

Fixes FAForever#1614  

* fixed hash function for supcom.exe (FAForever#1614)

Co-authored-by: Slothologist <rfeldh@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants