Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johnny Cai
wine
Commits
8da55cef
Commit
8da55cef
authored
26 years ago
by
Ulrich Weigand
Committed by
Alexandre Julliard
26 years ago
Browse files
Options
Downloads
Patches
Plain Diff
GetBinaryType[AW] moved to loader/module.c, modified to recognize .COM
and .PIF files.
parent
f6a93619
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
win32/kernel32.c
+0
-204
0 additions, 204 deletions
win32/kernel32.c
with
0 additions
and
204 deletions
win32/kernel32.c
+
0
−
204
View file @
8da55cef
...
...
@@ -4,8 +4,6 @@
* Copyright 1997-1998 Marcus Meissner
* Copyright 1998 Ulrich Weigand
*
* BUG: The GetBinaryType implementation is not complete. See
* the function documentation for more details.
*/
#include
<string.h>
...
...
@@ -1162,208 +1160,6 @@ BOOL WINAPI WaitNamedPipeW (LPCWSTR lpNamedPipeName, DWORD nTimeOut)
return
FALSE
;
}
/***********************************************************************
* GetBinaryType32A [KERNEL32.280]
*
* The GetBinaryType function determines whether a file is executable
* or not and if it is it returns what type of executable it is.
* The type of executable is a property that determines in which
* subsystem an executable file runs under.
*
* lpApplicationName: points to a fully qualified path of the file to test
* lpBinaryType: points to a variable that will receive the binary type info
*
* Binary types returned:
* SCS_32BIT_BINARY: A win32 based application
* SCS_DOS_BINARY: An MS-Dos based application
* SCS_WOW_BINARY: A 16bit OS/2 based application
* SCS_PIF_BINARY: A PIF file that executes an MS-Dos based app ( Not implemented )
* SCS_POSIX_BINARY: A POSIX based application ( Not implemented )
* SCS_OS216_BINARY: A 16bit Windows based application ( Not implemented )
*
* Returns TRUE if the file is an executable in which case
* the value pointed by lpBinaryType is set.
* Returns FALSE if the file is not an executable or if the function fails.
*
* This function is not complete. It can only determine if a file
* is a DOS, 32bit/16bit Windows executable. Also .COM file support
* is not complete.
* To do so it opens the file and reads in the header information
* if the extended header information is not presend it will
* assume that that the file is a DOS executable.
* If the extended header information is present it will
* determine if the file is an 16 or 32 bit Windows executable
* by check the flags in the header.
*/
BOOL
WINAPI
GetBinaryTypeA
(
LPCSTR
lpApplicationName
,
LPDWORD
lpBinaryType
)
{
BOOL
ret
=
FALSE
;
HFILE
hfile
;
OFSTRUCT
ofs
;
IMAGE_DOS_HEADER
mz_header
;
char
magic
[
4
];
TRACE
(
win32
,
"%s
\n
"
,
lpApplicationName
);
/* Sanity check.
*/
if
(
lpApplicationName
==
NULL
||
lpBinaryType
==
NULL
)
{
return
FALSE
;
}
/* Open the file indicated by lpApplicationName for reading.
*/
hfile
=
OpenFile
(
lpApplicationName
,
&
ofs
,
OF_READ
);
/* If we cannot read the file return failed.
*/
if
(
hfile
==
HFILE_ERROR
)
{
return
FALSE
;
}
/* Seek to the start of the file and read the DOS header information.
*/
if
(
_llseek
(
hfile
,
0
,
SEEK_SET
)
>=
0
&&
_lread
(
hfile
,
&
mz_header
,
sizeof
(
mz_header
)
)
==
sizeof
(
mz_header
)
)
{
/* Now that we have the header check the e_magic field
* to see if this is a dos image.
*/
if
(
mz_header
.
e_magic
==
IMAGE_DOS_SIGNATURE
)
{
BOOL
lfanewValid
=
FALSE
;
/* We do have a DOS image so we will now try to seek into
* the file by the amount indicated by the field
* "Offset to extended header" and read in the
* "magic" field information at that location.
* This will tell us if there is more header information
* to read or not.
*/
/* But before we do we will make sure that header
* structure encompasses the "Offset to extended header"
* field.
*/
if
(
(
mz_header
.
e_cparhdr
<<
4
)
>=
sizeof
(
IMAGE_DOS_HEADER
)
)
{
if
(
(
mz_header
.
e_crlc
==
0
&&
mz_header
.
e_lfarlc
==
0
)
||
(
mz_header
.
e_lfarlc
>=
sizeof
(
IMAGE_DOS_HEADER
)
)
)
{
if
(
mz_header
.
e_lfanew
>=
sizeof
(
IMAGE_DOS_HEADER
)
&&
_llseek
(
hfile
,
mz_header
.
e_lfanew
,
SEEK_SET
)
>=
0
&&
_lread
(
hfile
,
magic
,
sizeof
(
magic
)
)
==
sizeof
(
magic
)
)
{
lfanewValid
=
TRUE
;
}
}
}
if
(
lfanewValid
==
FALSE
)
{
/* If we cannot read this "extended header" we will
* assume that we have a simple DOS executable.
*/
FIXME
(
win32
,
"Determine if this check is complete enough
\n
"
);
*
lpBinaryType
=
SCS_DOS_BINARY
;
ret
=
TRUE
;
}
else
{
/* Reading the magic field succeeded so
* we will not try to determine what type it is.
*/
if
(
*
(
DWORD
*
)
magic
==
IMAGE_NT_SIGNATURE
)
{
/* This is an NT signature.
*/
*
lpBinaryType
=
SCS_32BIT_BINARY
;
ret
=
TRUE
;
}
else
if
(
*
(
WORD
*
)
magic
==
IMAGE_OS2_SIGNATURE
)
{
/* The IMAGE_OS2_SIGNATURE indicates that the
* "extended header is a Windows executable (NE)
* header. This is a bit misleading, but it is
* documented in the SDK. ( for more details see
* the neexe.h file )
*/
/* Now we know that it is a Windows executable
* we will read in the Windows header and
* determine if it is a 16/32bit Windows executable.
*/
IMAGE_OS2_HEADER
ne_header
;
if
(
_lread
(
hfile
,
&
ne_header
,
sizeof
(
ne_header
)
)
==
sizeof
(
ne_header
)
)
{
/* Check the format flag to determine if it is
* Win32 or not.
*/
if
(
ne_header
.
format_flags
&
NE_FFLAGS_WIN32
)
{
*
lpBinaryType
=
SCS_32BIT_BINARY
;
ret
=
TRUE
;
}
else
{
/* We will assume it is a 16bit Windows executable.
* I'm not sure if this check is sufficient.
*/
FIXME
(
win32
,
"Determine if this check is complete enough
\n
"
);
*
lpBinaryType
=
SCS_WOW_BINARY
;
ret
=
TRUE
;
}
}
}
}
}
}
/* Close the file.
*/
CloseHandle
(
hfile
);
return
ret
;
}
/***********************************************************************
* GetBinaryType32W [KERNEL32.281]
*
* See GetBinaryType32A.
*/
BOOL
WINAPI
GetBinaryTypeW
(
LPCWSTR
lpApplicationName
,
LPDWORD
lpBinaryType
)
{
BOOL
ret
=
FALSE
;
LPSTR
strNew
=
NULL
;
TRACE
(
win32
,
"%s
\n
"
,
debugstr_w
(
lpApplicationName
));
/* Sanity check.
*/
if
(
lpApplicationName
==
NULL
||
lpBinaryType
==
NULL
)
{
return
FALSE
;
}
/* Convert the wide string to a ascii string.
*/
strNew
=
HEAP_strdupWtoA
(
GetProcessHeap
(),
0
,
lpApplicationName
);
if
(
strNew
!=
NULL
)
{
ret
=
GetBinaryTypeA
(
strNew
,
lpBinaryType
);
/* Free the allocated string.
*/
HeapFree
(
GetProcessHeap
(),
0
,
strNew
);
}
return
ret
;
}
/*********************************************************************
* PK16FNF [KERNEL32.91]
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment