public synchronized List<String> getArguments() { if(arguments!=null) return arguments; arguments = new ArrayList<String>(argc); if (argc == 0) { return arguments; } int psize = b64 ? 8 : 4; Memory m = new Memory(psize); try { if(LOGGER.isLoggable(FINER)) LOGGER.finer("Reading "+getFile("as")); int fd = LIBC.open(getFile("as").getAbsolutePath(), 0); try { for( int n=0; n<argc; n++ ) { // read a pointer to one entry LIBC.pread(fd, m, new NativeLong(psize), new NativeLong(argp+n*psize)); long addr = b64 ? m.getLong(0) : to64(m.getInt(0)); arguments.add(readLine(fd, addr, "argv["+ n +"]")); } } finally { LIBC.close(fd); } } catch (IOException | LastErrorException e) { // failed to read. this can happen under normal circumstances (most notably permission denied) // so don't report this as an error. } arguments = Collections.unmodifiableList(arguments); return arguments; }
long addr = b64 ? m.getLong(0) : to64(m.getInt(0)); if (addr == 0) // completed the walk break;
/** * Retrieves the number of this line. * * @return The number of the line. */ public int getLine() { return this.memory.getInt( NativeGpioLineInfo.OFFSET_LINE ) ; }
/** * Retrieves how many lines this GPIO device can handle, at most 64. * * @return The number of lines. */ public int getLines() { return this.memory.getInt( NativeGpioChipInfo.OFFSET_LINES ) ; }
/** * Retrieves which line will be requested. * * @return Number of the line. */ public int getLine() { return this.memory.getInt( NativeGpioEventRequest.OFFSET_LINE ) ; }
@Override public Object readFrom(Memory buffer, Class<?> type) { return buffer.getInt(0); } @Override public Memory bufferForResult(Object methodCallResult) {
int getFD() { return this.memory.getInt( NativeGpioHandleRequest.OFFSET_FD ) ; }
int getFD() { return this.memory.getInt( NativeGpioEventRequest.OFFSET_FD ) ; }
private int getRawFlags() { return this.memory.getInt( NativeGpioLineInfo.OFFSET_FLAGS ) ; }
/** * Retrieves the flags specifying how the lines will be handled. * * @return The flags. */ public GpioFlags getFlags() { return new GpioFlags().fromRequest( this.memory.getInt( NativeGpioHandleRequest.OFFSET_FLAGS ) ) ; }
/** * Retrieves the flags describing how the lines involved in this request should be handled. * * @return Flags. */ public GpioFlags getFlags() { return new GpioFlags().fromRequest( this.memory.getInt( NativeGpioEventRequest.OFFSET_HANDLE_FLAGS ) ) ; }
public static void main(String... args) { int pid = getProcessId("Solitaire"); Pointer process = openProcess(PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_VM_OPERATION, pid); long dynAddress = findDynAddress(process,offsets,baseAddress); Memory scoreMem = readMemory(process,dynAddress,4); int score = scoreMem.getInt(0); System.out.println(score); } public static Memory readMemory(Pointer process, long address, int bytesToRead) { IntByReference read = new IntByReference(0); Memory output = new Memory(bytesToRead); kernel32.ReadProcessMemory(process, address, output, bytesToRead, read); return output; }
pointerAddress = ((pTemp.getInt(0)+offsets[i]));
private int getIntSockopt(int option) { Memory value = new Memory(Integer.SIZE / 8); LongByReference length = new LongByReference(Integer.SIZE / 8); zmq.zmq_getsockopt(ptr, option, value, length); return value.getInt(0); }
public static void main(String... args) { int pid = getProcessId("Solitaire"); Pointer process = openProcess(PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_VM_OPERATION, pid); long dynAddress = findDynAddress(process,offsets,baseAddress); Memory scoreMem = readMemory(process,dynAddress,4); int score = scoreMem.getInt(0); System.out.println(score); byte[] newScore = new byte[]{0x22,0x22,0x22,0x22}; writeMemory(process, dynAddress, newScore); } public static void writeMemory(Pointer process, long address, byte[] data) { int size = data.length; Memory toWrite = new Memory(size); for(int i = 0; i < size; i++) { toWrite.setByte(i, data[i]); } boolean b = kernel32.WriteProcessMemory(process, address, toWrite, size, null); }
/** * Adds a GPIO line to the request. * <p> * A handle can drive at most 64 lines at once. * * @param lineNumber * Which line. * * @return A GPIO line useful for handling a buffer. * * @see GpioBuffer */ public GpioLine addLine( int lineNumber ) { int index = this.memory.getInt( NativeGpioHandleRequest.OFFSET_LINES ) ; this.memory.setInt( NativeGpioHandleRequest.OFFSET_LINE_OFFSETS + 4 * index , lineNumber ) ; this.memory.setInt( NativeGpioHandleRequest.OFFSET_LINES , index + 1 ) ; return new GpioLine( lineNumber , index ) ; }