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
720ab29a
Commit
720ab29a
authored
Nov 28, 2006
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Nov 28, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Add more obscure PE images that XP is able to load.
parent
7e4d3d95
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
10 deletions
+35
-10
loader.c
dlls/kernel32/tests/loader.c
+35
-10
No files found.
dlls/kernel32/tests/loader.c
View file @
720ab29a
...
@@ -104,46 +104,46 @@ START_TEST(loader)
...
@@ -104,46 +104,46 @@ START_TEST(loader)
{
{
static
const
struct
test_data
static
const
struct
test_data
{
{
WORD
size_of_optional_header
;
WORD
number_of_sections
,
size_of_optional_header
;
DWORD
section_alignment
,
file_alignment
;
DWORD
section_alignment
,
file_alignment
;
DWORD
size_of_image
,
size_of_headers
;
DWORD
size_of_image
,
size_of_headers
;
DWORD
error
;
/* 0 means LoadLibrary should succeed */
DWORD
error
;
/* 0 means LoadLibrary should succeed */
}
td
[]
=
}
td
[]
=
{
{
{
0
,
0
,
0
,
0
,
0
,
{
1
,
0
,
0
,
0
,
0
,
0
,
ERROR_BAD_EXE_FORMAT
ERROR_BAD_EXE_FORMAT
},
},
{
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x1000
,
0x1000
,
{
1
,
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x1000
,
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0xe00
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0xe00
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
ERROR_BAD_EXE_FORMAT
/* XP doesn't like too small image size */
ERROR_BAD_EXE_FORMAT
/* XP doesn't like too small image size */
},
},
{
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x1000
,
0x1000
,
{
1
,
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x1000
,
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
ERROR_SUCCESS
ERROR_SUCCESS
},
},
{
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x1000
,
0x1000
,
{
1
,
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x1000
,
0x1000
,
0x1f00
,
0x1f00
,
0x1000
,
0x1000
,
ERROR_SUCCESS
ERROR_SUCCESS
},
},
{
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x200
,
0x200
,
{
1
,
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x200
,
0x200
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
ERROR_SUCCESS
ERROR_SUCCESS
},
},
{
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x200
,
0x1000
,
{
1
,
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x200
,
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
ERROR_BAD_EXE_FORMAT
/* XP doesn't like aligments */
ERROR_BAD_EXE_FORMAT
/* XP doesn't like aligments */
},
},
{
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x1000
,
0x200
,
{
1
,
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x1000
,
0x200
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
ERROR_SUCCESS
ERROR_SUCCESS
},
},
{
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x1000
,
0x200
,
{
1
,
sizeof
(
IMAGE_OPTIONAL_HEADER
),
0x1000
,
0x200
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0x1000
,
sizeof
(
dos_header
)
+
sizeof
(
nt_header
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0x1000
,
0x200
,
0x200
,
ERROR_SUCCESS
ERROR_SUCCESS
...
@@ -151,10 +151,30 @@ START_TEST(loader)
...
@@ -151,10 +151,30 @@ START_TEST(loader)
/* Mandatory are all fields up to SizeOfHeaders, everything else
/* Mandatory are all fields up to SizeOfHeaders, everything else
* is really optional (at least that's true for XP).
* is really optional (at least that's true for XP).
*/
*/
{
FIELD_OFFSET
(
IMAGE_OPTIONAL_HEADER
,
CheckSum
),
0x200
,
0x200
,
{
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
,
sizeof
(
dos_header
)
+
sizeof
(
DWORD
)
+
sizeof
(
IMAGE_FILE_HEADER
)
+
FIELD_OFFSET
(
IMAGE_OPTIONAL_HEADER
,
CheckSum
)
+
sizeof
(
IMAGE_SECTION_HEADER
)
+
0x10
,
sizeof
(
dos_header
)
+
sizeof
(
DWORD
)
+
sizeof
(
IMAGE_FILE_HEADER
)
+
FIELD_OFFSET
(
IMAGE_OPTIONAL_HEADER
,
CheckSum
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
sizeof
(
dos_header
)
+
sizeof
(
DWORD
)
+
sizeof
(
IMAGE_FILE_HEADER
)
+
FIELD_OFFSET
(
IMAGE_OPTIONAL_HEADER
,
CheckSum
)
+
sizeof
(
IMAGE_SECTION_HEADER
),
ERROR_SUCCESS
ERROR_SUCCESS
},
{
0
,
FIELD_OFFSET
(
IMAGE_OPTIONAL_HEADER
,
CheckSum
),
0x200
,
0x200
,
0xd0
,
/* beyond of the end of file */
0xc0
,
/* beyond of the end of file */
ERROR_SUCCESS
},
{
0
,
FIELD_OFFSET
(
IMAGE_OPTIONAL_HEADER
,
CheckSum
),
0x200
,
0x200
,
0x1000
,
0
,
ERROR_SUCCESS
},
{
0
,
FIELD_OFFSET
(
IMAGE_OPTIONAL_HEADER
,
CheckSum
),
0x200
,
0x200
,
1
,
0
,
ERROR_SUCCESS
},
{
0
,
FIELD_OFFSET
(
IMAGE_OPTIONAL_HEADER
,
CheckSum
),
0x200
,
0x200
,
0
,
0
,
ERROR_BAD_EXE_FORMAT
/* image size == 0 -> failure */
}
}
};
};
static
const
char
filler
[
0x1000
];
static
const
char
filler
[
0x1000
];
...
@@ -188,6 +208,7 @@ START_TEST(loader)
...
@@ -188,6 +208,7 @@ START_TEST(loader)
ok
(
WriteFile
(
hfile
,
&
dos_header
,
sizeof
(
dos_header
),
&
dummy
,
NULL
),
ok
(
WriteFile
(
hfile
,
&
dos_header
,
sizeof
(
dos_header
),
&
dummy
,
NULL
),
"WriteFile error %d
\n
"
,
GetLastError
());
"WriteFile error %d
\n
"
,
GetLastError
());
nt_header
.
FileHeader
.
NumberOfSections
=
td
[
i
].
number_of_sections
;
nt_header
.
FileHeader
.
SizeOfOptionalHeader
=
td
[
i
].
size_of_optional_header
;
nt_header
.
FileHeader
.
SizeOfOptionalHeader
=
td
[
i
].
size_of_optional_header
;
nt_header
.
OptionalHeader
.
SectionAlignment
=
td
[
i
].
section_alignment
;
nt_header
.
OptionalHeader
.
SectionAlignment
=
td
[
i
].
section_alignment
;
...
@@ -207,6 +228,9 @@ START_TEST(loader)
...
@@ -207,6 +228,9 @@ START_TEST(loader)
"WriteFile error %d
\n
"
,
GetLastError
());
"WriteFile error %d
\n
"
,
GetLastError
());
}
}
assert
(
nt_header
.
FileHeader
.
NumberOfSections
<=
1
);
if
(
nt_header
.
FileHeader
.
NumberOfSections
)
{
if
(
nt_header
.
OptionalHeader
.
SectionAlignment
==
si
.
dwPageSize
)
if
(
nt_header
.
OptionalHeader
.
SectionAlignment
==
si
.
dwPageSize
)
{
{
section
.
VirtualAddress
=
nt_header
.
OptionalHeader
.
SectionAlignment
;
section
.
VirtualAddress
=
nt_header
.
OptionalHeader
.
SectionAlignment
;
...
@@ -235,6 +259,7 @@ START_TEST(loader)
...
@@ -235,6 +259,7 @@ START_TEST(loader)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ok
(
WriteFile
(
hfile
,
filler
,
0x10
,
&
dummy
,
NULL
),
ok
(
WriteFile
(
hfile
,
filler
,
0x10
,
&
dummy
,
NULL
),
"WriteFile error %d
\n
"
,
GetLastError
());
"WriteFile error %d
\n
"
,
GetLastError
());
}
CloseHandle
(
hfile
);
CloseHandle
(
hfile
);
...
...
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