chore: fix some warnings, cleanup

This commit is contained in:
goat 2022-04-25 20:04:17 +02:00
parent 9a38a9470c
commit 96ed22534c
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
49 changed files with 413 additions and 440 deletions

View file

@ -0,0 +1,34 @@
using System;
using System.Diagnostics;
using System.Reflection;
using Microsoft.Win32.SafeHandles;
namespace Dalamud.Injector;
/// <summary>
/// Class representing an already held process handle.
/// </summary>
internal class ExistingProcess : Process
{
/// <summary>
/// Initializes a new instance of the <see cref="ExistingProcess"/> class.
/// </summary>
/// <param name="handle">The existing held process handle.</param>
public ExistingProcess(IntPtr handle)
{
this.SetHandle(handle);
}
private void SetHandle(IntPtr handle)
{
var baseType = this.GetType().BaseType;
if (baseType == null)
return;
var setProcessHandleMethod = baseType.GetMethod(
"SetProcessHandle",
BindingFlags.NonPublic | BindingFlags.Instance);
setProcessHandleMethod?.Invoke(this, new object[] { new SafeProcessHandle(handle, true) });
}
}