feat: make bufflength optional on write and search methods#42
Merged
Conversation
bufflength now defaults to None on write_process_memory, search_by_value, search_by_value_between and search_by_addresses, so the value/addresses can be passed by keyword without a placeholder None. - numeric types fall back to their default width (int->4, float->8, bool->1) - str/bytes infer the width from the value on search_by_value/_between (search_by_addresses still needs an explicit size: no value to measure) - a new UNSET sentinel keeps value/start/end/addresses required while bufflength has a default; a clear error is raised when they are omitted - positional calls keep working unchanged Docs and tests updated accordingly.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
bufflengthis now optional (defaults toNone) onwrite_process_memory,search_by_value,search_by_value_betweenandsearch_by_addresses. Previously it was a required positional parameter sitting before the value, forcing calls likewrite_process_memory(addr, str, None, "hi"). Now you can simply write:Behavior
int/float/bool) fall back to their default width (4/8/1) whenbufflengthis omitted.str/bytesonsearch_by_value/search_by_value_betweeninfer the width from the value being searched (UTF-8 forstr; the longer endpoint for a range search).search_by_addressesstill requires an explicit size forstr/bytes— there is no value to infer the width from, only addresses to read (same asread_process_memory).UNSETsentinel keepsvalue/start/end/addressesrequired whilebufflengthcarries a default; omitting them raises a clearTypeError.write_process_memory(addr, int, 4, 99)andsearch_by_value(int, 4, 100)are fully backward compatible.Changes
util/convert.py:UNSETsentinel andresolve_bufflength_for_valuehelper;prepare_writevalidates a missing value.process/abstract.py+win32/linux/macosbackends: optionalbufflength, sentinel-defaulted required args, updated docstrings.read-write,searching,openprocess,index) updated; no more positional-Noneexamples.Verification
make type-check(mypy): clean.