Oleg Korzhukov
Oleg Korzhukov

Reputation: 681

LoadLibraryEx error 87 (The parameter is incorrect)

One of my applications cannot load a system lib on the only machine. LoadLibraryEx returns 0 and the GetLastError returns 87 (The parameter is incorrect).

That can cause such error and how do I debug it?

Error appears only on a single machine which belongs to my client (server 2008R2). Libarary is located in system32 folder. Here is the code:

HMODULE lib = LoadLibraryEx(L"authui.dll", NULL,
                            LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_SEARCH_SYSTEM32);
if (lib == NULL)
{
    DWORD err=GetLastError();
    Log(L"error id: ", err);
    throw;
}

I cannot reproduce the error on my copy of 2008R2 and have no idea what can cause the error. My app is written in VS2015 C++ (pure WinApi, no MFC or third party libs) and it is 64-bit.

Upvotes: 0

Views: 2623

Answers (2)

user9684877
user9684877

Reputation: 1

Use the absolute path of authui.dll as the first parameter of LoadLibraryEx.

Upvotes: 0

Oleg Korzhukov
Oleg Korzhukov

Reputation: 681

Joel was right. The problem is in KB2533623 update which was not installed on the problem machine. I have changed my code to use absolute path as David Heffernan recommended and it works fine now.

Upvotes: 0

Related Questions