Extract memory manager#7
Open
CorentinGS wants to merge 7 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the Unicorn API surface by extracting hook, memory, control, and register operations into dedicated manager components, while keeping Unicorn as the primary façade.
Changes:
- Introduces
HookManager,MemoryManager,ControlEngine, andRegisterBankand wires them intoUnicorn.Core. - Relocates memory and hook APIs into new folder structure (
Memory/,Hooks/,Control/) and updatesMemoryRegion/HookBuilderto depend on manager interfaces. - Adds auto-generated register enum constants and new unit tests covering the extracted managers.
Reviewed changes
Copilot reviewed 29 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| UnicornNet/Unicorn.NativeCallbacks.cs | Removed; native hook callback thunks moved into HookManager. |
| UnicornNet/Unicorn.Memory.cs | Removed; memory APIs relocated under UnicornNet/Memory/. |
| UnicornNet/Unicorn.HooksInternal.cs | Removed; internal hook simulation logic moved behind _hooks. |
| UnicornNet/Unicorn.Hooks.cs | Removed; hook registration APIs relocated under UnicornNet/Hooks/. |
| UnicornNet/Unicorn.HookRegistration.cs | Removed; hook registration lifecycle moved into HookManager. |
| UnicornNet/Unicorn.Core.cs | Wires up new manager instances and delegates hook validation/cleanup. |
| UnicornNet/Unicorn.Constants.cs | Updates ControlCommand to optionally carry argument payloads; updates hook delegate commentary. |
| UnicornNet/Registers/Unicorn.Registers.cs | Delegates register read/write to RegisterBank. |
| UnicornNet/Registers/Unicorn.Registers.Constants.cs | Adds auto-generated register enum constants by architecture. |
| UnicornNet/Registers/RegisterBank.cs | New extracted register read/write implementation over native proxy. |
| UnicornNet/Registers/IRegisterBank.cs | New abstraction for register bank operations. |
| UnicornNet/Memory/Unicorn.Memory.cs | Reintroduces Unicorn memory façade delegating to MemoryManager. |
| UnicornNet/Memory/MemoryRegion.cs | Updates to call IMemoryManager rather than Unicorn directly. |
| UnicornNet/Memory/MemoryManager.cs | New extracted memory map/protect/read/write implementation over native proxy. |
| UnicornNet/Memory/IMemoryManager.cs | New abstraction for memory operations used by MemoryRegion. |
| UnicornNet/Hooks/Unicorn.HooksInternal.cs | Reintroduces Unicorn internal hook simulation façade delegating to HookManager. |
| UnicornNet/Hooks/Unicorn.Hooks.cs | Reintroduces Unicorn hook façade delegating to HookManager. |
| UnicornNet/Hooks/IHookManager.cs | New abstraction for hook registration/removal. |
| UnicornNet/Hooks/HookManager.cs | New extracted hook registry, native callback thunks, and simulation logic. |
| UnicornNet/Hooks/HookBuilder.cs | Updated to use IHookManager instead of Unicorn. |
| UnicornNet/Control/Unicorn.Control.cs | Adds Unicorn control façade delegating to ControlEngine. |
| UnicornNet/Control/IControlEngine.cs | New abstraction for control operations. |
| UnicornNet/Control/ControlEngine.cs | New extracted uc_ctl forwarding implementation over native proxy. |
| UnicornNet.Tests/RegisterBankTests.cs | Adds tests for register serialization/deserialization and enum normalization. |
| UnicornNet.Tests/NewFeaturesTests.cs | Updates MemoryRegion construction to use IMemoryManager test double. |
| UnicornNet.Tests/MemoryManagerTests.cs | Adds tests for MemoryManager forwarding and MemoryRegion manager usage. |
| UnicornNet.Tests/HookManagerTests.cs | Adds tests for non-generic public hook registration API and fake manager behavior. |
| UnicornNet.Tests/FakeNativeProxy.cs | Extends test native proxy to record memory operations for new tests. |
| UnicornNet.Tests/FakeHookManager.cs | Adds a test double implementing IHookManager. |
| UnicornNet.Tests/ControlEngineTests.cs | Adds tests for ControlCommand argument carriage and ControlEngine forwarding. |
| .gitignore | Adds ignores for local agent-skill tracker artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+12
to
+15
| internal void Control(ControlCommand command, nint arg1) | ||
| { | ||
| Control(command.WithArguments([arg1])); | ||
| } |
Comment on lines
+7
to
+9
| // Hook state is stored as object? because native callbacks return through IntPtr userData; | ||
| // value-type state is boxed, so generic hook overloads are intentionally not exposed. | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
No description provided.