public static boolean isAeroEnabled(){ if( HearthHelper.getOSName().equals("win") && DWM == null){ try{ DWM = NativeLibrary.getInstance("dwmapi"); } catch(Throwable e) {} } boolean dwmEnabled = false; if(DWM != null){ boolean[] bool = { false }; Object[] args = { bool }; Function DwmIsCompositionEnabled = DWM.getFunction("DwmIsCompositionEnabled"); HRESULT result = (HRESULT) DwmIsCompositionEnabled.invoke(HRESULT.class, args); boolean success = result.intValue()==0; if(success && bool[0]){ dwmEnabled = true; } } return dwmEnabled; }
@Override public String toString() { if (getPointer() == null) { return "null"; } if (getPointer() instanceof Function || getPointer() instanceof Memory) { return "Java initialized, not a real CF type"; } CFStringRef description = INSTANCE.CFCopyDescription(this); try { return description.toString(); } finally { INSTANCE.CFRelease(description); } }
private static void initialize() { if (ApplicationManager.getApplication().isUnitTestMode()) { return; } Ole32 ole32 = Ole32.INSTANCE; ole32.CoInitializeEx(Pointer.NULL, 0); Guid.GUID CLSID_TaskbarList = Ole32Util.getGUIDFromString("{56FDF344-FD6D-11d0-958A-006097C9A090}"); Guid.GUID IID_ITaskbarList3 = Ole32Util.getGUIDFromString("{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}"); PointerByReference p = new PointerByReference(); WinNT.HRESULT hr = ole32.CoCreateInstance(CLSID_TaskbarList, Pointer.NULL, ObjBase.CLSCTX_ALL, IID_ITaskbarList3, p); if (!W32Errors.S_OK.equals(hr)) { LOG.error("Win7TaskBar CoCreateInstance(IID_ITaskbarList3) hResult: " + hr); ourInitialized = false; return; } myInterfacePointer = p.getValue(); Pointer vTablePointer = myInterfacePointer.getPointer(0); Pointer[] vTable = new Pointer[TaskBarList_Methods]; vTablePointer.read(0, vTable, 0, vTable.length); mySetProgressValue = Function.getFunction(vTable[TaskBarList_SetProgressValue], Function.ALT_CONVENTION); mySetProgressState = Function.getFunction(vTable[TaskBarList_SetProgressState], Function.ALT_CONVENTION); mySetOverlayIcon = Function.getFunction(vTable[TaskBarList_SetOverlayIcon], Function.ALT_CONVENTION); }
@FuseMethod final int _readdir(final String path, final Pointer buf, final Pointer fillFunction, final TypeOff offset, final StructFuseFileInfo info) { return readdir( path, new DirectoryFillerImpl(buf, Function.getFunction(fillFunction))); }
@Override public INativeFunction createFunction(long address, Object callingConvention) { int callFlags; if (callingConvention == INativeFunction.CallingConventionCdecl) { callFlags = Function.C_CONVENTION; } else if (callingConvention == INativeFunction.CallingConventionStdcall) { callFlags = Function.ALT_CONVENTION; } else { throw new IllegalArgumentException("illegal calling convention"); } Pointer pointer = new Pointer(address); Function function = Function.getFunction(pointer, callFlags); return new JnaNativeFunction(function); }
@Override public INativeLibrary createLibrary(String name, Object callingConvention) { Map<String, Object> options = new HashMap<>(2); if (callingConvention == INativeFunction.CallingConventionCdecl) { options.put(Library.OPTION_CALLING_CONVENTION, Function.C_CONVENTION); } else if (callingConvention == INativeFunction.CallingConventionStdcall) { options.put(Library.OPTION_CALLING_CONVENTION, Function.ALT_CONVENTION); } else { throw new IllegalArgumentException("illegal calling convention"); } options.put(Library.OPTION_OPEN_FLAGS, -1); return new JnaNativeLibrary(this, name, options); }
public static void onWindows() { // Windows taskbar fix: provideAppUserModelID try { NativeLibrary lib = NativeLibrary.getInstance("shell32"); Function function = lib.getFunction("SetCurrentProcessExplicitAppUserModelID"); Object[] args = {new WString(APPID)}; function.invokeInt(args); } catch (Error e) { return; } catch (Exception x) { return; } }
public native short SECKFMGetPublicKey( Memory pName, short Function, short Flags, IntByReference rethPubKey);
@FuseMethod final int _readdir(final String path, final Pointer buf, final Pointer fillFunction, final TypeOff offset, final StructFuseFileInfo info) { return readdir(path, new DirectoryFillerImpl(buf, Function.getFunction(fillFunction))); }
DirectoryFillerImpl(final Pointer buf, final Function nativeFunction) { this.buf = buf; this.nativeFunction = nativeFunction; add(currentDirectory, parentDirectory); }
@Override public INativeFunction getFunction(String name) { Function function = getLibrary().getFunction(name); return new JnaNativeFunction(function); }
public JnaNativeFunction(Function function) { this.function = function; }
protected Function getFunction() { return function; }