]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - windows/winmisc.c
first pass
[PuTTY.git] / windows / winmisc.c
index 11e2ca0f7d1353b46db523ca2d66f48b8ba85ad6..8bd4c77f88171fbea6672425a5eabed1817ba4bc 100644 (file)
@@ -176,11 +176,25 @@ void dll_hijacking_protection(void)
     }
 
     if (p_SetDefaultDllDirectories) {
-        /* LOAD_LIBRARY_SEARCH_SYSTEM32 only */
-        p_SetDefaultDllDirectories(0x800);
+        /* LOAD_LIBRARY_SEARCH_SYSTEM32 | LOAD_LIBRARY_SEARCH_USER_DIRS only */
+        p_SetDefaultDllDirectories(0x800|0x400);
     }
 }
 
+void dll_hijacking_protection_add_path(const wchar_t *path)
+{
+    static HMODULE kernel32_module;
+    DECL_WINDOWS_FUNCTION(static, BOOL, AddDllDirectory, (PCWSTR));
+
+    if (!kernel32_module) {
+        kernel32_module = load_system32_dll("kernel32.dll");
+        GET_WINDOWS_FUNCTION(kernel32_module, AddDllDirectory);
+    }
+
+    if (p_AddDllDirectory) {
+        p_AddDllDirectory(path);
+    }
+}
 BOOL init_winver(void)
 {
     ZeroMemory(&osVersion, sizeof(osVersion));