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
803b5686
Commit
803b5686
authored
Mar 14, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up load_library_as_datafile().
parent
769a84fa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
33 deletions
+21
-33
module.c
loader/module.c
+21
-33
No files found.
loader/module.c
View file @
803b5686
...
@@ -984,47 +984,32 @@ DWORD WINAPI GetModuleFileNameW( HMODULE hModule, LPWSTR lpFileName, DWORD size
...
@@ -984,47 +984,32 @@ DWORD WINAPI GetModuleFileNameW( HMODULE hModule, LPWSTR lpFileName, DWORD size
/******************************************************************
/******************************************************************
* load_library_as_datafile
* load_library_as_datafile
*
*
*/
*/
static
BOOL
load_library_as_datafile
(
const
void
*
name
,
BOOL
unicod
e
,
HMODULE
*
hmod
)
static
BOOL
load_library_as_datafile
(
LPCWSTR
nam
e
,
HMODULE
*
hmod
)
{
{
static
const
WCHAR
dotDLL
[]
=
{
'.'
,
'd'
,
'l'
,
'l'
,
0
};
WCHAR
filenameW
[
MAX_PATH
];
HANDLE
hFile
=
INVALID_HANDLE_VALUE
;
HANDLE
hFile
=
INVALID_HANDLE_VALUE
;
HANDLE
mapping
;
HANDLE
mapping
;
*
hmod
=
0
;
if
(
unicode
)
*
hmod
=
0
;
{
WCHAR
filenameW
[
MAX_PATH
];
static
WCHAR
dotDLL
[]
=
{
'.'
,
'd'
,
'l'
,
'l'
,
0
};
if
(
SearchPathW
(
NULL
,
(
LPCWSTR
)
name
,
dotDLL
,
sizeof
(
filenameW
)
/
sizeof
(
filenameW
[
0
]),
filenameW
,
NULL
))
if
(
SearchPathW
(
NULL
,
(
LPCWSTR
)
name
,
dotDLL
,
sizeof
(
filenameW
)
/
sizeof
(
filenameW
[
0
]),
{
filenameW
,
NULL
))
hFile
=
CreateFileW
(
filenameW
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
}
}
else
{
{
char
filenameA
[
MAX_PATH
];
hFile
=
CreateFileW
(
filenameW
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
if
(
SearchPathA
(
NULL
,
(
const
char
*
)
name
,
".dll"
,
sizeof
(
filenameA
),
filenameA
,
NULL
))
{
hFile
=
CreateFileA
(
filenameA
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
}
}
}
if
(
hFile
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
if
(
hFile
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
switch
(
MODULE_GetBinaryType
(
hFile
))
switch
(
MODULE_GetBinaryType
(
hFile
))
{
{
case
BINARY_PE_EXE
:
case
BINARY_PE_EXE
:
case
BINARY_PE_DLL
:
case
BINARY_PE_DLL
:
mapping
=
CreateFileMapping
A
(
hFile
,
NULL
,
PAGE_READONLY
,
0
,
0
,
NULL
);
mapping
=
CreateFileMapping
W
(
hFile
,
NULL
,
PAGE_READONLY
,
0
,
0
,
NULL
);
if
(
mapping
)
if
(
mapping
)
{
{
*
hmod
=
(
HMODULE
)
MapViewOfFile
(
mapping
,
FILE_MAP_READ
,
0
,
0
,
0
);
*
hmod
=
MapViewOfFile
(
mapping
,
FILE_MAP_READ
,
0
,
0
,
0
);
CloseHandle
(
mapping
);
CloseHandle
(
mapping
);
}
}
break
;
break
;
...
@@ -1056,19 +1041,22 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
...
@@ -1056,19 +1041,22 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
SetLastError
(
ERROR_INVALID_PARAMETER
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
return
0
;
}
}
RtlCreateUnicodeStringFromAsciiz
(
&
wstr
,
libname
);
if
(
flags
&
LOAD_LIBRARY_AS_DATAFILE
)
if
(
flags
&
LOAD_LIBRARY_AS_DATAFILE
)
{
{
/* 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
,
FALSE
,
&
hModule
))
if
(
load_library_as_datafile
(
wstr
.
Buffer
,
&
hModule
))
{
RtlFreeUnicodeString
(
&
wstr
);
return
(
HMODULE
)((
ULONG_PTR
)
hModule
+
1
);
return
(
HMODULE
)((
ULONG_PTR
)
hModule
+
1
);
}
flags
|=
DONT_RESOLVE_DLL_REFERENCES
;
/* Just in case */
flags
|=
DONT_RESOLVE_DLL_REFERENCES
;
/* Just in case */
/* Fallback to normal behaviour */
/* Fallback to normal behaviour */
}
}
RtlCreateUnicodeStringFromAsciiz
(
&
wstr
,
libname
);
nts
=
LdrLoadDll
(
NULL
,
flags
,
&
wstr
,
&
hModule
);
nts
=
LdrLoadDll
(
NULL
,
flags
,
&
wstr
,
&
hModule
);
if
(
nts
!=
STATUS_SUCCESS
)
if
(
nts
!=
STATUS_SUCCESS
)
{
{
...
@@ -1097,10 +1085,10 @@ HMODULE WINAPI LoadLibraryExW(LPCWSTR libnameW, HANDLE hfile, DWORD flags)
...
@@ -1097,10 +1085,10 @@ HMODULE WINAPI LoadLibraryExW(LPCWSTR libnameW, HANDLE hfile, DWORD flags)
if
(
flags
&
LOAD_LIBRARY_AS_DATAFILE
)
if
(
flags
&
LOAD_LIBRARY_AS_DATAFILE
)
{
{
/* 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
(
libnameW
,
TRUE
,
&
hModule
))
if
(
load_library_as_datafile
(
libnameW
,
&
hModule
))
return
(
HMODULE
)((
ULONG_PTR
)
hModule
+
1
);
return
(
HMODULE
)((
ULONG_PTR
)
hModule
+
1
);
flags
|=
DONT_RESOLVE_DLL_REFERENCES
;
/* Just in case */
flags
|=
DONT_RESOLVE_DLL_REFERENCES
;
/* Just in case */
/* Fallback to normal behaviour */
/* Fallback to normal behaviour */
...
...
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