Post by Ben Voigt [C++ MVP]Post by Stephane BarizienWhen I get an STATUS_ENTRYPOINT_NOT_FOUND (0xC0000139) exception,
how do I get the name of the offending DLL and of the missing entry
point?
Under what conditions can that value reach an exception handler?
Raymond Chen explains that you see that as a process exit code, which
often are created from unhandled exceptions, but load-time imports
are processed before you get a chance to set up your exception
handlers. LoadLibrary would SetLastError instead of throwing an
exception. Is it an attached debugger receiving the exception? Or
are you using delay-load?
OK, apologies for not having given enough context.
The question pertains to a shell-style program that launches other commands
using CreateProcess() and needs to report why the CreateProcess() fails with
as much detail as possible.
Heavily borrowing code from koders.com (search for ldd.c) I was able to
create a
thingie that knows how to tell me if a DLL is missing and what DLL, but not
what entry point is missing if the DLL is present but an entry point cannot
be found:
$ ldd.exe -v m:/tmp/mks/missingdll/Debug/missingdll.exe
ntdll.dll => ntdll.dll (0x7c900000)
kernel32.dll => G:\WINDOWS\system32\kernel32.dll (0x7c800000)
code: c0000135, flags:1, params: 0, addr: 7c964ed1
TheDLL.dll => ?
KERNEL32.dll => G:\WINDOWS\system32\KERNEL32.dll
ntdll.dll => G:\WINDOWS\system32\ntdll.dll
$ ldd.exe -v m:/tmp/mks/missingentrypoint/Debug/missingentrypoint.exe
ntdll.dll => ntdll.dll (0x7c900000)
kernel32.dll => G:\WINDOWS\system32\kernel32.dll (0x7c800000)
TheDLL.dll => m:\tmp\mks\missingentrypoint\Debug\TheDLL.dll
(0x10000000)
code: c0000139, flags:1, params: 0, addr: 7c964ed1
Missing entry point in DLL!
Here's the related code snippet:
case EXCEPTION_DEBUG_EVENT:
{
EXCEPTION_RECORD *ex=&de->u.Exception.ExceptionRecord;
if (ex->ExceptionCode==EXCEPTION_BREAKPOINT && !opt_continous)
return 0;
printf("code: %x, flags:%x, params: %x, addr:
%x\n",ex->ExceptionCode,
ex->ExceptionFlags,
ex->NumberParameters,
ex->ExceptionAddress
);
if (ex->ExceptionCode==0xc0000135) walk_dependencies(cmdline);
if (ex->ExceptionCode==0xc0000139)
{
printf("Missing entry point in DLL!\n");
}
if (ex->ExceptionFlags==EXCEPTION_NONCONTINUABLE) return 0;
}
}