diff options
author | Sven Gothel <[email protected]> | 2013-06-20 08:11:29 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-06-20 08:11:29 +0200 |
commit | 23341a2df2d2ea36784a16fa1db8bc7385351a12 (patch) | |
tree | cfbddba0bcd9359754a90ed794dda69f198469d3 /src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java | |
parent | 6704fab767307b89fa21250c20f1dab56323ffac (diff) |
Security: Tighten DynamicLinker*, NativeLibrary and DynamicLibraryBundle access.
Diffstat (limited to 'src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java')
-rw-r--r-- | src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java index 884ac39..158bd7c 100644 --- a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java @@ -1,9 +1,36 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ package jogamp.common.os; import com.jogamp.common.os.DynamicLinker; import com.jogamp.common.util.SecurityUtil; -public class WindowsDynamicLinkerImpl implements DynamicLinker { +public final class WindowsDynamicLinkerImpl implements DynamicLinker { /** Interface to C language function: <br> <code> BOOL FreeLibrary(HANDLE hLibModule); </code> */ private static native int FreeLibrary(long hLibModule); @@ -19,13 +46,13 @@ public class WindowsDynamicLinkerImpl implements DynamicLinker { // --- Begin CustomJavaCode .cfg declarations - public long openLibraryLocal(String libraryName, boolean debug) throws SecurityException { + public final long openLibraryLocal(String libraryName, boolean debug) throws SecurityException { // How does that work under Windows ? // Don't know .. so it's an alias for the time being return openLibraryGlobal(libraryName, debug); } - public long openLibraryGlobal(String libraryName, boolean debug) throws SecurityException { + public final long openLibraryGlobal(String libraryName, boolean debug) throws SecurityException { SecurityUtil.checkLinkPermission(libraryName); long handle = LoadLibraryW(libraryName); if(0==handle && debug) { @@ -35,7 +62,7 @@ public class WindowsDynamicLinkerImpl implements DynamicLinker { return handle; } - public long lookupSymbol(long libraryHandle, String symbolName) { + public final long lookupSymbol(long libraryHandle, String symbolName) { String _symbolName = symbolName; long addr = GetProcAddressA(libraryHandle, _symbolName); if(0==addr) { @@ -54,7 +81,7 @@ public class WindowsDynamicLinkerImpl implements DynamicLinker { return addr; } - public long lookupSymbolGlobal(String symbolName) { + public final long lookupSymbolGlobal(String symbolName) { if(DEBUG_LOOKUP) { System.err.println("lookupSymbolGlobal: Not supported on Windows"); } @@ -62,11 +89,11 @@ public class WindowsDynamicLinkerImpl implements DynamicLinker { return 0; } - public void closeLibrary(long libraryHandle) { + public final void closeLibrary(long libraryHandle) { FreeLibrary(libraryHandle); } - public String getLastError() { + public final String getLastError() { final int err = GetLastError(); return "Last error: 0x"+Integer.toHexString(err)+" ("+err+")"; } |