[v4 3/5] kernel32: Support LIBRARY_SEARCH_USER_DIRS when loading dlls
Carlos Palminha
CARLOS.PALMINHA at synopsys.com
Wed Aug 16 07:01:46 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>
---
v4:
- fixed memory allocation issue with '\0' char
v3:
- no changes
v2:
- no changes
dlls/kernel32/module.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c
index 7c325e01cde..0d9aeb67961 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,28 @@ 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 + 1) * sizeof(WCHAR) );
+ }
+
+ if (p) {
+ strcpyW( p, dll_directory );
+ p += strlenW(p);
+ *p++ = ';';
+ *p++ = '\0';
+ }
+ }
+ RtlLeaveCriticalSection( &dlldir_section );
}
if (flags & LOAD_LIBRARY_SEARCH_SYSTEM32 || flags & LOAD_LIBRARY_SEARCH_DEFAULT_DIRS) {
--
2.11.0
More information about the wine-patches
mailing list