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
8d82ab4a
Commit
8d82ab4a
authored
Aug 28, 2017
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Add support for LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE flag.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e99811ae
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
6 deletions
+36
-6
module.c
dlls/kernel32/module.c
+7
-6
loader.c
dlls/kernel32/tests/loader.c
+29
-0
No files found.
dlls/kernel32/module.c
View file @
8d82ab4a
...
@@ -936,7 +936,7 @@ WCHAR *MODULE_get_dll_load_path( LPCWSTR module )
...
@@ -936,7 +936,7 @@ WCHAR *MODULE_get_dll_load_path( LPCWSTR module )
/******************************************************************
/******************************************************************
* load_library_as_datafile
* load_library_as_datafile
*/
*/
static
BOOL
load_library_as_datafile
(
LPCWSTR
name
,
HMODULE
*
hmod
)
static
BOOL
load_library_as_datafile
(
LPCWSTR
name
,
HMODULE
*
hmod
,
DWORD
flags
)
{
{
static
const
WCHAR
dotDLL
[]
=
{
'.'
,
'd'
,
'l'
,
'l'
,
0
};
static
const
WCHAR
dotDLL
[]
=
{
'.'
,
'd'
,
'l'
,
'l'
,
0
};
...
@@ -944,14 +944,16 @@ static BOOL load_library_as_datafile( LPCWSTR name, HMODULE* hmod)
...
@@ -944,14 +944,16 @@ static BOOL load_library_as_datafile( LPCWSTR name, HMODULE* hmod)
HANDLE
hFile
=
INVALID_HANDLE_VALUE
;
HANDLE
hFile
=
INVALID_HANDLE_VALUE
;
HANDLE
mapping
;
HANDLE
mapping
;
HMODULE
module
;
HMODULE
module
;
DWORD
sharing
=
FILE_SHARE_READ
;
*
hmod
=
0
;
*
hmod
=
0
;
if
(
!
(
flags
&
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE
))
sharing
|=
FILE_SHARE_WRITE
;
if
(
SearchPathW
(
NULL
,
name
,
dotDLL
,
sizeof
(
filenameW
)
/
sizeof
(
filenameW
[
0
]),
if
(
SearchPathW
(
NULL
,
name
,
dotDLL
,
sizeof
(
filenameW
)
/
sizeof
(
filenameW
[
0
]),
filenameW
,
NULL
))
filenameW
,
NULL
))
{
{
hFile
=
CreateFileW
(
filenameW
,
GENERIC_READ
,
FILE_SHARE_READ
,
hFile
=
CreateFileW
(
filenameW
,
GENERIC_READ
,
sharing
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
NULL
,
OPEN_EXISTING
,
0
,
0
);
}
}
if
(
hFile
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
if
(
hFile
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
...
@@ -987,7 +989,6 @@ static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags )
...
@@ -987,7 +989,6 @@ static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags )
static
const
DWORD
unsupported_flags
=
load_library_search_flags
|
static
const
DWORD
unsupported_flags
=
load_library_search_flags
|
LOAD_IGNORE_CODE_AUTHZ_LEVEL
|
LOAD_IGNORE_CODE_AUTHZ_LEVEL
|
LOAD_LIBRARY_AS_IMAGE_RESOURCE
|
LOAD_LIBRARY_AS_IMAGE_RESOURCE
|
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE
|
LOAD_LIBRARY_REQUIRE_SIGNED_TARGET
|
LOAD_LIBRARY_REQUIRE_SIGNED_TARGET
|
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
;
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
;
...
@@ -998,7 +999,7 @@ static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags )
...
@@ -998,7 +999,7 @@ static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags )
load_path
=
MODULE_get_dll_load_path
(
flags
&
LOAD_WITH_ALTERED_SEARCH_PATH
?
libname
->
Buffer
:
NULL
);
load_path
=
MODULE_get_dll_load_path
(
flags
&
LOAD_WITH_ALTERED_SEARCH_PATH
?
libname
->
Buffer
:
NULL
);
if
(
flags
&
LOAD_LIBRARY_AS_DATAFILE
)
if
(
flags
&
(
LOAD_LIBRARY_AS_DATAFILE
|
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE
)
)
{
{
ULONG_PTR
magic
;
ULONG_PTR
magic
;
...
@@ -1014,7 +1015,7 @@ static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags )
...
@@ -1014,7 +1015,7 @@ static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags )
/* The method in load_library_as_datafile allows searching for the
/* The method in load_library_as_datafile allows searching for the
* 'native' libraries only
* 'native' libraries only
*/
*/
if
(
load_library_as_datafile
(
libname
->
Buffer
,
&
hModule
))
goto
done
;
if
(
load_library_as_datafile
(
libname
->
Buffer
,
&
hModule
,
flags
))
goto
done
;
flags
|=
DONT_RESOLVE_DLL_REFERENCES
;
/* Just in case */
flags
|=
DONT_RESOLVE_DLL_REFERENCES
;
/* Just in case */
/* Fallback to normal behaviour */
/* Fallback to normal behaviour */
}
}
...
...
dlls/kernel32/tests/loader.c
View file @
8d82ab4a
...
@@ -523,6 +523,7 @@ static void test_Loader(void)
...
@@ -523,6 +523,7 @@ static void test_Loader(void)
};
};
int
i
;
int
i
;
DWORD
file_size
;
DWORD
file_size
;
HANDLE
h
;
HMODULE
hlib
,
hlib_as_data_file
;
HMODULE
hlib
,
hlib_as_data_file
;
char
temp_path
[
MAX_PATH
];
char
temp_path
[
MAX_PATH
];
char
dll_name
[
MAX_PATH
];
char
dll_name
[
MAX_PATH
];
...
@@ -706,8 +707,36 @@ static void test_Loader(void)
...
@@ -706,8 +707,36 @@ static void test_Loader(void)
ok
(
!
hlib
,
"GetModuleHandle should fail
\n
"
);
ok
(
!
hlib
,
"GetModuleHandle should fail
\n
"
);
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
h
=
CreateFileA
(
dll_name
,
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
h
!=
INVALID_HANDLE_VALUE
,
"open failed err %u
\n
"
,
GetLastError
()
);
CloseHandle
(
h
);
SetLastError
(
0xdeadbeef
);
ret
=
FreeLibrary
(
hlib_as_data_file
);
ok
(
ret
,
"FreeLibrary error %d
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
hlib_as_data_file
=
LoadLibraryExA
(
dll_name
,
0
,
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE
);
if
(
!
((
ULONG_PTR
)
hlib_as_data_file
&
1
)
||
/* winxp */
(
!
hlib_as_data_file
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
))
/* w2k3 */
{
win_skip
(
"LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE not supported
\n
"
);
FreeLibrary
(
hlib_as_data_file
);
}
else
{
ok
(
hlib_as_data_file
!=
0
,
"LoadLibraryEx error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
h
=
CreateFileA
(
dll_name
,
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
todo_wine
ok
(
h
==
INVALID_HANDLE_VALUE
,
"open succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_SHARING_VIOLATION
,
"wrong error %u
\n
"
,
GetLastError
()
);
CloseHandle
(
h
);
SetLastError
(
0xdeadbeef
);
ret
=
FreeLibrary
(
hlib_as_data_file
);
ret
=
FreeLibrary
(
hlib_as_data_file
);
ok
(
ret
,
"FreeLibrary error %d
\n
"
,
GetLastError
());
ok
(
ret
,
"FreeLibrary error %d
\n
"
,
GetLastError
());
}
query_image_section
(
i
,
dll_name
,
&
nt_header
);
query_image_section
(
i
,
dll_name
,
&
nt_header
);
}
}
...
...
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