Commit 4ca7e634 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

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

resource enumerator.
parent fc67be9a
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment