본문 바로가기

Programming Logs/Windows

LoadLibrary, FreeLibrary, GetModuleHandle

HMODULE hModule = LoadLibrary("ntdll.h")

HMODULE hModule = GetModuleHandle("ntdll.h")

 

LoadLibrary ⊃ GetModuleHandle

>> LoadLibrary = GetModuleHandle + "LoadCount++" + "Load DLL if Count is zero"

 

FreeLibrary unloads DLL if count is zero else just LoadCount--

 

* LoadCount belongs to process, means, each process has own module count evenif those are loading same module

 

if process ends :

    unload module, ignoring LoadCount

 

 

---

참조 : 

https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibrarya