private static string FindBAOPath(string SteamPath) { string BAOPath = null; try { string BAOManifestFile = System.IO.Path.Combine(SteamPath, Constants.FileData.BAOManifestFilePath); if (System.IO.File.Exists(BAOManifestFile)) { Gameloop.Vdf.Linq.VProperty BAOManifest = Gameloop.Vdf.VdfConvert.Deserialize(System.IO.File.ReadAllText(BAOManifestFile)); if (!string.IsNullOrEmpty(BAOManifest.Value["installdir"].ToString())) { string Path = System.IO.Path.Combine(SteamPath, Constants.FileData.SteamGamesFolderPath, BAOManifest.Value["installdir"].ToString(), Constants.FileData.OnlineDefaultWBIDVarsPath); if (System.IO.File.Exists(Path)) { BAOPath = System.IO.Path.Combine(SteamPath, Constants.FileData.SteamGamesFolderPath, BAOManifest.Value["installdir"].ToString()); } } } } catch { } if (string.IsNullOrEmpty(BAOPath)) { //Try the common path string Path = System.IO.Path.Combine(SteamPath, Constants.FileData.SteamGamesFolderPath, "Batman Arkham Origins", Constants.FileData.OnlineDefaultWBIDVarsPath); if (System.IO.File.Exists(Path)) { BAOPath = System.IO.Path.Combine(SteamPath, Constants.FileData.SteamGamesFolderPath, "Batman Arkham Origins"); } } return(BAOPath); }
private void PerformSteamInstall() { ActiveOperation = true; string SteamAppID = ""; string RelativePath = ""; try { SteamAppID = JsonRepostiory[_productSelected]["SteamAppID"].ToString(); } catch (Exception ex) { Log("JSON object missing RelativePath parameter!"); ActiveOperation = false; throw ex; } try { RelativePath = JsonRepostiory[_productSelected]["RelativePath"].ToString(); } catch { Log("JSON object missing RelativePath parameter!"); RelativePath = ""; } string AppManifest = ""; string LibraryRoot = ""; foreach (string library in SteamLibraries) { string path = library + "\\steamapps\\appmanifest_" + SteamAppID + ".acf"; if (File.Exists(path)) { AppManifest = path; LibraryRoot = library; Log("AppManifest file detected at " + AppManifest + "."); break; } } if (AppManifest != "") { Gameloop.Vdf.Linq.VProperty vProperty = VdfConvert.Deserialize(File.ReadAllText(AppManifest)); string InstallDirectory = ""; try { InstallDirectory = vProperty.Value["installdir"].ToString(); } catch { } if (InstallDirectory != "") { TargetInstallPath = LibraryRoot + "\\steamapps\\common\\" + InstallDirectory + RelativePath; bool fileExists = File.Exists(_tmpDownloadPath); bool cancel = false; if (fileExists) { Log("A file called " + _tmpArchiveName + " was found in the downloads folder. Prompting user on how to proceed."); switch (MessageBox.Show("A file called " + _tmpArchiveName + " was found in the downloads folder.\r\nDo you want to use that one?\r\n\r\nClicking 'No' will redownload the file from the Internet.", "Found local file for selected version", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3)) { case DialogResult.Yes: Log("User chose to reuse the local copy found."); break; case DialogResult.No: fileExists = false; Log("User chose to redownload the archive from the Internet."); break; case DialogResult.Cancel: cancel = true; ActiveOperation = false; Log("User canceled the install process."); break; } } if (cancel == false) { if (fileExists == false) { Log("Downloading " + _tmpDownloadURL); using (OngoingDownload = new WebClient()) { OngoingDownload.DownloadProgressChanged += OnDownloadProgressChanged; OngoingDownload.DownloadFileCompleted += (object sender, AsyncCompletedEventArgs e) => { if (!tsProgress.IsDisposed) { tsProgress.Visible = false; } if (e.Cancelled || e.Error != null) { if (e.Cancelled) { Log("Download cancelled!"); } else if (e.Error != null) { Log("Download failed!"); Log("Error message: " + e.Error.Message + "\r\n"); } Log("Cleaning up incomplete file " + _tmpDownloadPath); if (File.Exists(_tmpDownloadPath)) { File.Delete(_tmpDownloadPath); } ActiveOperation = false; CancelOperation = true; OngoingDownload.Dispose(); OngoingDownload = null; return; } Log("Download completed!"); FinalizeSteamInstall(); OngoingDownload.Dispose(); OngoingDownload = null; }; OngoingDownload.DownloadFileAsync(new Uri(_tmpDownloadURL), _tmpDownloadPath); } } else { FinalizeSteamInstall(); } } else { ActiveOperation = CancelOperation = false; } } } ActiveOperation = false; }
public Manage() { InitializeComponent(); lCurrentBranch.Text = ""; lCurrentVersion.Text = ""; Icon = Properties.Resources.pokeball; Directory.CreateDirectory(_tmpDownloadRoot); Log("**WARNING**\r\nThis is still a work in progress, and isn't recommended for mainstream use yet!\r\nUse at your own risk!\r\n"); Log("Detecting Steam install folders..."); var SteamInstallPath = Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\\Software\\Valve\\Steam", "SteamPath", "not found"); if (SteamInstallPath != null && SteamInstallPath.ToString() != "not found") { string primaryLibrary = SteamInstallPath.ToString().Replace("/", "\\"); Log("Primary library: " + primaryLibrary); SteamLibraries.Add(primaryLibrary); if (File.Exists(SteamInstallPath.ToString() + "\\steamapps\\libraryfolders.vdf")) { Gameloop.Vdf.Linq.VProperty vProperty = VdfConvert.Deserialize(File.ReadAllText(SteamInstallPath.ToString() + "\\steamapps\\libraryfolders.vdf")); foreach (var item in vProperty.Value.Children()) { if (!IsNumeric(item.Key)) { continue; } Log("Additional library: " + item.Value); SteamLibraries.Add(item.Value.ToString()); } } } else { Log("Steam does not seem to be installed.\r\n"); } Log("Downloading repository data..."); using (WebClient wc = new WebClient()) { wc.DownloadProgressChanged += OnDownloadProgressChanged; wc.DownloadFileCompleted += (object sender, AsyncCompletedEventArgs e) => { tsProgress.Visible = false; if (e.Cancelled || e.Error != null) { if (e.Cancelled) { Log("Download cancelled!"); } else if (e.Error != null) { Log("Download failed!"); Log("Error message: " + e.Error.Message + "\r\n"); } Log("Cleaning up incomplete file repository_new.json"); if (File.Exists("repository_new.json")) { File.Delete("repository_new.json"); } Log("Download failed. Falling back to local repository copy."); Log("Error message: " + e.Error.Message + "\r\n"); } else { File.Delete("repository.json"); File.Move("repository_new.json", "repository.json"); } Log("Reading repository data..."); JsonRepostiory = JObject.Parse(File.ReadAllText("repository.json")); foreach (KeyValuePair <string, JToken> product in JsonRepostiory) { cbProducts.Items.Add(product.Key); } Log("Ready to be used!\r\n"); tbLog.Enabled = true; lSelectProduct.Enabled = true; lSelectBranch.Enabled = true; lSelectVersion.Enabled = true; cbProducts.Enabled = true; cbBranches.Enabled = true; cbVersions.Enabled = true; tbSelectedProduct.Enabled = true; tbSelectedBranch.Enabled = true; tbSelectedVersion.Enabled = true; }; wc.DownloadFileAsync(new Uri("https://raw.githubusercontent.com/Idearum/SK-AltInjector/master/64bitMainApp/repository.json"), "repository_new.json"); } }
public static AppConfig FindAndSaveBAOPAth() { AppConfig AppConfig = LoadConfig(); if (!string.IsNullOrEmpty(AppConfig.BAOInstallationFolder) && System.IO.File.Exists(System.IO.Path.Combine(AppConfig.BAOInstallationFolder, Constants.FileData.OnlineDefaultWBIDVarsPath))) { return(AppConfig); } string SteamPath = (string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam", "InstallPath", null) ?? (string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam", "InstallPath", null); if (!string.IsNullOrEmpty(SteamPath)) { // Do stuff string BAOPath = FindBAOPath(SteamPath); if (!string.IsNullOrEmpty(BAOPath)) { AppConfig.BAOInstallationFolder = BAOPath; } else { try { string SteamLibraryFoldersFile = System.IO.Path.Combine(SteamPath, Constants.FileData.SteamLibraryFoldersFilePath); if (System.IO.File.Exists(SteamLibraryFoldersFile)) { Gameloop.Vdf.Linq.VProperty SteamLibraryFolders = Gameloop.Vdf.VdfConvert.Deserialize(System.IO.File.ReadAllText(SteamLibraryFoldersFile)); int i = 1; bool StillGotFolders = true; while (StillGotFolders) { string NextSteamPath = SteamLibraryFolders.Value[i.ToString()].ToString(); if (!string.IsNullOrEmpty(NextSteamPath)) { BAOPath = FindBAOPath(NextSteamPath); if (!string.IsNullOrEmpty(BAOPath)) { AppConfig.BAOInstallationFolder = BAOPath; StillGotFolders = false; } } else { StillGotFolders = false; } i++; } } } catch { } } if (!string.IsNullOrEmpty(BAOPath)) { string ConfigFile = System.IO.Path.Combine(Constants.FileData.ConfigPath, "Config.json"); using System.IO.StreamWriter SWriter = System.IO.File.CreateText(ConfigFile); Newtonsoft.Json.JsonSerializer Serializer = new() { DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include }; Serializer.Serialize(SWriter, AppConfig); } } if (string.IsNullOrEmpty(SteamPath) || string.IsNullOrEmpty(AppConfig.BAOInstallationFolder)) { Console.WriteLine(@"I am so sorry but I couldn't find the Batman: Arkham Origins installation folder. Please enter it manually in the Config file. Example value: ""C:\\Program Files (x86)\\Steam\\steamapps\\common\\Batman Arkham Origins"" Press Enter to exit."); Console.ReadLine(); Environment.Exit(0); } return(AppConfig); }