[PATCH] kernel32: Partial implement SetDllDirectory function
Carlos Palminha
CARLOS.PALMINHA at synopsys.com
Fri Aug 11 11:56:20 CDT 2017
Signed-off-by: Carlos Palminha <palminha at synopsys.com>
---
dlls/kernel32/module.c | 8 ++++----
dlls/kernel32/path.c | 39 ++++++++++++++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c
index f0d0a5b7105..3662332f48f 100644
--- a/dlls/kernel32/module.c
+++ b/dlls/kernel32/module.c
@@ -47,16 +47,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(module);
#define NE_FFLAGS_LIBMODULE 0x8000
-static WCHAR *dll_directory; /* extra path for SetDllDirectoryW */
+WCHAR *dll_directory; /* extra path for SetDllDirectoryW */
-static CRITICAL_SECTION dlldir_section;
-static CRITICAL_SECTION_DEBUG critsect_debug =
+CRITICAL_SECTION dlldir_section;
+CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &dlldir_section,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": dlldir_section") }
};
-static CRITICAL_SECTION dlldir_section = { &critsect_debug, -1, 0, 0, 0, 0 };
+CRITICAL_SECTION dlldir_section = { &critsect_debug, -1, 0, 0, 0, 0 };
/****************************************************************************
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 41a9cd89729..b86171bd36b 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -2082,12 +2082,45 @@ BOOL WINAPI SetSearchPathMode(DWORD flags)
return FALSE;
}
+extern CRITICAL_SECTION dlldir_section;
+extern WCHAR *dll_directory;
+
/*************************************************************************
* SetDefaultDllDirectories (KERNEL32.@)
+ *
+ * Sets the DLL search path for the life of the calling process
*/
BOOL WINAPI SetDefaultDllDirectories(DWORD flags)
{
- FIXME("(%x): stub\n", flags);
- SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
- return FALSE;
+ WCHAR path[MAX_PATH] = {'\0'};
+ WCHAR *p = &path[0];
+
+ if((flags & LOAD_LIBRARY_SEARCH_APPLICATION_DIR) || (flags & LOAD_LIBRARY_SEARCH_DEFAULT_DIRS)) {
+ FIXME ("Partial stub: flag %x, not supported\n", LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
+ SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
+ return FALSE;
+ }
+
+ if((flags & LOAD_LIBRARY_SEARCH_USER_DIRS) || (flags & LOAD_LIBRARY_SEARCH_DEFAULT_DIRS)) {
+ RtlEnterCriticalSection( &dlldir_section );
+ if(dll_directory) {
+ strcpyW(p, dll_directory);
+ p += strlenW(dll_directory);
+ *p++ = ';';
+ *p++ = '\0';
+ }
+ RtlLeaveCriticalSection( &dlldir_section );
+ }
+
+ if((flags & LOAD_LIBRARY_SEARCH_SYSTEM32) || (flags & LOAD_LIBRARY_SEARCH_DEFAULT_DIRS)){
+ WCHAR sys_dir[MAX_PATH];
+
+ GetSystemDirectoryW(sys_dir, MAX_PATH);
+ strcpyW(p, sys_dir);
+ p += strlenW(sys_dir);
+ *p++ = ';';
+ *p++ = '\0';
+ }
+ RtlInitUnicodeString (&(NtCurrentTeb()->Peb->ProcessParameters->DllPath), path);
+ return TRUE;
}
--
2.11.0
More information about the wine-patches
mailing list