[3/4] kernel32: Support for LIBRARY_SEARCH_USER_DIRS when loading dlls
Carlos Palminha
CARLOS.PALMINHA at synopsys.com
Thu Aug 3 11:07:47 CDT 2017
If LIBRARY_SEARCH_USER_DIRS flag is used when loading a dll,
directories add using AddDllDirectory or SetDllDirectory are searched.
Standard search path directories are not used and it cannot be
combined with ALTERED_SEARCH_PATH.
Signed-off-by: Carlos Palminha <palminha at synopsys.com>
---
dlls/kernel32/module.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c
index 21de9db503..f4841623d9 100644
--- a/dlls/kernel32/module.c
+++ b/dlls/kernel32/module.c
@@ -778,7 +778,7 @@ static inline const WCHAR *get_module_path_end(const WCHAR *module)
*/
WCHAR *MODULE_get_dll_load_path_flags( DWORD flags ) {
- int len = 0;
+ int len = 0, plen = 0;
WCHAR *ret = NULL, *p = NULL;
if (flags & LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR) {
@@ -790,7 +790,27 @@ WCHAR *MODULE_get_dll_load_path_flags( DWORD flags ) {
}
if (flags & LOAD_LIBRARY_SEARCH_USER_DIRS || flags & LOAD_LIBRARY_SEARCH_DEFAULT_DIRS) {
- FIXME("unsupported flag used LOAD_LIBRARY_SEARCH_USER_DIRS (flags: 0x%08x)\n", flags);
+ RtlEnterCriticalSection( &dlldir_section );
+ if (dll_directory) {
+ plen = len;
+ len += strlenW(dll_directory) + 1;
+
+ if (ret) {
+ ret = HeapReAlloc( GetProcessHeap(), 0, ret, len * sizeof(WCHAR) );
+ p = ret;
+ p += plen;
+ }
+ else {
+ p = ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+ }
+
+ if (p) {
+ strcpyW( p, dll_directory );
+ p += strlenW(p);
+ *p++ = ';';
+ }
+ }
+ RtlLeaveCriticalSection( &dlldir_section );
}
if (flags & LOAD_LIBRARY_SEARCH_SYSTEM32 || flags & LOAD_LIBRARY_SEARCH_DEFAULT_DIRS) {
@@ -801,11 +821,16 @@ WCHAR *MODULE_get_dll_load_path_flags( DWORD flags ) {
if (retStrSize) {
WCHAR strSys32[] = {'\\','s','y','s','t','e','m','3','2',0};
+ plen = len;
len += ( strlenW(szWinDir) + strlenW(strSys32) + 1 );
- if (ret)
+ if (ret) {
ret = HeapReAlloc( GetProcessHeap(), 0, ret, len * sizeof(WCHAR) );
- else
+ p = ret;
+ p += plen;
+ }
+ else {
p = ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+ }
strcpyW (p, szWinDir);
p += strlenW(p);
--
2.11.0
More information about the wine-patches
mailing list