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
9eba2de3
Commit
9eba2de3
authored
Feb 19, 2011
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Improve the error reporting for invalid PE file architectures.
parent
0fd822f4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
33 deletions
+55
-33
virtual.c
dlls/ntdll/virtual.c
+55
-33
No files found.
dlls/ntdll/virtual.c
View file @
9eba2de3
...
...
@@ -1030,6 +1030,60 @@ static NTSTATUS allocate_dos_memory( struct file_view **view, unsigned int vprot
/***********************************************************************
* check_architecture
*
* Check the architecture of a PE binary.
*/
static
NTSTATUS
check_architecture
(
const
IMAGE_NT_HEADERS
*
nt
)
{
static
const
char
*
arch
;
#ifdef __i386__
if
(
nt
->
FileHeader
.
Machine
==
IMAGE_FILE_MACHINE_I386
)
return
STATUS_SUCCESS
;
if
(
nt
->
FileHeader
.
Machine
==
IMAGE_FILE_MACHINE_AMD64
)
{
if
(
nt
->
FileHeader
.
Characteristics
&
IMAGE_FILE_DLL
)
/* don't warn for a 64-bit exe */
WARN
(
"loading amd64 dll in 32-bit mode will fail
\n
"
);
return
STATUS_INVALID_IMAGE_FORMAT
;
}
#elif defined(__x86_64__)
if
(
nt
->
FileHeader
.
Machine
==
IMAGE_FILE_MACHINE_AMD64
)
return
STATUS_SUCCESS
;
if
(
nt
->
FileHeader
.
Machine
==
IMAGE_FILE_MACHINE_I386
)
{
if
(
nt
->
FileHeader
.
Characteristics
&
IMAGE_FILE_DLL
)
/* don't warn for a 32-bit exe */
WARN
(
"loading 32-bit dll in 64-bit mode will fail
\n
"
);
return
STATUS_INVALID_IMAGE_FORMAT
;
}
#elif defined(__ARMEL__)
if
(
nt
->
FileHeader
.
Machine
==
IMAGE_FILE_MACHINE_ARM
||
nt
->
FileHeader
.
Machine
==
IMAGE_FILE_MACHINE_THUMB
)
return
STATUS_SUCCESS
;
#endif
switch
(
nt
->
FileHeader
.
Machine
)
{
case
IMAGE_FILE_MACHINE_UNKNOWN
:
arch
=
"Unknown"
;
break
;
case
IMAGE_FILE_MACHINE_I860
:
arch
=
"I860"
;
break
;
case
IMAGE_FILE_MACHINE_I386
:
arch
=
"I386"
;
break
;
case
IMAGE_FILE_MACHINE_R3000
:
arch
=
"R3000"
;
break
;
case
IMAGE_FILE_MACHINE_R4000
:
arch
=
"R4000"
;
break
;
case
IMAGE_FILE_MACHINE_R10000
:
arch
=
"R10000"
;
break
;
case
IMAGE_FILE_MACHINE_ALPHA
:
arch
=
"Alpha"
;
break
;
case
IMAGE_FILE_MACHINE_POWERPC
:
arch
=
"PowerPC"
;
break
;
case
IMAGE_FILE_MACHINE_IA64
:
arch
=
"IA-64"
;
break
;
case
IMAGE_FILE_MACHINE_ALPHA64
:
arch
=
"Alpha-64"
;
break
;
case
IMAGE_FILE_MACHINE_AMD64
:
arch
=
"AMD-64"
;
break
;
case
IMAGE_FILE_MACHINE_ARM
:
arch
=
"ARM"
;
break
;
case
IMAGE_FILE_MACHINE_THUMB
:
arch
=
"ARM Thumb"
;
break
;
case
IMAGE_FILE_MACHINE_SPARC
:
arch
=
"SPARC"
;
break
;
default:
arch
=
wine_dbg_sprintf
(
"Unknown-%04x"
,
nt
->
FileHeader
.
Machine
);
break
;
}
ERR
(
"Trying to load PE image for unsupported architecture %s
\n
"
,
arch
);
return
STATUS_INVALID_IMAGE_FORMAT
;
}
/***********************************************************************
* stat_mapping_file
*
* Stat the underlying file for a memory view.
...
...
@@ -1110,39 +1164,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
imports
=
nt
->
OptionalHeader
.
DataDirectory
+
IMAGE_DIRECTORY_ENTRY_IMPORT
;
if
(
!
imports
->
Size
||
!
imports
->
VirtualAddress
)
imports
=
NULL
;
/* check the architecture */
#ifdef __x86_64__
if
(
nt
->
FileHeader
.
Machine
!=
IMAGE_FILE_MACHINE_AMD64
)
#elif defined(__ARMEL__)
if
(
nt
->
FileHeader
.
Machine
!=
IMAGE_FILE_MACHINE_ARM
&&
nt
->
FileHeader
.
Machine
!=
IMAGE_FILE_MACHINE_THUMB
)
#else
if
(
nt
->
FileHeader
.
Machine
!=
IMAGE_FILE_MACHINE_I386
)
#endif
{
MESSAGE
(
"Trying to load PE image for unsupported architecture ("
);
switch
(
nt
->
FileHeader
.
Machine
)
{
case
IMAGE_FILE_MACHINE_UNKNOWN
:
MESSAGE
(
"Unknown"
);
break
;
case
IMAGE_FILE_MACHINE_I860
:
MESSAGE
(
"I860"
);
break
;
case
IMAGE_FILE_MACHINE_I386
:
MESSAGE
(
"I386"
);
break
;
case
IMAGE_FILE_MACHINE_R3000
:
MESSAGE
(
"R3000"
);
break
;
case
IMAGE_FILE_MACHINE_R4000
:
MESSAGE
(
"R4000"
);
break
;
case
IMAGE_FILE_MACHINE_R10000
:
MESSAGE
(
"R10000"
);
break
;
case
IMAGE_FILE_MACHINE_ALPHA
:
MESSAGE
(
"Alpha"
);
break
;
case
IMAGE_FILE_MACHINE_POWERPC
:
MESSAGE
(
"PowerPC"
);
break
;
case
IMAGE_FILE_MACHINE_IA64
:
MESSAGE
(
"IA-64"
);
break
;
case
IMAGE_FILE_MACHINE_ALPHA64
:
MESSAGE
(
"Alpha-64"
);
break
;
case
IMAGE_FILE_MACHINE_AMD64
:
MESSAGE
(
"AMD-64"
);
break
;
case
IMAGE_FILE_MACHINE_ARM
:
MESSAGE
(
"ARM"
);
break
;
case
IMAGE_FILE_MACHINE_THUMB
:
MESSAGE
(
"ARM Thumb"
);
break
;
case
IMAGE_FILE_MACHINE_SPARC
:
MESSAGE
(
"SPARC"
);
break
;
default:
MESSAGE
(
"Unknown-%04x"
,
nt
->
FileHeader
.
Machine
);
break
;
}
MESSAGE
(
")
\n
"
);
goto
error
;
}
if
(
check_architecture
(
nt
))
goto
error
;
/* check for non page-aligned binary */
...
...
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