31 private static native
int FreeLibrary(
long hLibModule);
34 private static native
int GetLastError();
37 private static native
long GetProcAddressA(
long hModule, java.lang.String lpProcName);
40 private static native
long LoadLibraryW(java.lang.String lpLibFileName);
46 return LoadLibraryW(libraryName);
51 return LoadLibraryW(libraryName);
57 System.err.println(
"lookupSymbolGlobal: Not supported on Windows");
63 private static final int symbolArgAlignment=4;
64 private static final int symbolMaxArguments=12;
67 protected final long lookupSymbolLocalImpl(
final long libraryHandle,
final String symbolName)
throws IllegalArgumentException {
68 String _symbolName = symbolName;
69 long addr = GetProcAddressA(libraryHandle, _symbolName);
73 for(
int arg=0; 0==addr && arg<=symbolMaxArguments; arg++) {
74 _symbolName = symbolName+
"@"+(arg*symbolArgAlignment);
75 addr = GetProcAddressA(libraryHandle, _symbolName);
82 protected final void closeLibraryImpl(
final long libraryHandle)
throws IllegalArgumentException {
83 FreeLibrary(libraryHandle);
88 final int err = GetLastError();
89 return "Last error: 0x"+Integer.toHexString(err)+
" ("+err+
")";
final long openLibraryGlobalImpl(final String libraryName)
final long openLibraryLocalImpl(final String libraryName)
final long lookupSymbolLocalImpl(final long libraryHandle, final String symbolName)
final long lookupSymbolGlobalImpl(final String symbolName)
final void closeLibraryImpl(final long libraryHandle)
final String getLastError()
Returns a string containing the last error.
static final boolean DEBUG_LOOKUP