PRB: LoadLibrary API Fails with 998 (ERROR_NOACCESS) Error (196069)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • the operating system: Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 2000
    • the operating system: Microsoft Windows XP

This article was previously published under Q196069

SYMPTOMS

The LoadLibrary() API may sometimes encounter an access violation while attempting to map a specified module into the address space of the calling process. In this event, LoadLibrary() returns a value of NULL and GetLastError() returns an error code of 998 (ERROR_NOACCESS).

CAUSE

The Windows NT status code STATUS_ACCESS_VIOLATION is mapped to the Win32 error code ERROR_NOACCESS. As a result, if the operating system loader encounters an access violation (exception C0000005) while mapping the specified DLL file image or executing the startup code, the loader will set the last error to 998 (ERROR_NOACCESS) and the LoadLibrary() function will fail with a return value of NULL.

MORE INFORMATION

When an access violation occurs anywhere in the startup code, the exception dispatcher detects whether the process that encountered this exception is being debugged. If so, this first chance exception is sent to the debugger.

To troubleshoot the LoadLibrary() failure, run the application under a debugger and enable first chance exception handling for the C0000005 Access Violation exception. If an access violation occurs when the LoadLibrary() function is called, the application will break into the debugger. The debugger's call stack can then be used to trace where the exception occurred. The stack trace should help you narrow down the actual problem related to the exception being encountered.

For information on how to enable first chance exception handling for the C0000005 Access violation exception, please refer to the debugger documentation.

Modification Type:MajorLast Reviewed:4/13/2004
Keywords:kbDLL kbKernBase kbprb KB196069