-
Notifications
You must be signed in to change notification settings - Fork 2
Dangerously hijack file handles to close them #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
BinToss
wants to merge
306
commits into
CodeDead:development
Choose a base branch
from
BinToss:unsafeCloseHandle
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 42 commits
Commits
Show all changes
306 commits
Select commit
Hold shift + click to select a range
3c1b2ca
docs: finish unfinished xml doc
BinToss 2f22c7e
docs: fix invalid reference of renamed enum
BinToss 1236997
docs: clean up re-used docs to reflect new class
BinToss a8ac39b
refactor: replace FileLockerEx.GetFileLockerEx() with constructor
BinToss 47b1bb7
refactor: rename ResultsFilter to HandlesFilter
BinToss 637471f
feat: add equivalent methods for handling handles to public API
BinToss f203ee1
refactor: resolve warning PInvoke004
BinToss 7cd5501
refactor: set structs, fields as readonly; ignore CS0649
BinToss 216a1ef
refactor: override GetHashCode() in pseudo-funcptr
BinToss e52fdbd
refactor: disable warning CS0169 for reserved field
BinToss 3c6cc06
refactor: move EnterDebugMode call to class FileLockerEx
BinToss c1ce4e7
refactor: move HandlesFilter params from const to methods
BinToss a6c31d2
refactor: override SafeFileHandleEx ToString with JSON serialization
BinToss 7616902
refactor: replace ToArray with Add and separate instantiation
BinToss ab3435f
refactor: add method CheckAccess for debugging purposes
BinToss d59487b
refactor: add parameter to pass out WarningException
BinToss 79397ec
refactor: move CsWin32 supplements to new files
BinToss 97e4992
refactor: slightly improve getting process command lines
BinToss 7d49548
refactor: move SYSTEM_HANDLE structs to new files
BinToss 123d581
refactor: catch exceptions thrown by file info queries
BinToss f0763ab
refactor: add constructor for copying a SafeHandleEx
BinToss 0e2083a
refactor: handle System process id issues; move GetFullProcessImageName
BinToss 44bccb8
refactor: ensure correct ACCESS_MASK is used
BinToss 023a2df
refactor: remove unused usings, update prop type and ref
BinToss 780275a
refactor: change ToString from JSON serialization to formatted text
BinToss 7d3ae8e
refactor: change Exception types, misc changes in GetSystemHandleInfoEx
BinToss 572ce32
refactor: use conditional access
BinToss 41b4c5a
refactor: if PID == 4, don't open process handle
BinToss 1f1dc4f
refactor: add more native definitions, supporting Types
BinToss cab4e5b
refactor: inline temporary variable
BinToss 9c29b0a
refactor: rename UnlockSystemHandle to CloseSourceHandle
BinToss 137c35f
refactor: refactor NTSTATUS, mimic dotnet/PInvoke
BinToss a9d70cb
docs: update inline code docs
BinToss 7a21538
style: update file encoding to UTF-8 BOM
BinToss f506116
refactor: move unsafe context to method declaration
BinToss 777e7ee
refactor: simplify 'using' statement
BinToss 96f3e5e
fix: use correct overload for 'out' param modifier
BinToss 0242b56
fix: use correct types for param rgsFileNames of RmRegisterResources
BinToss 58faeaf
docs: remove a TODO (will not implement)
BinToss 1a8cb83
refactor: improve details of custom exceptions
BinToss d1fe87b
refactor: replace target-OS vars with host-OS vars
BinToss ad659aa
refactor: utilize new ctor to init buffer
BinToss 143b27d
refactor: overhaul GetProcessCommandLine
BinToss 4b9135c
refactor: improve GetFullProcessImageName
BinToss ab43042
refactor: assign native handle value to SafeHandle handle field
BinToss 79f2abe
refactor: check if handle is File handle in SafeFileHandleEx ctor
BinToss 33453cc
refactor: improve TryGetFinalPath
BinToss 83c4bb1
refactor: replace C-style (U)LARGE_INTEGER structs with c# types
BinToss 06ac4f6
reactor: add internal method IsDebugModeEnabled
BinToss f13cff9
build: set EmitCompilerGeneratedFiles to true
BinToss e11386b
refactor: update NativeMethods.txt symbols
BinToss ee29401
style: remove trailing whitespace
BinToss 23a207f
refactor: clarify exception; make Path readonly
BinToss 63dc718
refactor: move SafeBufferT; add instance methods; utilize it
BinToss 75dc135
docs: update inline documentation
BinToss f652e54
style: remove trailing whitespace
BinToss 19469b6
refactor: move UIntPtr64<T> to new file
BinToss 8dd3f01
refactor: add struct PS_PROTECTION
BinToss 8605bce
refactor: display NTSTATUS Code enum value in debugger
BinToss 911b58e
refactor: remove redundant member 'AtlThunkSListPtr32'
BinToss 2efab6f
refactor: finish OBJECT_TYPES_INFORMATION definition
BinToss edd8920
refactor: set LDR_DATA_TABLE_ENTRY members to readonly
BinToss 01edeb7
style: remove trailing whitespace
BinToss f128e47
refactor: set structs or their members to readonly
BinToss 49b0e18
style: remove trailing whitespace
BinToss 3eca414
chore: disable CS0649 for readonly interop structs
BinToss af39417
fix: properly convert UNICODE_STRING 'byte' length to string's 'char'…
BinToss a3057cc
refactor: replace LARGE_INTEGER with long
BinToss cf09984
fix: use non-generic LIST_ENTRY
BinToss 72c5d2d
fix: prevent runtime TypeLoadException
BinToss 53a3cde
fix: UNICODE_STRING.ToStringLength() no longer returns garbage
BinToss 0a44710
refactor: rename two functions back to their original names
BinToss 70f8390
refactor: change ObjectTypesInformationBuffer to internal
BinToss 51b3682
refactor: rename function to original
BinToss dd2a087
refactor: move const to local scope
BinToss 9ee76c8
refactor: add GetSafeHandle() to system handle
BinToss 625e24c
refactor: set HANDLE members to internal
BinToss 894e679
refactor: replace PhGetObjectTypeName with custom solution
BinToss 06e1882
refactor: remove dysfunctional Ph functions
BinToss c83db4d
refactor: add GetHandleInformation method to system handle
BinToss 5bc848a
refactor: update usings
BinToss ef4337e
refactor: simplify access to JsonIgnore
BinToss 15fdd44
refactor: rename GetHandleInformation wrapper
BinToss abf91de
refactor: remove unused ToSafeFileHandle()
BinToss 34128bf
refactor: base ObjectTypesInformationBuffer on SafeBuffer<T>
BinToss dcdee0b
refactor: set SYSTEM_HANDLE_INFORMATION_EX as readonly
BinToss 96016f1
refactor: compare against Win32ErrorCode
BinToss c4d3ece
docs: remove old TODO
BinToss 952f1ba
refactor: remove ObjectTypesInformationBuffer
BinToss bca3936
refactor: move SYSTEM_HANDLE_INFORMATION_EX to Windows.Win32
BinToss 326cfaa
docs: remove old comments
BinToss 247e2eb
refactor: make NTSTATUS more similar to PInvoke definition
BinToss 238ce6b
refactor: add exception-throwing wrapper for GetHandleInformation
BinToss aa3a482
refactor: move IsFileHandle() to SafeHandleEx
BinToss feee78c
refactor: add TryGetFullProcessImageName
BinToss 8e46b33
refactor: return a tuple, as intended
BinToss 8d24878
refactor: move SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX to Windows.Win32
BinToss 6576402
refactor: add exception message
BinToss 8b43267
refactor: rework SafeHandleEx constructor, properties
BinToss 5048cdd
refactor: rework SafeFileHandleEx constructor, properties
BinToss 8b3df17
refactor: rework TryGetFinalPath()
BinToss 91655bc
refactor: finish SafeFileHandleEx.ToString()
BinToss 9cd45c6
refactor: remove redundant FreeHGlobal
BinToss b110aea
refactor: make NativeMethods non-partial
BinToss 28593c1
refactor: rewrite FindLockingHandles' Discard()
BinToss 64786cc
refactor: remove old DEBUG preprocessor ops
BinToss 48d4d12
refactor: change PS_PROTECTION to public, add enums
BinToss a92efb1
refactor: return exception to FileHandleType when IsFileHandle.v is n…
BinToss 71ac75a
refactor: convert FileName Get to block body with if-else
BinToss b86b304
refactor: remove redundant "is (not) default" checks
BinToss 05ac570
refactor: ensure all native GetProcessCommandLine exceptions are wrap…
BinToss 4a6cdf6
chore: split, update FileLockerEx TODO
BinToss 91860f6
docs: update FileLockerEx ctor 'remarks' with Debug, Admin notes
BinToss 5d50cc6
refactor: update HandlesFilter enum with IncludeProtectedProcesses
BinToss c07b8a1
refactor: remove unused variable 'exceptionData'
BinToss cc81b4b
refactor: prefix 'safe' GetProcessCommandLine with 'Try'
BinToss d8870cd
refactor: add return statements to expedite ProcessName Get accessor
BinToss 62f6ca1
refactor: convert ProcessMainModulePath body to expression
BinToss 7bc0972
refactor: simplify reference to NTSTATUS.Code enum
BinToss 06f05dd
refactor: convert HandleObject if-else to switch statement
BinToss fdb3a77
refactor: add SafeHandleEx.ProcessProtection property
BinToss 0750c40
refactor: convert ProcessIsProtected body to expression
BinToss ea8e997
refactor: check process protection for command line accessibility
BinToss a0dd6d6
style: change file encoding to UTF-8 with BOM
BinToss 7831d99
revert: remove try-catch from GetHandleObjectType
BinToss 1e5c1b0
refactor: wrap the entirety of TryGetFinalPath in try-catch
BinToss a07d7b5
refactor: implement IEquatable for PS_PROTECTION
BinToss 306e842
refactor: change which FileLockerEx ctor is used by FindLockingHandl…
BinToss d4c3247
refactor: add SafeFileHandleEx.FileNameInfo
BinToss c749fe3
refactor: remove silly, unused explicit operator from OBJECT_TYPES_IN…
BinToss d6f3e2c
docs: update docs for some OBJECT_INFORMATION_CLASS enums
BinToss ea2fb9f
docs: add missing exception doc for GetHandleObjectType()
BinToss 26c04bc
docs: add description for typeparam T of SafeBuffer<T>
BinToss 21d6048
refactor: inline TryGetFullProcessImageName
BinToss 57d0b38
docs: add UnauthorizedAccessException info for GetFullProcessImageName
BinToss 931038e
fix: prevent redundant unsuccessful Get ProcessProtection calls
BinToss 1f84d0c
refactor: add SafeHandle.ObjectName property
BinToss 9b01fe9
refactor: replace HandleObjectType's ProcessIsProtected refs with Pro…
BinToss 02a2afc
docs: add summaries for FileType
BinToss 09a4a4a
refactor: rewrite TryGetFinalPath exception conditions
BinToss 8faaca9
refactor: use UnauthorizedAccessExceptions where applicable
BinToss 419a38b
refactor: add ProcessInfo
BinToss c887584
refactor: change FindLockingHandles return type to List<ProcessInfo>
BinToss d8f6c6f
refactor: reduce TryGetFinalPath timeout
BinToss e44c523
docs: add ObjectName summary, examples of string values
BinToss a1ced27
fix: change string comparison operator
BinToss 6d8ca88
fix: handle null and zero-length returns for ObjectName
BinToss 2bc267b
refactor: add TryGetFinalPath stopwatch
BinToss 05bf4f7
feat: allow user to specify the how the handle list is sorted
BinToss 5dc8a17
docs: refine FileLockerEx.Path summary
BinToss 2f461e0
feat: add class ProcessQueryHandle to store access rights with handle
BinToss 717bf36
refactor: move process properties, methods to ProcessInfo
BinToss 3ee71ca
refactor: remove instanced process lists from FileLockerEx
BinToss e7b2019
build: expose CsWin32 API publicly
BinToss b186662
fix: assign correct field offsets for PROCESS_BASIC_INFORMATION64
BinToss 7df3ebc
build: add CsWin32 symbol IsWow64Process2
BinToss 4b05eeb
refactor: add explicit cast (T*)UIntPtr64<T>
BinToss 2f1b50d
refactor: remove unused usings
BinToss bcb5a94
docs: add FindLockingHandles remarks, TODO: review keep()
BinToss 3b61f26
refactor: make PROCESS_BASIC_INFORMATION public
BinToss a600f8f
refactor: add missing managed array properties
BinToss 8249163
refactor: remove PEB_Ex
BinToss a24601a
refactor: add record struct ProcessAndHostOSArch
BinToss e2bd6bb
perf: replace enum.HasFlag() with & operator
BinToss 67b48d1
refactor: add wrapper classes for 32-bit, 64-bit native definitions
BinToss 28d3dc5
refactor: add implicit cast of ProcessQueryHandle to SafeProcessHandle
BinToss 3ba04cc
refactor: remove alias of global::PInvoke.NTSTATUS
BinToss 436427e
fix: reference ProcessInfo.ProcessId instead of ProcessInfo.Process.Id
BinToss 12e7bdb
refactor: add properties Is32BitEmulatedProcess, ProcessAndHostOSArch
BinToss 29d8a20
refactor: pass Is32BitEmulateProcess to GetProcessCommandLine
BinToss acb957b
perf: assign return values to backing field
BinToss b142b96
refactor: add GetPropertiesViaProcessHandle(), ParentId
BinToss 696e434
refactor: shorten ProcessMainModulePath, ProcessName accessors
BinToss 89aa84f
refractor: remove ProcessInfo.ProcessIsProtected
BinToss e7ce7d6
refactor: add ParentId to SafeFileHandleEx.ToString()
BinToss dfeb9e9
fix: SortByProperty.HandleType sorts by HandleObjectType
BinToss ac118fc
refactor: rename ObjectProperName to ObjectRealName
BinToss 8c740cd
feat: add property safeFileHandleEx.IsFilePathRemote
BinToss df1c8e0
refactor: make CsWin32 additions public
BinToss bbac7d1
refactor: remove orphaned isProcessProtected field
BinToss 30bf1ad
refactor: simplify some ProcessInfo properties
BinToss 28b6631
refactor: change ProcessCommandLine to call GetPropertiesViaProcessHa…
BinToss 9e5cf56
refactor: add PS_PROTECTION.GetHashCode() override
BinToss f600e61
refactor: make ProcessProtection compare field to (null, null) instea…
BinToss 9045fa2
fix: allow casting List<ProcessInfo> to/from ProcessList
BinToss cc5c5a1
refactor: change Trace.WriteLine calls to Trace.TraceError
BinToss 61d8c30
refactor: make FileName check ObjectName if FileFullPath is null
BinToss b4f8987
refactor: inline TryGetFinalPath
BinToss 29e198d
fix: update remaining references of FILE_NAME enum to GETFINALPATHNAM…
BinToss acd9b15
refactor: copy TryGetFinalPath docs to FileFullPath
BinToss 7d5a7b8
refactor: remove TryGetFinalPath
BinToss 82ae66d
refactor: change handleObjectType from private to protected
BinToss edbaae2
refactor: override base IsClosed with call to GetHandleInformation
BinToss 2267f20
refactor: change objectName from private to protected
BinToss ea518ac
refactor: allow calling SafeFileHandleEx.ToString without initializin…
BinToss fbe991c
refactor: move HANDLE_FLAGS cast closer to target variable
BinToss 66104ff
refactor: add constants for FileFullPath strings
BinToss ee46bfb
refactor: do not normalize FileFullPath when IsFilePathRemote
BinToss 3431542
refactor: use PInvoke.Win32Exception wrapper in ProcessInfo
BinToss d0cadd7
refactor: make get_ProcessHandle assign values to canGetQueryLimitedI…
BinToss 8102108
refactor: make GetFullProcessImageName an instance method
BinToss d037aac
refactor: use SafeBuffer<T> instead of PWSTR
BinToss a1f886f
refactor: add const error messages to ProcessHandle
BinToss b1ca0d9
refactor: compare fields to const values instead of default
BinToss 5dd5b91
refactor: move UIntPtr32<T> to new file
BinToss 5273f06
refactor: sort SafeFileHandleEx properties lexicographically
BinToss 1c54e02
perf: remove superfluous GetFileInformationByHandleEx task
BinToss 771e379
fix: replace GetFileInformationByHandleEx buffer param with safeBuffer
BinToss f003c8b
refactor: inline temporary variable
BinToss 0e6c43b
fix: assign, return type when GetFileType succeeds
BinToss 0f298a9
refactor: rewrite IsDirectory to use GetFileInformationByHandleEx
BinToss 756d0b7
feat: add HandleAttributes property
BinToss 95d9eb0
refactor: invert if statement; remove else
BinToss beeb6b9
refactor: also check FileNameInfo for FileName processing
BinToss a056ce3
refactor: use errFailedMessage for FileName failures
BinToss 57dc820
feat: add ProcessId property to system handle ex struct; converts fro…
BinToss 28b576d
feat: finish SortByProperty implementation
BinToss e38511c
feat: finish implementing new IsClosed property
BinToss 4dd2396
docs: document GetHandleInfo(), GetHandleInformation(SafeHandle)
BinToss 4251f05
feat: add CloseSourceHandle(bool) overload
BinToss f5e5c72
docs: add readonly HandleAttributes remarks
BinToss 4312a64
fix: convert properties to strings for sorting instead of to byte arrays
BinToss 72fe0a3
fix: do not initialize properties by default when evaluating SafeFile…
BinToss bfb841b
refactor: remove FileFullPath stopwatch
BinToss 7ad0787
chore: sort NativeMethods.txt contents
BinToss 1ddff98
fix: if buffer too small and returnLength is less than buffer length,…
BinToss b4819c2
refactor: use 'is' when comparing to constants
BinToss bfbd325
fix: offset FileNameInfo buffer to start of char sequence
BinToss 36eceb1
fix: convert ex to string, not the ToString method
BinToss 1cdea26
fix: prevent reallocation loops when buffer larger than returnLength
BinToss cbbc524
feat: add NameBuffer placeholder for trailing char array
BinToss 7b052c5
refactor: realign output of SafeFileHandleEx.ToString()
BinToss 0087880
fix: subtract FileNameLength size from buffer length
BinToss 3766142
refactor: remove unnecessary parameter
BinToss 500c7ec
fix: remove trailing null characters from ProcessMainModulePath
BinToss 76a9c29
fix: correctly init, read FileNameInfo buffer
BinToss abae5f7
docs: add FileNameInfo summary
BinToss 491df6c
refactor: inline temporary variable
BinToss d32b6c8
feat: add handle-returning DuplicateHandle overload
BinToss 007e96e
refactor: define Handle-void* conversion
BinToss 7c6ead9
refactor: add overload SysHandleEx.GetHandleInfo(SafeProcessHandle)
BinToss 672cf78
feat: add property DuplicateHandle
BinToss b32aa35
refactor: rename ProcessQueryHandle to SafeProcessHandleEx
BinToss a5c665e
refactor: aggregate granted process access rights to open the SafePro…
BinToss b158c42
refactor: replace ProcessHandle's consecutive try-catch statements wi…
BinToss 886dbb8
fix: duplicate source handle when not owned by current process
BinToss 0375677
docs: update ProcessInfo.ProcessHandle exceptions
BinToss 0ec0c11
fix: finish IsClosed reference refactors
BinToss 0349dd0
fix: use ProcessInfo's ProcessId property, NOT the field
BinToss 192d36d
refactor: change ProcessBasicInformation's buffer reallocation implem…
BinToss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,219 @@ | ||
/// This file supplements code generated by CsWin32 | ||
using System.ComponentModel; | ||
using System.Runtime.InteropServices; | ||
using Windows.Win32.System.Threading; | ||
using NTSTATUS_plus = PInvoke.NTSTATUS; | ||
using NTStatusException = PInvoke.NTStatusException; | ||
|
||
namespace Windows.Win32 | ||
{ | ||
namespace Foundation | ||
{ | ||
internal partial struct HANDLE : IComparable<HANDLE> | ||
{ | ||
public static implicit operator HANDLE(nuint v) => new((nint)v); | ||
public static implicit operator nuint(HANDLE v) => (nuint)(nint)v.Value; | ||
|
||
public static implicit operator HANDLE(nint v) => new(v); | ||
public static implicit operator nint(HANDLE v) => v.Value; | ||
|
||
/// <summary> | ||
/// Close the handle via the CloseHandle function | ||
/// </summary> | ||
/// <exception cref="Win32Exception"> | ||
/// If the application is running under a debugger, the function will throw an | ||
/// exception if it receives either a handle value that is not valid or a | ||
/// pseudo-handle value. This can happen if you close a handle twice, or if you | ||
/// call CloseHandle on a handle returned by the FindFirstFile function instead | ||
/// of calling the FindClose function. | ||
/// </exception> | ||
public void Close() | ||
{ | ||
if (!PInvoke.CloseHandle(this)) | ||
throw new Win32Exception(); | ||
} | ||
|
||
public int CompareTo(HANDLE other) => Value.CompareTo(other); | ||
} | ||
|
||
internal readonly partial struct NTSTATUS | ||
{ | ||
public bool IsSuccessful => SeverityCode == Severity.Success; | ||
|
||
public NTStatusException GetNTStatusException() => new(this); | ||
|
||
public static implicit operator NTSTATUS_plus(NTSTATUS v) => new(v.Value); | ||
public static implicit operator NTSTATUS(NTSTATUS_plus v) => new(v.AsInt32); | ||
} | ||
|
||
internal unsafe readonly partial struct PWSTR : IDisposable | ||
{ | ||
/// <summary> | ||
/// Free the PWSTR's memory with Marshal.FreeHGlobal(IntPtr) | ||
/// </summary> | ||
public void Dispose() => Marshal.FreeHGlobal((IntPtr)Value); | ||
|
||
public static implicit operator PWSTR(IntPtr v) => new((char*)v); | ||
} | ||
|
||
internal partial struct UNICODE_STRING | ||
{ | ||
/// <summary> | ||
/// Allocates a managed string and copies a specified number of characters from an unmanaged Unicode string into it. | ||
/// </summary> | ||
public unsafe string ToStringLength() => Marshal.PtrToStringUni((IntPtr)Buffer.Value, Length); | ||
public string? ToStringZ() => Buffer.ToString(); | ||
public static explicit operator string(UNICODE_STRING v) => v.ToStringLength(); | ||
} | ||
} | ||
|
||
namespace Security | ||
{ | ||
/// <summary> | ||
/// A simple placeholder for dotnet/PInvoke's ACCESS_MASK struct | ||
/// </summary> | ||
/// <remarks>Process access modifiers are found in Windows.Win32.System.Threading.PROCESS_ACCESS_RIGHTS</remarks> | ||
internal struct ACCESS_MASK | ||
{ | ||
public ACCESS_MASK(uint v) | ||
{ | ||
Value = v; | ||
} | ||
|
||
public uint Value; | ||
public PROCESS_ACCESS_RIGHTS ProcessAccess => (PROCESS_ACCESS_RIGHTS)Value; | ||
|
||
public static implicit operator ACCESS_MASK(uint v) => new(v); | ||
public static implicit operator uint(ACCESS_MASK v) => v.Value; | ||
|
||
public const uint DELETE = 0x00010000; | ||
public const uint READ_CONTROL = 0x00020000; | ||
public const uint WRITE_DAC = 0x00040000; | ||
public const uint WRITE_OWNER = 0x00080000; | ||
public const uint SYNCHRONIZE = 0x00100000; | ||
|
||
#region StandardAccess | ||
public const uint STANDARD_RIGHTS_REQUIRED = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER; | ||
|
||
public const uint STANDARD_RIGHTS_READ = READ_CONTROL; | ||
public const uint STANDARD_RIGHTS_WRITE = READ_CONTROL; | ||
public const uint STANDARD_RIGHTS_EXECUTE = READ_CONTROL; | ||
|
||
public const uint STANDARD_RIGHTS_ALL = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE; | ||
|
||
#endregion StandardAccess | ||
|
||
public const uint SPECIFIC_RIGHTS_ALL = 0x0000FFFF; | ||
|
||
/// <summary> | ||
/// AccessSystemAcl access type | ||
/// </summary> | ||
public const uint ACCESS_SYSTEM_SECURITY = 0x01000000; | ||
|
||
/// <summary>These are the generic rights.</summary> | ||
#region GenericRights | ||
public const uint GENERIC_READ = 0x80000000; | ||
public const uint GENERIC_WRITE = 0x40000000; | ||
public const uint GENERIC_EXECUTE = 0x20000000; | ||
public const uint GENERIC_ALL = 0x10000000; | ||
|
||
#endregion GenericRights | ||
/// <summary> | ||
/// MaximumAllowed access type | ||
/// </summary> | ||
public const uint MAXIMUM_ALLOWED = 0x02000000; | ||
} | ||
} | ||
|
||
namespace System.WindowsProgramming | ||
{ | ||
// generated definition lacks SystemHandleInformation, SystemExtendedHandleInformation | ||
internal enum SYSTEM_INFORMATION_CLASS | ||
{ | ||
SystemBasicInformation = 0, | ||
SystemPerformanceInformation = 2, | ||
SystemTimeOfDayInformation = 3, | ||
SystemProcessInformation = 5, | ||
SystemProcessorPerformanceInformation = 8, | ||
SystemHandleInformation = 16, | ||
SystemInterruptInformation = 23, | ||
SystemExceptionInformation = 33, | ||
SystemRegistryQuotaInformation = 37, | ||
SystemLookasideInformation = 45, | ||
SystemExtendedHandleInformation = 64, | ||
SystemCodeIntegrityInformation = 103, | ||
SystemPolicyInformation = 134 | ||
} | ||
|
||
internal enum OBJECT_INFORMATION_CLASS | ||
{ | ||
ObjectBasicInformation = 0, | ||
ObjectNameInformation = 1, | ||
ObjectTypeInformation = 2, | ||
} | ||
} | ||
|
||
namespace System.Threading | ||
{ | ||
[UnmanagedFunctionPointer(CallingConvention.Winapi)] | ||
internal unsafe delegate void PS_POST_PROCESS_INIT_ROUTINE(); | ||
|
||
// Function Pointer workaround. C# 9's function pointers are only allowed in local scope. | ||
internal struct PPS_POST_PROCESS_INIT_ROUTINE : IEquatable<PPS_POST_PROCESS_INIT_ROUTINE> | ||
{ | ||
public IntPtr Value; | ||
|
||
public static explicit operator PPS_POST_PROCESS_INIT_ROUTINE(IntPtr v) | ||
{ | ||
try | ||
{ | ||
_ = Marshal.GetDelegateForFunctionPointer<PS_POST_PROCESS_INIT_ROUTINE>(v); | ||
return new() { Value = v }; | ||
} | ||
catch (Exception) | ||
{ | ||
// not a delegate or open generic type | ||
// or ptr is null | ||
return new() { Value = IntPtr.Zero }; | ||
} | ||
} | ||
|
||
public bool Equals(PPS_POST_PROCESS_INIT_ROUTINE other) => Value == other.Value; | ||
|
||
public override bool Equals(object? obj) | ||
=> obj is PPS_POST_PROCESS_INIT_ROUTINE pPS_POST_PROCESS_INIT_ROUTINE && Equals(pPS_POST_PROCESS_INIT_ROUTINE); | ||
} | ||
|
||
[global::System.CodeDom.Compiler.GeneratedCode("Microsoft.Windows.CsWin32", "0.2.46-beta+0e9cbfc7b9")] | ||
internal struct PROCESS_BASIC_INFORMATION | ||
{ | ||
internal unsafe void* Reserved1; | ||
internal unsafe PEB* PebBaseAddress; | ||
internal __IntPtr_2 Reserved2; | ||
internal nuint UniqueProcessId; | ||
internal unsafe void* Reserved3; | ||
|
||
internal struct __IntPtr_2 | ||
{ | ||
internal IntPtr _0, _1; | ||
|
||
/// <summary>Always <c>2</c>.</summary> | ||
internal readonly int Length => 2; | ||
|
||
/// <summary> | ||
/// Gets a ref to an individual element of the inline array. | ||
/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned reference outlive the stack frame that defines it. | ||
/// </summary> | ||
internal ref IntPtr this[int index] => ref AsSpan()[index]; | ||
|
||
/// <summary> | ||
/// Gets this inline array as a span. | ||
/// </summary> | ||
/// <remarks> | ||
/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned span outlive the stack frame that defines it. | ||
/// </remarks> | ||
internal Span<IntPtr> AsSpan() => MemoryMarshal.CreateSpan(ref _0, 2); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.