LdrUnlockLoaderLock

This function releases the special critical section known as the loader lock.

Declaration

NTSTATUS
LdrUnlockLoaderLock (
    ULONG Flags,
    ULONG Cookie);

Parameters

The Flags argument supplies bit flags to vary the function’s behaviour. There is one supported value:

0x01 do not return error, raise exception

The Cookie argument is a cookie that is expected to have been obtained from LdrLockLoaderLock.

Return Value

The function returns zero for success, else an error code.

If the 0x01 bit is set in the Flags, then all errors are reported as exceptions. If the function returns at all, it is successful. Indeed, the point to the 0x01 bit is surely that the function may be treated as returning void.

Behaviour

The function distinguishes several cases of invalid parameter:

STATUS_INVALID_PARAMETER_1 the Flags argument has a set bit other than the one shown above
STATUS_INVALID_PARAMETER_2 the Cookie argument is invalid (see below)

If the Cookie argument is zero, the function succeeds trivially, i.e., without releasing the loader lock. Otherwise, the cookie is tested for some sort of plausibility as having been generated by an earlier call to LdrLockLoaderLock by the same thread. The test is surely an implementation detail and should not be depended upon. Only the high word matters. Its high 4 bits must be clear. Its low 12 bits must be those of the thread ID.

Except for invalid parameters, the function can fail only if an exception occurs while trying to leave the loader lock. If the 0x01 bit is clear, such exceptions are caught within the function, so that the exception code becomes the returned value.

Availability

The LdrUnlockLoaderLock function is exported by name from NTDLL.DLL in version 5.1 and higher.