Skip to content

Latest commit

 

History

History
132 lines (104 loc) · 6.27 KB

reference.md

File metadata and controls

132 lines (104 loc) · 6.27 KB

Flags, commands, and scan behavior

Invocation

memedit.exe --name <exe> [flags]
memedit.exe --pid <n> [flags]

A --pid above zero selects the target and --name is then ignored. A name lookup walks a process snapshot, compares executable names without regard to case, and takes the first match. Without either flag, memedit exits with specify a target with --pid <n> or --name <exe>.

Flags

Flag Default Meaning
--name <exe> empty Executable name of the target, such as game.exe.
--pid <n> 0 Process ID of the target.
--type <t> int32 Value type: int32, uint32, int64, float32, or float64.
--align <n> value size Alignment of match offsets in bytes, counted from each region's base address. 1 checks every byte offset and is slower.
--workers <n> runtime.NumCPU() Goroutines that scan chunks in parallel.
--chunk <n> 2097152 Bytes read per chunk, before the overlap that catches values crossing a chunk boundary.
--include-mapped false Also scan file-mapped (MEM_MAPPED) regions.
--no-elevate false Do not request Administrator rights through UAC.
--yes false Answer the confirmation prompt for common values with yes.

A value type is 4 bytes wide for int32, uint32, and float32, and 8 bytes wide for int64 and float64.

--align, --workers, and --chunk fall back to their defaults when set to zero or a negative number. memedit raises the chunk size to at least the alignment, then rounds it down to a multiple of the alignment, so that every chunk starts at an aligned offset within its region.

Session commands

memedit reads one command per line from standard input and ignores blank lines.

Command Behavior
first <value> Scan every eligible region and replace the candidates with the matching addresses.
next <value> Keep the candidates that now hold <value>.
next> <value> Keep the candidates that now hold more than <value>.
next< <value> Keep the candidates that now hold less than <value>.
nextchanged Keep the candidates whose bits differ from the previous scan.
nextunchanged Keep the candidates whose bits equal the previous scan.
list [n] Print up to n candidates (default 20) as index, address, and current value.
set <value> Write <value> to every candidate.
set <index> <value> Write <value> to one candidate from the most recent list.
count Print the number of candidates.
reset Discard the candidates, their previous values, and the list indices.
help, h, ? Print the command list.
quit, exit, q End the session.

End of input ends the session as well. Any other word prints unknown command "..." (try 'help') and the session continues.

first prints the region count and total size, a row of up to 40 dots as workers finish chunks, and then the number of matching addresses. It records the scanned value as the previous value of every candidate.

The five next commands need candidates from an earlier first. Each one rereads all of them, drops the addresses it can no longer read, keeps the addresses its comparison accepts, and records the value it just read as the new previous value. next> and next< compare against the value you supply, not against the previous scan.

list shows ? for a candidate it cannot read, and prints showing <n> of <total> candidate(s). It stores the addresses it printed, and only those addresses are reachable through set <index> <value>. Every scan clears that list, so run list again after narrowing.

Both forms of set write without asking for confirmation. set reports wrote <value> to <n> address(es), plus ; <n> failed when a write fails. Neither form updates the previous values that nextchanged and nextunchanged compare against.

Value parsing

Integer inputs accept decimal digits and the 0x, 0o, and 0b prefixes. A leading 0 also means octal, so 010 is 8. A value that overflows the type is rejected, so scan for a value above 2147483647 with --type uint32 rather than --type int32. Float inputs accept the Go literal forms, including exponents such as 1.5e3.

Value matching

first, next, nextchanged, and nextunchanged compare raw bits. For the float types this is exact: -0.0 does not match 0.0, and a NaN matches only a NaN with the same payload. A health bar that displays 100 is rarely stored as exactly 100.0, so an exact float scan often finds nothing. Scan for the value as the game stores it, or narrow by direction with next> and next<.

next> and next< compare numbers in the ordering of the type. The float comparison reports "greater" whenever either side is NaN, so next> keeps every candidate holding NaN and next< drops them all.

No command can recover an address that first missed. When an exact scan finds nothing, run first again with a different value or type.

Scanned memory

A region is scanned when it is committed, not a guard page, and its base protection is PAGE_READWRITE, PAGE_WRITECOPY, PAGE_EXECUTE_READWRITE, or PAGE_EXECUTE_WRITECOPY. File-mapped regions are scanned only with --include-mapped.

Each region is split into chunks that start --chunk bytes apart. A chunk reads that many bytes plus the value size minus one, so a value straddling the boundary is complete in the earlier chunk and is still reported once. memedit skips a chunk it cannot read at all, scans however much a partial read returned, and ignores trailing bytes too short to hold a whole value. It returns the matching addresses in ascending order.

Confirmation for common values

first warns before scanning for a value that can match millions of addresses and use a lot of memory: 0 and 1 for the integer types, and the bit pattern of positive zero for the float types. The prompt is:

warning: 0 may match millions of addresses and use a lot of memory
proceed? [y/N]

The answer comes from the command input, so a piped script loses its next line to the prompt. Only y and yes proceed, in any case and with surrounding spaces allowed. Any other answer or end of input prints scan cancelled and leaves the candidates untouched. --yes prints the warning and skips the prompt.