Java Code Examples for com.sun.jna.Pointer#getString()
The following examples show how to use
com.sun.jna.Pointer#getString() .
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: TessAPITest.java From tess4j with Apache License 2.0 | 6 votes |
/** * Test of TessBaseAPIGetHOCRText method, of class TessAPI. * * @throws Exception while getting hocr text */ @Test public void testTessBaseAPIGetHOCRText() throws Exception { logger.info("TessBaseAPIGetHOCRText"); String filename = String.format("%s/%s", this.testResourcesDataPath, "eurotext.tif"); File tiff = new File(filename); BufferedImage image = ImageIO.read(new FileInputStream(tiff)); // require jai-imageio lib to read TIFF ByteBuffer buf = ImageIOHelper.convertImageData(image); int bpp = image.getColorModel().getPixelSize(); int bytespp = bpp / 8; int bytespl = (int) Math.ceil(image.getWidth() * bpp / 8.0); api.TessBaseAPISetPageSegMode(handle, TessPageSegMode.PSM_AUTO); api.TessBaseAPIInit3(handle, datapath, language); api.TessBaseAPISetImage(handle, buf, image.getWidth(), image.getHeight(), bytespp, bytespl); int page_number = 0; Pointer utf8Text = api.TessBaseAPIGetHOCRText(handle, page_number); String result = utf8Text.getString(0); api.TessDeleteText(utf8Text); assertTrue(result.contains("<div class='ocr_page'")); }
Example 2
Source File: Tesseract1.java From tess4j with Apache License 2.0 | 6 votes |
/** * Gets recognized text. * * @param filename input file name. Needed only for reading a UNLV zone * file. * @param pageNum page number; needed for hocr paging. * @return the recognized text */ protected String getOCRText(String filename, int pageNum) { if (filename != null && !filename.isEmpty()) { TessBaseAPISetInputName(handle, filename); } Pointer textPtr; if (String.valueOf(TRUE).equals(prop.getProperty("tessedit_create_hocr"))) { textPtr = TessBaseAPIGetHOCRText(handle, pageNum - 1); } else if (String.valueOf(TRUE).equals(prop.getProperty("tessedit_write_unlv"))) { textPtr = TessBaseAPIGetUNLVText(handle); } else if (String.valueOf(TRUE).equals(prop.getProperty("tessedit_create_alto"))) { textPtr = TessBaseAPIGetAltoText(handle, pageNum - 1); } else if (String.valueOf(TRUE).equals(prop.getProperty("tessedit_create_lstmbox"))) { textPtr = TessBaseAPIGetLSTMBoxText(handle, pageNum - 1); } else if (String.valueOf(TRUE).equals(prop.getProperty("tessedit_create_tsv"))) { textPtr = TessBaseAPIGetTsvText(handle, pageNum - 1); } else if (String.valueOf(TRUE).equals(prop.getProperty("tessedit_create_wordstrbox"))) { textPtr = TessBaseAPIGetWordStrBoxText(handle, pageNum - 1); } else { textPtr = TessBaseAPIGetUTF8Text(handle); } String str = textPtr.getString(0); TessDeleteText(textPtr); return str; }
Example 3
Source File: ARM32SyscallHandler.java From unidbg with Apache License 2.0 | 6 votes |
private int mkdir(Emulator<?> emulator) { RegisterContext context = emulator.getContext(); Pointer pathname = context.getPointerArg(0); int mode = context.getIntArg(1); String path = pathname.getString(0); if (emulator.getFileSystem().mkdir(path)) { if (log.isDebugEnabled()) { log.debug("mkdir pathname=" + path + ", mode=" + mode); } return 0; } else { log.info("mkdir pathname=" + path + ", mode=" + mode); emulator.getMemory().setErrno(UnixEmulator.EACCES); return -1; } }
Example 4
Source File: ARM64SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private long getxattr(Emulator<DarwinFileIO> emulator) { RegisterContext context = emulator.getContext(); Pointer path = context.getPointerArg(0); Pointer name = context.getPointerArg(1); UnicornPointer value = context.getPointerArg(2); int size = context.getIntArg(3); int position = context.getIntArg(4); int options = context.getIntArg(5); String pathname = path.getString(0); if (position != 0 || (options & XATTR_CREATE) != 0 || (options & XATTR_REPLACE) != 0) { log.info("getxattr path=" + pathname + ", name=" + name.getString(0) + ", value=" + value + ", size=" + size + ", position=" + position + ", options=0x" + Integer.toHexString(options)); return -1; } if (value != null) { value.setSize(size); } FileResult<DarwinFileIO> result = resolve(emulator, pathname, IOConstants.O_RDONLY); if (result.isSuccess()) { int ret = result.io.getxattr(emulator, name.getString(0), value, size); if (ret == -1) { log.info("getxattr path=" + pathname + ", name=" + name.getString(0) + ", value=" + value + ", size=" + size + ", position=" + position + ", options=0x" + Integer.toHexString(options)); } else { if (log.isDebugEnabled()) { log.debug("getxattr path=" + pathname + ", name=" + name.getString(0) + ", value=" + value + ", size=" + size + ", position=" + position + ", options=0x" + Integer.toHexString(options)); } } return ret; } else { log.info("getxattr path=" + pathname + ", name=" + name.getString(0) + ", value=" + value + ", size=" + size + ", position=" + position + ", options=0x" + Integer.toHexString(options)); emulator.getMemory().setErrno(UnixEmulator.ENOENT); return -1; } }
Example 5
Source File: ARM64SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private long setxattr(Emulator<DarwinFileIO> emulator) { RegisterContext context = emulator.getContext(); Pointer path = context.getPointerArg(0); Pointer name = context.getPointerArg(1); Pointer value = context.getPointerArg(2); int size = context.getIntArg(3); int position = context.getIntArg(4); int options = context.getIntArg(5); String pathname = path.getString(0); if (position != 0 || (options & XATTR_CREATE) != 0 || (options & XATTR_REPLACE) != 0) { log.info("setxattr path=" + pathname + ", name=" + name.getString(0) + ", value=" + value + ", size=" + size + ", position=" + position + ", options=0x" + Integer.toHexString(options)); return -1; } FileResult<DarwinFileIO> result = resolve(emulator, pathname, IOConstants.O_RDONLY); if (result.isSuccess()) { int ret = result.io.setxattr(name.getString(0), value.getByteArray(0, size)); if (ret == -1) { log.info("setxattr path=" + pathname + ", name=" + name.getString(0) + ", value=" + value + ", size=" + size + ", position=" + position + ", options=0x" + Integer.toHexString(options)); } else { if (log.isDebugEnabled()) { log.debug("setxattr path=" + pathname + ", name=" + name.getString(0) + ", value=" + value + ", size=" + size + ", position=" + position + ", options=0x" + Integer.toHexString(options)); } } return ret; } else { log.info("setxattr path=" + pathname + ", name=" + name.getString(0) + ", value=" + value + ", size=" + size + ", position=" + position + ", options=0x" + Integer.toHexString(options)); emulator.getMemory().setErrno(UnixEmulator.ENOENT); return -1; } }
Example 6
Source File: Tesseract1.java From tess4j with Apache License 2.0 | 5 votes |
/** * Gets result words at specified page iterator level from recognized pages. * * @param pageIteratorLevel TessPageIteratorLevel enum * @return list of <code>Word</code> */ private List<Word> getRecognizedWords(int pageIteratorLevel) { List<Word> words = new ArrayList<>(); try { TessResultIterator ri = TessBaseAPIGetIterator(handle); TessPageIterator pi = TessResultIteratorGetPageIterator(ri); TessPageIteratorBegin(pi); do { Pointer ptr = TessResultIteratorGetUTF8Text(ri, pageIteratorLevel); String text = ptr.getString(0); TessAPI1.TessDeleteText(ptr); float confidence = TessResultIteratorConfidence(ri, pageIteratorLevel); IntBuffer leftB = IntBuffer.allocate(1); IntBuffer topB = IntBuffer.allocate(1); IntBuffer rightB = IntBuffer.allocate(1); IntBuffer bottomB = IntBuffer.allocate(1); TessPageIteratorBoundingBox(pi, pageIteratorLevel, leftB, topB, rightB, bottomB); int left = leftB.get(); int top = topB.get(); int right = rightB.get(); int bottom = bottomB.get(); Word word = new Word(text, confidence, new Rectangle(left, top, right - left, bottom - top)); words.add(word); } while (TessPageIteratorNext(pi, pageIteratorLevel) == TRUE); } catch (Exception e) { logger.warn(e.getMessage(), e); } return words; }
Example 7
Source File: TessAPITest.java From tess4j with Apache License 2.0 | 5 votes |
/** * Test of TessBaseAPIGetAltoText method, of class TessAPI. * * @throws Exception while getting Alto text */ @Test public void testTessBaseAPIGetAltoText() throws Exception { logger.info("TessBaseAPIGetAltoText"); String filename = String.format("%s/%s", this.testResourcesDataPath, "eurotext.tif"); File tiff = new File(filename); BufferedImage image = ImageIO.read(new FileInputStream(tiff)); ByteBuffer buf = ImageIOHelper.convertImageData(image); int bpp = image.getColorModel().getPixelSize(); int bytespp = bpp / 8; int bytespl = (int) Math.ceil(image.getWidth() * bpp / 8.0); api.TessBaseAPISetPageSegMode(handle, TessPageSegMode.PSM_AUTO); api.TessBaseAPIInit3(handle, datapath, language); api.TessBaseAPISetImage(handle, buf, image.getWidth(), image.getHeight(), bytespp, bytespl); int page_number = 0; Pointer textPtr = api.TessBaseAPIGetAltoText(handle, page_number); String result = textPtr.getString(0); api.TessDeleteText(textPtr); assertTrue(result.contains("<Page WIDTH=\"1024\" HEIGHT=\"800\" PHYSICAL_IMG_NR=\"0\" ID=\"page_0\">")); // WordStr Box output textPtr = api.TessBaseAPIGetWordStrBoxText(handle, page_number); result = textPtr.getString(0); api.TessDeleteText(textPtr); assertTrue(result.contains("WordStr")); // TSV output textPtr = api.TessBaseAPIGetTsvText(handle, page_number); result = textPtr.getString(0); api.TessDeleteText(textPtr); assertTrue(result.contains("1\t")); // LSTM Box output textPtr = api.TessBaseAPIGetLSTMBoxText(handle, page_number); result = textPtr.getString(0); api.TessDeleteText(textPtr); assertTrue(result.contains("\t")); }
Example 8
Source File: ARM32SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private int stat64(Emulator<DarwinFileIO> emulator) { RegisterContext context = emulator.getContext(); Pointer pathname = context.getPointerArg(0); Pointer statbuf = context.getPointerArg(1); String path = pathname.getString(0); if (log.isDebugEnabled()) { log.debug("stat64 pathname=" + path + ", statbuf=" + statbuf + ", LR=" + context.getLRPointer()); } return stat64(emulator, FilenameUtils.normalize(path), statbuf); }
Example 9
Source File: OpenVRUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Get the value of the given string {@link JOpenVRLibrary.ETrackedDeviceProperty property} attached to the given device. * @param system the underlying OpenVR system. * @param deviceIndex the index of the device to query. * @param property the property to query. * @param bufferSize the size of the buffer to use for storing native string. * @return the value of the given string property attached to the given device. * @see OpenVRInput#getTrackedControllerCount() * @see JOpenVRLibrary.ETrackedDeviceProperty * @see #getTrackedDeviceStringProperty(VR_IVRSystem_FnTable, int, int) */ public static String getTrackedDeviceStringProperty(VR_IVRSystem_FnTable system, int deviceIndex, int property, int bufferSize){ String str =""; int unBufferSize = 256; Pointer pchValue = new Memory(unBufferSize); IntByReference pError = new IntByReference(); system.GetStringTrackedDeviceProperty.apply(deviceIndex, property, pchValue, unBufferSize, pError); if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_Success){ str = pchValue.getString(0); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_BufferTooSmall){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_CouldNotContactServer){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidDevice){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidOperation){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_NotYetAvailable){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_PermissionDenied){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_UnknownProperty){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDataType){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDeviceClass){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } else { throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")"); } return str; }
Example 10
Source File: ARM32SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private int readlink(Emulator<?> emulator) { RegisterContext context = emulator.getContext(); Pointer pathname = context.getPointerArg(0); Pointer buf = context.getPointerArg(1); int bufSize = context.getIntArg(2); String path = pathname.getString(0); return readlink(emulator, path, buf, bufSize); }
Example 11
Source File: ARM32SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private int readlink(Unicorn u, Emulator<?> emulator) { Pointer pathname = UnicornPointer.register(emulator, ArmConst.UC_ARM_REG_R0); Pointer buf = UnicornPointer.register(emulator, ArmConst.UC_ARM_REG_R1); int bufSize = ((Number) u.reg_read(ArmConst.UC_ARM_REG_R2)).intValue(); String path = pathname.getString(0); if (log.isDebugEnabled()) { log.debug("readlink path=" + path + ", buf=" + buf + ", bufSize=" + bufSize); } if ("/var/db/timezone/localtime".equals(path)) { // 设置时区 path = "/var/db/timezone/zoneinfo/Asia/Shanghai"; } buf.setString(0, path); return path.length() + 1; }
Example 12
Source File: ARM64SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private int readlinkat(Emulator<AndroidFileIO> emulator) { RegisterContext context = emulator.getContext(); int dirfd = context.getIntArg(0); Pointer pathname = context.getPointerArg(1); Pointer buf = context.getPointerArg(2); int bufSize = context.getIntArg(3); String path = pathname.getString(0); if (dirfd != IO.AT_FDCWD) { throw new UnicornException(); } return readlink(emulator, path, buf, bufSize); }
Example 13
Source File: ARM64SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private int rmdir(Emulator<?> emulator) { RegisterContext context = emulator.getContext(); Pointer path = context.getPointerArg(0); String pathname = path.getString(0); emulator.getFileSystem().rmdir(pathname); if (log.isDebugEnabled()) { log.debug("rmdir pathname=" + path); } return 0; }
Example 14
Source File: ARM32SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private int open_dprotected_np(Emulator<DarwinFileIO> emulator) { RegisterContext context = emulator.getContext(); Pointer path = context.getPointerArg(0); int flags = context.getIntArg(1); int _class = context.getIntArg(2); int dpflags = context.getIntArg(3); String pathname = path.getString(0); log.info("open_dprotected_np path=" + pathname + ", flags=0x" + Integer.toHexString(flags) + ", class=" + _class + ", dpflags=0x" + Integer.toHexString(dpflags)); return -1; }
Example 15
Source File: ARM64SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private int mkdirat(Unicorn u, Emulator<?> emulator) { int dirfd = ((Number) u.reg_read(ArmConst.UC_ARM_REG_R0)).intValue(); Pointer pathname_p = UnicornPointer.register(emulator, ArmConst.UC_ARM_REG_R1); int mode = ((Number) u.reg_read(ArmConst.UC_ARM_REG_R2)).intValue(); String pathname = pathname_p.getString(0); if (log.isDebugEnabled()) { log.debug("mkdirat dirfd=" + dirfd + ", pathname=" + pathname + ", mode=" + Integer.toHexString(mode)); } emulator.getMemory().setErrno(UnixEmulator.EACCES); return -1; }
Example 16
Source File: ARM64SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private long setattrlist(Emulator<DarwinFileIO> emulator) { RegisterContext context = emulator.getContext(); Pointer path = context.getPointerArg(0); Pointer attrListPointer = context.getPointerArg(1); UnicornPointer attrBuf = context.getPointerArg(2); int attrBufSize = context.getIntArg(3); int options = context.getIntArg(4); String pathname = path.getString(0); AttrList attrList = new AttrList(attrListPointer); attrBuf.setSize(attrBufSize); String msg = "setattrlist path=" + pathname + ", attrList=" + attrList + ", attrBuf=" + attrBuf + ", attrBufSize=" + attrBufSize + ", options=0x" + Integer.toHexString(options); FileResult<DarwinFileIO> result = resolve(emulator, pathname, IOConstants.O_RDONLY); if (result != null && result.isSuccess()) { int ret = result.io.setattrlist(attrList, attrBuf, attrBufSize); if (ret != 0) { log.info(msg + ", ret=" + ret); } else { if (log.isDebugEnabled()) { log.debug(msg + ", ret=" + ret); } } return ret; } emulator.getMemory().setErrno(result != null ? result.errno : UnixEmulator.EACCES); log.info(msg); return -1; }
Example 17
Source File: ARM32SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
protected int statfs64(Emulator<DarwinFileIO> emulator) { RegisterContext context = emulator.getContext(); Pointer pathPointer = context.getPointerArg(0); Pointer buf = context.getPointerArg(1); String path = pathPointer.getString(0); FileResult<DarwinFileIO> result = resolve(emulator, path, IOConstants.O_RDONLY); if (log.isDebugEnabled()) { log.debug("statfs64 pathPointer=" + pathPointer + ", buf=" + buf + ", path=" + path); } if (result != null && result.isSuccess()) { return result.io.fstatfs(new StatFS(buf)); } log.info("statfs64 pathPointer=" + pathPointer + ", buf=" + buf + ", path=" + path); throw new UnicornException("statfs64 path=" + path + ", buf=" + buf); }
Example 18
Source File: ARM64SyscallHandler.java From unidbg with Apache License 2.0 | 5 votes |
private int access(Unicorn u, Emulator<AndroidFileIO> emulator) { Pointer pathname = UnicornPointer.register(emulator, ArmConst.UC_ARM_REG_R0); int mode = ((Number) u.reg_read(ArmConst.UC_ARM_REG_R1)).intValue(); String path = pathname.getString(0); if (log.isDebugEnabled()) { log.debug("access pathname=" + path + ", mode=" + mode); } int ret = faccessat(emulator, path); if (ret == -1) { log.info("access pathname=" + path + ", mode=" + mode); } return ret; }
Example 19
Source File: Nc4Iosp.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
private Array decodeVlen(DataType dt, int pos, ByteBuffer bbuff) throws IOException { Array array; int n = (int) bbuff.getLong(pos); // Note that this does not increment the buffer position long addr = getNativeAddr(pos + com.sun.jna.Native.POINTER_SIZE, bbuff); Pointer p = new Pointer(addr); Object data; switch (dt) { case BOOLEAN: /* byte[] */ case ENUM1: case BYTE: data = p.getByteArray(0, n); break; case ENUM2: case SHORT: /* short[] */ data = p.getShortArray(0, n); break; case ENUM4: case INT: /* int[] */ data = p.getIntArray(0, n); break; case LONG: /* long[] */ data = p.getLongArray(0, n); break; case FLOAT: /* float[] */ data = p.getFloatArray(0, n); break; case DOUBLE: /* double[] */ data = p.getDoubleArray(0, n); break; case CHAR: /* char[] */ data = p.getCharArray(0, n); break; case STRING: /* String[] */ // For now we need to use p.getString() // because p.getStringArray(int,int) does not exist // in jna version 3.0.9, but does exist in // verssion 4.0 and possibly some intermediate versions String[] stringdata = new String[n]; for (int i = 0; i < n; i++) stringdata[i] = p.getString(i * 8); data = stringdata; break; case OPAQUE: case STRUCTURE: default: throw new IllegalStateException(); } array = Array.factory(dt, new int[] {n}, data); return array; }
Example 20
Source File: ARM32SyscallHandler.java From unidbg with Apache License 2.0 | 4 votes |
private int proc_info(Emulator<?> emulator) { Unicorn unicorn = emulator.getUnicorn(); int callNum = ((Number) unicorn.reg_read(ArmConst.UC_ARM_REG_R0)).intValue(); int pid = ((Number) unicorn.reg_read(ArmConst.UC_ARM_REG_R1)).intValue(); int flavor = ((Number) unicorn.reg_read(ArmConst.UC_ARM_REG_R2)).intValue(); int r3 = ((Number) unicorn.reg_read(ArmConst.UC_ARM_REG_R3)).intValue(); long r4 = ((Number) unicorn.reg_read(ArmConst.UC_ARM_REG_R4)).intValue(); long arg = r3 | (r4 << 32); Pointer buffer = UnicornPointer.register(emulator, ArmConst.UC_ARM_REG_R5); int bufferSize = ((Number) unicorn.reg_read(ArmConst.UC_ARM_REG_R6)).intValue(); String msg = "proc_info callNum=" + callNum + ", pid=" + pid + ", flavor=" + flavor + ", arg=" + arg + ", buffer=" + buffer + ", bufferSize=" + bufferSize; if (PROC_INFO_CALL_SETCONTROL == callNum && PROC_SELFSET_THREADNAME == flavor) { String threadName = buffer.getString(0); if (log.isDebugEnabled()) { log.debug(msg + ", threadName=" + threadName); } return 0; } else if (PROC_INFO_CALL_PIDINFO == callNum && PROC_PIDT_SHORTBSDINFO == flavor) { ProcBsdShortInfo info = new ProcBsdShortInfo(buffer); info.unpack(); String processName = emulator.getProcessName(); if (processName == null) { processName = "unidbg"; } info.pbsi_pid = pid; info.pbsi_status = ProcBsdShortInfo.SRUN; info.pbsi_comm = Arrays.copyOf(Arrays.copyOf(processName.getBytes(), DarwinSyscall.MAXCOMLEN-1), DarwinSyscall.MAXCOMLEN); info.pbsi_flags = 0x24090; info.pbsi_uid = 0; info.pbsi_ruid = 0; info.pbsi_svuid = 0; info.pbsi_gid = 0; info.pbsi_rgid = 0; info.pbsi_svgid = 0; info.pbsi_pgid = 0; info.pbsi_ppid = pid - 1; info.pack(); if (log.isDebugEnabled()) { log.debug(msg + ", info=" + info); } return info.size(); } else { log.info(msg); return 1; } }