├── .gitattributes ├── .gitignore ├── GOGWrapper.sln ├── GOGWrapper ├── GOG │ ├── GOGGalaxy.cs │ ├── GOGGame.cs │ └── GOGRegistry.cs ├── GOGWrapper.csproj ├── GOGWrapper.ico ├── GOGWrapper.png ├── LaunchingForm.Designer.cs ├── LaunchingForm.cs ├── LaunchingForm.resx ├── MainForm.Designer.cs ├── MainForm.cs ├── MainForm.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Steam │ ├── SteamUtils.cs │ └── VDFParser │ │ ├── Exceptions.cs │ │ ├── Extensions.cs │ │ ├── GenericWriter.cs │ │ ├── Machines │ │ ├── VDFFieldsSM.cs │ │ ├── VDFIndexedArraySM.cs │ │ └── VDFSM.cs │ │ ├── Models │ │ ├── VDFEntry.cs │ │ ├── VDFField.cs │ │ └── VDFFieldType.cs │ │ ├── Shared.cs │ │ ├── VDFParser.cs │ │ └── VDFSerializer.cs ├── Utils │ └── WinAPI.cs └── app.config └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /GOGWrapper.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.14 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GOGWrapper", "GOGWrapper\GOGWrapper.csproj", "{9A18280C-D97E-4753-9ED9-690091A7355F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {9A18280C-D97E-4753-9ED9-690091A7355F}.Debug|x86.ActiveCfg = Debug|x86 15 | {9A18280C-D97E-4753-9ED9-690091A7355F}.Debug|x86.Build.0 = Debug|x86 16 | {9A18280C-D97E-4753-9ED9-690091A7355F}.Release|x86.ActiveCfg = Release|x86 17 | {9A18280C-D97E-4753-9ED9-690091A7355F}.Release|x86.Build.0 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /GOGWrapper/GOG/GOGGalaxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading; 7 | using System.IO; 8 | 9 | using GOGWrapper.Utils; 10 | 11 | namespace GOGWrapper.GOG 12 | { 13 | class GOGGalaxy 14 | { 15 | private static int _x = 420; 16 | private static int _y = 190; 17 | 18 | public static void open(GOGGame game) 19 | { 20 | if(game == null) return; 21 | GOGGalaxy.open(game.ID); 22 | } 23 | public static void launch(GOGGame game) 24 | { 25 | if (game == null) return; 26 | GOGGalaxy.launch(game.ID); 27 | } 28 | 29 | public static void open(string id) 30 | { 31 | Process.Start(GOGRegistry.ClientExecutable, $@"/gameid {id} /command launch"); 32 | } 33 | 34 | public static void launch(string id, Action callback = null) 35 | { 36 | // GOGGalaxy.launchWinapi(id); // old hacky way 37 | 38 | Process.Start(GOGRegistry.ClientExecutable, $@"/gameid {id} /command runGame"); 39 | GOGGalaxy.waitForStartup(); 40 | 41 | GOGGame game = GOGRegistry.Game(id); 42 | 43 | if(game?.ExecutableName?.Length > 0) 44 | { 45 | Thread.Sleep(5000); 46 | 47 | Process[] procs = Process.GetProcessesByName(game.ExecutableName.Replace(".exe", "")); 48 | 49 | if (procs?.Length > 0) 50 | { 51 | procs[0].WaitForExit(); 52 | } 53 | 54 | Thread.Sleep(5000); 55 | 56 | procs = Process.GetProcesses(); 57 | 58 | foreach(Process proc in procs) 59 | { 60 | try 61 | { 62 | if(normalize(proc.MainModule.FileName).StartsWith(normalize(game.Path))) 63 | { 64 | proc.WaitForExit(); 65 | break; 66 | } 67 | } 68 | catch {} 69 | } 70 | } 71 | 72 | callback?.Invoke(); 73 | } 74 | 75 | private static void launchWinapi(string id) 76 | { 77 | GOGGalaxy.open(id); 78 | 79 | IntPtr hwnd = GOGGalaxy.waitForStartup(); 80 | 81 | WinAPI.SetForegroundWindow(hwnd); 82 | WinAPI.Click(hwnd, new System.Drawing.Point(_x, _y)); 83 | } 84 | 85 | private static IntPtr waitForStartup() 86 | { 87 | IntPtr hwnd = WinAPI.FindWindow("GalaxyClientClass", null); 88 | 89 | bool windowExists = WinAPI.IsWindow(hwnd); 90 | 91 | Thread.Sleep(500); 92 | 93 | if (!windowExists) 94 | { 95 | hwnd = WinAPI.WaitForWindow("GalaxyClientClass", null); 96 | Thread.Sleep(5000); 97 | } 98 | 99 | return hwnd; 100 | } 101 | 102 | private static string normalize(string path) 103 | { 104 | return Path.GetFullPath(new Uri(path).LocalPath).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /GOGWrapper/GOG/GOGGame.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Drawing; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace GOGWrapper.GOG 11 | { 12 | class GOGGame : IComparable 13 | { 14 | private string _id; 15 | private string _name; 16 | private string _path; 17 | private string _exename; 18 | private string _exepath; 19 | 20 | public string ID => this._id; 21 | public string Name => this._name; 22 | public string Path => this._path; 23 | public string ExecutableName => this._exename; 24 | public string ExecutablePath => this._exepath; 25 | public string Icon => $@"{this.Path}\goggame-{this.ID}.ico"; 26 | 27 | public GOGGame(RegistryKey key) 28 | { 29 | this._id = (string) key.GetValue("gameID"); 30 | this._name = (string) key.GetValue("GAMENAME"); 31 | this._path = (string) key.GetValue("PATH"); 32 | this._exename = (string) key.GetValue("EXEFILE"); 33 | this._exepath = (string) key.GetValue("EXE"); 34 | } 35 | 36 | public static bool IsValidGame(RegistryKey key) 37 | { 38 | if(key == null) return false; 39 | 40 | string depends = (string)key.GetValue("DEPENDSON"); 41 | if(depends != null && depends.Trim().Length > 0) return false; 42 | 43 | return !_keyExists(key, "DEPENDSON") 44 | && _keyExists(key, "gameID") 45 | && _keyExists(key, "GAMENAME") 46 | && _keyExists(key, "PATH"); 47 | } 48 | 49 | public override string ToString() 50 | { 51 | return this._name ?? this._id ?? ""; 52 | } 53 | 54 | private static bool _keyExists(RegistryKey key, string name) 55 | { 56 | string val = (string) key.GetValue(name); 57 | return val != null && val.Trim().Length > 0; 58 | } 59 | 60 | public int CompareTo(GOGGame other) 61 | { 62 | return this.Name.CompareTo(other.Name); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /GOGWrapper/GOG/GOGRegistry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Win32; 6 | 7 | namespace GOGWrapper.GOG 8 | { 9 | class GOGRegistry 10 | { 11 | #region Registry keys 12 | 13 | private static RegistryKey _regroot; 14 | public static RegistryKey REGRoot 15 | { 16 | get 17 | { 18 | _regroot = _regroot ?? Registry.LocalMachine.OpenSubKey(@"SOFTWARE\GOG.com"); 19 | return _regroot; 20 | } 21 | } 22 | 23 | private static RegistryKey _regclient; 24 | public static RegistryKey REGClient 25 | { 26 | get 27 | { 28 | _regclient = _regclient ?? GOGRegistry.REGRoot?.OpenSubKey(@"GalaxyClient\paths"); 29 | return _regclient; 30 | } 31 | } 32 | 33 | private static RegistryKey _reggames; 34 | public static RegistryKey REGGames 35 | { 36 | get 37 | { 38 | _reggames = _reggames ?? GOGRegistry.REGRoot?.OpenSubKey(@"Games"); 39 | return _reggames; 40 | } 41 | } 42 | 43 | #endregion 44 | 45 | #region Values 46 | 47 | private static string _clientPath; 48 | public static string ClientPath 49 | { 50 | get 51 | { 52 | if(_clientPath == null || _clientPath.Trim().Length == 0) 53 | { 54 | _clientPath = (string) GOGRegistry.REGClient?.GetValue("client"); 55 | } 56 | return _clientPath; 57 | } 58 | } 59 | public static string ClientExecutable => (GOGRegistry.ClientPath ?? "") + @"\GalaxyClient.exe"; 60 | 61 | private static List _games; 62 | public static List Games 63 | { 64 | get 65 | { 66 | if(_games == null) 67 | { 68 | _games = new List(); 69 | 70 | RegistryKey g = GOGRegistry.REGGames; 71 | 72 | if(g != null) 73 | { 74 | foreach(string id in g.GetSubKeyNames()) 75 | { 76 | RegistryKey key = g.OpenSubKey(id); 77 | 78 | if(GOGGame.IsValidGame(key)) _games.Add(new GOGGame(key)); 79 | } 80 | } 81 | 82 | _games.Sort(); 83 | } 84 | 85 | return _games; 86 | } 87 | } 88 | 89 | public static GOGGame Game(string id) 90 | { 91 | foreach (GOGGame game in GOGRegistry.Games) 92 | { 93 | if (game.ID == id) 94 | { 95 | return game; 96 | } 97 | } 98 | return null; 99 | } 100 | 101 | #endregion 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /GOGWrapper/GOGWrapper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {9A18280C-D97E-4753-9ED9-690091A7355F} 8 | WinExe 9 | GOGWrapper 10 | GOGWrapper 11 | v4.5 12 | 512 13 | 14 | publish\ 15 | true 16 | Disk 17 | false 18 | Foreground 19 | 7 20 | Days 21 | false 22 | false 23 | true 24 | 0 25 | 1.0.0.%2a 26 | false 27 | false 28 | true 29 | 30 | 31 | true 32 | bin\x86\Debug\ 33 | DEBUG;TRACE 34 | full 35 | x86 36 | prompt 37 | MinimumRecommendedRules.ruleset 38 | false 39 | 40 | 41 | bin\x86\Release\ 42 | TRACE 43 | true 44 | pdbonly 45 | x86 46 | prompt 47 | MinimumRecommendedRules.ruleset 48 | false 49 | 50 | 51 | GOGWrapper.ico 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | Form 71 | 72 | 73 | LaunchingForm.cs 74 | 75 | 76 | Form 77 | 78 | 79 | MainForm.cs 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | LaunchingForm.cs 98 | 99 | 100 | MainForm.cs 101 | 102 | 103 | ResXFileCodeGenerator 104 | Resources.Designer.cs 105 | Designer 106 | 107 | 108 | True 109 | Resources.resx 110 | True 111 | 112 | 113 | 114 | SettingsSingleFileGenerator 115 | Settings.Designer.cs 116 | 117 | 118 | True 119 | Settings.settings 120 | True 121 | 122 | 123 | 124 | 125 | False 126 | .NET Framework 3.5 SP1 127 | false 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /GOGWrapper/GOGWrapper.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkashkin/GOGWrapper/5ac19f61d4187f82c360761e3018efe982ab5047/GOGWrapper/GOGWrapper.ico -------------------------------------------------------------------------------- /GOGWrapper/GOGWrapper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkashkin/GOGWrapper/5ac19f61d4187f82c360761e3018efe982ab5047/GOGWrapper/GOGWrapper.png -------------------------------------------------------------------------------- /GOGWrapper/LaunchingForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GOGWrapper 2 | { 3 | partial class LaunchingForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.gameIcon = new System.Windows.Forms.PictureBox(); 32 | this.gameName = new System.Windows.Forms.Label(); 33 | this.progress = new System.Windows.Forms.ProgressBar(); 34 | ((System.ComponentModel.ISupportInitialize)(this.gameIcon)).BeginInit(); 35 | this.SuspendLayout(); 36 | // 37 | // gameIcon 38 | // 39 | this.gameIcon.Location = new System.Drawing.Point(12, 8); 40 | this.gameIcon.Name = "gameIcon"; 41 | this.gameIcon.Size = new System.Drawing.Size(48, 48); 42 | this.gameIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; 43 | this.gameIcon.TabIndex = 5; 44 | this.gameIcon.TabStop = false; 45 | // 46 | // gameName 47 | // 48 | this.gameName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 49 | | System.Windows.Forms.AnchorStyles.Right))); 50 | this.gameName.AutoEllipsis = true; 51 | this.gameName.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 52 | this.gameName.Location = new System.Drawing.Point(66, 15); 53 | this.gameName.Name = "gameName"; 54 | this.gameName.Size = new System.Drawing.Size(282, 30); 55 | this.gameName.TabIndex = 4; 56 | this.gameName.Text = "Game"; 57 | // 58 | // progress 59 | // 60 | this.progress.Location = new System.Drawing.Point(-1, 62); 61 | this.progress.Name = "progress"; 62 | this.progress.Size = new System.Drawing.Size(362, 8); 63 | this.progress.Style = System.Windows.Forms.ProgressBarStyle.Marquee; 64 | this.progress.TabIndex = 6; 65 | // 66 | // LaunchingForm 67 | // 68 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 69 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 70 | this.BackColor = System.Drawing.SystemColors.Window; 71 | this.ClientSize = new System.Drawing.Size(360, 70); 72 | this.ControlBox = false; 73 | this.Controls.Add(this.progress); 74 | this.Controls.Add(this.gameIcon); 75 | this.Controls.Add(this.gameName); 76 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 77 | this.MaximizeBox = false; 78 | this.MinimizeBox = false; 79 | this.Name = "LaunchingForm"; 80 | this.ShowIcon = false; 81 | this.ShowInTaskbar = false; 82 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 83 | this.Text = "Launching..."; 84 | ((System.ComponentModel.ISupportInitialize)(this.gameIcon)).EndInit(); 85 | this.ResumeLayout(false); 86 | 87 | } 88 | 89 | #endregion 90 | 91 | private System.Windows.Forms.PictureBox gameIcon; 92 | private System.Windows.Forms.Label gameName; 93 | private System.Windows.Forms.ProgressBar progress; 94 | } 95 | } -------------------------------------------------------------------------------- /GOGWrapper/LaunchingForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using System.Threading; 10 | using System.Diagnostics; 11 | 12 | using GOGWrapper.GOG; 13 | 14 | namespace GOGWrapper 15 | { 16 | public partial class LaunchingForm : Form 17 | { 18 | public bool ExitGalaxy = false; 19 | 20 | public LaunchingForm(String gameid) 21 | { 22 | InitializeComponent(); 23 | 24 | GOGGame game = GOGRegistry.Game(gameid); 25 | 26 | this.gameName.Text = game?.Name; 27 | this.gameIcon.ImageLocation = game?.Icon; 28 | 29 | new Thread(new ThreadStart(() => GOGGalaxy.launch(gameid, this.Exit))).Start(); 30 | } 31 | 32 | private void GalaxyPreExit() 33 | { 34 | this.Text = "Exiting in 20 seconds..."; 35 | this.progress.Visible = false; 36 | //this.Hide(); 37 | } 38 | 39 | private void Exit() 40 | { 41 | if (this.ExitGalaxy) 42 | { 43 | foreach (Process proc in Process.GetProcessesByName("GalaxyClient")) 44 | { 45 | this.Invoke((MethodInvoker) this.GalaxyPreExit); 46 | 47 | proc.CloseMainWindow(); 48 | Thread.Sleep(20000); // delay for galaxy sync, etc 49 | try // user can kill process before timeout 50 | { 51 | proc.Kill(); 52 | } 53 | catch { } 54 | break; 55 | } 56 | } 57 | 58 | this.Invoke((MethodInvoker) this.Close); 59 | } 60 | 61 | protected override void OnClosed(EventArgs e) 62 | { 63 | base.OnClosed(e); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /GOGWrapper/LaunchingForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /GOGWrapper/MainForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GOGWrapper 2 | { 3 | partial class MainForm 4 | { 5 | /// 6 | /// Обязательная переменная конструктора. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Освободить все используемые ресурсы. 12 | /// 13 | /// истинно, если управляемый ресурс должен быть удален; иначе ложно. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Код, автоматически созданный конструктором форм Windows 24 | 25 | /// 26 | /// Требуемый метод для поддержки конструктора — не изменяйте 27 | /// содержимое этого метода с помощью редактора кода. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); 32 | this.gamesList = new System.Windows.Forms.ListBox(); 33 | this.gameName = new System.Windows.Forms.Label(); 34 | this.gameID = new System.Windows.Forms.Label(); 35 | this.gameIcon = new System.Windows.Forms.PictureBox(); 36 | this.gamePath = new System.Windows.Forms.Label(); 37 | this.gameGalaxyBtn = new System.Windows.Forms.Button(); 38 | this.gameLaunchBtn = new System.Windows.Forms.Button(); 39 | this.gameSteamShortcut = new System.Windows.Forms.Button(); 40 | ((System.ComponentModel.ISupportInitialize)(this.gameIcon)).BeginInit(); 41 | this.SuspendLayout(); 42 | // 43 | // gamesList 44 | // 45 | this.gamesList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 46 | | System.Windows.Forms.AnchorStyles.Left))); 47 | this.gamesList.BackColor = System.Drawing.SystemColors.Window; 48 | this.gamesList.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 49 | this.gamesList.FormattingEnabled = true; 50 | this.gamesList.IntegralHeight = false; 51 | this.gamesList.ItemHeight = 15; 52 | this.gamesList.Location = new System.Drawing.Point(0, 0); 53 | this.gamesList.Name = "gamesList"; 54 | this.gamesList.Size = new System.Drawing.Size(160, 321); 55 | this.gamesList.TabIndex = 0; 56 | this.gamesList.SelectedValueChanged += new System.EventHandler(this.gamesList_SelectedValueChanged); 57 | // 58 | // gameName 59 | // 60 | this.gameName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 61 | | System.Windows.Forms.AnchorStyles.Right))); 62 | this.gameName.AutoEllipsis = true; 63 | this.gameName.Font = new System.Drawing.Font("Segoe UI", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 64 | this.gameName.Location = new System.Drawing.Point(220, 6); 65 | this.gameName.Name = "gameName"; 66 | this.gameName.Size = new System.Drawing.Size(392, 40); 67 | this.gameName.TabIndex = 1; 68 | this.gameName.Text = "Game"; 69 | // 70 | // gameID 71 | // 72 | this.gameID.Font = new System.Drawing.Font("Segoe UI", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 73 | this.gameID.ForeColor = System.Drawing.SystemColors.ControlDark; 74 | this.gameID.Location = new System.Drawing.Point(225, 47); 75 | this.gameID.Name = "gameID"; 76 | this.gameID.Size = new System.Drawing.Size(86, 12); 77 | this.gameID.TabIndex = 2; 78 | this.gameID.Text = " 123"; 79 | // 80 | // gameIcon 81 | // 82 | this.gameIcon.Location = new System.Drawing.Point(166, 12); 83 | this.gameIcon.Name = "gameIcon"; 84 | this.gameIcon.Size = new System.Drawing.Size(48, 48); 85 | this.gameIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; 86 | this.gameIcon.TabIndex = 3; 87 | this.gameIcon.TabStop = false; 88 | // 89 | // gamePath 90 | // 91 | this.gamePath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 92 | | System.Windows.Forms.AnchorStyles.Right))); 93 | this.gamePath.AutoEllipsis = true; 94 | this.gamePath.Font = new System.Drawing.Font("Segoe UI", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 95 | this.gamePath.ForeColor = System.Drawing.SystemColors.ControlDarkDark; 96 | this.gamePath.Location = new System.Drawing.Point(317, 47); 97 | this.gamePath.Name = "gamePath"; 98 | this.gamePath.Size = new System.Drawing.Size(295, 12); 99 | this.gamePath.TabIndex = 4; 100 | this.gamePath.Text = "D:\\GOG\\Game"; 101 | this.gamePath.Click += new System.EventHandler(this.gamePath_Click); 102 | // 103 | // gameGalaxyBtn 104 | // 105 | this.gameGalaxyBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 106 | this.gameGalaxyBtn.Location = new System.Drawing.Point(484, 269); 107 | this.gameGalaxyBtn.Name = "gameGalaxyBtn"; 108 | this.gameGalaxyBtn.Size = new System.Drawing.Size(128, 40); 109 | this.gameGalaxyBtn.TabIndex = 5; 110 | this.gameGalaxyBtn.Text = "Open GOG Galaxy"; 111 | this.gameGalaxyBtn.UseVisualStyleBackColor = true; 112 | this.gameGalaxyBtn.Click += new System.EventHandler(this.gameGalaxyBtn_Click); 113 | // 114 | // gameLaunchBtn 115 | // 116 | this.gameLaunchBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 117 | | System.Windows.Forms.AnchorStyles.Right))); 118 | this.gameLaunchBtn.Location = new System.Drawing.Point(166, 66); 119 | this.gameLaunchBtn.Name = "gameLaunchBtn"; 120 | this.gameLaunchBtn.Size = new System.Drawing.Size(446, 40); 121 | this.gameLaunchBtn.TabIndex = 6; 122 | this.gameLaunchBtn.Text = "Launch"; 123 | this.gameLaunchBtn.UseVisualStyleBackColor = true; 124 | this.gameLaunchBtn.Click += new System.EventHandler(this.gameLaunchBtn_Click); 125 | // 126 | // gameSteamShortcut 127 | // 128 | this.gameSteamShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 129 | this.gameSteamShortcut.Location = new System.Drawing.Point(166, 269); 130 | this.gameSteamShortcut.Name = "gameSteamShortcut"; 131 | this.gameSteamShortcut.Size = new System.Drawing.Size(210, 40); 132 | this.gameSteamShortcut.TabIndex = 7; 133 | this.gameSteamShortcut.Text = "Add shortcut to the Steam Library"; 134 | this.gameSteamShortcut.UseVisualStyleBackColor = true; 135 | this.gameSteamShortcut.Click += new System.EventHandler(this.gameSteamShortcut_Click); 136 | // 137 | // MainForm 138 | // 139 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 140 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 141 | this.BackColor = System.Drawing.SystemColors.Window; 142 | this.ClientSize = new System.Drawing.Size(624, 321); 143 | this.Controls.Add(this.gameSteamShortcut); 144 | this.Controls.Add(this.gameLaunchBtn); 145 | this.Controls.Add(this.gameGalaxyBtn); 146 | this.Controls.Add(this.gamePath); 147 | this.Controls.Add(this.gameIcon); 148 | this.Controls.Add(this.gameID); 149 | this.Controls.Add(this.gameName); 150 | this.Controls.Add(this.gamesList); 151 | this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); 152 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 153 | this.MinimumSize = new System.Drawing.Size(640, 360); 154 | this.Name = "MainForm"; 155 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 156 | this.Text = "GOGWrapper"; 157 | ((System.ComponentModel.ISupportInitialize)(this.gameIcon)).EndInit(); 158 | this.ResumeLayout(false); 159 | 160 | } 161 | 162 | #endregion 163 | 164 | private System.Windows.Forms.ListBox gamesList; 165 | private System.Windows.Forms.Label gameName; 166 | private System.Windows.Forms.Label gameID; 167 | private System.Windows.Forms.PictureBox gameIcon; 168 | private System.Windows.Forms.Label gamePath; 169 | private System.Windows.Forms.Button gameGalaxyBtn; 170 | private System.Windows.Forms.Button gameLaunchBtn; 171 | private System.Windows.Forms.Button gameSteamShortcut; 172 | } 173 | } 174 | 175 | -------------------------------------------------------------------------------- /GOGWrapper/MainForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using System.Diagnostics; 10 | 11 | using GOGWrapper.GOG; 12 | 13 | using GOGWrapper.Steam; 14 | using GOGWrapper.Steam.VDFParser.Models; 15 | 16 | using GOGWrapper.Utils; 17 | 18 | namespace GOGWrapper 19 | { 20 | public partial class MainForm : Form 21 | { 22 | public MainForm() 23 | { 24 | InitializeComponent(); 25 | 26 | this.Text = $"GOGWrapper - {GOGRegistry.ClientPath}"; 27 | this.gamesList.DataSource = GOGRegistry.Games; 28 | } 29 | 30 | private void gamesList_SelectedValueChanged(object sender, EventArgs e) 31 | { 32 | GOGGame game = (GOGGame) this.gamesList.SelectedValue; 33 | 34 | if(game == null) return; 35 | 36 | this.gameName.Text = game.Name; 37 | this.gameID.Text = game.ID; 38 | this.gameIcon.ImageLocation = game.Icon; 39 | this.gamePath.Text = game.Path; 40 | } 41 | 42 | private void gamePath_Click(object sender, EventArgs e) 43 | { 44 | GOGGame game = (GOGGame) this.gamesList.SelectedValue; 45 | if (game == null) return; 46 | Process.Start(game.Path); 47 | } 48 | 49 | private void gameGalaxyBtn_Click(object sender, EventArgs e) 50 | { 51 | GOGGame game = (GOGGame) this.gamesList.SelectedValue; 52 | GOGGalaxy.open(game); 53 | } 54 | 55 | private void gameLaunchBtn_Click(object sender, EventArgs e) 56 | { 57 | GOGGame game = (GOGGame) this.gamesList.SelectedValue; 58 | new LaunchingForm(game.ID).ShowDialog(); 59 | } 60 | 61 | private void gameSteamShortcut_Click(object sender, EventArgs e) 62 | { 63 | GOGGame game = (GOGGame)this.gamesList.SelectedValue; 64 | if (game == null) return; 65 | 66 | this.gameSteamShortcut.Enabled = false; 67 | 68 | try 69 | { 70 | string[] users = SteamUtils.GetUsers(); 71 | 72 | VDFEntry shortcut = new VDFEntry() 73 | { 74 | AppName = game.Name, 75 | Exe = $"\"{Application.ExecutablePath}\" {game.ID} -e", 76 | StartDir = $"\"{game.Path}\"", 77 | Icon = game.Icon, 78 | ShortcutPath = "", 79 | IsHidden = 0, 80 | AllowDesktopConfig = 1, 81 | OpenVR = 0, 82 | Tags = new string[] { "GOG.com" }, 83 | Index = 0 84 | }; 85 | 86 | foreach(string user in users) 87 | { 88 | List shortcuts = new List(SteamUtils.ReadShortcuts(user)); 89 | 90 | shortcuts.Add(shortcut); 91 | 92 | SteamUtils.WriteShortcuts(shortcuts.ToArray(), user); 93 | } 94 | 95 | MessageBox.Show("You may need to restart Steam to use new shortcut", "Steam shortcut added", MessageBoxButtons.OK, MessageBoxIcon.Information); 96 | } 97 | catch (Exception ex) 98 | { 99 | MessageBox.Show(ex.ToString(), "Steam shortcut add failed", MessageBoxButtons.OK, MessageBoxIcon.Error); 100 | } 101 | 102 | this.gameSteamShortcut.Enabled = true; 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /GOGWrapper/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | using GOGWrapper.GOG; 7 | 8 | namespace GOGWrapper 9 | { 10 | static class Program 11 | { 12 | /// 13 | /// Главная точка входа для приложения. 14 | /// 15 | [STAThread] 16 | static void Main() 17 | { 18 | Application.EnableVisualStyles(); 19 | Application.SetCompatibleTextRenderingDefault(false); 20 | 21 | string[] args = Environment.GetCommandLineArgs(); 22 | 23 | if (args.Length > 1) 24 | { 25 | string gameid = args[1]; 26 | bool exitGalaxy = false; 27 | 28 | if (args.Length > 2) 29 | { 30 | for (int i = 2; i < args.Length; i++) 31 | { 32 | string arg = args[i]; 33 | 34 | switch (arg) 35 | { 36 | case "--exit": 37 | case "-e": 38 | case "/exit": 39 | exitGalaxy = true; 40 | break; 41 | 42 | default: break; 43 | } 44 | } 45 | } 46 | 47 | LaunchingForm form = new LaunchingForm(gameid); 48 | form.ExitGalaxy = exitGalaxy; 49 | 50 | Application.Run(form); 51 | } 52 | else 53 | { 54 | Application.Run(new MainForm()); 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /GOGWrapper/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Общие сведения об этой сборке предоставляются следующим набором 6 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, 7 | // связанные со сборкой. 8 | [assembly: AssemblyTitle("GOGWrapper")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("GOGWrapper")] 13 | [assembly: AssemblyCopyright("Copyright © tk 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми 18 | // для компонентов COM. Если необходимо обратиться к типу в этой сборке через 19 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа. 20 | [assembly: ComVisible(false)] 21 | 22 | // Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM 23 | [assembly: Guid("9a18280c-d97e-4753-9ed9-690091a7355f")] 24 | 25 | // Сведения о версии сборки состоят из следующих четырех значений: 26 | // 27 | // Основной номер версии 28 | // Дополнительный номер версии 29 | // Номер сборки 30 | // Редакция 31 | // 32 | // Можно задать все значения или принять номер сборки и номер редакции по умолчанию. 33 | // используя "*", как показано ниже: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /GOGWrapper/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Этот код создан программой. 4 | // Исполняемая версия:4.0.30319.42000 5 | // 6 | // Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае 7 | // повторной генерации кода. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace GOGWrapper.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. 17 | /// 18 | // Этот класс создан автоматически классом StronglyTypedResourceBuilder 19 | // с помощью такого средства, как ResGen или Visual Studio. 20 | // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen 21 | // с параметром /str или перестройте свой проект VS. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GOGWrapper.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Перезаписывает свойство CurrentUICulture текущего потока для всех 51 | /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /GOGWrapper/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /GOGWrapper/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Этот код создан программой. 4 | // Исполняемая версия:4.0.30319.42000 5 | // 6 | // Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае 7 | // повторной генерации кода. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace GOGWrapper.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /GOGWrapper/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GOGWrapper/Steam/SteamUtils.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using System; 3 | using System.IO; 4 | using GOGWrapper.Steam.VDFParser; 5 | using GOGWrapper.Steam.VDFParser.Models; 6 | 7 | namespace GOGWrapper.Steam 8 | { 9 | public static class SteamUtils 10 | { 11 | /// 12 | /// Returns Steam's current installed path 13 | /// 14 | /// 15 | public static string GetSteamFolder() 16 | { 17 | RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Valve\\Steam"); 18 | if (key == null) 19 | if ((key = Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Valve\\Steam")) == null) 20 | return null; 21 | return key.GetValue("InstallPath").ToString(); 22 | } 23 | 24 | /// 25 | /// Returns all the users on userdata 26 | /// 27 | /// Steam's current installed path 28 | /// ListString of users path 29 | public static String[] GetUsers(string steamInstallPath = null) 30 | { 31 | steamInstallPath = steamInstallPath ?? SteamUtils.GetSteamFolder(); 32 | return Directory.GetDirectories(steamInstallPath + "\\userdata"); 33 | } 34 | 35 | public static VDFEntry[] ReadShortcuts(string userPath) 36 | { 37 | string shortcutFile = userPath + "\\config\\shortcuts.vdf"; 38 | VDFEntry[] shortcuts = new VDFEntry[0]; 39 | 40 | //Some users don't seem to have the config directory at all or the shortcut file, return a empty entry for those 41 | if (!Directory.Exists(userPath + "\\config\\") || !File.Exists(shortcutFile)) 42 | { 43 | return shortcuts; 44 | } 45 | 46 | shortcuts = VDFParser.VDFParser.Parse(shortcutFile); 47 | 48 | return shortcuts; 49 | } 50 | 51 | public static void WriteShortcuts(VDFEntry[] vdf, string userPath) 52 | { 53 | byte[] result = VDFSerializer.Serialize(vdf); 54 | 55 | try 56 | { 57 | File.WriteAllBytes(userPath + "\\config\\shortcuts.vdf", result); 58 | } 59 | catch (Exception e) 60 | { 61 | throw e; 62 | } 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/Exceptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace GOGWrapper.Steam.VDFParser 3 | { 4 | /// 5 | /// Indicates that a VDF file is too short (either it does not contain any 6 | /// substantial data, or is corrupted) 7 | /// 8 | public class VDFTooShortException : Exception 9 | { 10 | public VDFTooShortException(string message) : base(message) { } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text; 3 | 4 | namespace GOGWrapper.Steam.VDFParser 5 | { 6 | public static class Extensions 7 | { 8 | /// 9 | /// Gets a string from this byte array 10 | /// 11 | /// A decoded string from the byte array 12 | public static string StringFromByteArray(this List b) 13 | { 14 | return b.ToArray().StringFromByteArray(); 15 | } 16 | 17 | /// 18 | /// Gets a string from this byte array 19 | /// 20 | /// A decoded string from the byte array 21 | public static string StringFromByteArray(this byte[] list) 22 | { 23 | return new UTF8Encoding().GetString(list); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/GenericWriter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | using System; 4 | 5 | namespace GOGWrapper.Steam.VDFParser 6 | { 7 | /// 8 | /// Implements a generic writer utility for writing a VDF file 9 | /// 10 | public class GenericWriter 11 | { 12 | Stream s; 13 | 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// Stream to be written to 18 | public GenericWriter(Stream s) 19 | { 20 | this.s = s; 21 | } 22 | 23 | /// 24 | /// Writes a nil byte to the stream 25 | /// 26 | public void Nil() 27 | { 28 | s.WriteByte(0x00); 29 | } 30 | 31 | /// 32 | /// Writes a given value to the stream 33 | /// 34 | /// String value to be written 35 | public void Write(string value) 36 | { 37 | Write(Encoding.UTF8.GetBytes(value)); 38 | } 39 | 40 | /// 41 | /// Writes a given value to the stream 42 | /// 43 | /// Byte array to be written 44 | public void Write(byte[] value) 45 | { 46 | s.Write(value, 0, value.Length); 47 | } 48 | 49 | /// 50 | /// Writes a given value to the stream 51 | /// 52 | /// Integer to be written 53 | public void Write(int value) 54 | { 55 | Write(BitConverter.GetBytes(value)); 56 | } 57 | 58 | /// 59 | /// Writes a given value to the stream 60 | /// 61 | /// Single byte to be written 62 | public void Write(byte value) 63 | { 64 | s.WriteByte(value); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/Machines/VDFFieldsSM.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace GOGWrapper.Steam.VDFParser.Machines 4 | { 5 | /// 6 | /// State machine used to parse fields out from a VDF structure 7 | /// 8 | public class VDFFieldsSM 9 | { 10 | enum State 11 | { 12 | BeginIndicator, // 0x00 13 | Type, // ATM, 0x00 || 0x01 || 0x02 14 | Name, // [^0x00]+ 15 | Value, // [^0x00]+ 16 | } 17 | 18 | readonly Dictionary results; 19 | readonly List tmpBuffer; 20 | State state; 21 | byte lastByte; 22 | byte tmpFieldType; 23 | string tmpFieldName; 24 | 25 | /// 26 | /// Gets the parsing result 27 | /// 28 | /// Fields returned by the SM 29 | public Dictionary Fields 30 | { 31 | get 32 | { 33 | return results; 34 | } 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | public VDFFieldsSM() 41 | { 42 | results = new Dictionary(); 43 | tmpBuffer = new List(); 44 | } 45 | 46 | /// 47 | /// Resets this instance, cleaning all parsed data and fields 48 | /// 49 | public void Reset() 50 | { 51 | results.Clear(); 52 | state = State.BeginIndicator; 53 | tmpBuffer.Clear(); 54 | lastByte = 0x00; 55 | tmpFieldType = 0x00; 56 | tmpFieldName = null; 57 | } 58 | 59 | /// 60 | /// Feeds a given byte to the SM 61 | /// 62 | /// Incoming byte to be fed to the SM 63 | public bool Feed(byte b) 64 | { 65 | switch (state) 66 | { 67 | case State.BeginIndicator: 68 | if (b == 0x00) 69 | { 70 | state = State.Type; 71 | tmpBuffer.Clear(); 72 | } 73 | break; 74 | case State.Type: 75 | if (b == 0x01 || b == 0x02 || b == 0x00) 76 | { 77 | tmpFieldType = b; 78 | state = State.Name; 79 | } 80 | else 81 | { 82 | state = State.BeginIndicator; 83 | } 84 | break; 85 | case State.Name: 86 | if (b == 0x00) 87 | { 88 | tmpFieldName = tmpBuffer.StringFromByteArray(); 89 | tmpBuffer.Clear(); 90 | state = State.Value; 91 | } 92 | else 93 | { 94 | tmpBuffer.Add(b); 95 | } 96 | break; 97 | case State.Value: 98 | bool vdfEnd = false; 99 | if (b == 0x08 && lastByte == 0x08) 100 | { 101 | // This reaches the end of VDFEntry and the last interaction 102 | // added an extra byte to the temp buffer. Pop it and 103 | // move along. 104 | tmpBuffer.RemoveAt(tmpBuffer.Count - 1); 105 | vdfEnd = true; 106 | } 107 | if ((tmpFieldType == 0x02 && tmpBuffer.Count == 3) || (tmpFieldType == 0x01 && b == 0x00) || (tmpFieldType == 0x00 && b == 0x08 && lastByte == 0x08)) 108 | { 109 | if (tmpFieldType == 0x02) 110 | { 111 | tmpBuffer.Add(b); 112 | } 113 | 114 | if (!string.IsNullOrEmpty(tmpFieldName)) 115 | { 116 | results.Add(tmpFieldName, tmpBuffer.ToArray()); 117 | } 118 | 119 | tmpFieldName = null; 120 | tmpBuffer.Clear(); 121 | 122 | if (vdfEnd) 123 | { 124 | state = State.BeginIndicator; 125 | return true; 126 | } 127 | state = State.Type; 128 | 129 | } 130 | else 131 | { 132 | tmpBuffer.Add(b); 133 | } 134 | break; 135 | } 136 | lastByte = b; 137 | return false; 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/Machines/VDFIndexedArraySM.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | namespace GOGWrapper.Steam.VDFParser.Machines 3 | { 4 | 5 | /// 6 | /// State Machine used to parse an indexed array from the VDF structure 7 | /// 8 | public class VDFIndexedArraySM 9 | { 10 | enum State 11 | { 12 | IndexIdentifier, 13 | Index, 14 | Value 15 | } 16 | State state; 17 | readonly List result; 18 | readonly List tmpBuffer; 19 | 20 | /// 21 | /// Gets the parsed array. 22 | /// 23 | /// The parsed array. 24 | public string[] ParsedArray 25 | { 26 | get 27 | { 28 | return result.ToArray(); 29 | } 30 | } 31 | 32 | /// 33 | /// Resets this instance, cleaning all parsed results 34 | /// 35 | public void Reset() 36 | { 37 | result.Clear(); 38 | tmpBuffer.Clear(); 39 | state = State.IndexIdentifier; 40 | } 41 | 42 | /// 43 | /// Flushes any remaining field to the result array 44 | /// 45 | public void Flush() 46 | { 47 | if (tmpBuffer.Count > 0) 48 | { 49 | result.Add(tmpBuffer.StringFromByteArray()); 50 | } 51 | } 52 | 53 | /// 54 | /// Initializes a new instance of the class. 55 | /// 56 | public VDFIndexedArraySM() 57 | { 58 | result = new List(); 59 | tmpBuffer = new List(); 60 | } 61 | 62 | /// 63 | /// Feeds a given byte to the SM 64 | /// 65 | /// Incoming byte to be fed to the SM 66 | public void Feed(byte b) 67 | { 68 | switch (state) 69 | { 70 | case State.IndexIdentifier: 71 | if (b == 0x01) 72 | { 73 | state = State.Index; 74 | Flush(); 75 | tmpBuffer.Clear(); 76 | } 77 | break; 78 | case State.Index: 79 | if (b == 0x00) 80 | { 81 | // Look! Is this an index metadata we're getting rid of? 82 | tmpBuffer.Clear(); 83 | state = State.Value; 84 | } 85 | // tmpBuffer.Add(b); 86 | break; 87 | case State.Value: 88 | if (b == 0x00) 89 | { 90 | result.Add(tmpBuffer.StringFromByteArray()); 91 | tmpBuffer.Clear(); 92 | state = State.IndexIdentifier; 93 | break; 94 | } 95 | tmpBuffer.Add(b); 96 | break; 97 | } 98 | } 99 | 100 | /// 101 | /// Feeds a given byte array to the SM 102 | /// 103 | /// Incoming byte array to be fed to the SM 104 | public void Feed(List b) { Feed(b.ToArray()); } 105 | 106 | /// 107 | /// Feeds a given byte array to the SM 108 | /// 109 | /// Incoming byte array to be fed to the SM 110 | public void Feed(byte[] input) 111 | { 112 | foreach (var b in input) 113 | { 114 | Feed(b); 115 | } 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/Machines/VDFSM.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | using GOGWrapper.Steam.VDFParser.Models; 5 | 6 | namespace GOGWrapper.Steam.VDFParser.Machines 7 | { 8 | /// 9 | /// State machine used to parse a VDF structure 10 | /// 11 | public class VDFSM 12 | { 13 | enum MainSMState 14 | { 15 | IndexBeginIndicator, // 0x00 16 | IndexValue, // [^0x00]+ 17 | IndexEndIndicator, // 0x00 18 | Fields, // 0x00 19 | } 20 | 21 | readonly List tmpBuffer; 22 | readonly VDFIndexedArraySM arraySM; 23 | readonly VDFFieldsSM fieldsSM; 24 | static readonly Type entryType = typeof(VDFEntry); 25 | 26 | List entries; 27 | VDFEntry currentEntry; 28 | 29 | MainSMState mainState; 30 | 31 | /// 32 | /// Gets the parsed entries 33 | /// 34 | /// The entries. 35 | public VDFEntry[] Entries 36 | { 37 | get 38 | { 39 | return entries.ToArray(); 40 | } 41 | } 42 | 43 | /// 44 | /// Initializes a new instance of the class. 45 | /// 46 | public VDFSM() 47 | { 48 | entries = new List(); 49 | tmpBuffer = new List(); 50 | mainState = MainSMState.IndexBeginIndicator; 51 | 52 | arraySM = new VDFIndexedArraySM(); 53 | fieldsSM = new VDFFieldsSM(); 54 | } 55 | 56 | /// 57 | /// Flushes any remaining entry to the result array 58 | /// 59 | public void Flush() 60 | { 61 | if (currentEntry != null) 62 | { 63 | Console.WriteLine("Parsed " + currentEntry); 64 | entries.Add(currentEntry); 65 | } 66 | currentEntry = null; 67 | } 68 | 69 | /// 70 | /// Feeds a given byte to the SM 71 | /// 72 | /// Incoming byte to be fed to the SM 73 | public void Feed(byte b) 74 | { 75 | switch (mainState) 76 | { 77 | case MainSMState.IndexBeginIndicator: 78 | if (b == 0x00) 79 | { 80 | Flush(); 81 | mainState = MainSMState.IndexValue; 82 | tmpBuffer.Clear(); 83 | fieldsSM.Reset(); 84 | } 85 | break; 86 | case MainSMState.IndexValue: 87 | if (b == 0x00) 88 | { // Okay, next would be IndexEndIndicator, 89 | // but the terminator is also the separator, 90 | // and things would get messy. Let's just 91 | // skip a whole SM step here and pretend 92 | // everything is fine. 93 | int indexResult; 94 | if (int.TryParse(tmpBuffer.StringFromByteArray(), out indexResult)) 95 | { 96 | currentEntry = new VDFEntry(); 97 | currentEntry.Index = indexResult; 98 | mainState = MainSMState.Fields; 99 | } 100 | 101 | // The next is necessary to satisfy the SM pattern. 102 | fieldsSM.Feed(b); 103 | break; 104 | } 105 | tmpBuffer.Add(b); 106 | break; 107 | case MainSMState.Fields: 108 | if (fieldsSM.Feed(b)) 109 | { 110 | foreach (KeyValuePair k in fieldsSM.Fields) 111 | { 112 | FillEntry(k.Key, k.Value); 113 | } 114 | mainState = MainSMState.IndexBeginIndicator; 115 | } 116 | break; 117 | } 118 | } 119 | 120 | 121 | void FillEntry(string fieldName, byte[] value) 122 | { 123 | var props = from p in entryType.GetProperties() 124 | where Attribute.IsDefined(p, typeof(VDFField)) 125 | where p.Name.Equals(fieldName, StringComparison.InvariantCultureIgnoreCase) 126 | select p; 127 | var prop = props.FirstOrDefault(); 128 | if (prop == null) 129 | { 130 | return; 131 | } 132 | 133 | object result = null; 134 | if (prop.PropertyType == typeof(int)) 135 | { 136 | result = BitConverter.ToInt32(value, 0); 137 | } 138 | else if (prop.PropertyType == typeof(string)) 139 | { 140 | result = value.StringFromByteArray(); 141 | } 142 | else if (prop.PropertyType.IsArray && prop.PropertyType.GetElementType() == typeof(string)) 143 | { 144 | result = parseIndexedArray(value); 145 | } 146 | else 147 | { 148 | Console.WriteLine("Unable to deserialize field '" + fieldName + "': Not Implemented."); 149 | return; 150 | } 151 | 152 | prop.SetValue(currentEntry, result); 153 | } 154 | 155 | string[] parseIndexedArray(byte[] input) 156 | { 157 | if (input.Length < 5) 158 | { 159 | return new string[] { }; 160 | } 161 | arraySM.Reset(); 162 | arraySM.Feed(input); 163 | arraySM.Flush(); 164 | return arraySM.ParsedArray; 165 | } 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/Models/VDFEntry.cs: -------------------------------------------------------------------------------- 1 | namespace GOGWrapper.Steam.VDFParser.Models 2 | { 3 | /// 4 | /// Represents a VDF entry 5 | /// 6 | public class VDFEntry 7 | { 8 | /// 9 | /// Gets or sets the index. 10 | /// 11 | /// The index. 12 | public int Index { get; set; } 13 | 14 | /// 15 | /// Gets or sets the name of the app. 16 | /// 17 | /// The name of the app. 18 | [VDFField("appname")] 19 | public string AppName { get; set; } 20 | 21 | /// 22 | /// Gets or sets the app executable path. Extra arguments should be provided 23 | /// within this string and should use the following format: 24 | /// "/path/to/binary" -arg1 "argument with spaces" 25 | /// or the following format, if no argument is required: 26 | /// "/path/to/binary" 27 | /// 28 | /// The executable path, along with its command line arguments 29 | [VDFField("exe")] 30 | public string Exe { get; set; } 31 | 32 | /// 33 | /// Gets or sets the application start directory 34 | /// 35 | /// The start directory 36 | [VDFField("StartDir")] 37 | public string StartDir { get; set; } 38 | 39 | /// 40 | /// Gets or sets the application icon 41 | /// 42 | /// The application icon 43 | [VDFField("icon")] 44 | public string Icon { get; set; } 45 | 46 | /// 47 | /// Gets or sets the application shortcut path. 48 | /// 49 | /// The application shortcut path. 50 | [VDFField("ShortcutPath")] 51 | public string ShortcutPath { get; set; } 52 | 53 | /// 54 | /// Gets or sets whether the application is hidden. 55 | /// Use 1 for true, or 0 otherwise. 56 | /// 57 | /// Whether the application is hidden. 58 | [VDFField("IsHidden", Type = VDFFieldType.Integer)] 59 | public int IsHidden { get; set; } 60 | 61 | /// 62 | /// Gets or sets whether desktop configuration is allowed. 63 | /// Use 1 for true, or 0 otherwise. 64 | /// 65 | /// Whether the desktop configuration is allowed 66 | [VDFField("AllowDesktopConfig", Type = VDFFieldType.Integer)] 67 | public int AllowDesktopConfig { get; set; } 68 | 69 | /// 70 | /// Gets or sets whether this is an OpenVR application 71 | /// Use 1 for true, or 0 otherwise. 72 | /// 73 | /// Whether this is an OpenVR application 74 | [VDFField("OpenVR", Type = VDFFieldType.Integer)] 75 | public int OpenVR { get; set; } 76 | 77 | /// 78 | /// Gets or sets a list of tags for the application 79 | /// 80 | /// Tags list for the application 81 | [VDFField("tags", Type = VDFFieldType.IndexedArray)] 82 | public string[] Tags { get; set; } 83 | 84 | /// 85 | /// Returns a that represents the current . 86 | /// 87 | /// A that represents the current . 88 | public override string ToString() 89 | { 90 | return string.Format("[VDFEntry: AppName={0}, Exe={1}, StartDir={2}, Icon={3}, ShortcutPath={4}, IsHidden={5}, AllowDesktopConfig={6}, OpenVR={7}, Tags={8}]", AppName, Exe, StartDir, Icon, ShortcutPath, IsHidden, AllowDesktopConfig, OpenVR, Tags == null ? "(null)" : string.Join(", ", Tags)); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/Models/VDFField.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace GOGWrapper.Steam.VDFParser.Models 3 | { 4 | [AttributeUsage(AttributeTargets.Property)] 5 | public class VDFField : Attribute 6 | { 7 | public readonly string Name; 8 | public VDFFieldType Type { get; set; } 9 | 10 | public VDFField(string name) 11 | { 12 | Name = name; 13 | Type = VDFFieldType.String; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/Models/VDFFieldType.cs: -------------------------------------------------------------------------------- 1 | namespace GOGWrapper.Steam.VDFParser.Models 2 | { 3 | public enum VDFFieldType 4 | { 5 | String, 6 | Integer, 7 | IndexedArray 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/Shared.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace GOGWrapper.Steam.VDFParser 3 | { 4 | public class Shared 5 | { 6 | public static readonly byte[] VDFHeader = { 0x00, 0x73, 0x68, 0x6F, 0x72, 0x74, 0x63, 0x75, 0x74, 0x73, 0x00 }; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/VDFParser.cs: -------------------------------------------------------------------------------- 1 | using GOGWrapper.Steam.VDFParser.Machines; 2 | using GOGWrapper.Steam.VDFParser.Models; 3 | using System.IO; 4 | using System.Linq; 5 | 6 | namespace GOGWrapper.Steam.VDFParser 7 | { 8 | /// 9 | /// Implements a specialized parser for VDF files 10 | /// 11 | public static class VDFParser 12 | { 13 | /// 14 | /// Parses a given VDF file into an array of class 15 | /// Throws a if the file does not exist. 16 | /// Throws a if the file is too short or does not contain substantial information. 17 | /// Throws an if the target file does not contain a valid header. 18 | /// 19 | /// Path to the file to be parsed. 20 | public static VDFEntry[] Parse(string path) 21 | { 22 | if (!File.Exists(path)) 23 | { 24 | throw new FileNotFoundException(path); 25 | } 26 | using (FileStream stream = new FileStream(path, FileMode.Open)) 27 | { 28 | return Parse(stream); 29 | } 30 | } 31 | 32 | /// 33 | /// Parses a given VDF file into an array of class 34 | /// Throws a if the file is too short or does not contain substantial information. 35 | /// Throws an if the target file does not contain a valid header. 36 | /// 37 | /// Stream to be parsed. 38 | public static VDFEntry[] Parse(Stream stream) 39 | { 40 | if (stream.Length < 16) 41 | { 42 | throw new VDFTooShortException("VDF is too short and probably does not contain any substantial information."); 43 | } 44 | byte[] headerBuffer = new byte[11]; 45 | stream.Read(headerBuffer, 0, 11); 46 | 47 | 48 | if (!headerBuffer.SequenceEqual(Shared.VDFHeader)) 49 | { 50 | throw new InvalidDataException("Invalid header detected. Cannot continue."); 51 | } 52 | 53 | byte[] buffer = new byte[1024]; 54 | int bufferLen; 55 | 56 | var sm = new VDFSM(); 57 | while ((bufferLen = stream.Read(buffer, 0, buffer.Length)) > 0) 58 | { 59 | for (var i = 0; i < bufferLen; i++) 60 | { 61 | sm.Feed(buffer[i]); 62 | } 63 | } 64 | sm.Flush(); 65 | return sm.Entries; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /GOGWrapper/Steam/VDFParser/VDFSerializer.cs: -------------------------------------------------------------------------------- 1 | using GOGWrapper.Steam.VDFParser.Models; 2 | using System.IO; 3 | using System; 4 | using System.Linq; 5 | 6 | namespace GOGWrapper.Steam.VDFParser 7 | { 8 | /// 9 | /// Provides facilities for writing back a VDF file from a given set of 10 | /// 11 | public static class VDFSerializer 12 | { 13 | const byte PROPTYPE_STRING = 0x01; 14 | const byte PROPTYPE_INTEGER = 0x02; 15 | const byte PROPTYPE_LIST = 0x00; 16 | const byte ENTRY_SEPARATOR = 0x08; 17 | 18 | static readonly Type eType = typeof(VDFEntry); 19 | 20 | /// 21 | /// Serialize the specified entries. 22 | /// 23 | /// Entries to be serialized 24 | public static byte[] Serialize(VDFEntry[] entries) 25 | { 26 | int index = 0; 27 | var props = from prop in eType.GetProperties() 28 | where Attribute.IsDefined(prop, typeof(VDFField)) 29 | select prop; 30 | 31 | 32 | var s = new MemoryStream(); 33 | s.Write(Shared.VDFHeader, 0, Shared.VDFHeader.Length); 34 | var w = new GenericWriter(s); 35 | foreach (var e in entries) 36 | { 37 | w.Nil(); 38 | w.Write((index++).ToString()); 39 | w.Nil(); 40 | foreach (var p in props) 41 | { 42 | byte typeId = PROPTYPE_LIST; 43 | var fieldMeta = (VDFField)Attribute.GetCustomAttribute(p, typeof(VDFField)); 44 | if (p.PropertyType == typeof(string)) 45 | { 46 | typeId = PROPTYPE_STRING; 47 | } 48 | else if (p.PropertyType == typeof(int)) 49 | { 50 | typeId = PROPTYPE_INTEGER; 51 | } 52 | 53 | w.Write(typeId); 54 | w.Write(fieldMeta.Name); 55 | w.Nil(); 56 | if (typeId == PROPTYPE_STRING) 57 | { 58 | var data = (string)p.GetValue(e); 59 | if (data != null) 60 | { 61 | w.Write((string)p.GetValue(e)); 62 | } 63 | w.Nil(); 64 | } 65 | else if (typeId == PROPTYPE_INTEGER) 66 | { 67 | w.Write((int)p.GetValue(e)); 68 | } 69 | else 70 | { 71 | SerializeIndexedArray((string[])p.GetValue(e), w); 72 | } 73 | } 74 | w.Write(new byte[] { ENTRY_SEPARATOR, ENTRY_SEPARATOR }); 75 | } 76 | w.Write(new byte[] { ENTRY_SEPARATOR, ENTRY_SEPARATOR }); 77 | return s.ToArray(); 78 | } 79 | 80 | static void SerializeIndexedArray(string[] arr, GenericWriter w) 81 | { 82 | for (var i = 0; i < arr.Length; i++) 83 | { 84 | w.Write(PROPTYPE_STRING); 85 | w.Write(i.ToString()); 86 | w.Nil(); 87 | w.Write(arr[i]); 88 | w.Nil(); 89 | } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /GOGWrapper/Utils/WinAPI.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Runtime.InteropServices; 4 | using System.Threading; 5 | using System.Windows.Forms; 6 | 7 | namespace GOGWrapper.Utils 8 | { 9 | public class WinAPI 10 | { 11 | public const int WM_COMMAND = 0x111; 12 | public const int WM_LBUTTONDOWN = 0x201; 13 | public const int WM_LBUTTONUP = 0x202; 14 | public const int WM_LBUTTONDBLCLK = 0x203; 15 | public const int WM_RBUTTONDOWN = 0x204; 16 | public const int WM_RBUTTONUP = 0x205; 17 | public const int WM_RBUTTONDBLCLK = 0x206; 18 | public const int WM_KEYDOWN = 0x100; 19 | public const int WM_KEYUP = 0x101; 20 | 21 | [DllImport("user32.dll")] 22 | public static extern IntPtr FindWindow(string strClassName, string strWindowName); 23 | 24 | [DllImport("user32.dll")] 25 | public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string strClassName, string strWindowName); 26 | 27 | [DllImport("user32.dll")] 28 | public static extern bool IsWindow(IntPtr hwnd); 29 | 30 | [DllImport("user32.dll")] 31 | public static extern Int32 SendMessage(IntPtr hWnd, Int32 Msg, Int32 wParam, [MarshalAs(UnmanagedType.LPStr)] string lParam); 32 | 33 | [DllImport("user32.dll")] 34 | public static extern Int32 SendMessage(IntPtr hWnd, Int32 Msg, Int32 wParam, Int32 lParam); 35 | 36 | public static IntPtr WaitForWindow(string className, string windowName) 37 | { 38 | IntPtr hwnd = (IntPtr) 0; 39 | while(!WinAPI.IsWindow(hwnd)) 40 | { 41 | hwnd = WinAPI.FindWindow(className, windowName); 42 | Thread.Sleep(100); 43 | } 44 | return hwnd; 45 | } 46 | 47 | public static IntPtr WaitForChildWindow(IntPtr parent, string className, string windowName) 48 | { 49 | IntPtr hwnd = (IntPtr) 0; 50 | while (!WinAPI.IsWindow(hwnd)) 51 | { 52 | hwnd = WinAPI.FindWindowEx(parent, (IntPtr) 0, className, windowName); 53 | Thread.Sleep(100); 54 | } 55 | return parent; 56 | } 57 | 58 | [DllImport("user32.dll")] 59 | static extern bool ClientToScreen(IntPtr hWnd, ref Point lpPoint); 60 | 61 | [DllImport("user32.dll")] 62 | internal static extern uint SendInput(uint nInputs, [MarshalAs(UnmanagedType.LPArray), In] INPUT[] pInputs, int cbSize); 63 | 64 | [DllImport("user32.dll")] 65 | public static extern bool SetForegroundWindow(IntPtr hWnd); 66 | 67 | internal struct INPUT 68 | { 69 | public UInt32 Type; 70 | public MOUSEKEYBDHARDWAREINPUT Data; 71 | } 72 | 73 | [StructLayout(LayoutKind.Explicit)] 74 | internal struct MOUSEKEYBDHARDWAREINPUT 75 | { 76 | [FieldOffset(0)] 77 | public MOUSEINPUT Mouse; 78 | } 79 | 80 | internal struct MOUSEINPUT 81 | { 82 | public Int32 X; 83 | public Int32 Y; 84 | public UInt32 MouseData; 85 | public UInt32 Flags; 86 | public UInt32 Time; 87 | public IntPtr ExtraInfo; 88 | } 89 | 90 | public static void Click(IntPtr wndHandle, Point clientPoint) 91 | { 92 | var oldPos = Cursor.Position; 93 | ClientToScreen(wndHandle, ref clientPoint); 94 | 95 | Cursor.Position = new Point(clientPoint.X, clientPoint.Y); 96 | var inputMouseDown = new INPUT(); 97 | inputMouseDown.Type = 0; 98 | inputMouseDown.Data.Mouse.Flags = 0x0002; 99 | 100 | var inputMouseUp = new INPUT(); 101 | inputMouseUp.Type = 0; 102 | inputMouseUp.Data.Mouse.Flags = 0x0004; 103 | 104 | var inputs = new INPUT[] { inputMouseDown, inputMouseUp }; 105 | SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(typeof(INPUT))); 106 | 107 | Cursor.Position = oldPos; 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /GOGWrapper/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GOGWrapper 2 | Launch GOG games with GOG Galaxy using shortcuts 3 | 4 | ## GUI 5 | GOGWrapper has a simple GUI which lets user to open game page in Galaxy, launch game or add it to the Steam Library 6 | 7 | ![GOGWrapper](GOGWrapper/GOGWrapper.png?raw=true) 8 | 9 | ## CLI 10 | ``` 11 | GOGWrapper.exe gameid [-e|--exit|/exit] 12 | gameid - GOG id of game 13 | -e|--exit|/exit - kill GOG Galaxy when game exits 14 | Galaxy will be killed after 20 seconds timeout 15 | ``` 16 | --------------------------------------------------------------------------------