Cygwin: Fix previous attempt to drop i386 targets from hookapi
Somehow this patch looks like it was pushed before having been
finished. Let's try again...
Fixes: e46f15c2d1
("Cygwin: hookapi: drop handling i386 targets")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
5192d5ea51
commit
33395637a1
|
@ -29,22 +29,24 @@ struct function_hook
|
||||||
|
|
||||||
/* Given an HMODULE, returns a pointer to the PE header. */
|
/* Given an HMODULE, returns a pointer to the PE header. */
|
||||||
static PIMAGE_NT_HEADERS
|
static PIMAGE_NT_HEADERS
|
||||||
PEHeaderFromHModule (HMODULE hModule, bool &is_64bit)
|
PEHeaderFromHModule (HMODULE hModule)
|
||||||
{
|
{
|
||||||
PIMAGE_NT_HEADERS pNTHeader;
|
|
||||||
|
|
||||||
if (PIMAGE_DOS_HEADER (hModule) ->e_magic != IMAGE_DOS_SIGNATURE)
|
if (PIMAGE_DOS_HEADER (hModule) ->e_magic != IMAGE_DOS_SIGNATURE)
|
||||||
pNTHeader = NULL;
|
return NULL;
|
||||||
else
|
|
||||||
|
PIMAGE_NT_HEADERS pNTHeader =
|
||||||
|
PIMAGE_NT_HEADERS (PBYTE (hModule)
|
||||||
|
+ PIMAGE_DOS_HEADER (hModule) ->e_lfanew);
|
||||||
|
if (pNTHeader->Signature != IMAGE_NT_SIGNATURE)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Return valid PIMAGE_NT_HEADERS only for supported architectures. */
|
||||||
|
switch (pNTHeader->FileHeader.Machine)
|
||||||
{
|
{
|
||||||
pNTHeader = PIMAGE_NT_HEADERS (PBYTE (hModule)
|
case IMAGE_FILE_MACHINE_AMD64:
|
||||||
+ PIMAGE_DOS_HEADER (hModule) ->e_lfanew);
|
break;
|
||||||
if (pNTHeader->Signature == IMAGE_NT_SIGNATURE)
|
default:
|
||||||
pNTHeader = NULL;
|
return NULL;
|
||||||
else if (pNTHeader->FileHeader.Machine == IMAGE_FILE_MACHINE_AMD64)
|
|
||||||
is_64bit = true;
|
|
||||||
else
|
|
||||||
pNTHeader = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pNTHeader;
|
return pNTHeader;
|
||||||
|
@ -273,10 +275,8 @@ find_first_notloaded_dll (path_conv& pc)
|
||||||
if (!hm)
|
if (!hm)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
bool is_64bit;
|
pExeNTHdr = PEHeaderFromHModule (hm);
|
||||||
pExeNTHdr = PEHeaderFromHModule (hm, is_64bit);
|
if (!pExeNTHdr)
|
||||||
|
|
||||||
if (!pExeNTHdr || !is_64bit)
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
importRVA = pExeNTHdr->OptionalHeader.DataDirectory
|
importRVA = pExeNTHdr->OptionalHeader.DataDirectory
|
||||||
|
@ -333,12 +333,11 @@ void *
|
||||||
hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys, HANDLE h)
|
hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys, HANDLE h)
|
||||||
{
|
{
|
||||||
HMODULE hm = fn ? GetModuleHandle (NULL) : (HMODULE) name;
|
HMODULE hm = fn ? GetModuleHandle (NULL) : (HMODULE) name;
|
||||||
bool is_64bit;
|
PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule (hm);
|
||||||
PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule (hm, is_64bit);
|
|
||||||
|
|
||||||
/* Shortcut. We don't have to do anything further from here, if the
|
/* Shortcut. We don't have to do anything further from here, if the
|
||||||
executable's architecture doesn't match. */
|
executable's architecture doesn't match. */
|
||||||
if (!pExeNTHdr || !is_64bit)
|
if (!pExeNTHdr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
DWORD importRVA, importRVASize;
|
DWORD importRVA, importRVASize;
|
||||||
|
|
Loading…
Reference in New Issue