Skip to content

[dev] Microsoft Store Games (Legacy)

Infernio edited this page Sep 26, 2023 · 2 revisions

WARNING: This is now mostly obsolete. Microsoft have changed how new installations of these games work. We still support this method for existing installations though, so the information may still be useful.

Detecting games that are installed via the Microsoft Store is much more complicated than usual games, due to the way Windows stores them on your hard-drive.

Note there are varying names given to this platform, all or some might be used by different authors: Windows Store, Microsoft Store, and Game Pass.

Background

Windows Store stores its games in a virtual file system, and provides a few links into that virtual file system with varying properties.

  • All of the actual files are stored in a virtual file system. The virtual filesystems are in %PROGRAMFILES%\MSIVS\.
  • A highly protected (read: permissions are strictly controlled, and even taking ownership is difficult) view is available at the default location of %PROGRAMFILES%\WindowsApps\. While this is the closest you can get to an actual filesystem view of the files for the app, due to the permission issues you should basically never access these locations.
  • Some apps provide a "Mutable" view of the files. This works similar to other virtual file systems: you can modify/edit/create files here, and any changes override whatever is in the actual virtual filesystem. Apps that intend to be modifiable (ex: Bethesda games) provide this location. This is where you should be reading/writing to to modify an app. The default location for these is at %PROGAMFILES\ModifiableWindowsApps.
    • Note: Even though this is the most modifiable location, executables (EXEs) still act very abnormally here. They show up in the File Explorer, but to most programs they do not exist or at the very least cannot be opened or run, resulting in errors (ie: [WinError 650] The device object parameter is either not a valid device object or is not attached to the volume specified by the file name: 'C:\\Program Files\\ModifiableWindowsApps\\Skyrim Special Edition (PC)\\SkyrimSE.exe from a python script). Clearly the rational is modifying assets is OK, but modifying the executable opens the system up to vulnerabilities. This is the major reason why script extenders (xSE) and tools that utilize their own virtual file systems - which hook into the executables, don't work).
    • This also means reading the EXE to obtain version information is a non-starter. You need an alternative method to determine an app's version.
    • Similarly, attempting to start an app by executing the EXE directly won't work. We need an alternative method (see below).
  • The default locations for the above are not reliable. For example in the Xbox app if you choose to install a game to a different drive, these location will be on that drive. In fact, the relative locations of the highly protected view and the mutable view may be different from drive to drive (rant: Sometimes even telling the Xbox app to install to the D: drive will still install everything to the C: drive, ugh! Thankfully, the Windows Registry has the correct locations).
  • The location where AppData is stored per application seems to include two locations:
    • The "normal" location: %LOCALAPPDATA\{progam_folder}
    • A "virtual" location: %LOCALAPPDATA\Local\Packages\{full_name}\LocalCache\Local\{program_folder}
    • It's unclear at the moment if this is 100% the case, but it seems that the "normal" location is used as a fallback in case data in the "virtual" location does not exist. For the moment Wrye Bash reads/writes to both, for Justin, prioritizing the "virtual" location when conflicts occur.

So the hurdles to overcome are:

  • Determine the mutable location for an app
  • Figure out how to launch an app, since the EXE cannot be read from the mutable location, and the highly protected view by default isn't accessible.
  • Determine the version of an app: it looks like this comes down to the developer. In some cases (Bethsoft's initial Windows Store releases), the executable cannot be parsed for version information. In some cases (Bethsoft updated this sometime before March 22, 2021), the executable can be parsed, so the usual methods work.

For a read on figuring all this out, see #585.

Most of the information about a Windows Store app exist in the Windows Registry, but in varying locations, sometimes requiring multiple queries to actually get to the information you want. Some additional information can be found in appxmanifest.xml located in the mutable location (launch entry point, version string). Although the version string can also be obtained by parsing the full name of the app.

Names

There are they name strings that show up in various contexts, Wrye Bash uses these names internally for each:

  • App Name: The human readable name of the game. Ex: BethesdaSoftworks.SkryimSE-PC.
  • Package Name: The name of the game, including the Publisher ID. The basic format is {app_name}_{publisher_id}. Ex: BethesdaSoftworks.SkryimSE-PC_3275kfvn8vcwc.
  • Package Full Name (or Full Name): The unique string identifying an installation of the game, including version and architecture. The basic format is {app_name}_{version}_{architecture}__{publisher_id}. Ex: BethesdaSoftworks.SkrimSE-PC_1.11.0.0_x64__3275kfvn8vcwc.

Finding a game

There are multiple steps involved to reliably find the modifiable location for the particular Windows Store App.

First, you need to know the App Name of the game and Publisher ID for the game. Currently we only support Bethesda games, so here are those:

Publisher IDs

  • Bethesda: 3275kfvn8vcwc

App Names

  • Fallout 3: BethesdaSoftworks.Fallout3
  • Fallout 4: BethesdaSoftworks.Fallout4-PC
  • Fallout NV: BethesdaSoftworks.FalloutNewVegas
  • Morrowind GOTY: BethesdaSoftworks.TESMorrowind-PC
  • Oblivion GOTY: BethesdaSoftworks.TESOblivion-PC
  • Skyrim SE: BethesdaSoftworks.SkyrimSE-PC

Finding the Package Full Name (Full Name)

Next, you can get the Full Name of the package using App Name and Publisher ID. First the Package Name is given by {app_name}_{publisher_id}. Next look up the Full Name, which exist as sub-keys of HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Families\{package_name} Each sub-key corresponds to a different version and/or architecture, so these should be enumerated.

Package Full Name

Note: The InstallTime key is a 64-bit hex value holding the FileTime for which the app was installed, in case you want to gather that information as well. If you happen to have a InstallDate key, that's a 32-bit hex value holding the Unix Time the app was installed.

Finding the Package Index

Now that you know the package's Full Name, we can query the registry for the index the package uses to find its mutable location. These are stored as a single subkey to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModel\StateRepository\Cache\Package\Index\PackageFullName\{full_name}

Package Index

Finally finding the Mutable location

Home stretch, the mutable locations are stored in the registry as well, in the string value HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModel\StateRepository\Cache\Package\Data\{index}\MutableLocation

Mutable Location

Launching an App

Once you've found the mutable location for the app, you might think you're done. I challenge you: launch the game from the filesystem (not the Xbox App). This doesn't work because the executable isn't actually there, and unlike other files in the mutable view of the virtual file system, the executable is still protected from modification. To most programs, it probably shows up as not existing.

So how do you launch the app? With the windows start command. Execute the following: start shell:AppsFolder\{package_name}!{entry_point} (Note: A backslash here is important, a forward slash will not work). Where {package_name} is {app_name}_{publisher_id}, the same used for locating the game. For Bethesda's games, the entry_point is Game. However this might not always be the case. For other apps, parse appxmanifest.xml or MicrosoftGame.config (in the mutable location) and find the node Package->Applications->Application (or Game->ExecutableList->Executable) and read its Id attribute. For example, for SSE the applicable line looks like this:

<Application Id="Game" Executable="SkyrimSELauncher.exe" EntryPoint="Windows.FullTrustApplication">

This makes the full command for SkryimSE: start shell:AppsFolder\BethesdaSoftworks.SkyrimSE-PC_3275kfvn8vcwc!Game

Getting an App Version

There are three ways you can get the version of the game in the event that the executables are not able to be parsed:

  1. Parse the Full Name string, taking out the version string in it. Recall the Full Name is of the form {app_name}_{version}_{architecture}__{publisher_id}.
  2. Parse appxmanifest.xml located in the mutable location. The version is an attribute on the Identity node.
  3. Parse MicrosoftGame.config located in the mutable location. This is an XML file as well, the version is an attribute on the Identity node.

Note: appxmanifest.xml and MicrosoftGame.config use XML Namespaces, so make sure your parsing tool either handles these for you or you handle them on your end.

Note: The version gathered using this method may not match that of the actual game. For example, SkryimSE has the executable version at 1.5.111, while the manifest and full name have 1.11.0.0. You'll have to evaluate based on a game-by-game basis, but at least for Bethsoft games, the executable version is readable and the accurate version.

Example: Morrowind GOTY

Here's the steps involved to determine the mutable location for Morrowind GOTY on my computer:

  1. First, I need the App Name and Publisher ID for the game. These are BethesdaSoftworks.TESMorrowind-PC and 3275kfvn8vcwc We use those to access HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Families\BethesdaSoftworks.TESMorrowind-PC_3275kfvn8vcwc. On my computer, this has a single sub key (you should always enumerate through all of them in the case of multiple versions), that sub key is BethesdaSoftworks.TESMorrowind-PC_1.0.0.0_x86__3275kfvn8vcwc, the Full Name for my Morrowind install.
  2. Next, I need the index for the game. For this I enumerate HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModel\StateRepository\Cache\Package\Index\PackageFullName\BethesdaSoftworks.TESMorrowind-PC_1.0.0.0_x86__3275kfvn8vcwc to get its unique sub key c9 on my computer.

It's c9 on my computer, but it almost always will be something different on your computer.

  1. Using the index c9 and the Full Name, I can finally look up the mutable location. That's stored in the string key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModel\StateRepository\Cache\Package\Data\c9\MutableLocation. On my computer this is C:\Program Files\ModifiableWindowsApps\Morrowind GOTY (PC).

Now I've found the install location for my Morrowind GOTY Microsoft Store version.

From this point there may be complications based on the game. For example, Morrowind has sub directories based on which language of the game to run. There's Morrowind GOTY English, Morrowind GOTY French, and Morrowind GOTY German. For this we can look inside launcher_settings.cfg or MicrosoftGame.Config and see that those three languages are indeed listed inside. This indicates that this app uses the Windows language preferences to determine which version to launch. However it doesn't help with which directory to use for each language. At this point, I don't see a reliable way to check which one to use. We can get the system default language, and use a hard-coded map to map that to the subfolders, this is the best I've come up with at this point.

Other games don't have this issue (except Oblivion). For example Skyrim SE has the mutable location pointing directly at the desired directory. This is because Skyrim SE directly handles the language settings within the program, whereas Morrowind has different binaries and everything per language.

If I want to launch Morrowind, I'll run the command start shell:AppFolder\BethesdaSoftworks.TESMorrowind-PC_3275kfvn8vcwc!Game.

Common Location References

Gathered and compiled by the Nexus Mods team.

Note (lojack): These are the default locations for these, but if the user chooses to install them to a different drive the method above should be used to find (in particular) the Mod Install Location.

Skyrim Special Edition

  • Game Pass Publisher ID: 3275kfvn8vcwc
  • Game Pass ID: BethesdaSoftworks.SkyrimSE-PC
  • Mod Install Location: C:\Program Files\ModifiableWindowsApps\Skyrim Special Edition (PC)
  • INI/Saves Location: C:\Users\{USER}\Documents\My Games\Skyrim Special Edition MS
  • Plugins.txt Location 1: %LOCALAPPDATA%\Packages\BethesdaSoftworks.SkyrimSE-PC_3275kfvn8vcwc\LocalCache\Local\Skyrim Special Edition MS\Plugins.txt
  • Plugins.txt Location 2: %LOCALAPPDATA%\Skyrim Special Edition MS\Plugins.txt

Fallout 4

  • Game Pass Publisher ID: 3275kfvn8vcwc
  • Game Pass ID: BethesdaSoftworks.Fallout4-PC
  • Mod Install Location: C:\Program Files\ModifiableWindowsApps\Fallout 4 (PC)
  • INI/Saves Location: C:\Users\{USER}\Documents\My Games\Fallout4 MS
  • Plugins.txt Location 1: %LOCALAPPDATA%\Packages\BethesdaSoftworks.Fallout4-PC_3275kfvn8vcwc\LocalCache\Local\Fallout4 MS\Plugins.txt
  • Plugins.txt Location 2: %LOCALAPPDATA%\Fallout4 MS\Plugins.txt

*Note: The Fallout 4 version on Game Pass does not include any of the DLCs, they can be purchased separately. *

Oblivion

  • Game Pass Publisher ID: 3275kfvn8vcwc
  • Game Pass ID: BethesdaSoftworks.TESOblivion-PC
  • Mod Install Location: C:\Program Files\ModifiableWindowsApps\Oblivion GOTY (PC)
  • INI/Saves Location: C:\Users\{USER}\Documents\My Games\Oblivion
  • Plugins.txt Location 1: %LOCALAPPDATA%\Packages\BethesdaSoftworks.TESOblivion-PC_3275kfvn8vcwc\LocalCache\Local\Oblivion\Plugins.txt
  • Plugins.txt Location 2: %LOCALAPPDATA%\Oblivion\Plugins.txt

*Note: Oblivion installs several different language versions of the game in separate folders. The mod installation location will vary depending on which version you are trying to play. *

Morrowind

  • Game Pass Publisher ID: 3275kfvn8vcwc
  • Game Pass ID: BethesdaSoftworks.TESMorrowind-PC
  • Mod Install Location: C:\Program Files\ModifiableWindowsApps\Morrowind GOTY (PC)
  • INI/Saves Location: C:\Program Files\ModifiableWindowsApps\Morrowind GOTY (PC)

*Note: Morrowind installs several different language versions of the game in separate folders. The INI and mod installation locations will vary depending on which version you are trying to play. *

Clone this wiki locally