namespace WhiteMagic.Native;
///
/// Access rights that open a process object.
///
[Flags]
public enum ProcessAccess : uint
{
/// The right to terminate the process with TerminateProcess.
Terminate = 0x0001,
/// The right to create a thread in the process.
CreateThread = 0x0002,
/// The right to operate on the address space of the process.
VmOperation = 0x0008,
/// The right to read memory with ReadProcessMemory.
VmRead = 0x0010,
/// The right to write memory with WriteProcessMemory.
VmWrite = 0x0020,
/// The right to duplicate a handle with DuplicateHandle.
DupHandle = 0x0040,
/// The right to set information about the process.
SetInformation = 0x0200,
/// The right to read information about the process, such as the exit code.
QueryInformation = 0x0400,
/// The right to suspend or resume the process.
SuspendResume = 0x0800,
/// The right to read a limited set of information about the process.
QueryLimitedInformation = 0x1000,
/// The right to use the process object for synchronization.
Synchronize = 0x00100000,
/// All access rights for a process object.
AllAccess = 0x001F0000 | Synchronize | 0xFFFF,
}
///
/// Values that control how VirtualAllocEx allocates memory.
///
[Flags]
public enum MemoryAllocationType : uint
{
/// Commit physical storage for the reserved pages. The pages start as zero.
Commit = 0x00001000,
/// Reserve a range of address space without physical storage.
Reserve = 0x00002000,
/// Reset the data in the range to indicate that it is no longer of interest.
Reset = 0x00080000,
/// Allocate memory at the highest possible address.
TopDown = 0x00100000,
}
///
/// Values that protect a block of memory.
///
[Flags]
public enum MemoryProtectionType : uint
{
/// No access to the committed pages.
NoAccess = 0x01,
/// Read access to the committed pages.
ReadOnly = 0x02,
/// Read and write access to the committed pages.
ReadWrite = 0x04,
/// Copy-on-write access to the committed pages.
WriteCopy = 0x08,
/// Execute access to the committed pages.
Execute = 0x10,
/// Execute and read access to the committed pages.
ExecuteRead = 0x20,
/// Execute, read, and write access to the committed pages.
ExecuteReadWrite = 0x40,
/// Execute and copy-on-write access to the committed pages.
ExecuteWriteCopy = 0x80,
/// The pages in the range become guard pages.
Guard = 0x100,
/// The system does not cache the committed pages.
NoCache = 0x200,
/// The system uses write-combined access for the pages.
WriteCombine = 0x400,
}
///
/// Values that control how VirtualFreeEx frees memory.
///
[Flags]
public enum MemoryFreeType : uint
{
/// Decommit the committed pages. The address range stays reserved.
Decommit = 0x4000,
/// Release the range of pages. The size must be zero.
Release = 0x8000,
}
///
/// Values that set the initial state of a new thread.
///
[Flags]
public enum ThreadCreationFlags : uint
{
/// The thread runs immediately after creation.
RunImmediately = 0,
/// The thread starts in a suspended state. Call ResumeThread to start it.
CreateSuspended = 0x00000004,
/// The stack-size parameter sets the reserve size of the stack.
StackSizeParamIsAReservation = 0x00010000,
}
///
/// Flags that select the registers that the thread-context functions read or write.
/// There are separate constants for 32-bit (x86/WOW64) and 64-bit (AMD64) contexts.
///
public static class ContextFlags
{
/// Architecture identifier for x86 contexts.
public const uint X86 = 0x00010000;
/// Architecture identifier for AMD64 contexts.
public const uint Amd64 = 0x00100000;
/// x86: SS:SP, CS:IP, FLAGS, and BP.
public const uint X86Control = X86 | 0x01;
/// x86: AX, BX, CX, DX, SI, and DI.
public const uint X86Integer = X86 | 0x02;
/// x86: DS, ES, FS, and GS.
public const uint X86Segments = X86 | 0x04;
/// x86: control, integer, and segment registers.
public const uint X86Full = X86Control | X86Integer | X86Segments;
/// AMD64: SegSs, Rsp, SegCs, Rip, and EFlags.
public const uint Amd64Control = Amd64 | 0x01;
/// AMD64: Rax, Rcx, Rdx, Rbx, Rbp, Rsi, Rdi, and R8 to R15.
public const uint Amd64Integer = Amd64 | 0x02;
/// AMD64: SegDs, SegEs, SegFs, and SegGs.
public const uint Amd64Segments = Amd64 | 0x04;
/// AMD64: control, integer, and segment registers.
public const uint Amd64Full = Amd64Control | Amd64Integer | Amd64Segments;
}