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
1a7dd7cd
Commit
1a7dd7cd
authored
May 06, 2020
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
May 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add a PE test image that resembles format of some of 8k demos.
Signed-off-by:
Dmitry Timoshkov
<
dmitry@baikal.ru
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
360820fb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
2 deletions
+38
-2
loader.c
dlls/kernel32/tests/loader.c
+38
-2
No files found.
dlls/kernel32/tests/loader.c
View file @
1a7dd7cd
...
...
@@ -228,7 +228,7 @@ static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size,
{
SetLastError
(
0xdeadbeef
);
ret
=
WriteFile
(
hfile
,
&
nt_header
->
OptionalHeader
,
min
(
nt_header
->
FileHeader
.
SizeOfOptionalHeader
,
sizeof
(
IMAGE_OPTIONAL_HEADER
)
),
sizeof
(
IMAGE_OPTIONAL_HEADER
),
&
dummy
,
NULL
);
ok
(
ret
,
"WriteFile error %d
\n
"
,
GetLastError
());
if
(
nt_header
->
FileHeader
.
SizeOfOptionalHeader
>
sizeof
(
IMAGE_OPTIONAL_HEADER
))
...
...
@@ -244,6 +244,8 @@ static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size,
assert
(
nt_header
->
FileHeader
.
NumberOfSections
<=
1
);
if
(
nt_header
->
FileHeader
.
NumberOfSections
)
{
SetFilePointer
(
hfile
,
dos_size
+
sizeof
(
DWORD
)
+
sizeof
(
IMAGE_FILE_HEADER
)
+
nt_header
->
FileHeader
.
SizeOfOptionalHeader
,
NULL
,
FILE_BEGIN
);
section
.
SizeOfRawData
=
10
;
if
(
nt_header
->
OptionalHeader
.
SectionAlignment
>=
page_size
)
...
...
@@ -268,6 +270,17 @@ static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size,
ret
=
WriteFile
(
hfile
,
section_data
,
sizeof
(
section_data
),
&
dummy
,
NULL
);
ok
(
ret
,
"WriteFile error %d
\n
"
,
GetLastError
());
}
/* Minimal PE image that Windows7+ is able to load: 268 bytes */
size
=
GetFileSize
(
hfile
,
NULL
);
if
(
size
<
268
)
{
file_align
=
268
-
size
;
SetLastError
(
0xdeadbeef
);
ret
=
WriteFile
(
hfile
,
filler
,
file_align
,
&
dummy
,
NULL
);
ok
(
ret
,
"WriteFile error %d
\n
"
,
GetLastError
());
}
size
=
GetFileSize
(
hfile
,
NULL
);
CloseHandle
(
hfile
);
return
size
;
...
...
@@ -417,7 +430,8 @@ static BOOL query_image_section( int id, const char *dll_name, const IMAGE_NT_HE
ok
(
image
.
LoaderFlags
==
(
cor_header
!=
NULL
),
"%u: LoaderFlags wrong %08x
\n
"
,
id
,
image
.
LoaderFlags
);
ok
(
image
.
ImageFileSize
==
file_size
||
broken
(
!
image
.
ImageFileSize
),
/* winxpsp1 */
"%u: ImageFileSize wrong %08x / %08x
\n
"
,
id
,
image
.
ImageFileSize
,
file_size
);
ok
(
image
.
CheckSum
==
nt_header
->
OptionalHeader
.
CheckSum
,
"%u: CheckSum wrong %08x / %08x
\n
"
,
id
,
ok
(
image
.
CheckSum
==
nt_header
->
OptionalHeader
.
CheckSum
||
broken
(
truncated
),
"%u: CheckSum wrong %08x / %08x
\n
"
,
id
,
image
.
CheckSum
,
nt_header
->
OptionalHeader
.
CheckSum
);
if
(
nt_header
->
OptionalHeader
.
SizeOfCode
||
nt_header
->
OptionalHeader
.
AddressOfEntryPoint
)
...
...
@@ -768,6 +782,7 @@ static void test_Loader(void)
/* Mandatory are all fields up to SizeOfHeaders, everything else
* is really optional (at least that's true for XP).
*/
#if 0 /* 32-bit Windows 8 crashes inside of LoadLibrary */
{ sizeof(dos_header),
1, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
sizeof(dos_header) + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER) + FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum) + sizeof(IMAGE_SECTION_HEADER) + 0x10,
...
...
@@ -775,6 +790,7 @@ static void test_Loader(void)
{ ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT, ERROR_INVALID_ADDRESS,
ERROR_NOACCESS }
},
#endif
{
sizeof
(
dos_header
),
0
,
FIELD_OFFSET
(
IMAGE_OPTIONAL_HEADER
,
CheckSum
),
0x200
,
0x200
,
0xd0
,
/* beyond of the end of file */
...
...
@@ -843,6 +859,14 @@ static void test_Loader(void)
0x40
,
/* minimal image size that Windows7 accepts */
0
,
{
ERROR_SUCCESS
}
},
/* the following data mimics the PE image which 8k demos have */
{
0x04
,
0
,
0x08
,
0x04
/* also serves as e_lfanew in the truncated MZ header */
,
0x04
,
0x200000
,
0x40
,
{
ERROR_SUCCESS
}
}
};
int
i
;
...
...
@@ -1077,6 +1101,18 @@ static void test_Loader(void)
ok
(
ret
,
"FreeLibrary error %d
\n
"
,
GetLastError
());
}
SetLastError
(
0xdeadbeef
);
ret
=
DeleteFileA
(
dll_name
);
ok
(
ret
,
"DeleteFile error %d
\n
"
,
GetLastError
());
nt_header
.
OptionalHeader
.
AddressOfEntryPoint
=
0x12345678
;
file_size
=
create_test_dll
(
&
dos_header
,
td
[
i
].
size_of_dos_header
,
&
nt_header
,
dll_name
);
if
(
!
file_size
)
{
ok
(
0
,
"could not create %s
\n
"
,
dll_name
);
break
;
}
query_image_section
(
i
,
dll_name
,
&
nt_header
,
NULL
);
}
else
...
...
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