├── .gitattributes ├── .github └── workflows │ ├── YuzuEAUpdater.yaml │ └── publish.yml ├── .gitignore ├── README.md ├── Updater ├── Program.cs └── Updater.csproj ├── YuzuEAUpdater.sln └── YuzuEAUpdater ├── 7zip ├── darwin │ └── 7zz ├── linux │ └── ia32 │ │ ├── 7zz │ │ └── 7zzs └── win32 │ ├── ia32 │ ├── 7za.dll │ ├── 7za.exe │ └── 7zxa.dll │ └── x64 │ ├── 7za.dll │ ├── 7za.exe │ └── 7zxa.dll ├── App.config ├── BananaFile.cs ├── BananaMod.cs ├── BananaReponse.cs ├── Game.cs ├── PR.cs ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── PublishProfiles │ ├── FolderProfile.pubxml │ └── FolderProfile1.pubxml ├── Resources.Designer.cs └── Resources.resx ├── Release.cs ├── UI └── MainUI.cs ├── YuzuEAUpdater.csproj └── ZipExtension.cs /.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 | -------------------------------------------------------------------------------- /.github/workflows/YuzuEAUpdater.yaml: -------------------------------------------------------------------------------- 1 | name: "Publish" 2 | 3 | on: 4 | push: 5 | branches: 6 | - '**' 7 | paths-ignore: 8 | - '**/*.md' 9 | - '**/*.gitignore' 10 | - '**/*.gitattributes' 11 | workflow_dispatch: 12 | branches: 13 | - main 14 | paths-ignore: 15 | - '**/*.md' 16 | - '**/*.gitignore' 17 | - '**/*.gitattributes' 18 | 19 | env: 20 | PROJECT_PATH: YuzuEAUpdater\YuzuEAUpdater.csproj 21 | ZIP_PATH_WINDOWS: YuzuEAUpdater\bin\Release\netcoreapp3.1\win-x64\publish\windows-x64.zip 22 | ZIP_PATH_LINUX: YuzuEAUpdater\bin\Release\netcoreapp3.1\linux-x64\publish\linux-x64.zip 23 | WINDOWS_PATH: YuzuEAUpdater\bin\Release\netcoreapp3.1\win-x64\publish 24 | LINUX_PATH: YuzuEAUpdater\bin\Release\netcoreapp3.1\linux-x64\publish 25 | WINDOWS_EXEC: YuzuEAUpdater\bin\Release\netcoreapp3.1\win-x64\publish\YuzuEAUpdater.exe 26 | LINUX_EXEC: YuzuEAUpdater\bin\Release\netcoreapp3.1\linux-x64\publish\YuzuEAUpdater 27 | 28 | 29 | jobs: 30 | deploy: 31 | runs-on: windows-latest 32 | steps: 33 | - name: Initialize Actions 34 | uses: actions/checkout@v2 35 | 36 | - name: Setup .NET SDK 37 | uses: actions/setup-dotnet@v3 38 | with: 39 | dotnet-version: 7.0.x 40 | 41 | - name: Restore Project 42 | run: dotnet restore ${{ env.PROJECT_PATH }} 43 | 44 | - name: Publish Project Windows 45 | run: dotnet publish ${{ env.PROJECT_PATH }} -c Release --self-contained -p:PublishSingleFile=true --no-restore -r win-x64 46 | 47 | - name: Publish Project Linux 48 | run: dotnet publish ${{ env.PROJECT_PATH }} -c Release --self-contained -p:PublishSingleFile=true --no-restore -r linux-x64 49 | 50 | - name: Create Zip File WINDOWS 51 | uses: papeloto/action-zip@v1 52 | with: 53 | files: ${{ env.WINDOWS_PATH }} 54 | dest: ${{ env.ZIP_PATH_WINDOWS}} 55 | 56 | - name: Create Zip File LINUX 57 | uses: papeloto/action-zip@v1 58 | with: 59 | files: ${{ env.LINUX_PATH }} 60 | dest: ${{ env.ZIP_PATH_LINUX}} 61 | 62 | - name: Initialize Release 63 | uses: actions/create-release@latest 64 | id: create_release 65 | env: 66 | GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} 67 | with: 68 | tag_name: Release-${{ github.run_id }} 69 | release_name: Release-${{ github.run_id }} 70 | body: | 71 | ${{ github.event.head_commit.message }} 72 | draft: false 73 | prerelease: false 74 | 75 | - name: Create Release 76 | uses: csexton/release-asset-action@v2 77 | with: 78 | github-token: ${{ secrets.ACCESS_TOKEN }} 79 | files: | 80 | ${{ env.ZIP_PATH_WINDOWS }} 81 | ${{ env.ZIP_PATH_LINUX }} 82 | release-url: ${{ steps.create_release.outputs.upload_url }} -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: "Publish" 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" 7 | 8 | env: 9 | PROJECT_PATH: YuzuEAUpdater/YuzuEAUpdater.csproj 10 | ZIP_PATH_WINDOWS: YuzuEAUpdater/bin/Release/netcoreapp3.1/publish/windows-x64.zip 11 | ZIP_PATH_LINUX: YuzuEAUpdater/bin/Release/netcoreapp3.1/publish/linux-x64.zip 12 | WINDOWS_PATH: YuzuEAUpdater/bin/Release/netcoreapp3.1/publish/win-x64 13 | LINUX_PATH: YuzuEAUpdater/bin/Release/netcoreapp3.1/publish/linux-x64 14 | 15 | 16 | jobs: 17 | deploy: 18 | runs-on: windows-latest 19 | steps: 20 | - name: Initialize Actions 21 | uses: actions/checkout@v2 22 | 23 | - name: Initialize .Net 24 | uses: actions/setup-dotnet@v1 25 | with: 26 | dotnet-version: 7.0.x 27 | 28 | - name: Restore Project 29 | run: dotnet restore ${{ env.PROJECT_PATH }} 30 | 31 | - name: Publish Project Windows 32 | run: dotnet publish ${{ env.PROJECT_PATH }} -c Release --self-contained -r win-x64 -p:PublishSingleFile=true --no-restore 33 | 34 | - name: Publish Project Linux 35 | run: dotnet publish ${{ env.PROJECT_PATH }} -c Release --self-contained -r linux-x64 -p:PublishSingleFile=true --no-restore 36 | 37 | - name: Create Zip File WINDOWS 38 | uses: papeloto/action-zip@v1 39 | with: 40 | files: ${{ env.WINDOWS_PATH }} 41 | dest: ${{ env.ZIP_PATH_WINDOWS}} 42 | 43 | - name: Create Zip File LINUX 44 | uses: papeloto/action-zip@v1 45 | with: 46 | files: ${{ env.LINUX_PATH }} 47 | dest: ${{ env.ZIP_PATH_LINUX}} 48 | 49 | - name: Initialize Release 50 | uses: actions/create-release@v1 51 | id: create_release 52 | env: 53 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 54 | with: 55 | tag_name: ${{ github.ref }} 56 | release_name: ${{ github.ref }} 57 | 58 | - name: Create Release 59 | uses: csexton/release-asset-action@v2 60 | with: 61 | github-token: ${{ secrets.GITHUB_TOKEN }} 62 | files: | 63 | ${{ env.ZIP_PATH_WINDOWS }} 64 | ${{ env.ZIP_PATH_LINUX }} 65 | release-url: ${{ steps.create_release.outputs.upload_url }} 66 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![alt text](https://i.ibb.co/zbdG3Qz/Sans-titre.png) 2 | 3 | # YuzuEAUpdater 4 | -Ability to install latest Yuzu and automatically update during future launches. 5 | 6 | -Change log. 7 | 8 | -Customizable binary location (Yuzu.exe) through use of editing the launchUpdater.txt file. 9 | 10 | -You can change yuzu build easyly with switch section. 11 | 12 | -Ability to download and install automatically mods from banana. 13 | 14 | -Automatic launch yuzu after update disable/enable by settings menu. 15 | 16 | -Automaic backup save yuzu game on launch disable/enable. 17 | 18 | -Optimise processor settings for starting yuzu automatically. 19 | 20 | -Kill process that use CPU on yuzu launch. 21 | 22 | 23 | # Install 24 | -Excecutable must be placed in Yuzu directory or a empty folder. 25 | 26 | 27 | -------------------------------------------------------------------------------- /Updater/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.IO; 4 | using System.Text.RegularExpressions; 5 | using System.IO.Compression; 6 | using System.Runtime.InteropServices; 7 | using System.Diagnostics; 8 | using System.Security.Cryptography; 9 | 10 | public class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | string latestReleaseUrl = "https://github.com/pilout/YuzuUpdater/releases/latest"; 15 | Uri latestReleaseUri = new Uri(latestReleaseUrl); 16 | DateTime latestReleaseDate ; 17 | string updaterFilePath = (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "YuzuEAUpdater" : "YuzuEAUpdater.exe"); 18 | 19 | foreach(Process process in Process.GetProcessesByName(updaterFilePath.Replace(".exe",""))) 20 | { 21 | process.Kill(); 22 | } 23 | 24 | 25 | using (var client = new WebClient()) 26 | { 27 | client.Headers.Add("User-Agent", "request"); 28 | Stream stream = client.OpenRead(latestReleaseUri); 29 | StreamReader reader = new StreamReader(stream); 30 | string htmlContent = reader.ReadToEnd(); 31 | 32 | string datePattern = Regex.Match(htmlContent, @"datetime=""(.*)Z""").Groups[1].Value + "Z"; 33 | 34 | if (datePattern.Length>0) 35 | { 36 | latestReleaseDate = DateTime.Parse(datePattern); 37 | 38 | FileInfo fileInfo = new FileInfo(updaterFilePath); 39 | DateTime updaterCreatedDate = File.GetCreationTime(updaterFilePath); 40 | 41 | if (latestReleaseDate > updaterCreatedDate) 42 | { 43 | Console.WriteLine("Update found, downloading..."); 44 | // /pilout/YuzuUpdater/releases/tag/1.9" /> 45 | string version = Regex.Match(htmlContent, @"\/pilout\/YuzuUpdater\/releases\/tag\/(.*)""").Groups[1].Value; 46 | version = version.Substring(0, version.IndexOf("\"")); 47 | 48 | string releasePackageUrl = "https://github.com/pilout/YuzuUpdater/releases/download/" + version + "/" + (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "linux" : "windows" ) + "-x64.zip"; 49 | string zipFilePath = Path.Combine(Directory.GetCurrentDirectory(),"update00.zip"); 50 | client.Headers.Add("User-Agent", "request"); 51 | client.DownloadFile(releasePackageUrl, zipFilePath); 52 | string extractPath = Path.Combine(Directory.GetCurrentDirectory()); 53 | FileStream streamzip = File.OpenRead(zipFilePath); 54 | var zipFile = new ZipArchive(streamzip); 55 | 56 | for (int i = 0; i < zipFile.Entries.Count; i++) 57 | { 58 | try 59 | { 60 | ZipArchiveEntry entry = zipFile.Entries[i]; 61 | string path = Path.Combine(extractPath, entry.FullName); 62 | var ind = entry.FullName.LastIndexOf("/"); 63 | if (ind > 0) 64 | { 65 | string pathDirEntry = entry.FullName.Substring(0, ind); 66 | Directory.CreateDirectory(Path.Combine(extractPath, pathDirEntry)); 67 | if(entry.FullName.EndsWith("/")) 68 | continue; 69 | } 70 | 71 | 72 | if (path == System.Reflection.Assembly.GetExecutingAssembly().Location) 73 | continue; 74 | 75 | entry.ExtractToFile(path, true); 76 | Console.WriteLine("Extracting " + entry.FullName); 77 | } 78 | catch(Exception ex) 79 | { 80 | Console.WriteLine(ex.Message); 81 | Console.ReadLine(); 82 | } 83 | 84 | } 85 | 86 | streamzip.Close(); 87 | File.Delete(zipFilePath); 88 | Console.WriteLine("Update done, restarting..."); 89 | 90 | 91 | } 92 | else 93 | { 94 | Console.WriteLine("No update found, restarting..."); 95 | } 96 | 97 | if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 98 | Process.Start("chmod", "+x " + updaterFilePath); 99 | 100 | 101 | } 102 | } 103 | 104 | var startInfo = new ProcessStartInfo(updaterFilePath); 105 | startInfo.UseShellExecute = true; 106 | Process.Start(startInfo); 107 | System.Threading.Thread.Sleep(5000); 108 | Environment.Exit(0); 109 | 110 | } 111 | 112 | 113 | public static string SHA256CheckSum(string filePath) 114 | { 115 | using (SHA256 SHA256 = SHA256Managed.Create()) 116 | { 117 | using (FileStream fileStream = File.OpenRead(filePath)) 118 | return Convert.ToBase64String(SHA256.ComputeHash(fileStream)); 119 | } 120 | } 121 | } -------------------------------------------------------------------------------- /Updater/Updater.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | Exe 5 | false 6 | Program 7 | False 8 | embedded 9 | updateUpdater 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /YuzuEAUpdater.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33516.290 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YuzuEAUpdater", "YuzuEAUpdater\YuzuEAUpdater.csproj", "{7F565065-2CDB-45F1-A5A1-33FC5F52A043}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "Updater\Updater.csproj", "{63C3A3A0-560B-4596-BD05-79514D2C0B4C}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {7F565065-2CDB-45F1-A5A1-33FC5F52A043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {7F565065-2CDB-45F1-A5A1-33FC5F52A043}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {7F565065-2CDB-45F1-A5A1-33FC5F52A043}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {7F565065-2CDB-45F1-A5A1-33FC5F52A043}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {63C3A3A0-560B-4596-BD05-79514D2C0B4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {63C3A3A0-560B-4596-BD05-79514D2C0B4C}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {63C3A3A0-560B-4596-BD05-79514D2C0B4C}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {63C3A3A0-560B-4596-BD05-79514D2C0B4C}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {01D0E8E8-6709-4C65-BEC2-F6E97CA67DAD} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /YuzuEAUpdater/7zip/darwin/7zz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pilout/YuzuUpdater/37669167c49498e37f47267a61b3310a43579aa3/YuzuEAUpdater/7zip/darwin/7zz -------------------------------------------------------------------------------- /YuzuEAUpdater/7zip/linux/ia32/7zz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pilout/YuzuUpdater/37669167c49498e37f47267a61b3310a43579aa3/YuzuEAUpdater/7zip/linux/ia32/7zz -------------------------------------------------------------------------------- /YuzuEAUpdater/7zip/linux/ia32/7zzs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pilout/YuzuUpdater/37669167c49498e37f47267a61b3310a43579aa3/YuzuEAUpdater/7zip/linux/ia32/7zzs -------------------------------------------------------------------------------- /YuzuEAUpdater/7zip/win32/ia32/7za.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pilout/YuzuUpdater/37669167c49498e37f47267a61b3310a43579aa3/YuzuEAUpdater/7zip/win32/ia32/7za.dll -------------------------------------------------------------------------------- /YuzuEAUpdater/7zip/win32/ia32/7za.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pilout/YuzuUpdater/37669167c49498e37f47267a61b3310a43579aa3/YuzuEAUpdater/7zip/win32/ia32/7za.exe -------------------------------------------------------------------------------- /YuzuEAUpdater/7zip/win32/ia32/7zxa.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pilout/YuzuUpdater/37669167c49498e37f47267a61b3310a43579aa3/YuzuEAUpdater/7zip/win32/ia32/7zxa.dll -------------------------------------------------------------------------------- /YuzuEAUpdater/7zip/win32/x64/7za.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pilout/YuzuUpdater/37669167c49498e37f47267a61b3310a43579aa3/YuzuEAUpdater/7zip/win32/x64/7za.dll -------------------------------------------------------------------------------- /YuzuEAUpdater/7zip/win32/x64/7za.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pilout/YuzuUpdater/37669167c49498e37f47267a61b3310a43579aa3/YuzuEAUpdater/7zip/win32/x64/7za.exe -------------------------------------------------------------------------------- /YuzuEAUpdater/7zip/win32/x64/7zxa.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pilout/YuzuUpdater/37669167c49498e37f47267a61b3310a43579aa3/YuzuEAUpdater/7zip/win32/x64/7zxa.dll -------------------------------------------------------------------------------- /YuzuEAUpdater/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /YuzuEAUpdater/BananaFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace YuzuEAUpdater 6 | { 7 | public class BananaFile 8 | { 9 | public int _idRow { get; set; } 10 | public string _sFile { get; set; } 11 | public int _nFilesize { get; set; } 12 | public string _sDescription { get; set; } 13 | public long _tsDateAdded { get; set; } 14 | public int _nDownloadCount { get; set; } 15 | public string _sAnalysisState { get; set; } 16 | public string _sDownloadUrl { get; set; } 17 | public string _sMd5Checksum { get; set; } 18 | public string _sClamAvResult { get; set; } 19 | public string _sAnalysisResult { get; set; } 20 | public bool _bContainsExe { get; set; } 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /YuzuEAUpdater/BananaMod.cs: -------------------------------------------------------------------------------- 1 | using SevenZip; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO.Compression; 5 | using System.IO; 6 | using System.Net.Http; 7 | using System.Net; 8 | using System.Text; 9 | using System.Text.Json; 10 | using System.Linq; 11 | namespace YuzuEAUpdater 12 | { 13 | 14 | 15 | public class BananaMod 16 | { 17 | public int _idRow { get; set; } 18 | public string _sModelName { get; set; } 19 | public string _sSingularTitle { get; set; } 20 | public string _sIconClasses { get; set; } 21 | public string _sName { get; set; } 22 | public string _sProfileUrl { get; set; } 23 | public long _tsDateAdded { get; set; } 24 | public long _tsDateModified { get; set; } 25 | public bool _bHasFiles { get; set; } 26 | public string[] _aTags { get; set; } 27 | public string _sVersion { get; set; } 28 | public long _tsDateUpdated { get; set; } 29 | public bool _bIsObsolete { get; set; } 30 | public string _sInitialVisibility { get; set; } 31 | public bool _bHasContentRatings { get; set; } 32 | public int _nLikeCount { get; set; } 33 | public int _nPostCount { get; set; } 34 | public bool _bWasFeatured { get; set; } 35 | public int _nViewCount { get; set; } 36 | public bool _bIsOwnedByAccessor { get; set; } 37 | 38 | public List files; 39 | 40 | public string pathApp; 41 | 42 | 43 | public void loadFiles() 44 | { 45 | HttpClient _httpClient = new HttpClient(); 46 | String uri = "https://gamebanana.com/apiv11/Mod/" + _idRow + "/Files"; 47 | String src = _httpClient.GetAsync(uri).Result.Content.ReadAsStringAsync().Result; 48 | files = JsonSerializer.Deserialize>(src); 49 | 50 | } 51 | 52 | public void download() 53 | { 54 | if (!Directory.Exists("_tempMod")) 55 | { 56 | Directory.CreateDirectory("_tempMod"); 57 | } 58 | 59 | if (files == null) 60 | loadFiles(); 61 | 62 | foreach (BananaFile file in files) 63 | { 64 | if (file._sClamAvResult == "clean") 65 | { 66 | using (var client = new WebClient()) 67 | { 68 | if (file._sFile.EndsWith(".zip") || file._sFile.EndsWith(".7z")) 69 | { 70 | UI.MainUI.addTextConsole(" -Downloading " + file._sFile + "\n"); 71 | if (System.IO.File.Exists("_tempMod/" + file._sFile)) 72 | { 73 | System.IO.File.Delete("_tempMod/" + file._sFile); 74 | } 75 | 76 | try 77 | { 78 | client.DownloadFile(file._sDownloadUrl, "_tempMod/" + file._sFile); 79 | } 80 | catch (Exception e) 81 | { 82 | UI.MainUI.addTextConsole("Error while downloading " + file._sFile + " : " + e.Message + "\n"); 83 | } 84 | } 85 | } 86 | } 87 | } 88 | 89 | } 90 | 91 | public void extract() 92 | { 93 | 94 | foreach (BananaFile f in files) 95 | { 96 | if (f._sFile.EndsWith(".zip") || f._sFile.EndsWith(".7z")) 97 | { 98 | UI.MainUI.addTextConsole(" -Extracting " + f._sFile + "\n"); 99 | try 100 | { 101 | if (f._sFile.EndsWith(".zip")) 102 | { 103 | ZipArchive zipArchive = ZipFile.OpenRead("_tempMod/" + f._sFile); 104 | bool isCorrectModFolder = zipArchive.Entries.ToList().FirstOrDefault(f => f.FullName.Contains("romfs") || f.FullName.Contains("exefs") || f.FullName.Contains("cheats")) != null; 105 | if (isCorrectModFolder) 106 | ZipFile.ExtractToDirectory("_tempMod/" + f._sFile, pathApp, true); 107 | 108 | zipArchive.Dispose(); 109 | } 110 | else 111 | { 112 | SevenZipExtractor extractor = new SevenZipExtractor("_tempMod/" + f._sFile); 113 | bool isCorrectModFolder = extractor.ArchiveFileNames.ToList().FirstOrDefault(f => f.Contains("romfs") || f.Contains("exefs") || f.Contains("cheats")) != null; 114 | if (isCorrectModFolder) 115 | extractor.ExtractArchive(pathApp); 116 | 117 | extractor.Dispose(); 118 | } 119 | System.Threading.Thread.Sleep(1000); 120 | } 121 | catch (Exception e) 122 | { 123 | UI.MainUI.addTextConsole("Error while extracting " + f._sFile + " : " + e.Message); 124 | } 125 | finally 126 | { 127 | if (System.IO.File.Exists("_tempMod/" + f._sFile)) 128 | { 129 | System.IO.File.Delete("_tempMod/" + f._sFile); 130 | } 131 | } 132 | } 133 | } 134 | } 135 | 136 | //Replace the current ToString implementation with a formatted date string 137 | public override string ToString() 138 | { 139 | return $"{_sName} ({_nLikeCount} likes)"; 140 | } 141 | 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /YuzuEAUpdater/BananaReponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace YuzuEAUpdater 6 | { 7 | public class BananaResponse 8 | { 9 | public List _aRecords { get; set; } 10 | 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /YuzuEAUpdater/Game.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http; 5 | using System.Text; 6 | using System.Text.Json; 7 | using System.Text.RegularExpressions; 8 | 9 | namespace YuzuEAUpdater 10 | { 11 | public class Game 12 | { 13 | public string id; 14 | public string name; 15 | public string pathApp; 16 | public List bananaMods = new List(); 17 | 18 | public string pathMods 19 | { 20 | get 21 | { 22 | return pathApp + "\\load\\" + this.id; 23 | } 24 | } 25 | 26 | 27 | 28 | 29 | public List validBananaMods => bananaMods.Where(x => x._sModelName == "Mod" && !x._bIsObsolete && x._bHasFiles) 30 | .OrderBy(x => x._sName.ToLower()) 31 | .OrderByDescending(x => x._nLikeCount).ToList(); 32 | 33 | 34 | public Game(string id, string name, string pathApp) 35 | { 36 | this.id = id; 37 | this.name = name; 38 | this.pathApp = pathApp + "\\load\\" + id + "\\"; 39 | } 40 | 41 | public void loadMods(IProgress progess = null) 42 | { 43 | if (bananaMods.Count == 0) 44 | { 45 | HttpClient _httpClient = new HttpClient(); 46 | 47 | String src = _httpClient.GetAsync("https://gamebanana.com/apiv11/Util/Game/NameMatch?_sName=" + name.Replace(" ", "+").Replace("™","") + "&_nPerpage=10&_nPage=1").Result.Content.ReadAsStringAsync().Result; 48 | String idGameBanana = Regex.Match(src, @"""_idRow"": (\d+)").Groups[1].Value; 49 | 50 | if (idGameBanana == "") 51 | return; 52 | 53 | BananaResponse bananaResponse = null; 54 | int p = 1; 55 | while (bananaResponse == null || bananaResponse._aRecords.Count > 0) 56 | { 57 | src = _httpClient.GetAsync("https://gamebanana.com/apiv11/Game/" + idGameBanana + "/Subfeed?_nPage=" + p + "&_sSort=default").Result.Content.ReadAsStringAsync().Result; 58 | bananaResponse = JsonSerializer.Deserialize(src); 59 | bananaResponse._aRecords.ForEach((m) => 60 | { 61 | m.pathApp = this.pathApp; 62 | }); 63 | 64 | bananaMods.AddRange(bananaResponse._aRecords); 65 | p++; 66 | 67 | if(progess != null) 68 | { 69 | progess.Report(0.1f); 70 | } 71 | } 72 | } 73 | 74 | if(progess != null) 75 | progess.Report(1f); 76 | } 77 | } 78 | 79 | 80 | } 81 | -------------------------------------------------------------------------------- /YuzuEAUpdater/PR.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Text.RegularExpressions; 5 | 6 | namespace YuzuEAUpdater 7 | { 8 | public class PR 9 | { 10 | public PR(string prVersion) 11 | { 12 | idIssue = Regex.Match(prVersion, @"(.*)").Groups[1].Value; 14 | releaseDate = DateTime.Parse(Regex.Match(prVersion, @"datetime=""(.*)Z""").Groups[1].Value + "Z"); 15 | 16 | var labels = Regex.Matches(prVersion, @"data-name=""(.*)"" style="); 17 | foreach (Match label in labels) 18 | { 19 | this.label += label.Groups[1].Value + " "; 20 | } 21 | } 22 | 23 | public string idIssue; 24 | public string description; 25 | public DateTime releaseDate; 26 | public string label = ""; 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /YuzuEAUpdater/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.IO.Compression; 6 | using System.Linq; 7 | using System.Net; 8 | using System.Net.Http; 9 | using System.Runtime.InteropServices; 10 | using System.Text.RegularExpressions; 11 | using System.Threading.Tasks; 12 | using Terminal.Gui; 13 | using YuzuEAUpdater.UI; 14 | 15 | namespace YuzuEAUpdater 16 | { 17 | public class Program 18 | { 19 | static void Main(string[] args) 20 | { 21 | 22 | Application.Run(); 23 | Application.Shutdown(); 24 | 25 | } 26 | } 27 | 28 | public class MainWindow : Window 29 | { 30 | private List releases = new List(); 31 | private List prList = new List(); 32 | 33 | private string currentVersion = null; 34 | private Release myCurrentRelease = null; 35 | private string currentExe = "yuzu.exe"; 36 | public List games = new List(); 37 | public static object lockObj = new object(); 38 | private string pathApp = ""; 39 | public Boolean optimizePerf = true; 40 | public Boolean killCpuProccess = false; 41 | public bool autoStartYuzu; 42 | public bool confirmDownload; 43 | public bool backupSave = false; 44 | public static MainUI MainUI; 45 | 46 | 47 | 48 | 49 | 50 | private void InitializeComponent() 51 | { 52 | Application.MainLoop.Invoke(() => 53 | { 54 | Title = "YuzuTool 1.8"; 55 | this.AutoSize = true; 56 | X = 0; 57 | Y = 1; 58 | Width = Dim.Fill(); 59 | Height = Dim.Fill(); 60 | 61 | MainUI = new MainUI(this); 62 | 63 | Application.Init(); 64 | Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight); 65 | this.SetNeedsDisplay(); 66 | }); 67 | 68 | } 69 | 70 | 71 | public MainWindow() 72 | { 73 | getSettings(); 74 | InitializeComponent(); 75 | Task.Run(() => 76 | { 77 | try 78 | { 79 | 80 | while (MainUI.mainConsole == null || MainUI.mainConsole.SuperView == null) 81 | { 82 | System.Threading.Thread.Sleep(1500); 83 | Console.WriteLine("Initialise UI..."); 84 | } 85 | purgeUncessaryFiles(); 86 | _saveBackup(); 87 | getCurrentVersion(); 88 | checkVersion(); 89 | waitYuzuLaunch(); 90 | } 91 | catch (Exception ex) 92 | { 93 | Application.Shutdown(); 94 | Console.Write(ex.StackTrace); 95 | System.Threading.Thread.Sleep(10000); 96 | Console.ReadLine(); 97 | } 98 | 99 | }); 100 | 101 | 102 | } 103 | 104 | private void killYuzus() 105 | { 106 | Process[] processes = new Process[0]; 107 | 108 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) 109 | processes = Process.GetProcessesByName(currentExe.Replace(".exe", "")); 110 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 111 | processes = Process.GetProcessesByName("yuzu"); 112 | 113 | if (processes.Length > 0) 114 | MainUI.addTextConsole("Kill yuzu process\n"); 115 | 116 | foreach (Process p in processes) 117 | p.Kill(); 118 | 119 | } 120 | 121 | private void waitYuzuLaunch(){ 122 | var timer = 10000; 123 | 124 | while (!autoStartYuzu) 125 | { 126 | System.Threading.Thread.Sleep(1000); 127 | } 128 | 129 | if(!System.IO.File.Exists(currentExe)) 130 | { 131 | MainUI.addTextConsole("Yuzu not found\n"); 132 | return; 133 | } 134 | 135 | MainUI.addTextConsole("Starting Yuzu...\n"); 136 | Process p = new Process(); 137 | p.StartInfo.FileName = currentExe; 138 | p.StartInfo.UseShellExecute = false; 139 | p.StartInfo.RedirectStandardOutput = true; 140 | p.StartInfo.RedirectStandardError = true; 141 | 142 | if(this.killCpuProccess) 143 | Utils.KillProcessesByCpuUsage(3); 144 | 145 | p.Start(); 146 | p.WaitForInputIdle(); 147 | if (this.optimizePerf) 148 | { 149 | Utils.SetPowerSavingMode(false); 150 | Utils.setAffinityMask(p); 151 | p.PriorityClass = ProcessPriorityClass.RealTime; 152 | } 153 | 154 | 155 | while (p.MainWindowHandle==IntPtr.Zero && RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ||( timer > 0)) 156 | { 157 | System.Threading.Thread.Sleep(1000); 158 | timer -= 1000; 159 | Console.Write("."); 160 | p = Process.GetProcessById(p.Id); 161 | } 162 | 163 | System.Environment.Exit(0); 164 | Application.Shutdown(); 165 | 166 | 167 | } 168 | 169 | public void getSettings() 170 | { 171 | string[] data = new string[0]; 172 | if (System.IO.File.Exists("launchUpdater.txt")) 173 | { 174 | StreamReader reader = new StreamReader("launchUpdater.txt"); 175 | data = reader.ReadToEnd().Replace("\r\n", "").Split("|"); 176 | reader.Close(); 177 | } 178 | 179 | 180 | if (data.Length > 0) 181 | currentExe = data[0]; 182 | 183 | autoStartYuzu = data.Length > 1 ? bool.Parse(data[1]) : true; 184 | confirmDownload = data.Length > 2 ? bool.Parse(data[2]) : true; 185 | backupSave = data.Length > 3 ? bool.Parse(data[3]) : true; 186 | optimizePerf = data.Length > 4 ? bool.Parse(data[4]) : true; 187 | killCpuProccess = data.Length > 5 ? bool.Parse(data[5]) : false; 188 | 189 | Utils.init7ZipPaht(); 190 | initAppPath(); 191 | } 192 | 193 | public void setSettings() 194 | { 195 | StreamWriter writer = new StreamWriter("launchUpdater.txt"); 196 | writer.Write(currentExe + "|" + autoStartYuzu + "|" + confirmDownload + "|" + backupSave + "|" + optimizePerf + "|" + killCpuProccess); 197 | writer.Close(); 198 | } 199 | 200 | private HttpClient httpClient() 201 | { 202 | 203 | HttpClientHandler httpClientHandler = new HttpClientHandler(); 204 | httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual; 205 | httpClientHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; 206 | HttpClient client = new HttpClient(httpClientHandler); 207 | 208 | return client ; 209 | } 210 | 211 | void getCurrentVersion() 212 | { 213 | try 214 | { 215 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 216 | { 217 | 218 | var files = Directory.EnumerateFiles(System.Environment.CurrentDirectory, "*.AppImage"); 219 | if (files.Count() > 0) 220 | { 221 | currentExe = files.First(); 222 | currentVersion = currentExe.Substring(currentExe.LastIndexOf("-") + 1, currentExe.LastIndexOf(".") - currentExe.LastIndexOf("-") - 1); 223 | currentVersion = "EA-" + currentVersion; 224 | MainUI.addTextConsole("Yuzu EA version found : " + currentVersion + "\n"); 225 | } 226 | } 227 | else 228 | { 229 | if (System.IO.File.Exists(currentExe)) 230 | { 231 | StreamReader reader = new StreamReader(currentExe); 232 | currentVersion = reader.ReadToEnd(); 233 | reader.Close(); 234 | var index = currentVersion.IndexOf("yuzu Early Access"); 235 | currentVersion = currentVersion.Substring(index - 20, 20).Replace("\0", "").Replace("\00", ""); 236 | if (currentVersion.StartsWith("0")) 237 | currentVersion = currentVersion.Substring(1); 238 | 239 | currentVersion = "EA-" + currentVersion; 240 | MainUI.addTextConsole("Yuzu EA version found : " + currentVersion + "\n"); 241 | } 242 | } 243 | } 244 | catch(ArgumentOutOfRangeException e) 245 | { 246 | MainUI.addTextConsole("Its seem you dont use EA Yuzu version." + "\n"); 247 | MainUI.addTextConsole("You must use EA version from pineapple here : https://github.com/pineappleEA/pineapple-src/releases." + "\n"); 248 | } 249 | 250 | 251 | 252 | } 253 | 254 | public void checkVersion() 255 | { 256 | ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; 257 | MainUI.addTextConsole("Check for YUZU EA update" + "\n"); 258 | 259 | 260 | String src = httpClient().GetAsync("https://github.com/pineappleEA/pineapple-src/releases/").Result.Content.ReadAsStringAsync().Result; 261 | string[] releaseVersions = src.Split(new String[] { "h2 class=\"sr-only\"" }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray(); 262 | releaseVersions = releaseVersions.Take(releaseVersions.Length - 1).ToArray(); 263 | 264 | for(int i = 0; i < releaseVersions.Length; i++) 265 | { 266 | releases.Add(new Release(releaseVersions[i])); 267 | } 268 | 269 | if(currentVersion == null) 270 | MainUI.addTextConsole("No version found" + "\n"); 271 | 272 | myCurrentRelease = releases.Where(x => x.version == currentVersion).FirstOrDefault(); 273 | if(myCurrentRelease == null) 274 | myCurrentRelease = new Release(currentVersion,true); 275 | 276 | if (myCurrentRelease != releases.FirstOrDefault()) 277 | { 278 | MainUI.addTextConsole("Retrieve PRs from github" + "\n"); 279 | for (var p = 0; p < 4; p++) 280 | { 281 | MainUI.progress.Report((p + 1) * 0.25f); 282 | src = httpClient().GetAsync("https://github.com/yuzu-emu/yuzu/issues?page=" + p + "&q=sort%3Acreated-desc").Result.Content.ReadAsStringAsync().Result; 283 | 284 | string[] prs = src.Split(new String[] { "
" }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray(); 285 | prs = prs.Take(prs.Length - 1).ToArray(); 286 | 287 | for (int i = 0; i < prs.Length; i++) 288 | { 289 | var pr = new PR(prs[i]); 290 | //CHECK IF UNIQUE BECAUSE BUG IDK WHY 291 | if(prList.FirstOrDefault(x => x.idIssue == pr.idIssue) == null) 292 | prList.Add(pr); 293 | } 294 | } 295 | 296 | 297 | string changeLog = getChangeLog(); 298 | 299 | MainUI.addTextConsole("New Version found , pass from " + currentVersion + " to " + releases[0].version + "\n" + getChangeLog()); 300 | if(confirmDownload) 301 | { 302 | MainUI.addTextConsole("Do you want to download it ? (y/n)" + "\n"); 303 | string answer = MainUI.waitInput().Result; 304 | if (answer != "y") 305 | return; 306 | } 307 | downloadRelease(releases[0]); 308 | } 309 | else 310 | { 311 | MainUI.addTextConsole("Yuzu is up to date" + "\n"); 312 | } 313 | 314 | } 315 | 316 | public void downloadRelease(Release release) 317 | { 318 | try{ 319 | killYuzus(); 320 | MainUI.addTextConsole("Downloading "+ release.version + " version" + "\n"); 321 | 322 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 323 | { 324 | String fileName = System.IO.Path.GetFileName(new Uri(release.downloadUrl).LocalPath); 325 | download(release.downloadUrl, fileName).GetAwaiter().GetResult(); 326 | MainUI.addTextConsole("Make executable" + "\n"); 327 | Process.Start("chmod", "+x " + fileName); 328 | MainUI.addTextConsole("Remove old version" + "\n"); 329 | if (System.IO.File.Exists(currentExe)) 330 | System.IO.File.Delete(currentExe); 331 | 332 | currentExe = fileName; 333 | } 334 | else 335 | { 336 | download(release.downloadUrl, "YuzuEA.zip").GetAwaiter().GetResult(); 337 | ZipArchive zip = ZipFile.OpenRead("YuzuEA.zip"); 338 | zip.ExtractToDirectory(System.Environment.CurrentDirectory, true); 339 | zip.Dispose(); 340 | MainUI.addTextConsole("Remove zip file" + "\n"); 341 | System.IO.File.Delete("YuzuEA.zip"); 342 | string[] files = Directory.GetFiles(System.Environment.CurrentDirectory + "/yuzu-windows-msvc-early-access"); 343 | MainUI.addTextConsole("Move files and directory to root directory" + "\n"); 344 | if (System.IO.File.Exists(currentExe)) 345 | System.IO.File.Delete(currentExe); 346 | Utils.DirectoryCopyAndDelete(System.Environment.CurrentDirectory + "/yuzu-windows-msvc-early-access", System.Environment.CurrentDirectory); 347 | System.IO.File.Move("yuzu.exe", currentExe); 348 | } 349 | MainUI.addTextConsole("Install to " + release.version + " success !\n"); 350 | purgeUncessaryFiles(); 351 | } 352 | catch(Exception ex){ 353 | MainUI.addTextConsole(ex.StackTrace + " " + ex.Message + "\n"); 354 | 355 | } 356 | } 357 | 358 | private string getChangeLog() 359 | { 360 | string changeLog = ""; 361 | List prs = prList.Where(x => x.releaseDate > myCurrentRelease.releaseDate && x.label.Contains("merge")).ToList(); 362 | 363 | foreach(PR pr in prs) 364 | { 365 | changeLog += pr.idIssue + " - " + pr.description + " - " + pr.label + " - " + pr.releaseDate + "\n"; 366 | } 367 | return changeLog; 368 | } 369 | 370 | private async Task download(String uri,String filename) 371 | { 372 | HttpClient _httpClient = httpClient(); 373 | _httpClient.BaseAddress = new Uri(uri); 374 | _httpClient.DefaultRequestHeaders.Accept.Clear(); 375 | _httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/octet-stream")); 376 | using (var file = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None)) 377 | { 378 | 379 | await _httpClient.DownloadAsync(uri, file, MainUI.progress); 380 | } 381 | 382 | } 383 | 384 | 385 | 386 | public void scanTitlesIdAndGetName() 387 | { 388 | if(pathApp == "") 389 | { 390 | MainUI.addTextConsole("Path to yuzu data not found" + "\n"); 391 | return; 392 | } 393 | else 394 | { 395 | MainUI.addTextConsole("Path to yuzu data found: " + pathApp + "\n"); 396 | } 397 | 398 | 399 | if (games.Count == 0) 400 | { 401 | 402 | List directorys = Directory.GetDirectories(pathApp ,"010*",SearchOption.AllDirectories).Select(d => Path.GetFileName(d).ToUpper()).ToList(); 403 | directorys = directorys.Distinct().ToList(); 404 | 405 | HttpClient _httpClient = httpClient(); 406 | String src = _httpClient.GetAsync("https://switchbrew.org/w/index.php?title=Title_list/Games&mobileaction=toggle_view_desktop").Result.Content.ReadAsStringAsync().Result; 407 | 408 | foreach (String directory in directorys) 409 | { 410 | String id = directory.Substring(0, 16); 411 | string name = Regex.Match(src, @"" + id + @"\s*(.*)").Groups[1].Value; 412 | 413 | if (name != "") 414 | { 415 | games.Add(new Game(id, name, pathApp)); 416 | } 417 | 418 | } 419 | } 420 | } 421 | 422 | 423 | private void _saveBackup() 424 | { 425 | try 426 | { 427 | MainUI.addTextConsole("Save game backup..." + "\n"); 428 | string sourceDir = Path.Combine(pathApp, "nand", "user", "save"); 429 | DirectoryInfo directoryInfo = new DirectoryInfo(sourceDir); 430 | if (this.backupSave && directoryInfo.Exists && directoryInfo.GetDirectories().Length>0) 431 | { 432 | if(!Directory.Exists(Path.Combine(Environment.CurrentDirectory, "savesBackup"))) 433 | Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "savesBackup")); 434 | 435 | string zipFilePath = Path.Combine(Environment.CurrentDirectory,"savesBackup", DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".7z"); 436 | 437 | SevenZip.SevenZipCompressor compressor = new SevenZip.SevenZipCompressor(); 438 | compressor.CompressionLevel = SevenZip.CompressionLevel.Ultra; 439 | compressor.CompressionMethod = SevenZip.CompressionMethod.Lzma2; 440 | compressor.CompressionMode = SevenZip.CompressionMode.Create; 441 | 442 | compressor.CompressDirectory(sourceDir, zipFilePath); 443 | 444 | _deleteOldBackups(); 445 | 446 | } 447 | 448 | 449 | 450 | } 451 | catch (Exception ex) 452 | { 453 | MainUI.addTextConsole(ex.StackTrace + " " + ex.Message + "\n"); 454 | Console.ReadLine(); 455 | } 456 | 457 | 458 | } 459 | 460 | 461 | private void _deleteOldBackups() 462 | { 463 | string backupDir = Path.Combine(Environment.CurrentDirectory, "savesBackup"); 464 | if (!Directory.Exists(backupDir)) return; // backup directory does not exist 465 | var backupFiles = new DirectoryInfo(backupDir).GetFiles("*.7z", SearchOption.AllDirectories).OrderBy(f => f.LastWriteTime).ToList(); // get all backup files in the directory sorted by date 466 | if (backupFiles.Count < 4) return; // less than 3 backup files present 467 | 468 | backupFiles[0].Delete(); // delete the oldest backup file 469 | } 470 | 471 | 472 | public void restoreLatestBackup() 473 | { 474 | string backupDir = Path.Combine(Environment.CurrentDirectory, "savesBackup"); 475 | DirectoryInfo dirInfo = new DirectoryInfo(backupDir); 476 | if (dirInfo.Exists) 477 | { 478 | FileInfo[] files = dirInfo.GetFiles("*.7z"); 479 | if (files.Length > 0) 480 | { 481 | Array.Sort(files, (x, y) => y.CreationTime.CompareTo(x.CreationTime)); 482 | FileInfo latestBackup = files[0]; 483 | MainUI.addTextConsole("Restoring latest backup: " + latestBackup.CreationTime.ToString() + "\n"); 484 | SevenZip.SevenZipExtractor extractor = new SevenZip.SevenZipExtractor(latestBackup.FullName); 485 | extractor.ExtractArchive(Path.Combine(pathApp, "nand", "user", "save")); 486 | MainUI.addTextConsole("Restore complete.\n"); 487 | } 488 | else 489 | { 490 | MainUI.addTextConsole("No backup file found.\n"); 491 | } 492 | } 493 | else 494 | { 495 | MainUI.addTextConsole("Backup directory does not exist.\n"); 496 | } 497 | } 498 | 499 | 500 | private void initAppPath() 501 | { 502 | pathApp = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) ,"yuzu"); 503 | 504 | if (!Directory.Exists(pathApp)) 505 | pathApp = "user"; 506 | if (!Directory.Exists(pathApp)) 507 | pathApp = ""; 508 | 509 | } 510 | 511 | 512 | private void purgeUncessaryFiles() 513 | { 514 | MainUI.addTextConsole("Purging uncessary files...\n"); 515 | //FIND all FILLS THAT BEGIN WITH yuzu-windows-msvc-source- in current directory 516 | var files = Directory.GetFiles(Environment.CurrentDirectory, "yuzu-windows-msvc-source-*"); 517 | foreach (var file in files) 518 | { 519 | try 520 | { 521 | System.IO.File.Delete(file); 522 | FileInfo fileInfo = new FileInfo(file); 523 | MainUI.addTextConsole(" -Deleted " + fileInfo.Name + "\n"); 524 | } 525 | catch (Exception ex) 526 | { 527 | MainUI.addTextConsole(ex.StackTrace + " " + ex.Message + "\n"); 528 | Console.ReadLine(); 529 | } 530 | } 531 | 532 | } 533 | 534 | 535 | public void checkUpdate() 536 | { 537 | MainUI.addTextConsole("W'll restart for updates...\n"); 538 | 539 | WebClient webClient = new WebClient(); 540 | 541 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) 542 | { 543 | if(!File.Exists("updateUpdater.exe")) 544 | File.Delete("updateUpdater.exe"); 545 | webClient.DownloadFile("https://github.com/pilout/YuzuUpdater/releases/download/updater/updateUpdater.exe", "updateUpdater.exe"); 546 | } 547 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 548 | { 549 | if (!File.Exists("updateUpdater")) 550 | File.Delete("updateUpdater"); 551 | webClient.DownloadFile("https://github.com/pilout/YuzuUpdater/releases/download/updater/updateUpdater", "updateUpdater"); 552 | } 553 | 554 | ProcessStartInfo startInfo = null; 555 | 556 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 557 | { 558 | Process.Start("chmod", "+x updateUpdater"); 559 | startInfo = new ProcessStartInfo("updateUpdater"); 560 | } 561 | else 562 | startInfo = new ProcessStartInfo("updateUpdater.exe"); 563 | 564 | 565 | startInfo.UseShellExecute = true; 566 | Process.Start(startInfo); 567 | Process.GetCurrentProcess().Kill(); 568 | } 569 | } 570 | 571 | 572 | } 573 | -------------------------------------------------------------------------------- /YuzuEAUpdater/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Les informations générales relatives à un assembly dépendent de 6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations 7 | // associées à un assembly. 8 | [assembly: AssemblyTitle("YuzuEAUpdater")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("YuzuEAUpdater")] 13 | [assembly: AssemblyCopyright("Copyright © 2023")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly 18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de 19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM 23 | [assembly: Guid("7f565065-2cdb-45f1-a5a1-33fc5f52a043")] 24 | 25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes : 26 | // 27 | // Version principale 28 | // Version secondaire 29 | // Numéro de build 30 | // Révision 31 | // 32 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut 33 | // en utilisant '*', comme indiqué ci-dessous : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /YuzuEAUpdater/Properties/PublishProfiles/FolderProfile.pubxml: -------------------------------------------------------------------------------- 1 |  2 | 5 | 6 | 7 | Release 8 | Any CPU 9 | bin\Release\netcoreapp3.1\publish\linux-x64\ 10 | FileSystem 11 | <_TargetId>Folder 12 | netcoreapp3.1 13 | linux-x64 14 | true 15 | true 16 | 17 | -------------------------------------------------------------------------------- /YuzuEAUpdater/Properties/PublishProfiles/FolderProfile1.pubxml: -------------------------------------------------------------------------------- 1 |  2 | 5 | 6 | 7 | Release 8 | Any CPU 9 | bin\Release\netcoreapp3.1\publish\win-x64\ 10 | FileSystem 11 | <_TargetId>Folder 12 | netcoreapp3.1 13 | win-x64 14 | true 15 | true 16 | false 17 | 18 | -------------------------------------------------------------------------------- /YuzuEAUpdater/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Ce code a été généré par un outil. 4 | // Version du runtime :4.0.30319.42000 5 | // 6 | // Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si 7 | // le code est régénéré. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace YuzuEAUpdater.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. 17 | /// 18 | // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder 19 | // à l'aide d'un outil, tel que ResGen ou Visual Studio. 20 | // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen 21 | // avec l'option /str ou régénérez votre projet VS. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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 | /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. 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("YuzuEAUpdater.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Remplace la propriété CurrentUICulture du thread actuel pour toutes 51 | /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. 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 | -------------------------------------------------------------------------------- /YuzuEAUpdater/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 61 | 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 | text/microsoft-resx 91 | 92 | 93 | 1.3 94 | 95 | 96 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 97 | 98 | 99 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 100 | 101 | -------------------------------------------------------------------------------- /YuzuEAUpdater/Release.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Text.RegularExpressions; 6 | 7 | namespace YuzuEAUpdater 8 | { 9 | public class Release 10 | { 11 | public Release(string releaseVersion) 12 | { 13 | 14 | this.version = Regex.Match(releaseVersion, @""">(.*)").Groups[1].Value; 15 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 16 | this.downloadUrl = @"https://github.com/pineappleEA/pineapple-src/releases/download/" + this.version + "/Linux-Yuzu-" + this.version + ".AppImage"; 17 | else 18 | this.downloadUrl = @"https://github.com/pineappleEA/pineapple-src/releases/download/" + this.version + "/Windows-Yuzu-" + this.version + ".zip"; 19 | 20 | 21 | this.releaseDate = DateTime.Parse(Regex.Match(releaseVersion, @"datetime=""(.*)"">").Groups[1].Value); 22 | 23 | } 24 | 25 | public Release(string version, bool none) 26 | { 27 | if (version == null) 28 | { 29 | this.version = "EA-0"; 30 | } 31 | else 32 | { 33 | this.version = "EA-" + version; 34 | } 35 | 36 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 37 | this.downloadUrl = @"https://github.com/pineappleEA/pineapple-src/releases/download/" + this.version + "/Linux-Yuzu-" + this.version + ".AppImage"; 38 | else 39 | this.downloadUrl = @"https://github.com/pineappleEA/pineapple-src/releases/download/" + this.version + "/Windows-Yuzu-" + this.version + ".zip"; 40 | 41 | this.releaseDate = DateTime.MinValue; 42 | } 43 | 44 | public string version; 45 | public string downloadUrl; 46 | public DateTime releaseDate; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /YuzuEAUpdater/UI/MainUI.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Terminal.Gui; 7 | 8 | namespace YuzuEAUpdater.UI 9 | { 10 | public class MainUI 11 | { 12 | public static Label mainConsole; 13 | private static ProgressBar progressBar; 14 | private static ListView listView; 15 | private bool checkall = false; 16 | private Boolean _waitInput = false; 17 | private string _input = ""; 18 | private static List linesIndex = new List(); 19 | 20 | public MainUI(MainWindow window) 21 | { 22 | var MenuBar = new MenuBar(); 23 | FrameView mainFram = new FrameView(); 24 | FrameView switchFram = new FrameView(); 25 | FrameView modFram = new FrameView(); 26 | List items = new List(); 27 | listView = new ListView() 28 | { 29 | X = 1, 30 | Y = 2, 31 | Height = Dim.Fill(), 32 | Width = Dim.Fill(1), 33 | //ColorScheme = Colors.TopLevel, 34 | AllowsMarking = true, 35 | AllowsMultipleSelection = true 36 | }; 37 | 38 | Label labelFoundMods = new Label(); 39 | labelFoundMods.X = 1; 40 | labelFoundMods.Y = 1; 41 | labelFoundMods.Text = ""; 42 | Button btnDownloadMods = new Button("Install"); 43 | btnDownloadMods.Visible = false; 44 | btnDownloadMods.X = Pos.Percent(60); 45 | btnDownloadMods.Y = 1; 46 | Button chkAll = new Button("Check All"); 47 | chkAll.X = Pos.Right(btnDownloadMods) + 1; 48 | chkAll.Y = 1; 49 | chkAll.Visible = false; 50 | chkAll.Clicked += () => 51 | { 52 | if (listView.Source == null) 53 | return; 54 | var i = 0; 55 | foreach (var mod in listView.Source.ToList()) 56 | { 57 | listView.Source.SetMark(i, !checkall); 58 | i++; 59 | } 60 | 61 | checkall = !checkall; 62 | if (checkall) 63 | chkAll.Text = "Uncheck All"; 64 | else 65 | chkAll.Text = "Check All"; 66 | }; 67 | Task modsTask = null; 68 | btnDownloadMods.Clicked += () => 69 | { 70 | if (listView.Source.Count == 0 || (modsTask != null && !modsTask.IsCompleted)) 71 | return; 72 | 73 | List mods = listView.Source.ToList() as List; 74 | modsTask = new Task(() => 75 | { 76 | List markedMods = new List(); 77 | var i = 0; 78 | foreach (var mod in mods) 79 | { 80 | if (listView.Source.IsMarked(i)) 81 | markedMods.Add(mod); 82 | i++; 83 | } 84 | 85 | List tasks = new List(); 86 | var index = 0; 87 | var nbTaskDone = 0; 88 | foreach (BananaMod mod in markedMods) 89 | { 90 | Task task = new Task(() => 91 | { 92 | mod.download(); 93 | mod.extract(); 94 | lock (MainWindow.lockObj) 95 | { 96 | nbTaskDone++; 97 | progress.Report((float)nbTaskDone / (float)markedMods.Count); 98 | } 99 | }); 100 | tasks.Add(task); 101 | task.Start(); 102 | index++; 103 | 104 | if (index % 3 == 0) 105 | Task.WaitAll(tasks.ToArray()); 106 | 107 | } 108 | 109 | Task.WaitAll(tasks.ToArray()); 110 | 111 | }); 112 | modsTask.Start(); 113 | }; 114 | 115 | 116 | var autoStartItem = new MenuItem("AutoStart Yuzu", null, null, null, null, Key.Null); 117 | Action autoStartAction = () => 118 | { 119 | autoStartItem.Checked = !autoStartItem.Checked; 120 | window.autoStartYuzu = autoStartItem.Checked; 121 | window.setSettings(); 122 | }; 123 | autoStartItem.Action = autoStartAction; 124 | autoStartItem.Checked = window.autoStartYuzu; 125 | autoStartItem.CheckType = MenuItemCheckStyle.Checked; 126 | 127 | 128 | var confirmDownload = new MenuItem("Ask download", null, null, null, null, Key.Null); 129 | Action actionConfirmD = () => 130 | { 131 | confirmDownload.Checked = !confirmDownload.Checked; 132 | window.confirmDownload = confirmDownload.Checked; 133 | window.setSettings(); 134 | }; 135 | confirmDownload.Action = actionConfirmD; 136 | confirmDownload.Checked = window.confirmDownload; 137 | confirmDownload.CheckType = MenuItemCheckStyle.Checked; 138 | 139 | 140 | var backupSave = new MenuItem("Backup Save at start", null, null, null, null, Key.Null); 141 | Action actionBackupSave = () => 142 | { 143 | backupSave.Checked = !backupSave.Checked; 144 | window.backupSave = backupSave.Checked; 145 | window.setSettings(); 146 | }; 147 | backupSave.Action = actionBackupSave; 148 | backupSave.Checked = window.backupSave; 149 | backupSave.CheckType = MenuItemCheckStyle.Checked; 150 | 151 | 152 | var optimizePerfomance = new MenuItem("Optimise Perfomance", null, null, null, null, Key.Null); 153 | Action actionOptimizePerfomance = () => 154 | { 155 | optimizePerfomance.Checked = !optimizePerfomance.Checked; 156 | window.optimizePerf = optimizePerfomance.Checked; 157 | window.setSettings(); 158 | }; 159 | optimizePerfomance.Action = actionOptimizePerfomance; 160 | optimizePerfomance.Checked = window.optimizePerf; 161 | optimizePerfomance.CheckType = MenuItemCheckStyle.Checked; 162 | 163 | 164 | var killProccessCPU = new MenuItem("Kill Proccess CPU", null, null, null, null, Key.Null); 165 | Action actionKillProccessCPU = () => 166 | { 167 | killProccessCPU.Checked = !killProccessCPU.Checked; 168 | window.killCpuProccess = killProccessCPU.Checked; 169 | window.setSettings(); 170 | }; 171 | killProccessCPU.Action = actionKillProccessCPU; 172 | killProccessCPU.Checked = window.killCpuProccess; 173 | killProccessCPU.CheckType = MenuItemCheckStyle.Checked; 174 | 175 | 176 | items.Add(new MenuBarItem("[Settings]", new MenuItem[] 177 | {autoStartItem, 178 | confirmDownload, 179 | backupSave, 180 | optimizePerfomance, 181 | killProccessCPU 182 | })); 183 | 184 | 185 | 186 | window.Add(MenuBar); 187 | items.Add(new MenuBarItem("[Restore latest backup]", null, window.restoreLatestBackup)); 188 | items.Add(new MenuBarItem("[Get last version]", null, window.checkUpdate)); 189 | 190 | MenuBar.Menus = items.ToArray(); 191 | 192 | 193 | Task t = new Task(() => 194 | { 195 | window.scanTitlesIdAndGetName(); 196 | if (window.games.Count > 0) 197 | items.Add(new MenuBarItem("[Mods]", window.games.Select(g => new MenuItem(g.name, null, () => 198 | { 199 | Task task = new Task(() => 200 | { 201 | g.loadMods(this.progress); 202 | modFram.Title = "Mods for " + g.name; 203 | labelFoundMods.Text = g.validBananaMods.Count + " mods found"; 204 | listView.SetSource(g.validBananaMods); 205 | btnDownloadMods.Visible = true; 206 | chkAll.Visible = true; 207 | }); 208 | task.Start(); 209 | }, null, null, Key.Null)).ToArray())); 210 | else 211 | items.Add(new MenuBarItem("Mods", new MenuItem[] { new MenuItem("No game found", null, null, null, null, Key.Null) })); 212 | MenuBar.Menus = items.ToArray(); 213 | }); 214 | 215 | t.Start(); 216 | 217 | 218 | mainFram.X = 0; 219 | mainFram.Y = 1; 220 | mainFram.Width = Dim.Fill(); 221 | mainFram.Height = Dim.Percent(49); 222 | mainFram.Title = "Logs"; 223 | mainConsole = new Label(); 224 | mainConsole.X = 0; 225 | mainConsole.Y = 0; 226 | mainFram.Add(mainConsole); 227 | progressBar = new ProgressBar(); 228 | progressBar.X = 0; 229 | progressBar.Y = 0; 230 | progressBar.Width = Dim.Fill(); 231 | progressBar.Height = 1; 232 | progressBar.Visible = false; 233 | window.Add(mainFram); 234 | 235 | switchFram.Title = "Switch build"; 236 | switchFram.X = 0; 237 | switchFram.Y = Pos.Percent(51); 238 | switchFram.Width = Dim.Percent(17); 239 | switchFram.Height = Dim.Percent(49); 240 | Label switchLabel = new Label(); 241 | switchLabel.X = 0; 242 | switchLabel.Y = 0; 243 | switchLabel.Width = Dim.Fill(); 244 | switchLabel.Height = 2; 245 | switchLabel.Text = "Enter build number: "; 246 | switchFram.Add(switchLabel); 247 | TextField textField = new TextField(); 248 | textField.TextChanging += (args) => 249 | { 250 | if (args.NewText.Any(c => !char.IsDigit((char)c) && !char.IsControl((char)c))) 251 | args.Cancel = true; 252 | }; 253 | textField.X = 0; 254 | textField.Y = 2; 255 | textField.Width = Dim.Percent(80); 256 | textField.Height = 1; 257 | textField.Text = ""; 258 | switchFram.Add(textField); 259 | Button button = new Button("Install"); 260 | button.X = 0; 261 | button.Y = Pos.Bottom(textField) + 1; 262 | button.Width = Dim.Percent(50); 263 | button.Height = 1; 264 | button.Clicked += () => 265 | { 266 | Task t = null; 267 | if (textField.Text.Length > 0 && (t == null || t.IsCompleted)) 268 | { 269 | t = new Task(() => 270 | { 271 | window.downloadRelease(new Release(textField.Text.ToString(), true)); 272 | }); 273 | t.Start(); 274 | } 275 | }; 276 | switchFram.Add(button); 277 | 278 | modFram.Title = "Mods"; 279 | modFram.X = Pos.Percent(18); 280 | modFram.Y = Pos.Percent(51); 281 | modFram.Width = Dim.Fill(); 282 | modFram.Height = Dim.Percent(49); 283 | modFram.Visible = true; 284 | modFram.Add(labelFoundMods); 285 | modFram.Add(listView); 286 | modFram.Add(btnDownloadMods); 287 | modFram.Add(chkAll); 288 | listView.RowRender += ListView_RowRender; 289 | 290 | var _scrollBar = new ScrollBarView(listView, true); 291 | 292 | _scrollBar.ChangedPosition += () => { 293 | listView.TopItem = _scrollBar.Position; 294 | if (listView.TopItem != _scrollBar.Position) 295 | { 296 | _scrollBar.Position = listView.TopItem; 297 | } 298 | listView.SetNeedsDisplay(); 299 | }; 300 | 301 | _scrollBar.OtherScrollBarView.ChangedPosition += () => { 302 | listView.LeftItem = _scrollBar.OtherScrollBarView.Position; 303 | if (listView.LeftItem != _scrollBar.OtherScrollBarView.Position) 304 | { 305 | _scrollBar.OtherScrollBarView.Position = listView.LeftItem; 306 | } 307 | listView.SetNeedsDisplay(); 308 | }; 309 | 310 | listView.DrawContent += (e) => { 311 | if (listView.Source != null) 312 | { 313 | _scrollBar.Size = listView.Source.Count - 1; 314 | _scrollBar.Position = listView.TopItem; 315 | _scrollBar.OtherScrollBarView.Size = listView.Maxlength - 1; 316 | _scrollBar.OtherScrollBarView.Position = listView.LeftItem; 317 | _scrollBar.Refresh(); 318 | } 319 | }; 320 | 321 | 322 | window.Add(switchFram); 323 | window.Add(modFram); 324 | window.Add(progressBar); 325 | Application.RootKeyEvent += Application_RootKeyEvent; 326 | } 327 | 328 | 329 | private void ListView_RowRender(ListViewRowEventArgs obj) 330 | { 331 | if (obj.Row == listView.SelectedItem) 332 | { 333 | return; 334 | } 335 | if (listView.AllowsMarking && listView.Source.IsMarked(obj.Row)) 336 | { 337 | obj.RowAttribute = new Terminal.Gui.Attribute(Color.BrightRed, Color.BrightYellow); 338 | return; 339 | } 340 | if (obj.Row % 2 == 0) 341 | { 342 | obj.RowAttribute = new Terminal.Gui.Attribute(Color.BrightGreen, Color.Magenta); 343 | } 344 | else 345 | { 346 | obj.RowAttribute = new Terminal.Gui.Attribute(Color.BrightMagenta, Color.Green); 347 | } 348 | } 349 | 350 | 351 | public IProgress progress 352 | { 353 | get; set; 354 | 355 | } = new Progress(p => { 356 | if (progressBar.Visible == false) 357 | { 358 | progressBar.Y = progressBar.SuperView.Bounds.Bottom - 1; 359 | progressBar.Visible = true; 360 | } 361 | 362 | progressBar.Fraction = p; 363 | 364 | if (p == 1) 365 | progressBar.Visible = false; 366 | }); 367 | 368 | 369 | public static void addTextConsole(String text) 370 | { 371 | 372 | int[] indexs = text.Select((b, i) => b == '\n' ? i + mainConsole.Text.Length : -1).Where(i => i != -1).ToArray(); 373 | linesIndex.AddRange(indexs); 374 | 375 | Application.MainLoop.Invoke(() => 376 | { 377 | mainConsole.Text += (text); 378 | 379 | if (mainConsole.SuperView.Bounds.Height > 0) 380 | { 381 | while (linesIndex.Count > 0 && (mainConsole.Frame.Bottom) > mainConsole.SuperView.Bounds.Height) 382 | { 383 | var index = linesIndex.First(); 384 | 385 | if (index < mainConsole.Text.Length && index >0) 386 | mainConsole.Text = mainConsole.Text.Substring(index); 387 | else if(index >0) 388 | mainConsole.Text = ""; 389 | 390 | linesIndex.RemoveAt(0); 391 | 392 | foreach (var l in linesIndex.ToList()) 393 | { 394 | linesIndex[linesIndex.IndexOf(l)] = l - index; 395 | } 396 | 397 | } 398 | } 399 | 400 | 401 | mainConsole.SetNeedsDisplay(); 402 | }); 403 | } 404 | 405 | 406 | private bool Application_RootKeyEvent(KeyEvent arg) 407 | { 408 | if (_waitInput && MainUI.mainConsole.SuperView.SuperView.Visible) 409 | { 410 | if (arg.Key == Key.Enter) 411 | { 412 | _waitInput = false; 413 | addTextConsole("\n"); 414 | } 415 | else if (arg.Key == Key.DeleteChar || arg.Key == Key.Backspace) 416 | { 417 | if (_input.Length >= 1) 418 | { 419 | MainUI.mainConsole.Text = MainUI.mainConsole.Text.Substring(0, MainUI.mainConsole.Text.Length - 1); 420 | _input = _input.Substring(0, _input.Length - 1); 421 | } 422 | 423 | } 424 | else if (!char.IsControl((char)arg.Key)) 425 | { 426 | 427 | addTextConsole(((char)arg.Key).ToString()); 428 | _input += ((char)arg.Key).ToString(); 429 | 430 | } 431 | return true; 432 | } 433 | return false; 434 | } 435 | 436 | public async Task waitInput() 437 | { 438 | addTextConsole("\n"); 439 | _waitInput = true; 440 | while (_waitInput) 441 | { 442 | await Task.Delay(100); 443 | } 444 | var temp = _input; 445 | _input = ""; 446 | return temp; 447 | } 448 | } 449 | 450 | } 451 | -------------------------------------------------------------------------------- /YuzuEAUpdater/YuzuEAUpdater.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp3.1 4 | Exe 5 | false 6 | YuzuEAUpdater.Program 7 | False 8 | embedded 9 | win-x64;linux-x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | all 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /YuzuEAUpdater/ZipExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.IO.Compression; 8 | using System.Net.Security; 9 | using System.Net; 10 | using System.Runtime.InteropServices; 11 | using SevenZip; 12 | using System.Net.Http; 13 | using System.Threading; 14 | using System.Diagnostics; 15 | using System.ServiceProcess; 16 | 17 | namespace YuzuEAUpdater 18 | { 19 | public static class Utils 20 | { 21 | public static void ExtractToDirectory(this ZipArchive archive, string destinationDirectoryName, bool overwrite) 22 | { 23 | 24 | if (!overwrite) 25 | { 26 | archive.ExtractToDirectory(destinationDirectoryName); 27 | return; 28 | } 29 | 30 | DirectoryInfo di = Directory.CreateDirectory(destinationDirectoryName); 31 | string destinationDirectoryFullPath = di.FullName; 32 | 33 | foreach (ZipArchiveEntry file in archive.Entries) 34 | { 35 | string completeFileName = Path.GetFullPath(Path.Combine(destinationDirectoryFullPath, file.FullName)); 36 | string directory = Path.GetDirectoryName(completeFileName); 37 | 38 | if (!Directory.Exists(directory)) 39 | { 40 | Directory.CreateDirectory(directory); 41 | } 42 | 43 | if (!completeFileName.StartsWith(destinationDirectoryFullPath, StringComparison.OrdinalIgnoreCase)) 44 | { 45 | throw new IOException("Trying to extract file outside of destination directory. See this link for more info: https://snyk.io/research/zip-slip-vulnerability"); 46 | } 47 | 48 | 49 | 50 | if (file.Name == "") 51 | {// Assuming Empty for Directory 52 | Directory.CreateDirectory(Path.GetDirectoryName(completeFileName)); 53 | continue; 54 | } 55 | 56 | file.ExtractToFile(completeFileName, true); 57 | 58 | } 59 | } 60 | 61 | public static void DirectoryCopyAndDelete(string strSource, string Copy_dest) 62 | { 63 | DirectoryInfo dirInfo = new DirectoryInfo(strSource); 64 | 65 | DirectoryInfo[] directories = dirInfo.GetDirectories(); 66 | 67 | FileInfo[] files = dirInfo.GetFiles(); 68 | 69 | foreach (DirectoryInfo tempdir in directories) 70 | { 71 | 72 | Directory.CreateDirectory(Copy_dest + "/" + tempdir.Name);// creating the Directory 73 | 74 | var ext = System.IO.Path.GetExtension(tempdir.Name); 75 | 76 | if (System.IO.Path.HasExtension(ext)) 77 | { 78 | foreach (FileInfo tempfile in files) 79 | { 80 | tempfile.CopyTo(Path.Combine(strSource + "/" + tempfile.Name, Copy_dest + "/" + tempfile.Name),true); 81 | File.Delete(tempfile.FullName); 82 | } 83 | } 84 | DirectoryCopyAndDelete(strSource + "/" + tempdir.Name, Copy_dest + "/" + tempdir.Name); 85 | } 86 | 87 | FileInfo[] files1 = dirInfo.GetFiles(); 88 | 89 | foreach (FileInfo tempfile in files1) 90 | { 91 | tempfile.CopyTo(Path.Combine(Copy_dest, tempfile.Name),true); 92 | File.Delete(tempfile.FullName); 93 | 94 | } 95 | Directory.Delete(dirInfo.FullName); 96 | } 97 | 98 | 99 | public static void init7ZipPaht() 100 | { 101 | var platForm = RuntimeInformation.OSArchitecture; 102 | var OS = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "Linux" : RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Windows" : "MacOS"; 103 | bool check = File.Exists(Path.Combine(Environment.CurrentDirectory, "7zip", OS == "Windows" ? "win32" : "linux", platForm == Architecture.X64 ? "x64" : platForm == Architecture.Arm64 ? "arm64" : platForm == Architecture.Arm ? "arm" : "ia32", OS == "Windows" ? "7za.dll" : "7zz")); 104 | SevenZipBase.SetLibraryPath(Path.Combine(Environment.CurrentDirectory, "7zip", OS == "Windows" ? "win32" : "linux", platForm == Architecture.X64 ? "x64" : platForm == Architecture.Arm64 ? "arm64" : platForm == Architecture.Arm ? "arm" : "ia32", OS == "Windows" ? "7za.dll" : "7zz")); 105 | } 106 | 107 | 108 | public static async Task DownloadAsync(this HttpClient client, string requestUri, Stream destination, IProgress progress = null, CancellationToken cancellationToken = default) 109 | { 110 | // Get the http headers first to examine the content length 111 | using (var response = await client.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead)) 112 | { 113 | var contentLength = response.Content.Headers.ContentLength; 114 | 115 | using (var download = await response.Content.ReadAsStreamAsync()) 116 | { 117 | 118 | // Ignore progress reporting when no progress reporter was 119 | // passed or when the content length is unknown 120 | if (progress == null || !contentLength.HasValue) 121 | { 122 | await download.CopyToAsync(destination); 123 | return; 124 | } 125 | 126 | // Convert absolute progress (bytes downloaded) into relative progress (0% - 100%) 127 | var relativeProgress = new Progress(totalBytes => progress.Report((float)totalBytes / contentLength.Value)); 128 | // Use extension method to report progress while downloading 129 | await download.CopyToAsync(destination, 81920, relativeProgress, cancellationToken); 130 | progress.Report(1); 131 | } 132 | } 133 | } 134 | 135 | public static async Task CopyToAsync(this Stream source, Stream destination, int bufferSize, IProgress progress = null, CancellationToken cancellationToken = default) 136 | { 137 | if (source == null) 138 | throw new ArgumentNullException(nameof(source)); 139 | if (!source.CanRead) 140 | throw new ArgumentException("Has to be readable", nameof(source)); 141 | if (destination == null) 142 | throw new ArgumentNullException(nameof(destination)); 143 | if (!destination.CanWrite) 144 | throw new ArgumentException("Has to be writable", nameof(destination)); 145 | if (bufferSize < 0) 146 | throw new ArgumentOutOfRangeException(nameof(bufferSize)); 147 | 148 | var buffer = new byte[bufferSize]; 149 | long totalBytesRead = 0; 150 | int bytesRead; 151 | while ((bytesRead = await source.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0) 152 | { 153 | await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false); 154 | totalBytesRead += bytesRead; 155 | progress?.Report(totalBytesRead); 156 | } 157 | } 158 | 159 | 160 | public static void setAffinityMask(Process p) 161 | { 162 | // Récupération du nombre de processeurs logiques sur le système 163 | int processorCount = Environment.ProcessorCount; 164 | 165 | if (processorCount < 5) 166 | return; 167 | 168 | // Calcul du masque d'affinité en utilisant tous les threads disponibles 169 | long affinityMask = 0; 170 | for (int i = 0; i < processorCount; i++) 171 | { 172 | if (i % 2 == 0) // Activer chaque autre thread 173 | { 174 | affinityMask |= 1L << i; 175 | } 176 | } 177 | p.ProcessorAffinity= (IntPtr)affinityMask; 178 | } 179 | 180 | public static void SetPowerSavingMode(bool enable) 181 | { 182 | try 183 | { 184 | const int SC_MONITORPOWER = 0xF170; 185 | const int WM_SYSCOMMAND = 0x0112; 186 | 187 | IntPtr HWND_BROADCAST = new IntPtr(0xffff); 188 | 189 | int monitorState = enable ? 2 : -1; // 2 = POWER_ON, -1 = POWER_OFF 190 | 191 | NativeMethods.SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, monitorState); 192 | } 193 | catch (Exception ex) 194 | { 195 | Console.WriteLine("Error setting power saving mode: " + ex.Message); 196 | } 197 | } 198 | 199 | 200 | public static void KillProcessesByCpuUsage(float cpuUsageThreshold) 201 | { 202 | Process[] processes = Process.GetProcesses(); 203 | String[] ignoreProcessNames = new string[] { "explorer", "taskmgr", "System", "Idle" }; 204 | 205 | foreach (Process process in processes) 206 | { 207 | try 208 | { 209 | if (process.Id == Process.GetCurrentProcess().Id || ignoreProcessNames.Contains(process.ProcessName)) 210 | continue; 211 | 212 | if (process.TotalProcessorTime.TotalSeconds > TimeSpan.FromSeconds(cpuUsageThreshold).TotalSeconds) 213 | { 214 | UI.MainUI.addTextConsole($"Terminating process: {process.ProcessName} (ID: {process.Id})\n"); 215 | process.Kill(); 216 | 217 | } 218 | } 219 | catch (Exception ex) 220 | { 221 | Console.WriteLine($"Error terminating process: {process.ProcessName} (ID: {process.Id})"); 222 | Console.WriteLine(ex.Message); 223 | } 224 | } 225 | } 226 | 227 | 228 | 229 | 230 | internal static class NativeMethods 231 | { 232 | [System.Runtime.InteropServices.DllImport("user32.dll")] 233 | internal static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); 234 | } 235 | } 236 | } 237 | --------------------------------------------------------------------------------