Trap exceptions in RtlImageNtHeader.

This commit is contained in:
Alexandre Julliard 2002-08-15 22:09:53 +00:00
parent 1da297178a
commit becccaf168
1 changed files with 26 additions and 6 deletions

View File

@ -22,11 +22,21 @@
#include "ntddk.h" #include "ntddk.h"
#include "module.h" #include "module.h"
#include "wine/exception.h"
#include "msvcrt/excpt.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ntdll); WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
/* filter for page-fault exceptions */
static WINE_EXCEPTION_FILTER(page_fault)
{
if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
return EXCEPTION_EXECUTE_HANDLER;
return EXCEPTION_CONTINUE_SEARCH;
}
NTSTATUS WINAPI LdrDisableThreadCalloutsForDll(HANDLE hModule) NTSTATUS WINAPI LdrDisableThreadCalloutsForDll(HANDLE hModule)
{ {
if (DisableThreadLibraryCalls(hModule)) if (DisableThreadLibraryCalls(hModule))
@ -75,14 +85,24 @@ NTSTATUS WINAPI LdrGetProcedureAddress(PVOID base, PANSI_STRING name, ULONG ord,
*/ */
PIMAGE_NT_HEADERS WINAPI RtlImageNtHeader(HMODULE hModule) PIMAGE_NT_HEADERS WINAPI RtlImageNtHeader(HMODULE hModule)
{ {
IMAGE_NT_HEADERS *ret = NULL; IMAGE_NT_HEADERS *ret;
IMAGE_DOS_HEADER *dos = (IMAGE_DOS_HEADER *)hModule;
if (dos->e_magic == IMAGE_DOS_SIGNATURE) __TRY
{ {
ret = (IMAGE_NT_HEADERS *)((char *)dos + dos->e_lfanew); IMAGE_DOS_HEADER *dos = (IMAGE_DOS_HEADER *)hModule;
if (ret->Signature != IMAGE_NT_SIGNATURE) ret = NULL;
ret = NULL;
if (dos->e_magic == IMAGE_DOS_SIGNATURE)
{
ret = (IMAGE_NT_HEADERS *)((char *)dos + dos->e_lfanew);
if (ret->Signature != IMAGE_NT_SIGNATURE) ret = NULL;
}
} }
__EXCEPT(page_fault)
{
return NULL;
}
__ENDTRY
return ret; return ret;
} }