I am working on binding my own calls to a virtual machine, and one of the possibilities is the ability to search for standard libc functions by name at runtime. In windows this becomes a bit of a hassle because I need to get the handle to the msvcrt module that is currently loaded into this process. Usually it is msvcrt.dll, but it can be other options (msvcr100.dll, etc.), and the call to GetModuleHandle ("msvcrt") may fail if a variant with a different name is used.
What I would like to do is reverse the search, take a pointer to a function from libc (which I have in abundance) and get a handle to the module that provides it. Basically, something like this:
HANDLE hlibc = ReverseGetModuleHandle(fprintf);
Is there such a thing in the win32 API that does not fall into the manual handle of process handlers and symbol tables? And vice versa, if I think too much about the problem, is there an easier way to search for the libc function by name on win32?
c winapi
Whiteknight Jul 18 2018-11-18T00: 00Z
source share