Commit 4aa858c9 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: GetBinaryType() doesn't accept DLLs.

With help from Dmitry Timoshkov. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51790Signed-off-by: 's avatarHans Leidekker <hans@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent cba1faee
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winerror.h" #include "winerror.h"
...@@ -697,6 +700,51 @@ static DWORD WINAPI custom_client_thread(void *arg) ...@@ -697,6 +700,51 @@ static DWORD WINAPI custom_client_thread(void *arg)
return rc; return rc;
} }
/* based on kernel32.GetBinaryTypeW() */
static BOOL get_binary_type( const WCHAR *name, DWORD *type )
{
HANDLE hfile, mapping;
NTSTATUS status;
hfile = CreateFileW( name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
if (hfile == INVALID_HANDLE_VALUE)
return FALSE;
status = NtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY, NULL, NULL, PAGE_READONLY,
SEC_IMAGE, hfile );
CloseHandle( hfile );
switch (status)
{
case STATUS_SUCCESS:
{
SECTION_IMAGE_INFORMATION info;
status = NtQuerySection( mapping, SectionImageInformation, &info, sizeof(info), NULL );
CloseHandle( mapping );
if (status) return FALSE;
switch (info.Machine)
{
case IMAGE_FILE_MACHINE_I386:
case IMAGE_FILE_MACHINE_ARMNT:
*type = SCS_32BIT_BINARY;
return TRUE;
case IMAGE_FILE_MACHINE_AMD64:
case IMAGE_FILE_MACHINE_ARM64:
*type = SCS_64BIT_BINARY;
return TRUE;
default:
return FALSE;
}
}
case STATUS_INVALID_IMAGE_WIN_64:
*type = SCS_64BIT_BINARY;
return TRUE;
default:
return FALSE;
}
}
static msi_custom_action_info *do_msidbCustomActionTypeDll( static msi_custom_action_info *do_msidbCustomActionTypeDll(
MSIPACKAGE *package, INT type, LPCWSTR source, LPCWSTR target, LPCWSTR action ) MSIPACKAGE *package, INT type, LPCWSTR source, LPCWSTR target, LPCWSTR action )
{ {
...@@ -744,7 +792,7 @@ static msi_custom_action_info *do_msidbCustomActionTypeDll( ...@@ -744,7 +792,7 @@ static msi_custom_action_info *do_msidbCustomActionTypeDll(
info->package->rpc_server_started = 1; info->package->rpc_server_started = 1;
} }
ret = GetBinaryTypeW(source, &info->arch); ret = get_binary_type(source, &info->arch);
if (!ret) if (!ret)
info->arch = (sizeof(void *) == 8 ? SCS_64BIT_BINARY : SCS_32BIT_BINARY); info->arch = (sizeof(void *) == 8 ? SCS_64BIT_BINARY : SCS_32BIT_BINARY);
......
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