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
0e7314a2
Commit
0e7314a2
authored
Feb 24, 2012
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Feb 24, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Add a test for LoadLibrary called on a not DLL image.
parent
8f6ddf78
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
6 deletions
+33
-6
loader.c
dlls/kernel32/tests/loader.c
+33
-6
No files found.
dlls/kernel32/tests/loader.c
View file @
0e7314a2
...
...
@@ -559,7 +559,7 @@ static void test_ImportDescriptors(void)
}
}
static
void
test_image_mapping
(
const
char
*
dll_name
,
DWORD
scn_page_access
)
static
void
test_image_mapping
(
const
char
*
dll_name
,
DWORD
scn_page_access
,
BOOL
is_dll
)
{
HANDLE
hfile
,
hmap
;
NTSTATUS
status
;
...
...
@@ -617,7 +617,6 @@ static void test_image_mapping(const char *dll_name, DWORD scn_page_access)
}
ok
(
status
==
STATUS_IMAGE_NOT_AT_BASE
,
"expected STATUS_IMAGE_NOT_AT_BASE, got %x
\n
"
,
status
);
ok
(
addr2
!=
0
,
"mapped address should be valid
\n
"
);
ok
(
addr2
!=
addr1
,
"mapped addresses should be different
\n
"
);
SetLastError
(
0xdeadbeef
);
...
...
@@ -635,6 +634,7 @@ static void test_image_mapping(const char *dll_name, DWORD scn_page_access)
ok
(
status
==
STATUS_SUCCESS
,
"NtUnmapViewOfSection error %x
\n
"
,
status
);
addr2
=
MapViewOfFile
(
hmap
,
0
,
0
,
0
,
0
);
ok
(
addr2
!=
0
,
"mapped address should be valid
\n
"
);
ok
(
addr2
!=
addr1
,
"mapped addresses should be different
\n
"
);
SetLastError
(
0xdeadbeef
);
...
...
@@ -650,6 +650,24 @@ static void test_image_mapping(const char *dll_name, DWORD scn_page_access)
UnmapViewOfFile
(
addr2
);
SetLastError
(
0xdeadbeef
);
addr2
=
LoadLibrary
(
dll_name
);
if
(
is_dll
)
{
ok
(
!
addr2
,
"LoadLibrary should fail, is_dll %d
\n
"
,
is_dll
);
ok
(
GetLastError
()
==
ERROR_INVALID_ADDRESS
,
"expected ERROR_INVALID_ADDRESS, got %d
\n
"
,
GetLastError
());
}
else
{
BOOL
ret
;
ok
(
addr2
!=
0
,
"LoadLibrary error %d, is_dll %d
\n
"
,
GetLastError
(),
is_dll
);
ok
(
addr2
!=
addr1
,
"mapped addresses should be different
\n
"
);
SetLastError
(
0xdeadbeef
);
ret
=
FreeLibrary
(
addr2
);
ok
(
ret
,
"FreeLibrary error %d
\n
"
,
GetLastError
());
}
wine_is_broken:
status
=
pNtUnmapViewOfSection
(
GetCurrentProcess
(),
addr1
);
ok
(
status
==
STATUS_SUCCESS
,
"NtUnmapViewOfSection error %x
\n
"
,
status
);
...
...
@@ -955,13 +973,21 @@ static void test_section_access(void)
ret
=
FreeLibrary
(
hlib
);
ok
(
ret
,
"FreeLibrary error %d
\n
"
,
GetLastError
());
test_image_mapping
(
dll_name
,
td
[
i
].
scn_page_access
);
test_image_mapping
(
dll_name
,
td
[
i
].
scn_page_access
,
TRUE
);
/* reset IMAGE_FILE_DLL otherwise CreateProcess fails */
nt_header
.
FileHeader
.
Characteristics
=
IMAGE_FILE_EXECUTABLE_IMAGE
|
IMAGE_FILE_RELOCS_STRIPPED
;
SetLastError
(
0xdeadbeef
);
hfile
=
CreateFile
(
dll_name
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"CreateFile error %d
\n
"
,
GetLastError
());
/* LoadLibrary called on an already memory-mapped file in
* test_image_mapping() above leads to a file handle leak
* under nt4, and inability to overwrite and delete the file
* due to sharing violation error. Ignore it and skip the test,
* but leave a not deletable temporary file.
*/
ok
(
hfile
!=
INVALID_HANDLE_VALUE
||
broken
(
hfile
==
INVALID_HANDLE_VALUE
)
/* nt4 */
,
"CreateFile error %d
\n
"
,
GetLastError
());
if
(
hfile
==
INVALID_HANDLE_VALUE
)
goto
nt4_is_broken
;
SetFilePointer
(
hfile
,
sizeof
(
dos_header
),
NULL
,
FILE_BEGIN
);
SetLastError
(
0xdeadbeef
);
ret
=
WriteFile
(
hfile
,
&
nt_header
,
sizeof
(
DWORD
)
+
sizeof
(
IMAGE_FILE_HEADER
),
&
dummy
,
NULL
);
...
...
@@ -1002,11 +1028,12 @@ static void test_section_access(void)
CloseHandle
(
pi
.
hThread
);
CloseHandle
(
pi
.
hProcess
);
test_image_mapping
(
dll_name
,
td
[
i
].
scn_page_access
);
test_image_mapping
(
dll_name
,
td
[
i
].
scn_page_access
,
FALSE
);
nt4_is_broken:
SetLastError
(
0xdeadbeef
);
ret
=
DeleteFile
(
dll_name
);
ok
(
ret
,
"DeleteFile error %d
\n
"
,
GetLastError
());
ok
(
ret
||
broken
(
!
ret
)
/* nt4 */
,
"DeleteFile error %d
\n
"
,
GetLastError
());
}
}
...
...
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