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
0ea57721
Commit
0ea57721
authored
Mar 22, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Use NtAreMappedFilesTheSame() to find duplicated module mappings.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
20c4ae45
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletion
+31
-1
loader.c
dlls/ntdll/loader.c
+31
-1
No files found.
dlls/ntdll/loader.c
View file @
0ea57721
...
...
@@ -1167,6 +1167,8 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name
wm
->
ldr
.
Flags
=
LDR_DONT_RESOLVE_REFS
|
(
builtin
?
LDR_WINE_INTERNAL
:
0
);
wm
->
ldr
.
TlsIndex
=
-
1
;
wm
->
ldr
.
LoadCount
=
1
;
wm
->
ldr
.
CheckSum
=
nt
->
OptionalHeader
.
CheckSum
;
wm
->
ldr
.
TimeDateStamp
=
nt
->
FileHeader
.
TimeDateStamp
;
if
(
!
(
buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
nt_name
->
Length
-
3
*
sizeof
(
WCHAR
)
)))
{
...
...
@@ -2275,6 +2277,33 @@ static NTSTATUS open_dll_file( UNICODE_STRING *nt_name, WINE_MODREF **pwm, HANDL
/******************************************************************************
* find_existing_module
*
* Find an existing module that is the same mapping as the new module.
*/
static
WINE_MODREF
*
find_existing_module
(
HMODULE
module
)
{
WINE_MODREF
*
wm
;
LIST_ENTRY
*
mark
,
*
entry
;
LDR_DATA_TABLE_ENTRY
*
mod
;
IMAGE_NT_HEADERS
*
nt
=
RtlImageNtHeader
(
module
);
if
((
wm
=
get_modref
(
module
)))
return
wm
;
mark
=
&
NtCurrentTeb
()
->
Peb
->
LdrData
->
InMemoryOrderModuleList
;
for
(
entry
=
mark
->
Flink
;
entry
!=
mark
;
entry
=
entry
->
Flink
)
{
mod
=
CONTAINING_RECORD
(
entry
,
LDR_DATA_TABLE_ENTRY
,
InMemoryOrderLinks
);
if
(
mod
->
TimeDateStamp
!=
nt
->
FileHeader
.
TimeDateStamp
)
continue
;
if
(
mod
->
CheckSum
!=
nt
->
OptionalHeader
.
CheckSum
)
continue
;
if
(
NtAreMappedFilesTheSame
(
mod
->
DllBase
,
module
)
!=
STATUS_SUCCESS
)
continue
;
return
CONTAINING_RECORD
(
mod
,
WINE_MODREF
,
ldr
);
}
return
NULL
;
}
/******************************************************************************
* load_native_dll (internal)
*/
static
NTSTATUS
load_native_dll
(
LPCWSTR
load_path
,
const
UNICODE_STRING
*
nt_name
,
HANDLE
mapping
,
...
...
@@ -2351,12 +2380,13 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, UNICODE_STRING *nt_name,
status
=
unix_funcs
->
load_builtin_dll
(
nt_name
,
&
module
,
&
image_info
,
prefer_native
);
if
(
status
)
return
status
;
if
((
*
pwm
=
get_modref
(
module
)))
/* already loaded */
if
((
*
pwm
=
find_existing_module
(
module
)))
/* already loaded */
{
if
((
*
pwm
)
->
ldr
.
LoadCount
!=
-
1
)
(
*
pwm
)
->
ldr
.
LoadCount
++
;
TRACE
(
"Found %s for %s at %p, count=%d
\n
"
,
debugstr_us
(
&
(
*
pwm
)
->
ldr
.
FullDllName
),
debugstr_us
(
nt_name
),
(
*
pwm
)
->
ldr
.
DllBase
,
(
*
pwm
)
->
ldr
.
LoadCount
);
if
(
module
!=
(
*
pwm
)
->
ldr
.
DllBase
)
NtUnmapViewOfSection
(
NtCurrentProcess
(),
module
);
return
STATUS_SUCCESS
;
}
...
...
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