Miser LoadLibrary call in multiple DLLs?

Miser LoadLibrary call in multiple DLLs?

From the documentation I understand the Miser.dll library needs to be loaded using the LoadLibrary call.



. . .

HMODULE mdll = LoadLibrary ("Miser.dll");

if (NULL == mdll) {

// Report and handle fatal error


However, I am unclear if this needs to be done just in the main executable (and all DLL's used by this will then route their memory allocation calls to Miser) or if LoadLibrary needs to be done in each DLL that should use Miser for it's memory allocation.

- James

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

When you load Miser.dll into the process, it will iterate over all of the currently loaded modules and redirect all calls to C Runtime Library DLL memory routines to itself. It will also monitor the process for any additional calls to LoadLibrary (or any of its variants) and redirect calls from those modules, as well as any additional modules pulled in by the loaded module.

Ideally, you should load Miser.dll in the main executable before spawning any threads.

Miser redirects the calls by modifying the Import Address Table for each module. Since these are aligned, addess-sized values, writing them should be thread safe, so you should be able to load Miser.dll at any time. The only downside is that Miser will not recognize memory blocks allocated by the C Runtime Libraryand have to pass a memory routine call on to the C Runtime Library which can be a (small) performance hit.

- Barry

Leave a Comment

Please sign in to add a comment. Not a member? Join today