Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
b64530ee
Commit
b64530ee
authored
May 16, 2007
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Reimplement LdrGetDllHandle to use the same search algorithm as LdrLoadDll.
parent
4de936e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
62 deletions
+43
-62
loader.c
dlls/ntdll/loader.c
+41
-60
ntdll.spec
dlls/ntdll/ntdll.spec
+1
-1
winternl.h
include/winternl.h
+1
-1
No files found.
dlls/ntdll/loader.c
View file @
b64530ee
...
...
@@ -1136,64 +1136,6 @@ NTSTATUS WINAPI LdrUnlockLoaderLock( ULONG flags, ULONG magic )
/******************************************************************
* LdrGetDllHandle (NTDLL.@)
*/
NTSTATUS
WINAPI
LdrGetDllHandle
(
ULONG
x
,
ULONG
y
,
const
UNICODE_STRING
*
name
,
HMODULE
*
base
)
{
NTSTATUS
status
=
STATUS_DLL_NOT_FOUND
;
WCHAR
dllname
[
MAX_PATH
+
4
],
*
p
;
UNICODE_STRING
str
;
PLIST_ENTRY
mark
,
entry
;
PLDR_MODULE
mod
;
if
(
x
!=
0
||
y
!=
0
)
FIXME
(
"Unknown behavior, please report
\n
"
);
/* Append .DLL to name if no extension present */
if
(
!
(
p
=
strrchrW
(
name
->
Buffer
,
'.'
))
||
strchrW
(
p
,
'/'
)
||
strchrW
(
p
,
'\\'
))
{
if
(
name
->
Length
>=
MAX_PATH
)
return
STATUS_NAME_TOO_LONG
;
strcpyW
(
dllname
,
name
->
Buffer
);
strcatW
(
dllname
,
dllW
);
RtlInitUnicodeString
(
&
str
,
dllname
);
name
=
&
str
;
}
RtlEnterCriticalSection
(
&
loader_section
);
if
(
cached_modref
)
{
if
(
RtlEqualUnicodeString
(
name
,
&
cached_modref
->
ldr
.
FullDllName
,
TRUE
)
||
RtlEqualUnicodeString
(
name
,
&
cached_modref
->
ldr
.
BaseDllName
,
TRUE
))
{
*
base
=
cached_modref
->
ldr
.
BaseAddress
;
status
=
STATUS_SUCCESS
;
goto
done
;
}
}
mark
=
&
NtCurrentTeb
()
->
Peb
->
LdrData
->
InLoadOrderModuleList
;
for
(
entry
=
mark
->
Flink
;
entry
!=
mark
;
entry
=
entry
->
Flink
)
{
mod
=
CONTAINING_RECORD
(
entry
,
LDR_MODULE
,
InLoadOrderModuleList
);
if
(
RtlEqualUnicodeString
(
name
,
&
mod
->
FullDllName
,
TRUE
)
||
RtlEqualUnicodeString
(
name
,
&
mod
->
BaseDllName
,
TRUE
))
{
cached_modref
=
CONTAINING_RECORD
(
mod
,
WINE_MODREF
,
ldr
);
*
base
=
mod
->
BaseAddress
;
status
=
STATUS_SUCCESS
;
break
;
}
}
done:
RtlLeaveCriticalSection
(
&
loader_section
);
TRACE
(
"%x %x %s -> %p
\n
"
,
x
,
y
,
debugstr_us
(
name
),
status
?
NULL
:
*
base
);
return
status
;
}
/******************************************************************
* LdrGetProcedureAddress (NTDLL.@)
*/
NTSTATUS
WINAPI
LdrGetProcedureAddress
(
HMODULE
module
,
const
ANSI_STRING
*
name
,
...
...
@@ -1642,7 +1584,7 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname,
if
(
len
)
{
if
(
len
>=
*
size
)
goto
overflow
;
if
((
*
pwm
=
find_fullname_module
(
filename
))
!=
NULL
)
goto
found
;
if
((
*
pwm
=
find_fullname_module
(
filename
))
||
!
handle
)
goto
found
;
if
(
!
RtlDosPathNameToNtPathName_U
(
filename
,
&
nt_name
,
NULL
,
NULL
))
{
...
...
@@ -1682,7 +1624,7 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname,
len
=
nt_name
.
Length
-
4
*
sizeof
(
WCHAR
);
/* for \??\ prefix */
if
(
len
>=
*
size
)
goto
overflow
;
memcpy
(
filename
,
nt_name
.
Buffer
+
4
,
len
+
sizeof
(
WCHAR
)
);
if
(
!
(
*
pwm
=
find_fullname_module
(
filename
)))
if
(
!
(
*
pwm
=
find_fullname_module
(
filename
))
&&
handle
)
{
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
0
;
...
...
@@ -1839,6 +1781,45 @@ NTSTATUS WINAPI LdrLoadDll(LPCWSTR path_name, DWORD flags,
return
nts
;
}
/******************************************************************
* LdrGetDllHandle (NTDLL.@)
*/
NTSTATUS
WINAPI
LdrGetDllHandle
(
LPCWSTR
load_path
,
ULONG
flags
,
const
UNICODE_STRING
*
name
,
HMODULE
*
base
)
{
NTSTATUS
status
;
WCHAR
buffer
[
128
];
WCHAR
*
filename
;
ULONG
size
;
WINE_MODREF
*
wm
;
RtlEnterCriticalSection
(
&
loader_section
);
if
(
!
load_path
)
load_path
=
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
DllPath
.
Buffer
;
filename
=
buffer
;
size
=
sizeof
(
buffer
);
for
(;;)
{
status
=
find_dll_file
(
load_path
,
name
->
Buffer
,
filename
,
&
size
,
&
wm
,
NULL
);
if
(
filename
!=
buffer
)
RtlFreeHeap
(
GetProcessHeap
(),
0
,
filename
);
if
(
status
!=
STATUS_BUFFER_TOO_SMALL
)
break
;
/* grow the buffer and retry */
if
(
!
(
filename
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
size
)))
return
STATUS_NO_MEMORY
;
}
if
(
status
==
STATUS_SUCCESS
)
{
if
(
wm
)
*
base
=
wm
->
ldr
.
BaseAddress
;
else
status
=
STATUS_DLL_NOT_FOUND
;
}
RtlLeaveCriticalSection
(
&
loader_section
);
TRACE
(
"%s -> %p (load path %s)
\n
"
,
debugstr_us
(
name
),
status
?
NULL
:
*
base
,
debugstr_w
(
load_path
)
);
return
status
;
}
/******************************************************************
* LdrQueryProcessModuleInformation
*
...
...
dlls/ntdll/ntdll.spec
View file @
b64530ee
...
...
@@ -63,7 +63,7 @@
# @ stub LdrFindResourceEx_U
@ stdcall LdrFindResource_U(long ptr long ptr)
@ stub LdrFlushAlternateResourceModules
@ stdcall LdrGetDllHandle(
long
long ptr ptr)
@ stdcall LdrGetDllHandle(
wstr
long ptr ptr)
# @ stub LdrGetDllHandleEx
@ stdcall LdrGetProcedureAddress(ptr ptr long ptr)
# @ stub LdrHotPatchRoutine
...
...
include/winternl.h
View file @
b64530ee
...
...
@@ -1733,7 +1733,7 @@ NTSTATUS WINAPIV DbgPrintEx(ULONG iComponentId, ULONG Level, LPCSTR fmt, ...);
NTSTATUS
WINAPI
LdrAccessResource
(
HMODULE
,
const
IMAGE_RESOURCE_DATA_ENTRY
*
,
void
**
,
PULONG
);
NTSTATUS
WINAPI
LdrFindResourceDirectory_U
(
HMODULE
,
const
LDR_RESOURCE_INFO
*
,
ULONG
,
const
IMAGE_RESOURCE_DIRECTORY
**
);
NTSTATUS
WINAPI
LdrFindResource_U
(
HMODULE
,
const
LDR_RESOURCE_INFO
*
,
ULONG
,
const
IMAGE_RESOURCE_DATA_ENTRY
**
);
NTSTATUS
WINAPI
LdrGetDllHandle
(
ULONG
,
ULONG
,
const
UNICODE_STRING
*
,
HMODULE
*
);
NTSTATUS
WINAPI
LdrGetDllHandle
(
LPCWSTR
,
ULONG
,
const
UNICODE_STRING
*
,
HMODULE
*
);
NTSTATUS
WINAPI
LdrGetProcedureAddress
(
HMODULE
,
const
ANSI_STRING
*
,
ULONG
,
void
**
);
void
WINAPI
LdrInitializeThunk
(
ULONG
,
ULONG
,
ULONG
,
ULONG
);
NTSTATUS
WINAPI
LdrLoadDll
(
LPCWSTR
,
DWORD
,
const
UNICODE_STRING
*
,
HMODULE
*
);
...
...
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