Closed Hpmason closed 11 months ago
I've added linux support locally that I'll make a PR for in the coming days, and I've stumbled upon this issue.
The thing that worries me of minidl is that, for linux, it doesn't close libraries loaded via its library. The issue is that calling dlopen
on already loaded libraries will increment the reference count, which means that, to successfully close a library, dlclose
will have to be called as many times as dlopen
was called. This could affect unrelated programs.
This is why dlopen
is always paired with dlclose
in any program that just needs to get the address of a library.
For offset-based hooks, we can just cast it to a usize
so it shouldn't add much boilerplate or complexity.
UPDATE: I just noticed that it's a private field. Unfortunate.
I decided to open an issue to get an explanation behind it and it has cleared up my doubts. I was mostly coming from a single-threaded background detour / memory wise, so I was not aware that it would cause issues. I'll integrate it in the coming days and hopefully open a PR.
Thanks for looking into/implementing this! I'll make sure to review your PR once it's ready
Offset-based hooks will still have to be manually implemented since minidl is just symbol lookup.
I opened an issue and they were kind enough to implement an accessor to retrieve the library handle. https://github.com/MaulingMonkey/minidl/commit/6599152672997f514b67ac742837fbb4f1c320d8
Better to use another crate for symbol lookup to add some cross-platform support. minidl is no-dependency crate that seems to do the job pretty well.
Offset-based hooks will still have to be manually implemented since minidl is just symbol lookup.