com.sun.jna.Pointer Java Examples
The following examples show how to use
com.sun.jna.Pointer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Win32ProcessTools.java From jpexs-decompiler with GNU General Public License v3.0 | 7 votes |
public static BufferedImage extractExeIcon(String fullExeFile, int index, boolean large) { PointerByReference iconsLargeRef = new PointerByReference(); PointerByReference iconsSmallRef = new PointerByReference(); int cnt = Shell32.INSTANCE.ExtractIconEx(fullExeFile, index, iconsLargeRef, iconsSmallRef, new WinDef.UINT(1)).intValue(); if (cnt == 0) { return null; } Pointer iconsLarge = iconsLargeRef.getPointer(); Pointer iconsSmall = iconsSmallRef.getPointer(); WinDef.HICON icon; if (large) { icon = new WinDef.HICON(iconsLarge.getPointer(0)); } else { icon = new WinDef.HICON(iconsSmall.getPointer(0)); } BufferedImage ic = iconToImage(icon); User32.INSTANCE.DestroyIcon(icon); return ic; }
Example #2
Source File: ARM32SyscallHandler.java From unidbg with Apache License 2.0 | 6 votes |
private int write(Unicorn u, Emulator<?> emulator) { int fd = ((Number) u.reg_read(ArmConst.UC_ARM_REG_R0)).intValue(); Pointer buffer = UnicornPointer.register(emulator, ArmConst.UC_ARM_REG_R1); int count = ((Number) u.reg_read(ArmConst.UC_ARM_REG_R2)).intValue(); byte[] data = buffer.getByteArray(0, count); if (log.isDebugEnabled()) { log.debug("write fd=" + fd + ", buffer=" + buffer + ", count=" + count); } FileIO file = fdMap.get(fd); if (file == null) { emulator.getMemory().setErrno(UnixEmulator.EBADF); return -1; } return file.write(data); }
Example #3
Source File: KernelController.java From Spark-Reader with GNU General Public License v3.0 | 6 votes |
/** * Finds all windows * @param onlyJapanese limit window search to ones containing Japanese text * @return a map of all titles and their window pointers. */ public static Map<String, Pointer> findAllWindows(boolean onlyJapanese) { if(!isKernelAvailable())return null; HashMap<String, Pointer> windows = new HashMap<>(); user32.EnumWindows((hWnd, data) -> { //hWnd is the window pointer, data is usually return data (unused) String text = getWindowName(hWnd); if(text != null && (!onlyJapanese || Japanese.isJapaneseWriting(text))) { windows.put(text, hWnd); } return true; }, null); return windows; }
Example #4
Source File: MxNDManager.java From djl with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public MxSparseNDArray createCSR(Buffer data, long[] indptr, long[] indices, Shape shape) { SparseFormat fmt = SparseFormat.CSR; DataType dataType = DataType.fromBuffer(data); MxNDArray indptrNd = create(new Shape(indptr.length), DataType.INT64); indptrNd.set(indptr); MxNDArray indicesNd = create(new Shape(indices.length), DataType.INT64); indicesNd.set(indices); Pointer handle = JnaUtils.createSparseNdArray( fmt, device, shape, dataType, new DataType[] {indptrNd.getDataType(), indicesNd.getDataType()}, new Shape[] {indptrNd.getShape(), indicesNd.getShape()}, false); MxSparseNDArray sparse = create(handle, fmt); MxNDArray dataNd = create(new Shape(data.remaining()), dataType); dataNd.set(data); JnaUtils.ndArraySyncCopyFromNdArray(sparse, dataNd, -1); JnaUtils.ndArraySyncCopyFromNdArray(sparse, indptrNd, 0); JnaUtils.ndArraySyncCopyFromNdArray(sparse, indicesNd, 1); return sparse; }
Example #5
Source File: TransientStorePool.java From DDMQ with Apache License 2.0 | 5 votes |
public void destroy() { for (ByteBuffer byteBuffer : availableBuffers) { final long address = ((DirectBuffer) byteBuffer).address(); Pointer pointer = new Pointer(address); LibC.INSTANCE.munlock(pointer, new NativeLong(fileSize)); } }
Example #6
Source File: INotesNativeAPI32.java From domino-jna with Apache License 2.0 | 5 votes |
public short CalEntryAction( int hDB, Memory pszUID, Memory pszRecurID, int dwAction, int dwRange, Memory pszComments, NotesCalendarActionDataStruct pExtActionInfo, int dwFlags, Pointer pCtx);
Example #7
Source File: ARM32SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private int accept(Emulator<AndroidFileIO> emulator) { RegisterContext context = emulator.getContext(); int sockfd = context.getIntArg(0); Pointer addr = context.getPointerArg(1); Pointer addrlen = context.getPointerArg(2); return accept(emulator, sockfd, addr, addrlen, 0); }
Example #8
Source File: SecureStorageManagerTest.java From snowflake-jdbc with Apache License 2.0 | 5 votes |
@Override public int SecKeychainItemModifyContent( Pointer itemRef, Pointer attrList, int length, byte[] data) { MockMacKeychainManager.replaceCredential(itemRef, length, data); return SecureStorageAppleManager.SecurityLib.ERR_SEC_SUCCESS; }
Example #9
Source File: ARM32SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private int pthread_clone(Unicorn u, Emulator<?> emulator) { int flags = ((Number) u.reg_read(ArmConst.UC_ARM_REG_R0)).intValue(); Pointer child_stack = UnicornPointer.register(emulator, ArmConst.UC_ARM_REG_R1); List<String> list = new ArrayList<>(); if ((flags & CLONE_VM) != 0) { list.add("CLONE_VM"); } if ((flags & CLONE_FS) != 0) { list.add("CLONE_FS"); } if ((flags & CLONE_FILES) != 0) { list.add("CLONE_FILES"); } if ((flags & CLONE_SIGHAND) != 0) { list.add("CLONE_SIGHAND"); } if ((flags & CLONE_PTRACE) != 0) { list.add("CLONE_PTRACE"); } if ((flags & CLONE_VFORK) != 0) { list.add("CLONE_VFORK"); } if ((flags & CLONE_PARENT) != 0) { list.add("CLONE_PARENT"); } if ((flags & CLONE_THREAD) != 0) { list.add("CLONE_THREAD"); } if ((flags & CLONE_NEWNS) != 0) { list.add("CLONE_NEWNS"); } if ((flags & CLONE_SYSVSEM) != 0) { list.add("CLONE_SYSVSEM"); } if ((flags & CLONE_SETTLS) != 0) { list.add("CLONE_SETTLS"); } if ((flags & CLONE_PARENT_SETTID) != 0) { list.add("CLONE_PARENT_SETTID"); } if ((flags & CLONE_CHILD_CLEARTID) != 0) { list.add("CLONE_CHILD_CLEARTID"); } if ((flags & CLONE_DETACHED) != 0) { list.add("CLONE_DETACHED"); } if ((flags & CLONE_UNTRACED) != 0) { list.add("CLONE_UNTRACED"); } if ((flags & CLONE_CHILD_SETTID) != 0) { list.add("CLONE_CHILD_SETTID"); } if ((flags & CLONE_STOPPED) != 0) { list.add("CLONE_STOPPED"); } int threadId = ++this.threadId; Pointer fn = child_stack.getPointer(0); child_stack = child_stack.share(4); Pointer arg = child_stack.getPointer(0); child_stack = child_stack.share(4); log.info("pthread_clone child_stack=" + child_stack + ", thread_id=" + threadId + ", fn=" + fn + ", arg=" + arg + ", flags=" + list); threadMap.put(threadId, new LinuxThread(child_stack, fn, arg)); lastThread = threadId; return threadId; }
Example #10
Source File: UnixSyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
protected final int sigprocmask(Emulator<?> emulator, int how, Pointer set, Pointer oldset) { if (log.isDebugEnabled()) { log.debug("sigprocmask how=" + how + ", set=" + set + ", oldset=" + oldset); } emulator.getMemory().setErrno(UnixEmulator.EINVAL); return -1; }
Example #11
Source File: HtmlApi_UrlComponentStruct.java From domino-jna with Apache License 2.0 | 5 votes |
public static HtmlApi_UrlComponentStruct newInstance(final Pointer peer) { return AccessController.doPrivileged(new PrivilegedAction<HtmlApi_UrlComponentStruct>() { @Override public HtmlApi_UrlComponentStruct run() { return new HtmlApi_UrlComponentStruct(peer); } }); }
Example #12
Source File: NotesNativeAPI64.java From domino-jna with Apache License 2.0 | 5 votes |
public native short NSFProfileSetField( long hDB, Memory ProfileName, short ProfileNameLength, Memory UserName, short UserNameLength, Memory FieldName, short FieldNameLength, short Datatype, Pointer Value, int ValueLength);
Example #13
Source File: NotesNativeAPI32.java From domino-jna with Apache License 2.0 | 5 votes |
public native short MIMEGetEntityData( int hNote, Pointer pME, short wDataType, int dwOffset, int dwRetBytes, IntByReference phData, IntByReference pdwDataLen);
Example #14
Source File: MacProvider.java From netbeans with Apache License 2.0 | 5 votes |
public void delete(String key) { try { byte[] serviceName = key.getBytes("UTF-8"); byte[] accountName = "NetBeans".getBytes("UTF-8"); Pointer[] itemRef = new Pointer[1]; error("find (for delete)", SecurityLibrary.LIBRARY.SecKeychainFindGenericPassword(null, serviceName.length, serviceName, accountName.length, accountName, null, null, itemRef)); if (itemRef[0] != null) { error("delete", SecurityLibrary.LIBRARY.SecKeychainItemDelete(itemRef[0])); SecurityLibrary.LIBRARY.CFRelease(itemRef[0]); } } catch (UnsupportedEncodingException x) { LOG.log(Level.WARNING, null, x); } }
Example #15
Source File: WinNotesNamesListHeader32Struct.java From domino-jna with Apache License 2.0 | 5 votes |
public static WinNotesNamesListHeader32Struct newInstance(final Pointer p) { return AccessController.doPrivileged(new PrivilegedAction<WinNotesNamesListHeader32Struct>() { @Override public WinNotesNamesListHeader32Struct run() { return new WinNotesNamesListHeader32Struct(p); }}); }
Example #16
Source File: MockMxnetLibrary.java From djl with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public int MXCachedOpRegisterOpHook( Pointer handle, CachedOpMonitorCallback callback, byte monitor_all) { if (functions.containsKey("MXCachedOpRegisterOpHook")) { return functions .get("MXCachedOpRegisterOpHook") .apply(new Object[] {handle, callback, monitor_all}); } return 0; }
Example #17
Source File: INotesNativeAPI64.java From domino-jna with Apache License 2.0 | 5 votes |
public short CompoundTextAddParagraphExt( long hCompound, int dwStyleID, int FontID, Memory pchText, int dwTextLen, Pointer pInfo);
Example #18
Source File: CameraStateEventLogicDefaultMockTest.java From canon-sdk-java with MIT License | 5 votes |
@Test void unregisterCameraStateEvent() { when(edsdkLibrary().EdsSetCameraStateEventHandler(eq(fakeCamera), any(), any(), (Pointer) isNull())).thenReturn(new NativeLong(0)); spyCameraStateEventLogic.unregisterCameraStateEvent(fakeCamera); verify(edsdkLibrary(), times(1)).EdsSetCameraStateEventHandler(eq(fakeCamera), any(), any(), (Pointer) isNull()); }
Example #19
Source File: MockMxnetLibrary.java From djl with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public int MXNDArrayToDLPack(Pointer handle, PointerByReference out_dlpack) { if (functions.containsKey("MXNDArrayToDLPack")) { return functions.get("MXNDArrayToDLPack").apply(new Object[] {handle, out_dlpack}); } return 0; }
Example #20
Source File: MockMxnetLibrary.java From djl with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public int MXNDArrayDetach(Pointer handle, PointerByReference out) { if (functions.containsKey("MXNDArrayDetach")) { return functions.get("MXNDArrayDetach").apply(new Object[] {handle, out}); } return 0; }
Example #21
Source File: NotesScheduleListStruct.java From domino-jna with Apache License 2.0 | 4 votes |
public NotesScheduleListStruct(Pointer peer) { super(peer); }
Example #22
Source File: Fann.java From fannj with GNU Lesser General Public License v3.0 | 4 votes |
protected static native void fann_set_activation_steepness(Pointer ann, float steepness, int layer, int neuron);
Example #23
Source File: ITimerVal64.java From unidbg with Apache License 2.0 | 4 votes |
public ITimerVal64(Pointer p) { super(p); }
Example #24
Source File: MockMxnetLibrary.java From djl with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public int MXExecutorBindEX( Pointer symbol_handle, int dev_type, int dev_id, int num_map_keys, String[] map_keys, int[] map_dev_types, int[] map_dev_ids, int len, PointerByReference in_args, PointerByReference arg_grad_store, IntBuffer grad_req_type, int aux_states_len, PointerByReference aux_states, Pointer shared_exec, PointerByReference out) { if (functions.containsKey("MXExecutorBindEX")) { return functions .get("MXExecutorBindEX") .apply( new Object[] { symbol_handle, dev_type, dev_id, num_map_keys, map_keys, map_dev_types, map_dev_ids, len, in_args, arg_grad_store, grad_req_type, aux_states_len, aux_states, shared_exec, out }); } return 0; }
Example #25
Source File: OSVR_Quaternion.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
public OSVR_Quaternion(Pointer peer) { super(peer); }
Example #26
Source File: MachPortsLookupReply.java From unidbg with Apache License 2.0 | 4 votes |
public MachPortsLookupReply(Pointer p) { super(p); }
Example #27
Source File: KInfoProc32.java From unidbg with Apache License 2.0 | 4 votes |
public KInfoProc32(Pointer p) { super(p); }
Example #28
Source File: NotesSchedDetailDataStruct.java From domino-jna with Apache License 2.0 | 4 votes |
public NotesSchedDetailDataStruct(Pointer peer) { super(peer); }
Example #29
Source File: CFArray.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public CFArray(Pointer address) { super(address); }
Example #30
Source File: BaseDarwinFileIO.java From unidbg with Apache License 2.0 | 4 votes |
@Override public int listxattr(Pointer namebuf, int size, int options) { throw new UnsupportedOperationException(getClass().getName()); }