-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b85ef8e
commit 846a501
Showing
20 changed files
with
354 additions
and
136 deletions.
There are no files selected for viewing
Submodule Natsurainko.FluentCore
updated
5 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
Natsurainko.FluentLauncher/Models/AuthenticateRefreshAccountException.cs
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
Natsurainko.FluentLauncher/Models/CompleteGameResourcesFailedException.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Natsurainko.FluentLauncher/Utils/Extensions/ProcessExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Diagnostics; | ||
using System.Management; | ||
|
||
#nullable disable | ||
namespace Natsurainko.FluentLauncher.Utils.Extensions; | ||
|
||
internal static class ProcessExtensions | ||
{ | ||
public static string GetCommandLine(this Process process) | ||
{ | ||
string cmdLine = null; | ||
using (var searcher = new ManagementObjectSearcher( | ||
$"SELECT CommandLine FROM Win32_Process WHERE ProcessId = {process.Id}")) | ||
{ | ||
// By definition, the query returns at most 1 match, because the process | ||
// is looked up by ID (which is unique by definition). | ||
using (var matchEnum = searcher.Get().GetEnumerator()) | ||
{ | ||
if (matchEnum.MoveNext()) // Move to the 1st item. | ||
{ | ||
cmdLine = matchEnum.Current["CommandLine"]?.ToString(); | ||
} | ||
} | ||
} | ||
if (cmdLine == null) | ||
{ | ||
// Not having found a command line implies 1 of 2 exceptions, which the | ||
// WMI query masked: | ||
// An "Access denied" exception due to lack of privileges. | ||
// A "Cannot process request because the process (<pid>) has exited." | ||
// exception due to the process having terminated. | ||
// We provoke the same exception again simply by accessing process.MainModule. | ||
var dummy = process.MainModule; // Provoke exception. | ||
} | ||
return cmdLine; | ||
} | ||
} |
Oops, something went wrong.