mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
chore: fix some warnings, cleanup
This commit is contained in:
parent
9a38a9470c
commit
96ed22534c
49 changed files with 413 additions and 440 deletions
34
Dalamud.Injector/ExistingProcess.cs
Normal file
34
Dalamud.Injector/ExistingProcess.cs
Normal 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) });
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue