feat: move syscalls off UI thread; refactor mach write protection - #54
Merged
JeanExtreme002 merged 1 commit intoJun 6, 2026
Merged
Conversation
- CheatTable inline edits are now queued via _CheatPollWorker.request_write() and drained at the top of each tick, keeping write_process_memory off the UI thread. Failures come back through the new write_failed signal. - FirstScanWorker builds the MemoryRegion snapshot off the UI thread when request.build_snapshot=True, emitting it via snapshot_ready for reuse by subsequent refine/update scans. - Extracted _elevated_write_protection context manager from _mach_write so the protect-flip logic can be tested in isolation; _mach_write now defers to it for the retry path. - mach_port_deallocate return value is now checked; failures are logged as warnings instead of being silently swallowed. - Add .github/FUNDING.yml for GitHub Sponsors. - Add maintainers field and Funding URL to pyproject.toml. - Pin hatchling>=1.27 (required for PEP 639 SPDX licence expression). - Add tests for request_write queuing and failure reporting.
github-actions
Bot
deleted the
jeanextreme002/offload-syscalls-off-ui-thread
branch
June 6, 2026 14:09
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
Moves two expensive/potentially-blocking syscalls off the Qt UI thread and
refactors the macOS Mach write path.
Changes
UI-thread write offloading (
cheat_poll_worker.py,cheat_table.py)Inline value edits in the cheat table previously calledwrite_process_memorydirectly on the UI thread. A slow target or a page fault would stall the
interface for the full duration of the syscall. Writes are now queued via
_CheatPollWorker.request_write()and drained at the start of each poll tick.Failures are surfaced through the new
write_failedsignal so the cheat tablecan show an error dialog without the syscall touching the UI thread.
Region snapshot built on scan worker (
scan_worker.py,main_window.py)The first-scan snapshot of memory regions was previously enumerated on the UIthread before the scan worker started. On a large target this could visibly
stall the interface. When
ScanRequest.build_snapshot=Trueand no cachedsnapshot is supplied,
FirstScanWorkernow enumerates regions itself andemits the result via the new
snapshot_readysignal so the main window cancache it for subsequent refine/update scans.
macOS Mach write path (
macos/functions.py)Extracted the protect-flip logic from_mach_writeinto a standalone_elevated_write_protectioncontext manager._mach_writeis now a thinwrapper that calls
mach_vm_writedirectly on the fast path and defers to thecontext manager only on a retry-eligible failure code. The error messages now
consistently report the original kern return, not the one from the retry.
mach_port_deallocateerror handling (macos/functions.py)The return value was previously ignored. Failures are now logged as warnings sosend-right leaks are visible instead of silent.
pyproject.tomlmaintainersfield.FundingURL to[project.urls].hatchling>=1.27(required for the PEP 639 SPDXlicense = "MIT"expression and
license-filesglob already present in the file).**
.github/FUNDING.yml**Added GitHub Sponsors configuration.Tests
Two new tests in
tests/test_cheat_poll_worker.pycover:request_writeis queued and the syscall is deferred until_drain_pending_writesruns.