Java Code Examples for com.sun.jna.Pointer#createConstant()

The following examples show how to use com.sun.jna.Pointer#createConstant() . 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: ProcessHelper.java    From buck with Apache License 2.0 6 votes vote down vote up
@Nullable
private Long windowsProcessId(Object process) {
  Class<?> clazz = process.getClass();
  if (clazz.getName().equals("java.lang.Win32Process")
      || clazz.getName().equals("java.lang.ProcessImpl")) {
    try {
      Field f = clazz.getDeclaredField("handle");
      f.setAccessible(true);
      long peer = f.getLong(process);
      Pointer pointer = Pointer.createConstant(peer);
      WinNT.HANDLE handle = new WinNT.HANDLE(pointer);
      return (long) Kernel32.INSTANCE.GetProcessId(handle);
    } catch (Exception e) {
      LOG.warn(e, "Cannot get process id!");
    }
  }
  return null;
}
 
Example 2
Source File: JNABenchmark.java    From indexr with Apache License 2.0 5 votes vote down vote up
@Benchmark
public void memory_malloc_jna2() {
    long native_p = Native.malloc(100);
    ByteSlice buffer = ByteSlice.wrap(MemoryUtil.getByteBuffer(native_p, 100, true));
    for (int i = 0; i < 100; i++) {
        buffer.put(i, (byte) i);
    }

    Pointer.createConstant(native_p);

    //Native.free(native_p);
}
 
Example 3
Source File: JnaDirectNativeClock.java    From maestro-java with Apache License 2.0 4 votes vote down vote up
public JnaDirectNativeClock() {
    buffer = new UnsafeBuffer(BufferUtil.allocateDirectAligned(TIMESPEC_REQUIRED_CAPACITY, Long.BYTES));
    this.pointer = Pointer.createConstant(buffer.addressOffset());
}
 
Example 4
Source File: W32API.java    From AILibs with GNU Affero General Public License v3.0 4 votes vote down vote up
public HANDLE() {
	super.setPointer(Pointer.createConstant(-1));
}
 
Example 5
Source File: BaseTSD.java    From jpexs-decompiler with GNU General Public License v3.0 4 votes vote down vote up
public Pointer toPointer() {
    return Pointer.createConstant(longValue());
}
 
Example 6
Source File: BaseTSD.java    From jpexs-decompiler with GNU General Public License v3.0 4 votes vote down vote up
public Pointer toPointer() {
    return Pointer.createConstant(longValue());
}
 
Example 7
Source File: WinDef.java    From jpexs-decompiler with GNU General Public License v3.0 2 votes vote down vote up
/**
 * To pointer.
 *
 * @return the pointer
 */
public Pointer toPointer() {
    return Pointer.createConstant(longValue());
}
 
Example 8
Source File: WinDef.java    From jpexs-decompiler with GNU General Public License v3.0 2 votes vote down vote up
/**
 * To pointer.
 *
 * @return the pointer
 */
public Pointer toPointer() {
    return Pointer.createConstant(longValue());
}
 
Example 9
Source File: W32API.java    From consulo with Apache License 2.0 votes vote down vote up
public Pointer toPointer() { return Pointer.createConstant(longValue()); }