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

.Net 6 - Failed to free the memory region #55

Open
CryoMyst opened this issue Jan 9, 2022 · 3 comments
Open

.Net 6 - Failed to free the memory region #55

CryoMyst opened this issue Jan 9, 2022 · 3 comments

Comments

@CryoMyst
Copy link

CryoMyst commented Jan 9, 2022

I have just tried moving up the targeted framework to .Net 6 and am getting an error.
System.ComponentModel.Win32Exception (5): Failed to free the memory region at 0000000000010000.

CoreHook.CoreLoad.runtimeconfig.json

{
  "runtimeOptions": {
    "tfm": "net6.0",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "6.0.1"
    },
    "configProperties": {
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false
    },
    "additionalProbingPaths": [
    ]
  }
}
@wokhan
Copy link

wokhan commented May 6, 2023

Hi, I'm probably way too late to the party but still it could help someone.
According to dotnet official sample, and if I'm not mistaking, coreclr signatures changed and in fact the issue you see is a side effect of the coreload library failing to properly load .NET, which, if you look thoroughly, causes the target process to restart with a new PID.
Since it has a new PID, the following call (attemtping to inject the hook, this time), will fail, and memory won't be either freeable (or allocated in some cases I encountered) since there is no target process anymore.
Hope this helps you... as it would have helped me reconsider using .NET 7 (or 6) with CoreHook...
I may try to update this lib for .NET 6+, but looks way more complex than what I'm used to.

@CryoMyst
Copy link
Author

CryoMyst commented May 8, 2023

@wokhan Not too late but there doesn't seem to be any activity here to get this updated, I ended up just building an adapter library around https://crates.io/crates/netcorehost before moving onto my own implementation.

@wokhan
Copy link

wokhan commented May 9, 2023

Hi @CryoMyst, in fact I was also interested to see how bad my C++ was nowadays, so I've been working on this the last few days.
I hope I'll have something working soon, but I'm really unsure if it will be enough or not (rebuilding a new .NET 6/7 "corehost" lib is the simple part thank to the available samples, and I'm still not done with it)..

If I succeed, I might either issue a PR here or create a fork... We'll see...
It also depends on @unknownv2, as I've seen no activity here for a few years (hoping he's fine).

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

No branches or pull requests

2 participants