mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-21 07:17:45 +01:00
ntdll
This commit is contained in:
parent
d9a698fe19
commit
d663252ed1
2 changed files with 79 additions and 2 deletions
|
|
@ -1,11 +1,65 @@
|
||||||
|
using Microsoft.Win32.SafeHandles;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Dalamud.Injector.FFI
|
namespace Dalamud.Injector.FFI
|
||||||
{
|
{
|
||||||
internal static class Win32
|
internal static class Win32
|
||||||
{
|
{
|
||||||
|
[DllImport("kernel32", CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||||
|
public static extern SafeProcessHandle OpenProcess(uint dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwProcessId);
|
||||||
|
|
||||||
|
[DllImport("kernel32", CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||||
|
public static extern NtStatus NtQueryInformationProcess(/* TODO */);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal partial struct NtStatus
|
||||||
|
{
|
||||||
|
public uint Value { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal partial struct NtStatus
|
||||||
|
{
|
||||||
|
public NtStatus(uint value)
|
||||||
|
{
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Equivalent to NT_SUCCESS
|
||||||
|
/// </summary>
|
||||||
|
public bool Success => Value <= 0x7FFFFFFF;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Equivalent to NT_INFORMATION
|
||||||
|
/// </summary>
|
||||||
|
public bool Information => 0x40000000 <= Value && Value <= 0x7FFFFFFF;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Equivalent to NT_WARNING
|
||||||
|
/// </summary>
|
||||||
|
public bool Warning => 0x80000000 <= Value && Value <= 0xBFFFFFFF;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Equivalent to NT_ERROR
|
||||||
|
/// </summary>
|
||||||
|
public bool Error => 0xC0000000 <= Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct PROCESS_BASIC_INFORMATION
|
||||||
|
{
|
||||||
|
// https://github.com/processhacker/processhacker/blob/e43d7c0513ec5368c3309a58c9f2c2a3ca5de367/phnt/include/ntpsapi.h#L272
|
||||||
|
public NtStatus ExitStatus;
|
||||||
|
public IntPtr PebBaseAddress;
|
||||||
|
public IntPtr AffinityMask;
|
||||||
|
public IntPtr BasePriority;
|
||||||
|
public IntPtr UniqueProcessId;
|
||||||
|
public IntPtr InheritedFromUniqueProcessId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,33 @@
|
||||||
using System;
|
using Microsoft.Win32.SafeHandles;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Dalamud.Injector.OS
|
namespace Dalamud.Injector.OS
|
||||||
{
|
{
|
||||||
internal sealed class Process
|
internal sealed partial class Process : IDisposable
|
||||||
{
|
{
|
||||||
|
private SafeProcessHandle m_handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed partial class Process {
|
||||||
|
internal Process(SafeProcessHandle handle)
|
||||||
|
{
|
||||||
|
m_handle = handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Process Open(uint pid/* and perms? maybe? */)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
throw new NotImplementedException("TODO");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
m_handle?.Dispose();
|
||||||
|
m_handle = null!;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue