steamfiles icon indicating copy to clipboard operation
steamfiles copied to clipboard

modified appinfo.vdf is rejected by Steam

Open magiruuvelvet opened this issue 5 years ago • 5 comments

During a research how the appinfo.vdf file works I found your project. I started playing around with it as I plan to rename some game titles in my local library. But the problem is Steam rejects the newly created appinfo.vdf and just deletes it and starts a sync from the Steam cloud. Also adding the immutable flag (chattr +i) to the file doesn't help; Steam just ignores it and loads a temporary appinfo into memory. :/

The console output of the Steam client never mentions the file or any other meaningful information.

Here is the snippet I'm currently trying:

from collections import OrderedDict;
from steamfiles import appinfo;

with open("/ssd/steam/appcache/appinfo.vdf~", "rb") as f:
    data = appinfo.load(f, wrapper=OrderedDict);

with open("/ssd/steam/appcache/appinfo.vdf", "wb") as f:
    appinfo.dump(data, f);

I don't change anything and save back the data immediately to no avail.

Reading data from it works though. A snippet to list all games in the library:

for k,v in data.items():
    try:
        appinfo2 = v["sections"][b"appinfo"][b"common"];
        if (appinfo2[b"type"] == b"Game"):
            name = appinfo2[b"name"].decode("utf-8");
            print(k, name);

    except:
        # silently skip incompatible entries
        continue;

The file hash changes every time when Steam syncs back the file from Steam cloud. The file saved from your tool also have a different hash each time.

Do you have any idea what could be wrong; or am I missing something?

EDIT: I'm using the latest Steam Client Beta on Linux

EDIT2: Here are the 2 appinfo.vdf files, the original the Steam client created and the "unchanged" modified appinfo from the snippet above. appinfo.zip

magiruuvelvet avatar Jan 05 '19 17:01 magiruuvelvet

@magiruuvelvet After a brief investigation of the original VDF, I found out that in [app_id = 17500]['sections'][b'appinfo'][b'extended'], the key-value pair {"serverbrowsername": "Zombie Panic! Source'"} repeats twice. So 1 byte for the type of value, plus lengths of these two null-terminated strings is 40. And the difference between two VDF files is 40 bytes...

Not sure yet what to do with this. Sounds like two different problems: what to do when our assumption about non-repeating keys breaks, and Steam rejecting the changed file.

I'll play around with issue 1 and try to find other files with the same problem. As for point 2, it was never a guarantee that Steam won't outright reject the file with even minor changes.. I'd say it makes sense, even.

leovp avatar Jan 20 '19 10:01 leovp

Hi magiruuvelvet, can you tell me about how the appinfo.vdf file works?

Ajax001by7 avatar Sep 30 '19 12:09 Ajax001by7

What is changing in the appinfo.vdf file? What is it there for? How is Steam using it? What is its importance?

Ajax001by7 avatar Sep 30 '19 12:09 Ajax001by7

Appinfo is where the "configuration" of all games is stored, from launch parameters to supported languages and features, to even just the name of appids itself. I can also report like OP that "blindly editing the file" is reset as soon as possible... Though SteamEdit seems able to do that just fine. EDIT: maybe there's the size of the data area to respect/fix?

mirh avatar Apr 27 '20 15:04 mirh

When the section data changes, the checksum of the section needs to recomputed (as explained here, otherwise Steam will consider the file as invalid and throw it away.

pdfrod avatar Mar 25 '21 23:03 pdfrod