loot / libloot

A C++ library for accessing LOOT's metadata and sorting functionality.
GNU General Public License v3.0
32 stars 11 forks source link

product_version uses wrong path? #50

Closed TanninOne closed 5 years ago

TanninOne commented 5 years ago

Since updating Vortex to libloot version 0.14 I've started seeing error reports like this:

"Failed to evaluate condition "product_version("../SkyrimSE.exe", "1.5.62.0", <) and file("../SkyrimSE.exe") and version("Unofficial Skyrim Special Edition Patch.esp", "4.1.6", >=)". Details: An error was encountered while reading the version fields of "D:\Program Files (x86)\The Elder Scrolls V Skyrim Special Edition\Data../SkyrimSE.exe": entry not found"

or

"Failed to evaluate condition "version("Unofficial Fallout 4 Patch.esp", "2.0.5", >=) and not version("../Fallout4.exe", "1.10.111.0", >=)". Details: An error was encountered while reading the version fields of "C:\Games\Fallout 4\Data../Fallout4.exe": zero fill"

Not sure if this may be something I'm doing wrong but looking at the error message it appears like the relative path "../SkyrimSE.exe" is appended directly to the data path, without a (back-)slash so that would explain "entry not found" but why does it happen in the first place, why only for some users and what does "zero fill" mean?

MacSplody commented 5 years ago

@TanninOne There was an issue with product version in 14.0. https://loot-api.readthedocs.io/en/0.14.1/api/changelog.html

MacSplody commented 5 years ago

@TanninOne You'll be better off going with 14.3, as there is an issue with regex as well that was fixed. https://loot-api.readthedocs.io/en/0.14.4/api/changelog.html

TanninOne commented 5 years ago

Hmm, the libloot version for the first report is 0.14.4, the other might have been 0.14.2.

Ortham commented 5 years ago

I'll look into it this weekend, though I can't spot anything amiss in the code at first glance.

TanninOne commented 5 years ago

thanks

Ortham commented 5 years ago

The missing slash in the reported path is an issue with the error message, the actual path checked is correct.

If the file in a version or product_version condition doesn't exist, that doesn't cause an error: both error messages in the OP are indicating that the files were read but didn't have the expected field(s). For example:

"Skyrim.esm" contains a condition that could not be evaluated. Details: Failed to evaluate condition "version("../ultra.ini", "1.5.62.0", <)". Details: An error was encountered while reading the version fields of "C:\Games\Steam\steamapps\common\Skyrim Special Edition\Data../ultra.ini": bad magic

That's the executable parser complaining that the file doesn't have the expected magic number.

I can't see any reason for the error messages in the OP other than the files (incorrectly) given in the error message being invalid. Does Vortex do the same filesystem stuff as Mod Organiser? We've always had some users report issues that only ever occur through MO, this might be the same sort of thing.

TanninOne commented 5 years ago

Vortex has the vfs from MO as a (fairly well-hidden) option but that shouldn't cause this kind of error. The vfs only manipulates the path being accessed, once the application has a file handle, reading from it can't produce different results than an actual file on disk. The vfs could of course be used to present a different, non-PE, file as SkyrimSE.exe but why would it be set up like that?

I guess this error could happen when the user is currently updating/repairing their game through steam. I may be wrong but I think Steam doesn't add/replace file atomically so the exe could simply be a partial file at the time libloot tries to parse it. Or it could be a no-steam crack that replaces the exe with one that has no version field?

If you have no other, more likely, explanation, I'll catch this error and have vortex determine file size and md5 hash for the exe and include that in the error message, maybe that will shed some light on it.

Ortham commented 5 years ago

That's a good idea, I'm not sure what the cause could be, and can't think of anything likely.

TanninOne commented 5 years ago

I had the first bug report with the extended error message:

Error Message: Failed to evaluate condition "version("Homemaker.esm", "1.50", >=) and version("../Fallout4.exe", "1.7.9", <)". Details: An error was encountered while reading the version fields of "D:\R.G. Catalyst\Fallout 4\Data../Fallout4.exe": zero fill

Details

File:   D:\R.G. Catalyst\Fallout 4\Fallout4.exe
Exists: true
Size:   78280704
MD5:    a844ba76353f69dc1d8d8861418b0eda
Version:    1.2.37.0

So this is definitively a pirated version. From googling, "R.G. Catalyst" seems to be a piracy group. The file appears pretty large, a current Fallout4.exe is ~63MB. The version seems to be ancient too, but: Vortex was able to get the version number using GetFileVersionInfoW so it's odd libloot seems to producing the error.

I'll keep you updated if we get a report for a legitimate copy or if they're all pirated.

Ortham commented 5 years ago

Thanks for the info! Can you point me to where Vortex is calling GetFileVersionInfoW? LOOT uses a library to parse the executable without involving the Win32 API, and it might complain more than the latter. Maybe there's some fallback logic LOOT can try.

TanninOne commented 5 years ago

Sure, the code is here: https://github.com/Nexus-Mods/node-exe-version/blob/master/src/exever_win.cpp

TanninOne commented 5 years ago

update: As far as I can tell, all reports coming in about this are pirated versions of the game.

Ortham commented 5 years ago

I am not particularly enthusiastic about making any effort to support piracy, would leaving things as they are suit you?

TanninOne commented 5 years ago

dito, I've closed the issue on our end but I'll keep an eye on it, just in case there is a legitimate user with the issue after all.

Ortham commented 5 years ago

OK, I'll close this as wontfix, but if it happens for a legitimate user, feel free to post again and I'll reopen it.