From 7b37da872697a17aef6dae132e4277f9895eef2d Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Thu, 3 Mar 2011 14:16:57 -0800 Subject: [PATCH] 7016985: (launcher) implement safe secure dll loading Reviewed-by: mchung --- jdk/src/windows/bin/java_md.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/jdk/src/windows/bin/java_md.c b/jdk/src/windows/bin/java_md.c index dfa50ac8af8..4353ec5a12f 100644 --- a/jdk/src/windows/bin/java_md.c +++ b/jdk/src/windows/bin/java_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1212,11 +1212,22 @@ jclass FindBootStrapClass(JNIEnv *env, const char *classname) return findBootClass(env, classname); } +typedef BOOL (WINAPI *pfn_SetDllDirectory)(LPCTSTR); + void InitLauncher(boolean javaw) { INITCOMMONCONTROLSEX icx; + // Launcher links with kernel32 + HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32.dll")); + pfn_SetDllDirectory fn = (pfn_SetDllDirectory) GetProcAddress(hKernel32, + "SetDllDirectory"); + if (fn != NULL) { + // Exclude CWD from Dll search path + fn(""); + } + /* * Required for javaw mode MessageBox output as well as for * HotSpot -XX:+ShowMessageBoxOnError in java mode, an empty