Skip to content

Extract memory manager#7

Open
CorentinGS wants to merge 7 commits into
mainfrom
extract-memory-manager
Open

Extract memory manager#7
CorentinGS wants to merge 7 commits into
mainfrom
extract-memory-manager

Conversation

@CorentinGS

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and RegisterBank and wires them into Unicorn.Core.
  • Relocates memory and hook APIs into new folder structure (Memory/, Hooks/, Control/) and updates MemoryRegion/HookBuilder to 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 thread UnicornNet/Control/ControlEngine.cs
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants