mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-19 14:27:45 +01:00
Change SafeProcessHandle to IntPtr again, ugh
This commit is contained in:
parent
4042d138b2
commit
32af098159
13 changed files with 363 additions and 229 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Dalamud.Bootstrap.OS.Windows.Raw
|
||||
|
|
@ -12,5 +13,11 @@ namespace Dalamud.Bootstrap.OS.Windows.Raw
|
|||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi)]
|
||||
public static extern uint SetEntriesInAclA(ulong cCountOfExplicitEntries, ref ACL oldAcl, out ACL* NewAcl);
|
||||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||
public static extern void BuildExplicitAccessWithNameW(out EXPLICIT_ACCESS_W pExplicitAccess, string pTrusteeName, uint AccessPermissions, ACCESS_MODE AccessMode, uint Inheritance);
|
||||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi)]
|
||||
public static extern uint GetSecurityInfo(IntPtr handle, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,4 +66,62 @@ namespace Dalamud.Bootstrap.OS.Windows.Raw
|
|||
SE_SACL_PROTECTED = 0x2000,
|
||||
SE_SELF_RELATIVE = 0x8000,
|
||||
}
|
||||
|
||||
internal enum ACCESS_MODE : uint
|
||||
{
|
||||
NOT_USED_ACCESS,
|
||||
GRANT_ACCESS,
|
||||
SET_ACCESS,
|
||||
DENY_ACCESS,
|
||||
REVOKE_ACCESS,
|
||||
SET_AUDIT_SUCCESS,
|
||||
SET_AUDIT_FAILURE,
|
||||
}
|
||||
|
||||
internal enum MULTIPLE_TRUSTEE_OPERATION : uint
|
||||
{
|
||||
NO_MULTIPLE_TRUSTEE,
|
||||
TRUSTEE_IS_IMPERSONATE,
|
||||
}
|
||||
|
||||
internal enum TRUSTEE_FORM : uint
|
||||
{
|
||||
TRUSTEE_IS_SID,
|
||||
TRUSTEE_IS_NAME,
|
||||
TRUSTEE_BAD_FORM,
|
||||
TRUSTEE_IS_OBJECTS_AND_SID,
|
||||
TRUSTEE_IS_OBJECTS_AND_NAME,
|
||||
}
|
||||
|
||||
internal enum TRUSTEE_TYPE : uint
|
||||
{
|
||||
TRUSTEE_IS_UNKNOWN,
|
||||
TRUSTEE_IS_USER,
|
||||
TRUSTEE_IS_GROUP,
|
||||
TRUSTEE_IS_DOMAIN,
|
||||
TRUSTEE_IS_ALIAS,
|
||||
TRUSTEE_IS_WELL_KNOWN_GROUP,
|
||||
TRUSTEE_IS_DELETED,
|
||||
TRUSTEE_IS_INVALID,
|
||||
TRUSTEE_IS_COMPUTER,
|
||||
}
|
||||
|
||||
internal enum SE_OBJECT_TYPE : uint
|
||||
{
|
||||
|
||||
SE_UNKNOWN_OBJECT_TYPE,
|
||||
SE_FILE_OBJECT,
|
||||
SE_SERVICE,
|
||||
SE_PRINTER,
|
||||
SE_REGISTRY_KEY,
|
||||
SE_LMSHARE,
|
||||
SE_KERNEL_OBJECT,
|
||||
SE_WINDOW_OBJECT,
|
||||
SE_DS_OBJECT,
|
||||
SE_DS_OBJECT_ALL,
|
||||
SE_PROVIDER_DEFINED_OBJECT,
|
||||
SE_WMIGUID_OBJECT,
|
||||
SE_REGISTRY_WOW64_32KEY,
|
||||
SE_REGISTRY_WOW64_64KEY
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using Microsoft.Win32.SafeHandles;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
|
@ -10,33 +9,33 @@ namespace Dalamud.Bootstrap.OS.Windows.Raw
|
|||
private const string Name = "kernel32";
|
||||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||
public static extern SafeProcessHandle OpenProcess(uint dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwProcessId);
|
||||
public static extern IntPtr OpenProcess(uint dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwProcessId);
|
||||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool TerminateProcess(SafeProcessHandle hProcess, int uExitCode);
|
||||
public static extern bool TerminateProcess(IntPtr hProcess, int uExitCode);
|
||||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool ReadProcessMemory(SafeProcessHandle hProcess, IntPtr lpBaseAddress, void* lpBuffer, IntPtr nSize, out IntPtr lpNumberOfBytesRead);
|
||||
public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, void* lpBuffer, IntPtr nSize, out IntPtr lpNumberOfBytesRead);
|
||||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool WriteProcessMemory(SafeProcessHandle hProcess, IntPtr lpBaseAddress, void* lpBuffer, IntPtr nSize, out IntPtr lpNumberOfBytesWritten);
|
||||
public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, void* lpBuffer, IntPtr nSize, out IntPtr lpNumberOfBytesWritten);
|
||||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||
public static extern void* LocalFree(void* hMem);
|
||||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi)]
|
||||
public static extern uint GetProcessId(SafeProcessHandle hProcess);
|
||||
public static extern uint GetProcessId(IntPtr hProcess);
|
||||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool GetProcessTimes(SafeProcessHandle hProcess, out FILETIME lpCreationTime, out FILETIME lpExitTime, out FILETIME lpKernelTime, out FILETIME lpUserTime);
|
||||
public static extern bool GetProcessTimes(IntPtr hProcess, out FILETIME lpCreationTime, out FILETIME lpExitTime, out FILETIME lpKernelTime, out FILETIME lpUserTime);
|
||||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool QueryFullProcessImageNameW(SafeProcessHandle hProcess, uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpExeName, ref int lpdwSize);
|
||||
public static extern bool QueryFullProcessImageNameW(IntPtr hProcess, uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpExeName, ref int lpdwSize);
|
||||
|
||||
[DllImport(Name, CallingConvention = CallingConvention.Winapi, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
|
|
|
|||
|
|
@ -131,14 +131,23 @@ namespace Dalamud.Bootstrap.OS.Windows.Raw
|
|||
public IntPtr Dacl;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct EXPLICIT_ACCESS_A
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal unsafe struct TRUSTEE_W
|
||||
{
|
||||
public TRUSTEE_W* pMultipleTrustee;
|
||||
public MULTIPLE_TRUSTEE_OPERATION MULTIPLE_TRUSTEE_OPERATION;
|
||||
public TRUSTEE_FORM TrusteeForm;
|
||||
public TRUSTEE_TYPE TrusteeType;
|
||||
public void* ptstrName;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct EXPLICIT_ACCESS_W
|
||||
{
|
||||
// TODO
|
||||
uint grfAccessPermissions;
|
||||
ACCESS_MODE grfAccessMode;
|
||||
uint grfInheritance;
|
||||
TRUSTEE_A Trustee;
|
||||
TRUSTEE_W Trustee;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue