Skip to main content

Command Palette

Search for a command to run...

Loader Lock

Updated
1 min readView as Markdown
Loader Lock

what is loader lock ?

Loader Lock is a special internal lock , windows holds while loading or unloading DLLs

So Windows restricts these operations inside DllMain to avoid deadlocks or hangs.

So DLL Sideloading is not possible.

Inside DllMain, Windows holds the loader lock.

LoadLibrary() also needs the loader lock.

So:

  • DllMain holds the lock

  • LoadLibrary waits for the lock

  • Deadlock (process hangs)

That’s why loading another DLL from DllMain is considered unsafe and effectively “not possible.”

Loading another DLL from inside DllMain is unsafe and usually impossible without causing deadlocks.

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
    if (fdwReason == DLL_PROCESS_ATTACH)
    {
        LoadLibrary(L"example.dll");  // ❌ Dangerous here!
    }
    return TRUE;
}
14 views