Java Code Examples for com.sun.jna.Pointer#getPointer()
The following examples show how to use
com.sun.jna.Pointer#getPointer() .
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: ARM64SyscallHandler.java From unidbg with Apache License 2.0 | 6 votes |
private int pthread_set_self(Emulator<?> emulator) { RegisterContext context = emulator.getContext(); Pointer self = context.getPointerArg(0); Pthread pthread = new Pthread64(self.getPointer(0)); pthread.unpack(); UnicornPointer tsd = pthread.getTSD(); emulator.getUnicorn().reg_write(Arm64Const.UC_ARM64_REG_TPIDRRO_EL0, tsd.peer); MachOLoader loader = (MachOLoader) emulator.getMemory(); loader.setErrnoPointer(pthread.getErrno()); if (log.isDebugEnabled()) { String threadName = pthread.getName(); log.debug("pthread_set_self=" + self + ", pthread=" + pthread + ", threadName=" + threadName + ", LR=" + emulator.getContext().getLRPointer()); } return 0; }
Example 3
Source File: ARM32SyscallHandler.java From unidbg with Apache License 2.0 | 6 votes |
private int pthread_set_self(Emulator<?> emulator) { RegisterContext context = emulator.getContext(); Pointer self = context.getPointerArg(0); Pthread pthread = new Pthread32(self.getPointer(0)); pthread.unpack(); UnicornPointer tsd = pthread.getTSD(); emulator.getUnicorn().reg_write(ArmConst.UC_ARM_REG_C13_C0_3, tsd.peer); MachOLoader loader = (MachOLoader) emulator.getMemory(); loader.setErrnoPointer(pthread.getErrno()); if (log.isDebugEnabled()) { String threadName = pthread.getName(); log.debug("pthread_set_self=" + self + ", pthread=" + pthread + ", threadName=" + threadName + ", LR=" + emulator.getContext().getLRPointer()); } return 0; }
Example 4
Source File: MachOLoader.java From unidbg with Apache License 2.0 | 6 votes |
private void rebaseAt(Log log, int type, long address, Module module) { Pointer pointer = UnicornPointer.pointer(emulator, address); if (pointer == null) { throw new IllegalStateException(); } Pointer newPointer = pointer.getPointer(0); Pointer old = newPointer; if (newPointer == null) { newPointer = UnicornPointer.pointer(emulator, module.base); } else { newPointer = newPointer.share(module.base); } if (log.isTraceEnabled()) { log.trace("rebaseAt type=" + type + ", address=0x" + Long.toHexString(address - module.base) + ", module=" + module.name + ", old=" + old + ", new=" + newPointer); } switch (type) { case REBASE_TYPE_POINTER: case REBASE_TYPE_TEXT_ABSOLUTE32: pointer.setPointer(0, newPointer); break; default: throw new IllegalStateException("bad rebase type " + type); } }
Example 5
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 6
Source File: PAM.java From keycloak with Apache License 2.0 | 5 votes |
/** * Creates a new authenticator. * * @param serviceName PAM service name. This corresponds to the service name that shows up * in the PAM configuration, */ public PAM(String serviceName) throws PAMException { pam_conv conv = new pam_conv(new PamCallback() { public int callback(int num_msg, Pointer msg, Pointer resp, Pointer _) { LOGGER.debug("pam_conv num_msg=" + num_msg); if (factors == null) return PAM_CONV_ERR; // allocates pam_response[num_msg]. the caller will free this Pointer m = libc.calloc(pam_response.SIZE, num_msg); resp.setPointer(0, m); for (int i = 0; i < factors.length; i++) { pam_message pm = new pam_message(msg.getPointer(POINTER_SIZE * i)); LOGGER.debug(pm.msg_style + ":" + pm.msg); if (pm.msg_style == PAM_PROMPT_ECHO_OFF) { pam_response r = new pam_response(m.share(pam_response.SIZE * i)); r.setResp(factors[i]); r.write(); // write to (*resp)[i] } } return PAM_SUCCESS; } }); PointerByReference phtr = new PointerByReference(); check(libpam.pam_start(serviceName, null, conv, phtr), "pam_start failed"); pht = new pam_handle_t(phtr.getValue()); }
Example 7
Source File: ARM64SyscallHandler.java From unidbg with Apache License 2.0 | 4 votes |
private int pthread_clone(Emulator<?> emulator) { RegisterContext context = emulator.getContext(); int flags = context.getIntArg(0); Pointer child_stack = context.getPointerArg(1); 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 8
Source File: MachOLoader.java From unidbg with Apache License 2.0 | 4 votes |
final void setErrnoPointer(Pointer errno) { this.errno = errno.getPointer(0); this.setErrno(0); }