LoadLibrary Reference Counting

倖福魔咒の 提交于 2019-12-01 17:13:21

问题


From MSDN:

The system maintains a per-process reference count on all loaded modules. Calling LoadLibrary increments the reference count.

Where is that reference count stored?


回答1:


The actual windows loader is found in NTDLL.dll's LdrLoadDll function. This function is undocumented, and its internal functionality is subject to change in future versions of windows; only those with access to the windows source code could state for certain what happens behind the scenes.

However, wine's source is available, and you can see where it increments the reference count; it's stored in the LoadCount member of the LDR_MODULE heap structure. Since this doesn't seem to be a wine-internal structure, it's likely that this structure is based off the real, reverse-engineered windows structures, and thus windows probably stores it in the same way. However, since this is undocumented, it is subject to change in any future version of windows, or even with minor windows patches.




回答2:


This is just a guess, but it's probably a global variable inside kernel32.dll (that's the DLL that imlements LoadLibrary).



来源:https://stackoverflow.com/questions/3809767/loadlibrary-reference-counting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!