[v4 2/5] kernel32: Support for LIBRARY_SEARCH_SYSTEM32 when loading dlls
Carlos Palminha
CARLOS.PALMINHA at synopsys.com
Wed Aug 16 07:01:45 CDT 2017
If LIBRARY_SEARCH_SYSTEM32 flag is used when loading a dll,
%windows%\system32 is used to search.
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 | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c
index c6696d84918..7c325e01cde 100644
--- a/dlls/kernel32/module.c
+++ b/dlls/kernel32/module.c
@@ -778,6 +778,9 @@ static inline const WCHAR *get_module_path_end(const WCHAR *module)
*/
WCHAR *MODULE_get_dll_load_path_flags( DWORD flags ) {
+ int len = 0;
+ WCHAR *ret = NULL, *p = NULL;
+
if (flags & LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR) {
FIXME("unsupported flag used LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR (flags: 0x%08x)\n", flags);
}
@@ -791,9 +794,30 @@ WCHAR *MODULE_get_dll_load_path_flags( DWORD flags ) {
}
if (flags & LOAD_LIBRARY_SEARCH_SYSTEM32 || flags & LOAD_LIBRARY_SEARCH_DEFAULT_DIRS) {
- FIXME("unsupported flag used LOAD_LIBRARY_SEARCH_SYSTEM32 (flags: 0x%08x)\n", flags);
+ WCHAR sys_dir[MAX_PATH];
+ int retStrSize;
+
+ retStrSize = GetSystemDirectoryW(sys_dir,MAX_PATH);
+ if (retStrSize) {
+ plen = len;
+ len += ( strlenW(sys_dir) + 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) );
+ }
+
+ strcpyW (p, sys_dir);
+ p += strlenW(sys_dir);
+ *p++ = ';';
+ *p++ = '\0';
+ }
}
- return NULL;
+
+ return ret;
}
/******************************************************************
--
2.11.0
More information about the wine-patches
mailing list