Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory validation and runtime module dump #122

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

krulci
Copy link
Contributor

@krulci krulci commented May 4, 2024

  1. Memory region protection validation
    Current main stream implementation of FindMethodSignature fails when the memory region is protected.
    This leads to an access violation error.
    This pull request implemented memory validation and set them to execute_read_write before signature scanning.
    Protection right is restore after signature scanning.

  2. Runtime module dump to support obscure game assembly
    Current main stream implementation of interop generation uses raw GameAssembly.dll and global-metadata.dat.
    This will fail if the game is packed and if global-metadata.dat is embedded in GameAssembly.dll.
    This pull request implemented runtime module dump.
    global-metadata.dat is extracted using pattern matching.

  • Optional metadata magic fixing is also implemented for obfuscated global-metadata.dat, so the output product can be used in il2cppdumper.
  • ILogger is a required parameter for the considerations that this method may be used before interop generation. That is before Create.

Il2CppInterop.Runtime/MemoryUtils.cs Show resolved Hide resolved
Il2CppInterop.Runtime/MemoryUtils.cs Show resolved Hide resolved
Il2CppInterop.Runtime/MemoryUtils.cs Show resolved Hide resolved
Il2CppInterop.Runtime/MemoryUtils.cs Show resolved Hide resolved
Il2CppInterop.Runtime/MemoryUtils.cs Show resolved Hide resolved
Copy link
Member

@js6pak js6pak left a comment

Choose a reason for hiding this comment

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

This implementation is Windows-only so that would have to change.

But this is not something that's needed for vanilla unity and is highly specific to particular games, so maybe we should expose hooks for preloader plugins in BepInEx to handle this instead?

@krulci
Copy link
Contributor Author

krulci commented May 19, 2024

This implementation is Windows-only so that would have to change.

But this is not something that's needed for vanilla unity and is highly specific to particular games, so maybe we should expose hooks for preloader plugins in BepInEx to handle this instead?

If I am not mistaken, Preloader patches are applied after interop generation. The implementation I applied to BepInEx was before interop generation and after Cecil assembly definitions are generated.
If we were to do something similar to a preloader, we will need to change the execution order.

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.

None yet

3 participants