mirror of https://github.com/dahall/Vanara.git
Added SECURITY_CAPABILITIES and UMS_CREATE_THREAD_ATTRIBUTES
parent
c3dac3adc6
commit
36c538f872
|
@ -51,8 +51,8 @@ namespace Vanara.PInvoke
|
|||
/// </para>
|
||||
/// <para>To unregister the callback function, use the RemoveSecureMemoryCacheCallback function.</para>
|
||||
/// </remarks>
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/api/winnt/nc-winnt-psecure_memory_cache_callback
|
||||
// BOOLEAN PsecureMemoryCacheCallback( PVOID Addr, SIZE_T Range ) {...}
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/api/winnt/nc-winnt-psecure_memory_cache_callback BOOLEAN
|
||||
// PsecureMemoryCacheCallback( PVOID Addr, SIZE_T Range ) {...}
|
||||
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
|
||||
[PInvokeData("winnt.h", MSDNShortId = "abde4b6f-7cd8-4a4b-9b00-f035b2c29054")]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
|
@ -161,83 +161,6 @@ namespace Vanara.PInvoke
|
|||
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
|
||||
public delegate void RtlUmsSchedulerEntryPoint(RTL_UMS_SCHEDULER_REASON Reason, IntPtr ActivationPayload, IntPtr SchedulerParam);
|
||||
|
||||
/// <summary>Used by thread context functions.</summary>
|
||||
[PInvokeData("winnt.h")]
|
||||
public static class CONTEXT_FLAG
|
||||
{
|
||||
private static readonly uint systemContext;
|
||||
|
||||
static CONTEXT_FLAG()
|
||||
{
|
||||
GetNativeSystemInfo(out var info);
|
||||
switch (info.wProcessorArchitecture)
|
||||
{
|
||||
case ProcessorArchitecture.PROCESSOR_ARCHITECTURE_INTEL:
|
||||
systemContext = CONTEXT_i386;
|
||||
break;
|
||||
case ProcessorArchitecture.PROCESSOR_ARCHITECTURE_ARM:
|
||||
systemContext = CONTEXT_ARM;
|
||||
break;
|
||||
case ProcessorArchitecture.PROCESSOR_ARCHITECTURE_AMD64:
|
||||
systemContext = CONTEXT_AMD64;
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException("Processor context not recognized.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_AMD64 = 0x00100000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_ARM = 0x00200000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_i386 = 0x00010000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_CONTROL => systemContext | 0x00000001;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_INTEGER => systemContext | 0x00000002;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_SEGMENTS => systemContext | 0x00000004;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_FLOATING_POINT => systemContext | 0x00000008;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_DEBUG_REGISTERS => systemContext | 0x00000010;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_EXTENDED_REGISTERS => systemContext | 0x00000020;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_FULL => CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_ALL => CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_XSTATE => systemContext | 0x00000040;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_KERNEL_DEBUGGER = 0x04000000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_EXCEPTION_ACTIVE = 0x08000000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_SERVICE_ACTIVE = 0x10000000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_EXCEPTION_REQUEST = 0x40000000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_EXCEPTION_REPORTING = 0x80000000;
|
||||
}
|
||||
|
||||
/// <summary>The flags that control the enforcement of the minimum and maximum working set sizes.</summary>
|
||||
[PInvokeData("winnt.h")]
|
||||
[Flags]
|
||||
|
@ -319,16 +242,22 @@ namespace Vanara.PInvoke
|
|||
{
|
||||
/// <summary>Query the section object for information about the section. Drivers should set this flag.</summary>
|
||||
SECTION_QUERY = 0x0001,
|
||||
|
||||
/// <summary>Write views of the section.</summary>
|
||||
SECTION_MAP_WRITE = 0x0002,
|
||||
|
||||
/// <summary>Read views of the section.</summary>
|
||||
SECTION_MAP_READ = 0x0004,
|
||||
|
||||
/// <summary>Execute views of the section.</summary>
|
||||
SECTION_MAP_EXECUTE = 0x0008,
|
||||
|
||||
/// <summary>Dynamically extend the size of the section.</summary>
|
||||
SECTION_EXTEND_SIZE = 0x0010,
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
SECTION_MAP_EXECUTE_EXPLICIT = 0x0020,
|
||||
|
||||
/// <summary>All of the previous flags combined with STANDARD_RIGHTS_REQUIRED.</summary>
|
||||
SECTION_ALL_ACCESS = ACCESS_MASK.STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE,
|
||||
}
|
||||
|
@ -462,6 +391,52 @@ namespace Vanara.PInvoke
|
|||
public HARDWARE_COUNTER_DATA[] HwCounters;
|
||||
}
|
||||
|
||||
/// <summary>The <c>SECURITY_CAPABILITIES</c> structure defines the security capabilities of the app container.</summary>
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_security_capabilities typedef struct _SECURITY_CAPABILITIES {
|
||||
// #if ... PISID AppContainerSid; #if ... PSID_AND_ATTRIBUTES Capabilities; #else PSID AppContainerSid; #endif #else
|
||||
// PSID_AND_ATTRIBUTES Capabilities; #endif DWORD CapabilityCount; DWORD Reserved; } SECURITY_CAPABILITIES, *PSECURITY_CAPABILITIES, *LPSECURITY_CAPABILITIES;
|
||||
[PInvokeData("winnt.h", MSDNShortId = "1A865519-E042-4871-886C-9AA64D71CCE4")]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SECURITY_CAPABILITIES
|
||||
{
|
||||
/// <summary>The SID of the app container.</summary>
|
||||
public PSID AppContainerSid;
|
||||
|
||||
/// <summary>The specific capabilities.</summary>
|
||||
public IntPtr Capabilities;
|
||||
|
||||
/// <summary>The number of the capabilities.</summary>
|
||||
public uint CapabilityCount;
|
||||
|
||||
/// <summary>This member is reserved. Do not use it.</summary>
|
||||
public uint Reserved;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Specifies attributes for a user-mode scheduling (UMS) worker thread.</para>
|
||||
/// <para>This structure is used with the UpdateProcThreadAttribute function.</para>
|
||||
/// </summary>
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-ums_create_thread_attributes typedef struct
|
||||
// _UMS_CREATE_THREAD_ATTRIBUTES { DWORD UmsVersion; PVOID UmsContext; PVOID UmsCompletionList; } UMS_CREATE_THREAD_ATTRIBUTES, *PUMS_CREATE_THREAD_ATTRIBUTES;
|
||||
[PInvokeData("winnt.h", MSDNShortId = "5d3e1721-c439-49bb-9cb6-8386fa8aaf50")]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct UMS_CREATE_THREAD_ATTRIBUTES
|
||||
{
|
||||
/// <summary>The UMS version for which the application was built. This parameter must be <c>UMS_VERSION</c>.</summary>
|
||||
public uint UmsVersion;
|
||||
|
||||
/// <summary>
|
||||
/// A pointer to a UMS thread context for the worker thread to be created. This pointer is provided by the CreateUmsThreadContext function.
|
||||
/// </summary>
|
||||
public IntPtr UmsContext;
|
||||
|
||||
/// <summary>
|
||||
/// A pointer to a UMS completion list. This pointer is provided by the CreateUmsCompletionList function. The newly created
|
||||
/// worker thread is queued to the specified completion list.
|
||||
/// </summary>
|
||||
public IntPtr UmsCompletionList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Represents a context frame on WOW64. Refer to the header file WinNT.h for the definition of this structure.</para>
|
||||
/// </summary>
|
||||
|
@ -710,5 +685,85 @@ namespace Vanara.PInvoke
|
|||
/// </summary>
|
||||
public bool Granularity { get => GetBit(Flags, 15); set => SetBit(ref Flags, 15, value); }
|
||||
}
|
||||
|
||||
/// <summary>Used by thread context functions.</summary>
|
||||
[PInvokeData("winnt.h")]
|
||||
public static class CONTEXT_FLAG
|
||||
{
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_AMD64 = 0x00100000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_ARM = 0x00200000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_EXCEPTION_ACTIVE = 0x08000000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_EXCEPTION_REPORTING = 0x80000000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_EXCEPTION_REQUEST = 0x40000000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_i386 = 0x00010000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_KERNEL_DEBUGGER = 0x04000000;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public const uint CONTEXT_SERVICE_ACTIVE = 0x10000000;
|
||||
|
||||
private static readonly uint systemContext;
|
||||
|
||||
static CONTEXT_FLAG()
|
||||
{
|
||||
GetNativeSystemInfo(out var info);
|
||||
switch (info.wProcessorArchitecture)
|
||||
{
|
||||
case ProcessorArchitecture.PROCESSOR_ARCHITECTURE_INTEL:
|
||||
systemContext = CONTEXT_i386;
|
||||
break;
|
||||
|
||||
case ProcessorArchitecture.PROCESSOR_ARCHITECTURE_ARM:
|
||||
systemContext = CONTEXT_ARM;
|
||||
break;
|
||||
|
||||
case ProcessorArchitecture.PROCESSOR_ARCHITECTURE_AMD64:
|
||||
systemContext = CONTEXT_AMD64;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidOperationException("Processor context not recognized.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_ALL => CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_CONTROL => systemContext | 0x00000001;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_DEBUG_REGISTERS => systemContext | 0x00000010;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_EXTENDED_REGISTERS => systemContext | 0x00000020;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_FLOATING_POINT => systemContext | 0x00000008;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_FULL => CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_INTEGER => systemContext | 0x00000002;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_SEGMENTS => systemContext | 0x00000004;
|
||||
|
||||
/// <summary>Undocumented.</summary>
|
||||
public static uint CONTEXT_XSTATE => systemContext | 0x00000040;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue