From ad90304f5ecc7f67a86cfd4248a701104520e34c Mon Sep 17 00:00:00 2001 From: neru Date: Thu, 18 Jun 2026 15:27:10 -0300 Subject: [PATCH] feat: add GetGamePath (xbox only) --- src/dumper/utils.cs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/dumper/utils.cs diff --git a/src/dumper/utils.cs b/src/dumper/utils.cs new file mode 100644 index 0000000..721b263 --- /dev/null +++ b/src/dumper/utils.cs @@ -0,0 +1,35 @@ +using Microsoft.Win32; + +internal static class Utils +{ + public static string? GetGamePath() + { + string? path; + path = TryGetXboxPath(); + return path; + + /* + * to-do: + * implement steam and epic + */ + } + + private static string? TryGetXboxPath() + { + const string keyPath = @"Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages"; + using RegistryKey? key = Registry.CurrentUser.OpenSubKey(keyPath); + + if (key == null) return null; + + string? match = key.GetSubKeyNames().FirstOrDefault(n => n.StartsWith(Constants.PackageName, StringComparison.OrdinalIgnoreCase)); + if (match == null) return null; + + using RegistryKey? subKey = key.OpenSubKey(match); + if (subKey == null) return null; + + object? pkgRootFolder = subKey.GetValue("PackageRootFolder"); + if (pkgRootFolder == null) return null; + + return pkgRootFolder.ToString(); + } +}