Enums
ScanTypesEnum
- class ScanTypesEnum
Comparison modes for
search_by_value()andsearch_by_value_between().
from PyMemoryEditor import ScanTypesEnum
| Member | Value | Matches when… |
|---|---|---|
EXACT_VALUE | 0 | value == target (default) |
NOT_EXACT_VALUE | 1 | value != target |
BIGGER_THAN | 2 | value > target |
SMALLER_THAN | 3 | value < target |
BIGGER_THAN_OR_EXACT_VALUE | 4 | value ≥ target |
SMALLER_THAN_OR_EXACT_VALUE | 5 | value ≤ target |
VALUE_BETWEEN | 6 | min ≤ value ≤ max (used by search_by_value_between) |
NOT_VALUE_BETWEEN | 7 | value < min or value > max |
Example
from PyMemoryEditor import OpenProcess, ScanTypesEnum
with OpenProcess(process_name="game.exe") as process:
for address in process.search_by_value(int, value=1000, scan_type=ScanTypesEnum.BIGGER_THAN):
print(hex(address))
ProcessOperationsEnum (Windows only)
- class ProcessOperationsEnum
Bitmask of Windows process access rights, passed as the
permission=argument ofOpenProcesson Windows.
Bitmask of process access rights.
Defined as IntFlag so members can be combined with |:
from PyMemoryEditor import ProcessOperationsEnum
mask = (
ProcessOperationsEnum.PROCESS_VM_READ
| ProcessOperationsEnum.PROCESS_QUERY_INFORMATION
)
| Member | Hex | Required for |
|---|---|---|
PROCESS_TERMINATE | 0x0001 | TerminateProcess |
PROCESS_CREATE_THREAD | 0x0002 | Creating a thread |
PROCESS_VM_OPERATION | 0x0008 | Allocating / freeing / changing page protection |
PROCESS_VM_READ | 0x0010 | ReadProcessMemory |
PROCESS_VM_WRITE | 0x0020 | WriteProcessMemory |
PROCESS_DUP_HANDLE | 0x0040 | Duplicating a handle |
PROCESS_CREATE_PROCESS | 0x0080 | Creating a process |
PROCESS_SET_QUOTA | 0x0100 | Setting memory limits |
PROCESS_SET_INFORMATION | 0x0200 | Setting priority class, etc. |
PROCESS_QUERY_INFORMATION | 0x0400 | VirtualQueryEx, token info |
PROCESS_SUSPEND_RESUME | 0x0800 | Suspend/resume the process |
PROCESS_QUERY_LIMITED_INFORMATION | 0x1000 | Limited info queries |
PROCESS_SET_LIMITED_INFORMATION | 0x2000 | Limited info set |
PROCESS_ALL_ACCESS | 0x1FFFFF | Everything |
Default permission
The default mask used by OpenProcess on Windows is:
PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION | PROCESS_QUERY_INFORMATION
This is enough for both read and write operations plus region enumeration
(VirtualQueryEx needs PROCESS_QUERY_INFORMATION).
MemoryProtectionsEnum (Windows only)
- class MemoryProtectionsEnum
The Win32
PAGE_*page-protection constants.
The Win32 PAGE_* constants. Used as the permission= argument of
allocate_memory and surfaced in region["struct"].Protect.
from PyMemoryEditor.win32.enums.memory_protections import MemoryProtectionsEnum
| Member | Hex | Meaning |
|---|---|---|
PAGE_NOACCESS | 0x01 | Disables all access. |
PAGE_READONLY | 0x02 | Read-only. |
PAGE_READWRITE | 0x04 | Read + write. |
PAGE_WRITECOPY | 0x08 | Copy-on-write. |
PAGE_EXECUTE | 0x10 | Execute-only. |
PAGE_EXECUTE_READ | 0x20 | Read + execute. |
PAGE_EXECUTE_READWRITE | 0x40 | Read + write + execute. (allocate_memory default) |
PAGE_EXECUTE_WRITECOPY | 0x80 | Read + execute + copy-on-write. |
PAGE_GUARD | 0x100 | Pages become guard pages. |
PAGE_NOCACHE | 0x200 | Non-cachable. |
PAGE_WRITECOMBINE | 0x400 | Write-combined. |
Convenience composites
| Member | Includes |
|---|---|
PAGE_READABLE | Every PAGE_* that allows reads. |
PAGE_READWRITEABLE | Every PAGE_* that allows writes. |