Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
702f9e6b
Commit
702f9e6b
authored
May 09, 2023
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Allow loading ARM64EC binaries.
parent
f55a5812
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
loader.c
dlls/ntdll/loader.c
+32
-16
No files found.
dlls/ntdll/loader.c
View file @
702f9e6b
...
...
@@ -53,14 +53,19 @@ WINE_DECLARE_DEBUG_CHANNEL(imports);
#ifdef __i386__
static
const
WCHAR
pe_dir
[]
=
L"
\\
i386-windows"
;
static
const
USHORT
current_machine
=
IMAGE_FILE_MACHINE_I386
;
#elif defined __x86_64__
static
const
WCHAR
pe_dir
[]
=
L"
\\
x86_64-windows"
;
static
const
USHORT
current_machine
=
IMAGE_FILE_MACHINE_AMD64
;
#elif defined __arm__
static
const
WCHAR
pe_dir
[]
=
L"
\\
arm-windows"
;
static
const
USHORT
current_machine
=
IMAGE_FILE_MACHINE_ARMNT
;
#elif defined __aarch64__
static
const
WCHAR
pe_dir
[]
=
L"
\\
aarch64-windows"
;
static
const
USHORT
current_machine
=
IMAGE_FILE_MACHINE_ARM64
;
#else
static
const
WCHAR
pe_dir
[]
=
L""
;
static
const
USHORT
current_machine
=
IMAGE_FILE_MACHINE_UNKNOWN
;
#endif
/* we don't want to include winuser.h */
...
...
@@ -2322,33 +2327,44 @@ static BOOL is_com_ilonly( HANDLE file, const SECTION_IMAGE_INFORMATION *info )
return
!!
(
cor_header
.
Flags
&
COMIMAGE_FLAGS_ILONLY
);
}
#endif
/* check LOAD_CONFIG header for CHPE metadata */
static
BOOL
has_chpe_metadata
(
HANDLE
file
,
const
SECTION_IMAGE_INFORMATION
*
info
)
{
USHORT
magic
;
IMAGE_LOAD_CONFIG_DIRECTORY64
loadcfg
;
ULONG
len
=
read_image_directory
(
file
,
info
,
IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG
,
&
loadcfg
,
sizeof
(
loadcfg
),
&
magic
);
if
(
!
len
)
return
FALSE
;
if
(
magic
!=
IMAGE_NT_OPTIONAL_HDR64_MAGIC
)
return
FALSE
;
len
=
min
(
len
,
loadcfg
.
Size
);
if
(
len
<=
offsetof
(
IMAGE_LOAD_CONFIG_DIRECTORY64
,
CHPEMetadataPointer
))
return
FALSE
;
return
!!
loadcfg
.
CHPEMetadataPointer
;
}
/* On WoW64 setups, an image mapping can also be created for the other 32/64 CPU */
/* but it cannot necessarily be loaded as a dll, so we need some additional checks */
static
BOOL
is_valid_binary
(
HANDLE
file
,
const
SECTION_IMAGE_INFORMATION
*
info
)
{
#ifdef __i386__
return
info
->
Machine
==
IMAGE_FILE_MACHINE_I386
;
#elif defined(__arm__)
return
info
->
Machine
==
IMAGE_FILE_MACHINE_ARM
||
info
->
Machine
==
IMAGE_FILE_MACHINE_THUMB
||
info
->
Machine
==
IMAGE_FILE_MACHINE_ARMNT
;
#elif defined(_WIN64)
/* support 32-bit IL-only images on 64-bit */
#ifdef __x86_64__
if
(
info
->
Machine
==
IMAGE_FILE_MACHINE_AMD64
)
return
TRUE
;
#else
if
(
info
->
Machine
==
IMAGE_FILE_MACHINE_ARM64
)
return
TRUE
;
#endif
if
(
info
->
Machine
==
current_machine
)
return
TRUE
;
if
(
NtCurrentTeb
()
->
WowTebOffset
)
return
TRUE
;
/* support ARM64EC binaries on x86-64 */
if
(
current_machine
==
IMAGE_FILE_MACHINE_AMD64
&&
has_chpe_metadata
(
file
,
info
))
return
TRUE
;
/* support 32-bit IL-only images on 64-bit */
if
(
!
info
->
ImageContainsCode
)
return
TRUE
;
if
(
info
->
u
.
s
.
ComPlusNativeReady
)
return
TRUE
;
return
is_com_ilonly
(
file
,
info
);
#else
return
FALSE
;
/* no wow64 support on other platforms */
#endif
}
#else
/* _WIN64 */
static
BOOL
is_valid_binary
(
HANDLE
file
,
const
SECTION_IMAGE_INFORMATION
*
info
)
{
return
(
info
->
Machine
==
current_machine
);
}
#endif
/* _WIN64 */
/******************************************************************
* get_module_path_end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment