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
57512807
Commit
57512807
authored
Sep 25, 2018
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Reimplement GetBinaryTypeW to rely on the server for header parsing.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
622aeeba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
57 deletions
+65
-57
module.c
dlls/kernel32/module.c
+65
-57
No files found.
dlls/kernel32/module.c
View file @
57512807
...
...
@@ -563,76 +563,84 @@ void MODULE_get_binary_info( HANDLE hfile, struct binary_info *info )
* ".com" and ".pif" files are only recognized by their file name extension,
* as per native Windows.
*/
BOOL
WINAPI
GetBinaryTypeW
(
LPCWSTR
lpApplicationName
,
LPDWORD
lpBinaryT
ype
)
BOOL
WINAPI
GetBinaryTypeW
(
LPCWSTR
name
,
LPDWORD
t
ype
)
{
BOOL
ret
=
FALSE
;
HANDLE
hfile
;
struct
binary_info
binary_info
;
static
const
WCHAR
comW
[]
=
{
'.'
,
'c'
,
'o'
,
'm'
,
0
};
static
const
WCHAR
pifW
[]
=
{
'.'
,
'p'
,
'i'
,
'f'
,
0
};
HANDLE
hfile
,
mapping
;
NTSTATUS
status
;
const
WCHAR
*
ptr
;
TRACE
(
"%s
\n
"
,
debugstr_w
(
lpApplicationN
ame
)
);
TRACE
(
"%s
\n
"
,
debugstr_w
(
n
ame
)
);
/* Sanity check.
*/
if
(
lpApplicationName
==
NULL
||
lpBinaryType
==
NULL
)
return
FALSE
;
if
(
type
==
NULL
)
return
FALSE
;
/* Open the file indicated by lpApplicationName for reading.
*/
hfile
=
CreateFileW
(
lpApplicationName
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
hfile
=
CreateFileW
(
name
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
if
(
hfile
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
/* Check binary type
*/
MODULE_get_binary_info
(
hfile
,
&
binary_info
);
switch
(
binary_info
.
type
)
{
case
BINARY_UNKNOWN
:
status
=
NtCreateSection
(
&
mapping
,
STANDARD_RIGHTS_REQUIRED
|
SECTION_QUERY
,
NULL
,
NULL
,
PAGE_READONLY
,
SEC_IMAGE
,
hfile
);
CloseHandle
(
hfile
);
switch
(
status
)
{
static
const
WCHAR
comW
[]
=
{
'.'
,
'C'
,
'O'
,
'M'
,
0
};
static
const
WCHAR
pifW
[]
=
{
'.'
,
'P'
,
'I'
,
'F'
,
0
};
const
WCHAR
*
ptr
;
/* try to determine from file name */
ptr
=
strrchrW
(
lpApplicationName
,
'.'
);
if
(
!
ptr
)
break
;
if
(
!
strcmpiW
(
ptr
,
comW
))
case
STATUS_SUCCESS
:
{
*
lpBinaryType
=
SCS_DOS_BINARY
;
ret
=
TRUE
;
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_ARM
:
case
IMAGE_FILE_MACHINE_THUMB
:
case
IMAGE_FILE_MACHINE_ARMNT
:
case
IMAGE_FILE_MACHINE_POWERPC
:
*
type
=
SCS_32BIT_BINARY
;
return
TRUE
;
case
IMAGE_FILE_MACHINE_AMD64
:
case
IMAGE_FILE_MACHINE_ARM64
:
*
type
=
SCS_64BIT_BINARY
;
return
TRUE
;
}
return
FALSE
;
}
else
if
(
!
strcmpiW
(
ptr
,
pifW
))
case
STATUS_INVALID_IMAGE_WIN_16
:
*
type
=
SCS_WOW_BINARY
;
return
TRUE
;
case
STATUS_INVALID_IMAGE_WIN_32
:
*
type
=
SCS_32BIT_BINARY
;
return
TRUE
;
case
STATUS_INVALID_IMAGE_WIN_64
:
*
type
=
SCS_64BIT_BINARY
;
return
TRUE
;
case
STATUS_INVALID_IMAGE_NE_FORMAT
:
*
type
=
SCS_OS216_BINARY
;
return
TRUE
;
case
STATUS_INVALID_IMAGE_PROTECT
:
*
type
=
SCS_DOS_BINARY
;
return
TRUE
;
case
STATUS_INVALID_IMAGE_NOT_MZ
:
if
((
ptr
=
strrchrW
(
name
,
'.'
)))
{
*
lpBinaryType
=
SCS_PIF_BINARY
;
ret
=
TRUE
;
if
(
!
strcmpiW
(
ptr
,
comW
))
{
*
type
=
SCS_DOS_BINARY
;
return
TRUE
;
}
if
(
!
strcmpiW
(
ptr
,
pifW
))
{
*
type
=
SCS_PIF_BINARY
;
return
TRUE
;
}
}
break
;
}
case
BINARY_PE
:
*
lpBinaryType
=
(
binary_info
.
flags
&
BINARY_FLAG_64BIT
)
?
SCS_64BIT_BINARY
:
SCS_32BIT_BINARY
;
ret
=
TRUE
;
break
;
case
BINARY_WIN16
:
*
lpBinaryType
=
SCS_WOW_BINARY
;
ret
=
TRUE
;
break
;
case
BINARY_OS216
:
*
lpBinaryType
=
SCS_OS216_BINARY
;
ret
=
TRUE
;
break
;
case
BINARY_DOS
:
*
lpBinaryType
=
SCS_DOS_BINARY
;
ret
=
TRUE
;
break
;
case
BINARY_UNIX_EXE
:
case
BINARY_UNIX_LIB
:
ret
=
FALSE
;
break
;
return
FALSE
;
default:
return
FALSE
;
}
CloseHandle
(
hfile
);
return
ret
;
}
/***********************************************************************
...
...
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