BOSSoNe0013 / track-o-bot

The friendly Hearthstone Tracker (Linux port)
https://trackobot.com
GNU Lesser General Public License v2.1
39 stars 6 forks source link

PE version detection broken for Hearthstone versions over 65535 #99

Open stanczew opened 4 years ago

stanczew commented 4 years ago

After recent Hearthstone upgrade to version 19.0.0.66927, Track-o-Bot stopped correctly parsing version information:

DEBUG: Detected build: 1391
DEBUG: Download cards.json from: https://api.hearthstonejson.com/v1/1391/enUS/cards.json
INFO: Couldn't download card DB: https://api.hearthstonejson.com/v1/1391/enUS/cards.json. Maybe current HS version is too new.

Looking at PeVersionExtractor we see the following code:

version = ( fileinfo.Value.dwFileVersionLS >> 0 ) & 0xffff;

Version 66927 = 0x1056F, so masking it by 0xFFFF gives 0x56F = 1391.

I don't know what the purpose of this mask is/was. dwFileVersionLS field is declared as a dword, and version variable is an int, so the mask doesn't seem to be needed for anything. (Or maybe it should be changed to 0x7FFFFFFF, since dwFileVersionLS is unsigned while version is signed.)

With the mask removed, correct version is returned:

DEBUG: Detected build: 66927
DEBUG: Download cards.json from: https://api.hearthstonejson.com/v1/66927/enUS/cards.json
DEBUG: Downloaded cards.json 2594470 bytes
BOSSoNe0013 commented 3 years ago

Thanks for the feedback, i'll investigate