Avoid crashes if 16-bit module handle was passed to the 32-bit

resource enumerator.
This commit is contained in:
Dmitry Timoshkov 2000-09-26 00:39:06 +00:00 committed by Alexandre Julliard
parent fc67be9a01
commit 4ca7e6343f
1 changed files with 10 additions and 0 deletions

View File

@ -12,10 +12,12 @@
#include <stdlib.h>
#include <sys/types.h>
#include "wine/winestring.h"
#include "wine/unicode.h"
#include "windef.h"
#include "winnls.h"
#include "winerror.h"
#include "module.h"
#include "heap.h"
#include "task.h"
@ -24,6 +26,8 @@
#include "neexe.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(resource);
/**********************************************************************
* get_resdir
*
@ -35,6 +39,12 @@ static IMAGE_RESOURCE_DIRECTORY* get_resdir( HMODULE hmod )
IMAGE_RESOURCE_DIRECTORY *ret = NULL;
if (!hmod) hmod = GetModuleHandleA( NULL );
else if (!HIWORD(hmod))
{
FIXME("Enumeration of 16-bit resources is not supported\n");
SetLastError(ERROR_INVALID_HANDLE);
return NULL;
}
dir = &PE_HEADER(hmod)->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE];
if (dir->Size && dir->VirtualAddress)
ret = (IMAGE_RESOURCE_DIRECTORY *)((char *)hmod + dir->VirtualAddress);