MemoryModule icon indicating copy to clipboard operation
MemoryModule copied to clipboard

Reference counting behavior of LoadLibrary is missing

Open moradin opened this issue 8 years ago • 2 comments

Maybe I'm just not looking in the right places but it looks like the reference counting is not implemented.

The system maintains a per-process reference count on all loaded modules. Calling LoadLibrary increments the reference count. Calling the FreeLibrary or FreeLibraryAndExitThread function decrements the reference count. The system unloads a module when its reference count reaches zero or when the process terminates (regardless of the reference count).

(from https://msdn.microsoft.com/en-us/library/windows/desktop/ms684175(v=vs.85).aspx)

I'm not sure how this would work without some more information passed into MemoryLoadLibraryEx but it definitely looks like a big missing piece.

moradin avatar Jun 16 '16 14:06 moradin

MemoryModule loads DLLs from any memory blocks, so there is no "name" or similar that could be used to track if an application loads the same memory multiple times. Besides refcounting for that is something that could be easily done by the application using MemoryModule.

Or maybe I am missing something?

fancycode avatar Jun 16 '16 14:06 fancycode

Yes I understand that the current parameters are not enough for this but if the application is supposed to deal with it then it needs an additional layer on top to provide the same feature set. I think it would be nice if all the features of the original would be supported just for the sake of having one maintained solution but I understand if this is not the goal.

moradin avatar Jun 16 '16 15:06 moradin