Source:
private void parse() { try { arguments = new ArrayList<String>(); envVars = new EnvVars(); IntByReference _ = new IntByReference(); IntByReference argmaxRef = new IntByReference(0); IntByReference size = new IntByReference(sizeOfInt); if(LIBC.sysctl(new int[]{CTL_KERN,KERN_ARGMAX},2, argmaxRef.getPointer(), size, NULL, _)!=0) throw new IOException("Failed to get kernel.argmax: "+LIBC.strerror(Native.getLastError())); int argmax = argmaxRef.getValue(); class StringArrayMemory extends Memory { private long offset=0; StringArrayMemory(long l) { super(l); } int readInt() { int r = getInt(offset); offset+=sizeOfInt; return r; } byte peek() { return getByte(offset); } String readString() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte ch; while((ch = getByte(offset++))!='\0') baos.write(ch); return baos.toString(); } void skip0() { while(getByte(offset)=='\0') offset++; } } StringArrayMemory m = new StringArrayMemory(argmax); size.setValue(argmax); if(LIBC.sysctl(new int[]{CTL_KERN,KERN_PROCARGS2,pid},3, m, size, NULL, _)!=0) throw new IOException("Failed to obtain ken.procargs2: "+LIBC.strerror(Native.getLastError())); int argc = m.readInt(); String args0 = m.readString(); m.skip0(); try { for( int i=0; i<argc; i++) { arguments.add(m.readString()); } } catch (IndexOutOfBoundsException e) { throw new IllegalStateException("Failed to parse arguments: pid="+pid+", arg0="+args0+", arguments="+arguments+", nargs="+argc+". Please run 'ps e "+pid+"' and report this to <LINK_1>",e); } while(m.peek()!=0) envVars.addLine(m.readString()); } catch (IOException e) { } }

Target:
private void parse() { try { arguments = new ArrayList<String>(); envVars = new EnvVars(); IntByReference _ = new IntByReference(); IntByReference argmaxRef = new IntByReference(0); IntByReference size = new IntByReference(sizeOfInt); if(LIBC.sysctl(new int[]{CTL_KERN,KERN_ARGMAX},2, argmaxRef.getPointer(), size, NULL, _)!=0) throw new IOException("Failed to get kern.argmax: "+LIBC.strerror(Native.getLastError())); int argmax = argmaxRef.getValue(); class StringArrayMemory extends Memory { private long offset=0; StringArrayMemory(long l) { super(l); } int readInt() { int r = getInt(offset); offset+=sizeOfInt; return r; } byte peek() { return getByte(offset); } String readString() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte ch; while((ch = getByte(offset++))!='\0') baos.write(ch); return baos.toString(); } void skip0() { while(getByte(offset)=='\0') offset++; } } StringArrayMemory m = new StringArrayMemory(argmax); size.setValue(argmax); if(LIBC.sysctl(new int[]{CTL_KERN,KERN_PROCARGS2,pid},3, m, size, NULL, _)!=0) throw new IOException("Failed to obtain ken.procargs2: "+LIBC.strerror(Native.getLastError())); int argc = m.readInt(); String args0 = m.readString(); m.skip0(); try { for( int i=0; i<argc; i++) { arguments.add(m.readString()); } } catch (IndexOutOfBoundsException e) { throw new IllegalStateException("Failed to parse arguments: pid="+pid+", arg0="+args0+", arguments="+arguments+", nargs="+argc+". Please run 'ps e "+pid+"' and report this to <LINK_1>",e); } while(m.peek()!=0) envVars.addLine(m.readString()); } catch (IOException e) { } }