mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Partial fix for OriginLibrary v3.x
Note - doesn't work with Origin v2.1 files yet... still troubleshooting those!
This commit is contained in:
parent
aa74963d9b
commit
b6de9aa85f
@ -507,167 +507,97 @@ namespace DisplayMagician.GameLibraries
|
|||||||
logger.Trace($"OriginLibrary/LoadInstalledGames: Attempting to parse XML Game Installer Data file at {gameInstallerData}");
|
logger.Trace($"OriginLibrary/LoadInstalledGames: Attempting to parse XML Game Installer Data file at {gameInstallerData}");
|
||||||
// Now we parse the XML
|
// Now we parse the XML
|
||||||
XDocument xdoc = XDocument.Load(gameInstallerData);
|
XDocument xdoc = XDocument.Load(gameInstallerData);
|
||||||
originGame.GameName = xdoc.XPathSelectElement("/DiPManifest/gameTitles/gameTitle[@locale='en_US']").Value;
|
float manifestVersion;
|
||||||
logger.Trace($"OriginLibrary/LoadInstalledGames: Game Name {originGame.GameName} found in Game Installer Data file {gameInstallerData}");
|
// Try to figure out which version of the client created this game (as they changed their format a lot)
|
||||||
string gameFilePath = xdoc.XPathSelectElement("/DiPManifest/runtime/launcher/filePath").Value;
|
var thing = xdoc.XPathSelectElement("/DiPManifest").Attribute("version").Value;
|
||||||
logger.Trace($"OriginLibrary/LoadInstalledGames: Game File Path is {gameFilePath } found in Game Installer Data file {gameInstallerData}");
|
if (xdoc.XPathSelectElement("/DiPManifest").Attribute("version").Value != null)
|
||||||
|
|
||||||
string originGameInstallLocation = "";
|
|
||||||
// Check whether gameFilePath contains a registry key! Cause if it does we need to lookup the path there instead
|
|
||||||
if (gameFilePath.StartsWith("[HKEY_LOCAL_MACHINE"))
|
|
||||||
{
|
{
|
||||||
logger.Trace($"OriginLibrary/LoadInstalledGames: Game File Path starts with a registery key so needs to be translated");
|
if (Single.TryParse(xdoc.XPathSelectElement("/DiPManifest").Attribute("version").Value, out manifestVersion))
|
||||||
// The filePath contains a registry key lookup that we need to execute and replace
|
|
||||||
string originGameInstallKeyNameAndValue = "";
|
|
||||||
string originGameRestOfFile = "";
|
|
||||||
MatchCollection mc = Regex.Matches(gameFilePath, @"\[HKEY_LOCAL_MACHINE\\(.*)\](.*)");
|
|
||||||
if (mc.Count > 0)
|
|
||||||
{
|
{
|
||||||
// Split the Reg key bit from the File Path bit
|
// This is an Origin manifest Version 4.0 client installed game
|
||||||
|
logger.Trace($"OriginLibrary/LoadInstalledGames: v4 - Detected the {gameInstallerData} manifest version was v{manifestVersion}");
|
||||||
originGameInstallKeyNameAndValue = mc[0].Groups[1].ToString();
|
|
||||||
logger.Trace($"OriginLibrary/LoadInstalledGames: originGameInstallKeyNameAndValue = {originGameInstallKeyNameAndValue}");
|
|
||||||
originGameRestOfFile = mc[0].Groups[2].ToString();
|
|
||||||
logger.Trace($"OriginLibrary/LoadInstalledGames: originGameRestOfFile = {originGameRestOfFile}");
|
|
||||||
if (originGameInstallKeyNameAndValue == null || originGameInstallKeyNameAndValue == "")
|
|
||||||
{
|
|
||||||
// then we have a problem and we need to continue and ignore this game
|
|
||||||
logger.Warn($"OriginLibrary/LoadInstalledGames: Origin game with ID {originGame.GameID} has registry key but we can't extract it! gameFilePath is {gameFilePath}.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Split the reg key from the value name
|
|
||||||
|
|
||||||
string originGameInstallKeyName = "";
|
|
||||||
string originGameInstallKeyValue = "";
|
|
||||||
mc = Regex.Matches(originGameInstallKeyNameAndValue, @"(.*)\\([^\\]*)");
|
|
||||||
if (mc.Count > 0)
|
|
||||||
{
|
|
||||||
originGameInstallKeyName = mc[0].Groups[1].ToString();
|
|
||||||
logger.Trace($"OriginLibrary/LoadInstalledGames: originGameInstallKeyName = {originGameInstallKeyName }");
|
|
||||||
originGameInstallKeyValue = mc[0].Groups[2].ToString();
|
|
||||||
logger.Trace($"OriginLibrary/LoadInstalledGames: originGameInstallKeyValue = {originGameInstallKeyValue }");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lookup the reg key to figure out where the game is installed
|
|
||||||
try
|
|
||||||
{
|
|
||||||
RegistryKey originGameInstallKey = Registry.LocalMachine.OpenSubKey(originGameInstallKeyName, RegistryKeyPermissionCheck.ReadSubTree);
|
|
||||||
if (originGameInstallKey == null)
|
|
||||||
{
|
|
||||||
// then we have a problem as we cannot find the game exe location!
|
|
||||||
logger.Warn($"OriginLibrary/LoadInstalledGames: Origin game with ID {originGame.GameID} has a install reg key we cannot find! originGameInstallKey is {gameFilePath} and originGameInstallKeyValue is {originGameInstallKeyValue}.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
originGameInstallLocation = Path.Combine(originGameInstallKey.GetValue(originGameInstallKeyValue).ToString(), originGameRestOfFile);
|
|
||||||
if (!File.Exists(originGameInstallLocation))
|
|
||||||
{
|
|
||||||
// then we have a problem as we cannot locate the game exe file to start!
|
|
||||||
logger.Warn($"OriginLibrary/LoadInstalledGames: Origin game with ID {originGame.GameID} has gameexe we cannot find! originGameInstallLocation is {originGameInstallLocation}.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
originGame.GameExePath = originGameInstallLocation;
|
|
||||||
}
|
|
||||||
catch (SecurityException ex)
|
|
||||||
{
|
|
||||||
logger.Warn(ex, $"OriginLibrary/LoadInstalledGames: The user does not have the permissions required to read the Origin Game location registry key {originGameInstallKeyName}, so skipping game");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
catch (ObjectDisposedException ex)
|
|
||||||
{
|
|
||||||
logger.Warn(ex, "OriginLibrary/LoadInstalledGames: The Microsoft.Win32.RegistryKey is closed when trying to access the Origin ClientPath registry key (closed keys cannot be accessed), so skipping game");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
logger.Warn(ex, "OriginLibrary/LoadInstalledGames: The Origin ClientPath registry key has been marked for deletion so we cannot access the value dueing the OriginLibrary check, so skipping game");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
catch (UnauthorizedAccessException ex)
|
|
||||||
{
|
|
||||||
logger.Warn(ex, "OriginLibrary/LoadInstalledGames: The user does not have the necessary registry rights to check whether Origin is installed, so skipping game");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Warn($"OriginLibrary/LoadInstalledGames: Game File Path {gameFilePath} starts with '[HEKY_LOCAL_MACHINE' but didn't match the regex when it should have");
|
logger.Error($"OriginLibrary/LoadInstalledGames: v4 - Couldn't determine the Detected the installer.xml manifest version for {gameInstallerData}. Skipping processing file.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (gameFilePath.StartsWith("[HKEY_CURRENT_USER"))
|
else if (xdoc.XPathSelectElement("/game").Attribute("manifestVersion").Value != null)
|
||||||
{
|
{
|
||||||
// The filePath contains a registry key lookup that we need to execute and replace
|
if (Single.TryParse(xdoc.XPathSelectElement("/game").Attribute("manifestVersion").Value,out manifestVersion))
|
||||||
MatchCollection mc = Regex.Matches(gameFilePath, @"\[HKEY_CURRENT_USER\\(.*)\](.*)");
|
|
||||||
if (mc.Count > 0)
|
|
||||||
{
|
{
|
||||||
string originGameInstallKeyNameAndValue = mc[0].Groups[1].ToString();
|
// This is an Origin manifest Version 2.x or 3.0 client installed game
|
||||||
string originGameRestOfFile = mc[0].Groups[2].ToString();
|
logger.Trace($"OriginLibrary/LoadInstalledGames: v3 - Detected the {gameInstallerData} manifest version was v{manifestVersion}");
|
||||||
if (originGameInstallKeyNameAndValue == null)
|
|
||||||
{
|
|
||||||
// then we have a problem and we need to continue and ignore this game
|
|
||||||
logger.Warn($"OriginLibrary/LoadInstalledGames: Origin game with ID {originGame.GameID} has registry but we can't match it! gameFilePath is {gameFilePath}.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
mc = Regex.Matches(originGameInstallKeyNameAndValue, @"(.*)\\([^\\]*)");
|
|
||||||
string originGameInstallKeyName = mc[0].Groups[1].ToString();
|
|
||||||
string originGameInstallKeyValue = mc[0].Groups[2].ToString();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
RegistryKey originGameInstallKey = Registry.LocalMachine.OpenSubKey(originGameInstallKeyName, RegistryKeyPermissionCheck.ReadSubTree);
|
|
||||||
if (originGameInstallKey == null)
|
|
||||||
{
|
|
||||||
// then we have a problem as we cannot find the game exe location!
|
|
||||||
logger.Warn($"OriginLibrary/LoadInstalledGames: Origin game with ID {originGame.GameID} has a install reg key we cannot find! originGameInstallKey is {gameFilePath} and originGameInstallKeyValue is {originGameInstallKeyValue}.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
originGameInstallLocation = Path.Combine(originGameInstallKey.GetValue(originGameInstallKeyValue).ToString(), originGameRestOfFile);
|
|
||||||
if (!File.Exists(originGameInstallLocation))
|
|
||||||
{
|
|
||||||
// then we have a problem as we cannot locate the game exe file to start!
|
|
||||||
logger.Warn($"OriginLibrary/LoadInstalledGames: Origin game with ID {originGame.GameID} has gameexe we cannot find! originGameInstallLocation is {originGameInstallLocation}.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
originGame.GameExePath = originGameInstallLocation;
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (SecurityException ex)
|
|
||||||
{
|
|
||||||
logger.Warn(ex, $"OriginLibrary/LoadInstalledGames: The user does not have the permissions required to read the Origin Game location registry key {originGameInstallKeyName}, so skipping game");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
catch (ObjectDisposedException ex)
|
|
||||||
{
|
|
||||||
logger.Warn(ex, "OriginLibrary/LoadInstalledGames: The Microsoft.Win32.RegistryKey is closed when trying to access the Origin ClientPath registry key (closed keys cannot be accessed), so skipping game");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
logger.Warn(ex, "OriginLibrary/LoadInstalledGames: The Origin ClientPath registry key has been marked for deletion so we cannot access the value dueing the OriginLibrary check, so skipping game");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
catch (UnauthorizedAccessException ex)
|
|
||||||
{
|
|
||||||
logger.Warn(ex, "OriginLibrary/LoadInstalledGames: The user does not have the necessary registry rights to check whether Origin is installed, so skipping game");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Warn($"OriginLibrary/LoadInstalledGames: Game File Path {gameFilePath} starts with '[HKEY_CURRENT_USER' but didn't match the regex when it should have, so skipping game");
|
logger.Error($"OriginLibrary/LoadInstalledGames: v3 - Couldn't determine the Detected the installer.xml manifest version for {gameInstallerData}. Skipping processing file.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If we get here, then the gameFilepath is the actual filepath! So we just copy it.
|
// This is an unrecognised manifest file
|
||||||
logger.Trace($"OriginLibrary/LoadInstalledGames: Game File Path {gameFilePath} doesn't start with '[HKEY_LOCAL_MACHINE' or '[HKEY_CURRENT_USER' so it must be aplain file path");
|
logger.Error($"OriginLibrary/LoadInstalledGames: Unrecognised installer.xml manifest version for {gameInstallerData}. Skipping processing file.");
|
||||||
originGame.GameExePath = gameFilePath;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now we go through and attempt to process the various manifest versions
|
||||||
|
if (manifestVersion >= 4.0)
|
||||||
|
{
|
||||||
|
originGame.GameName = xdoc.XPathSelectElement("/DiPManifest/gameTitles/gameTitle[@locale='en_US']").Value;
|
||||||
|
logger.Trace($"OriginLibrary/LoadInstalledGames: Game Name {originGame.GameName} found in Game Installer Data file {gameInstallerData}");
|
||||||
|
// Look for the 64-bit version of the filepath
|
||||||
|
originGame.GameExePath = GetActualFilePath(xdoc.XPathSelectElement("/DiPManifest/runtime/launcher[requires64BitOS/text() = '1']/filePath").Value);
|
||||||
|
if (originGame.GameExePath == null)
|
||||||
|
{
|
||||||
|
// if not found, then look for the 32-bit version of the filepath
|
||||||
|
logger.Trace($"OriginLibrary/LoadInstalledGames: Couldn't find 64-bit game exe in Game Installer Data file {gameInstallerData}, so looking for 32-bit.");
|
||||||
|
originGame.GameExePath = GetActualFilePath(xdoc.XPathSelectElement("/DiPManifest/runtime/launcher[requires64BitOS/text() = '0']/filePath").Value);
|
||||||
|
if (originGame.GameExePath == null)
|
||||||
|
{
|
||||||
|
logger.Error($"OriginLibrary/LoadInstalledGames: Couldn't find 64-bit or 32-bit game exe in Game Installer Data file {gameInstallerData}, so skipping file.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
logger.Trace($"OriginLibrary/LoadInstalledGames: Game File Path is {originGame.GameExePath} found in Game Installer Data file {gameInstallerData}");
|
||||||
|
}
|
||||||
|
else if (manifestVersion >= 3.0 && manifestVersion < 4.0)
|
||||||
|
{
|
||||||
|
originGame.GameName = xdoc.XPathSelectElement("/game/metadata/localeInfo[@locale='en_US']/title").Value;
|
||||||
|
logger.Trace($"OriginLibrary/LoadInstalledGames: Game Name {originGame.GameName} found in Game Installer Data file {gameInstallerData}");
|
||||||
|
// Look for the 64-bit version of the filepath
|
||||||
|
originGame.GameExePath = GetActualFilePath(xdoc.XPathSelectElement("/game/runtime/launcher[requires64BitOS/text() = '1']/filePath").Value);
|
||||||
|
if (originGame.GameExePath == null)
|
||||||
|
{
|
||||||
|
// if not found, then look for the 32-bit version of the filepath
|
||||||
|
logger.Trace($"OriginLibrary/LoadInstalledGames: Couldn't find 64-bit game exe in Game Installer Data file {gameInstallerData}, so looking for 32-bit.");
|
||||||
|
originGame.GameExePath = GetActualFilePath(xdoc.XPathSelectElement("/game/runtime/launcher[requires64BitOS/text() = '0']/filePath").Value);
|
||||||
|
if (originGame.GameExePath == null)
|
||||||
|
{
|
||||||
|
logger.Error($"OriginLibrary/LoadInstalledGames: Couldn't find 64-bit or 32-bit game exe in Game Installer Data file {gameInstallerData}, so skipping file.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.Trace($"OriginLibrary/LoadInstalledGames: Game File Path is {originGame.GameExePath} found in Game Installer Data file {gameInstallerData}");
|
||||||
|
}
|
||||||
|
else if (manifestVersion >= 2.0 && manifestVersion < 3.0)
|
||||||
|
{
|
||||||
|
originGame.GameName = xdoc.XPathSelectElement("/game/metadata/localeInfo[@locale='en_US']/title").Value;
|
||||||
|
logger.Trace($"OriginLibrary/LoadInstalledGames: Game Name {originGame.GameName} found in Game Installer Data file {gameInstallerData}");
|
||||||
|
// This logger format requires more work and help from someon with the right game installed
|
||||||
|
logger.Error($"OriginLibrary/LoadInstalledGames: We currently don't have a way to extract the GameExePath from Origin v2.x installer.xml manifest files. Couldn't process {gameInstallerData}. Skipping processing file.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// This is a manifest file we cannot process as we've never seen it before
|
||||||
|
logger.Error($"OriginLibrary/LoadInstalledGames: Unrecognised installer.xml manifest version for {gameInstallerData}. Skipping processing file.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!File.Exists(originGame.GameExePath))
|
if (!File.Exists(originGame.GameExePath))
|
||||||
{
|
{
|
||||||
@ -751,6 +681,166 @@ namespace DisplayMagician.GameLibraries
|
|||||||
return gameProcess;
|
return gameProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private string GetActualFilePath(string gameFilePath)
|
||||||
|
{
|
||||||
|
string originGameInstallLocation = "";
|
||||||
|
// Check whether gameFilePath contains a registry key! Cause if it does we need to lookup the path there instead
|
||||||
|
if (gameFilePath.StartsWith("[HKEY_LOCAL_MACHINE"))
|
||||||
|
{
|
||||||
|
logger.Trace($"OriginLibrary/GetActualFilePath: Game File Path starts with a registery key so needs to be translated");
|
||||||
|
// The filePath contains a registry key lookup that we need to execute and replace
|
||||||
|
string originGameInstallKeyNameAndValue = "";
|
||||||
|
string originGameRestOfFile = "";
|
||||||
|
MatchCollection mc = Regex.Matches(gameFilePath, @"\[HKEY_LOCAL_MACHINE\\(.*)\](.*)");
|
||||||
|
if (mc.Count > 0)
|
||||||
|
{
|
||||||
|
// Split the Reg key bit from the File Path bit
|
||||||
|
|
||||||
|
originGameInstallKeyNameAndValue = mc[0].Groups[1].ToString();
|
||||||
|
logger.Trace($"OriginLibrary/GetActualFilePath: originGameInstallKeyNameAndValue = {originGameInstallKeyNameAndValue}");
|
||||||
|
originGameRestOfFile = mc[0].Groups[2].ToString();
|
||||||
|
logger.Trace($"OriginLibrary/GetActualFilePath: originGameRestOfFile = {originGameRestOfFile}");
|
||||||
|
if (originGameInstallKeyNameAndValue == null || originGameInstallKeyNameAndValue == "")
|
||||||
|
{
|
||||||
|
// then we have a problem and we need to continue and ignore this game
|
||||||
|
logger.Warn($"OriginLibrary/GetActualFilePath: Origin game path {gameFilePath} has registry key but we can't extract it!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split the reg key from the value name
|
||||||
|
|
||||||
|
string originGameInstallKeyName = "";
|
||||||
|
string originGameInstallKeyValue = "";
|
||||||
|
mc = Regex.Matches(originGameInstallKeyNameAndValue, @"(.*)\\([^\\]*)");
|
||||||
|
if (mc.Count > 0)
|
||||||
|
{
|
||||||
|
originGameInstallKeyName = mc[0].Groups[1].ToString();
|
||||||
|
logger.Trace($"OriginLibrary/GetActualFilePath: originGameInstallKeyName = {originGameInstallKeyName }");
|
||||||
|
originGameInstallKeyValue = mc[0].Groups[2].ToString();
|
||||||
|
logger.Trace($"OriginLibrary/GetActualFilePath: originGameInstallKeyValue = {originGameInstallKeyValue }");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lookup the reg key to figure out where the game is installed
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RegistryKey originGameInstallKey = Registry.LocalMachine.OpenSubKey(originGameInstallKeyName, RegistryKeyPermissionCheck.ReadSubTree);
|
||||||
|
if (originGameInstallKey == null)
|
||||||
|
{
|
||||||
|
// then we have a problem as we cannot find the game exe location!
|
||||||
|
logger.Warn($"OriginLibrary/GetActualFilePath: Origin game path {gameFilePath} has a install reg key we cannot find! originGameInstallKey is {gameFilePath} and originGameInstallKeyValue is {originGameInstallKeyValue}.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
originGameInstallLocation = Path.Combine(originGameInstallKey.GetValue(originGameInstallKeyValue).ToString(), originGameRestOfFile);
|
||||||
|
if (!File.Exists(originGameInstallLocation))
|
||||||
|
{
|
||||||
|
// then we have a problem as we cannot locate the game exe file to start!
|
||||||
|
logger.Warn($"OriginLibrary/GetActualFilePath: Origin game path {gameFilePath} has gameexe we cannot find! originGameInstallLocation is {originGameInstallLocation}.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return originGameInstallLocation;
|
||||||
|
}
|
||||||
|
catch (SecurityException ex)
|
||||||
|
{
|
||||||
|
logger.Warn(ex, $"OriginLibrary/GetActualFilePath: The user does not have the permissions required to read the Origin Game location registry key {originGameInstallKeyName}, so skipping game");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (ObjectDisposedException ex)
|
||||||
|
{
|
||||||
|
logger.Warn(ex, "OriginLibrary/GetActualFilePath: The Microsoft.Win32.RegistryKey is closed when trying to access the Origin ClientPath registry key (closed keys cannot be accessed), so skipping game");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
logger.Warn(ex, "OriginLibrary/GetActualFilePath: The Origin ClientPath registry key has been marked for deletion so we cannot access the value dueing the OriginLibrary check, so skipping game");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
logger.Warn(ex, "OriginLibrary/GetActualFilePath: The user does not have the necessary registry rights to check whether Origin is installed, so skipping game");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.Warn($"OriginLibrary/GetActualFilePath: Game File Path {gameFilePath} starts with '[HEKY_LOCAL_MACHINE' but didn't match the regex when it should have");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (gameFilePath.StartsWith("[HKEY_CURRENT_USER"))
|
||||||
|
{
|
||||||
|
// The filePath contains a registry key lookup that we need to execute and replace
|
||||||
|
MatchCollection mc = Regex.Matches(gameFilePath, @"\[HKEY_CURRENT_USER\\(.*)\](.*)");
|
||||||
|
if (mc.Count > 0)
|
||||||
|
{
|
||||||
|
string originGameInstallKeyNameAndValue = mc[0].Groups[1].ToString();
|
||||||
|
string originGameRestOfFile = mc[0].Groups[2].ToString();
|
||||||
|
if (originGameInstallKeyNameAndValue == null)
|
||||||
|
{
|
||||||
|
// then we have a problem and we need to continue and ignore this game
|
||||||
|
logger.Warn($"OriginLibrary/GetActualFilePath: Origin game path {gameFilePath} has registry but we can't match it! gameFilePath is {gameFilePath}.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
mc = Regex.Matches(originGameInstallKeyNameAndValue, @"(.*)\\([^\\]*)");
|
||||||
|
string originGameInstallKeyName = mc[0].Groups[1].ToString();
|
||||||
|
string originGameInstallKeyValue = mc[0].Groups[2].ToString();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RegistryKey originGameInstallKey = Registry.LocalMachine.OpenSubKey(originGameInstallKeyName, RegistryKeyPermissionCheck.ReadSubTree);
|
||||||
|
if (originGameInstallKey == null)
|
||||||
|
{
|
||||||
|
// then we have a problem as we cannot find the game exe location!
|
||||||
|
logger.Warn($"OriginLibrary/GetActualFilePath: Origin game path {gameFilePath} has a install reg key we cannot find! originGameInstallKey is {gameFilePath} and originGameInstallKeyValue is {originGameInstallKeyValue}.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
originGameInstallLocation = Path.Combine(originGameInstallKey.GetValue(originGameInstallKeyValue).ToString(), originGameRestOfFile);
|
||||||
|
if (!File.Exists(originGameInstallLocation))
|
||||||
|
{
|
||||||
|
// then we have a problem as we cannot locate the game exe file to start!
|
||||||
|
logger.Warn($"OriginLibrary/GetActualFilePath: Origin game path {gameFilePath} has gameexe we cannot find! originGameInstallLocation is {originGameInstallLocation}.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return originGameInstallLocation;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SecurityException ex)
|
||||||
|
{
|
||||||
|
logger.Warn(ex, $"OriginLibrary/GetActualFilePath: The user does not have the permissions required to read the Origin Game location registry key {originGameInstallKeyName}, so skipping game");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (ObjectDisposedException ex)
|
||||||
|
{
|
||||||
|
logger.Warn(ex, "OriginLibrary/GetActualFilePath: The Microsoft.Win32.RegistryKey is closed when trying to access the Origin ClientPath registry key (closed keys cannot be accessed), so skipping game");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
logger.Warn(ex, "OriginLibrary/GetActualFilePath: The Origin ClientPath registry key has been marked for deletion so we cannot access the value dueing the OriginLibrary check, so skipping game");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
logger.Warn(ex, "OriginLibrary/GetActualFilePath: The user does not have the necessary registry rights to check whether Origin is installed, so skipping game");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.Warn($"OriginLibrary/GetActualFilePath: Game File Path {gameFilePath} starts with '[HKEY_CURRENT_USER' but didn't match the regex when it should have, so skipping game");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If we get here, then the gameFilepath is the actual filepath! So we just copy it.
|
||||||
|
logger.Trace($"OriginLibrary/GetActualFilePath: Game File Path {gameFilePath} doesn't start with '[HKEY_LOCAL_MACHINE' or '[HKEY_CURRENT_USER' so it must be aplain file path");
|
||||||
|
return gameFilePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ using System.Resources;
|
|||||||
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
||||||
|
|
||||||
// Version information
|
// Version information
|
||||||
[assembly: AssemblyVersion("2.0.1.59")]
|
[assembly: AssemblyVersion("2.0.1.70")]
|
||||||
[assembly: AssemblyFileVersion("2.0.1.59")]
|
[assembly: AssemblyFileVersion("2.0.1.70")]
|
||||||
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
|
|
||||||
|
@ -209,9 +209,13 @@ namespace DisplayMagicianShared.AMD
|
|||||||
catch (DllNotFoundException ex)
|
catch (DllNotFoundException ex)
|
||||||
{
|
{
|
||||||
// If we get here then the AMD ADL DLL wasn't found. We can't continue to use it, so we log the error and exit
|
// If we get here then the AMD ADL DLL wasn't found. We can't continue to use it, so we log the error and exit
|
||||||
SharedLogger.logger.Info(ex, $"AMDLibrary/AMDLibrary: Exception trying to load the AMD ADL DLL {ADLImport.ATI_ADL_DLL}. This generally means you don't have the AMD ADL driver installed.");
|
SharedLogger.logger.Info(ex, $"AMDLibrary/AMDLibrary: DLL Not Found Exception trying to load the AMD ADL DLL {ADLImport.ATI_ADL_DLL}. This generally means you don't have the AMD ADL driver installed (which it won't be if you don't have an AMD card)");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// If we get here then something else happened
|
||||||
|
SharedLogger.logger.Info(ex, $"AMDLibrary/AMDLibrary: General Exception trying to load the AMD ADL DLL {ADLImport.ATI_ADL_DLL}. This generally means you don't have the AMD ADL driver installed (which it won't be if you don't have an AMD card)");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~AMDLibrary()
|
~AMDLibrary()
|
||||||
|
@ -193,7 +193,12 @@ namespace DisplayMagicianShared.NVIDIA
|
|||||||
catch (DllNotFoundException ex)
|
catch (DllNotFoundException ex)
|
||||||
{
|
{
|
||||||
// If this fires, then the DLL isn't available, so we need don't try to do anything else
|
// If this fires, then the DLL isn't available, so we need don't try to do anything else
|
||||||
SharedLogger.logger.Info(ex, $"NVIDIALibrary/NVIDIALibrary: Exception trying to load the NVIDIA NVAPI DLL. This generally means you don't have the NVIDIA driver installed.");
|
SharedLogger.logger.Info(ex, $"NVIDIALibrary/NVIDIALibrary: Exception trying to load the NVIDIA NVAPI DLL. This generally means you don't have the NVIDIA driver installed (which it won't be if you don't have an NVIDIA card).");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// If we get here then another problem happened
|
||||||
|
SharedLogger.logger.Info(ex, $"NVIDIALibrary/NVIDIALibrary: General Exception trying to load the NVAPI DLL. This generally means you don't have the NVIDIA NVAPI driver installed (which it won't be if you don't have an NVIDIA card)");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1045,7 +1045,6 @@ namespace DisplayMagicianShared
|
|||||||
{
|
{
|
||||||
SharedLogger.logger.Debug($"ProfileRepository/ProfileRepository: Initialising the NVIDIA NVAPI library.");
|
SharedLogger.logger.Debug($"ProfileRepository/ProfileRepository: Initialising the NVIDIA NVAPI library.");
|
||||||
nvidiaLibrary = new NVIDIALibrary();
|
nvidiaLibrary = new NVIDIALibrary();
|
||||||
_currentVideoMode = VIDEO_MODE.NVIDIA;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -1060,7 +1059,6 @@ namespace DisplayMagicianShared
|
|||||||
{
|
{
|
||||||
SharedLogger.logger.Debug($"ProfileRepository/ProfileRepository: Initialising the AMD ADL library.");
|
SharedLogger.logger.Debug($"ProfileRepository/ProfileRepository: Initialising the AMD ADL library.");
|
||||||
amdLibrary = new AMDLibrary();
|
amdLibrary = new AMDLibrary();
|
||||||
_currentVideoMode = VIDEO_MODE.AMD;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user