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(); + } +}