/** Provide a view of this memory using the given offset to calculate a new base address. */ public Pointer share(long offset) { return share(offset, 0); }
/** Ensure this memory has its size and layout calculated and its memory allocated. @param avoidFFIType used when computing FFI type information to avoid recursion */ private void ensureAllocated(boolean avoidFFIType) { if (memory == null) { allocateMemory(avoidFFIType); } else if (size == CALCULATE_SIZE) { this.size = calculateSize(true, avoidFFIType); if (!(this.memory instanceof AutoAllocated)) { // Ensure we've set bounds on the shared memory used try { this.memory = this.memory.share(0, this.size); } catch(IndexOutOfBoundsException e) { throw new IllegalArgumentException("Structure exceeds provided memory bounds", e); } } } }
int size = size(); for (int i=1;i < array.length;i++) { array[i] = newInstance(getClass(), memory.share(i*size, size)); array[i].conditionalAutoRead();
/** * @return A view of the native memory which backs this buffer */ public Pointer pointer() { return pointer.share(0); // share view rather than actual pointer }
/** * @return A view of the native memory which backs this buffer */ public Pointer pointer() { return pointer.share(0); // share view rather than actual pointer }
/** Provide a view of this memory using the given offset to calculate a new base address. */ public Pointer share(long offset) { return share(offset, 0); }
Structure first = sarray[0]; if (first == null) { first = Structure.newInstance((Class<Structure>) cls, share(offset)); first.conditionalAutoRead(); sarray[0] = first;
Structure first = sbuf[0]; if (first == null) { first = Structure.newInstance((Class<Structure>) cls, share(offset)); sbuf[0] = first; } else {
/** Provide a view of this pointer with a different peer base. */ public Pointer share(long offset, long sz) { return new Pointer(peer + offset); }
public JNAMemoryIO slice(long offset) { return offset == 0 ? this : new PointerIO(ptr.share(offset), size - offset); }
/** Ensure this memory has its size and layout calculated and its memory allocated. @param avoidFFIType used when computing FFI type information to avoid recursion */ private void ensureAllocated(boolean avoidFFIType) { if (memory == null) { allocateMemory(avoidFFIType); } else if (size == CALCULATE_SIZE) { this.size = calculateSize(true, avoidFFIType); if (!(this.memory instanceof AutoAllocated)) { // Ensure we've set bounds on the shared memory used try { this.memory = this.memory.share(0, this.size); } catch(IndexOutOfBoundsException e) { throw new IllegalArgumentException("Structure exceeds provided memory bounds", e); } } } }
private final void setDacl() { read(); if (Dacl != 0) { DACL = new ACL(getPointer().share(Dacl)); } } }
@Override public EventLogRecord next() { read(); EventLogRecord record = new EventLogRecord(_pevlr); _dwRead -= record.getLength(); _pevlr = _pevlr.share(record.getLength()); return record; }
public EventLogRecord next() { read(); EventLogRecord record = new EventLogRecord(_pevlr); _dwRead -= record.getLength(); _pevlr = _pevlr.share(record.getLength()); return record; }
public int callback(int num_msg, Pointer msg, Pointer resp, Pointer _) { LOGGER.fine("pam_conv num_msg="+num_msg); if(password==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<num_msg; i++ ) { pam_message pm = new pam_message(msg.getPointer(POINTER_SIZE*i)); LOGGER.fine(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(password); r.write(); // write to (*resp)[i] } } return PAM_SUCCESS; } });
public ACL(Pointer pointer) { super(pointer); read(); ACEs = new ACCESS_ACEStructure[AceCount]; int offset = size(); for (int i = 0; i < AceCount; i++) { Pointer share = pointer.share(offset); // ACE_HEADER.AceType final byte aceType = share.getByte(0); ACCESS_ACEStructure ace = null; switch (aceType) { case ACCESS_ALLOWED_ACE_TYPE: ace = new ACCESS_ALLOWED_ACE(share); break; case ACCESS_DENIED_ACE_TYPE: ace = new ACCESS_DENIED_ACE(share); break; default: throw new IllegalArgumentException("Unknwon ACE type " + aceType); } ACEs[i] = ace; offset += ace.AceSize; } }
public int callback(int num_msg, Pointer msg, Pointer resp, Pointer __) { LOGGER.fine("pam_conv num_msg="+num_msg); if(password==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<num_msg; i++ ) { pam_message pm = new pam_message(msg.getPointer(POINTER_SIZE*i)); LOGGER.fine(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(password); r.write(); // write to (*resp)[i] } } return PAM_SUCCESS; } });
/** * Give a framebuffer memory pointer to the application. * * @param addr Not used. * @param natLen Length of the memory to be mapped. * @param prot Mapping protocol for verification. * @param flags Mapping flags for verification. * @param fd Not used. * @param natOff Mapping offset. * @return Address to the mapped memory. */ @Override public Pointer mmap(Pointer addr, NativeLong natLen, int prot, int flags, int fd, NativeLong natOff) { long len = natLen.longValue(); long off = natOff.longValue(); if ((prot & NativeConstants.PROT_WRITE) == 0 || (prot & NativeConstants.PROT_READ) == 0) { countMmapBadProt++; } if ((flags & NativeConstants.MAP_SHARED) == 0) { countMmapBadFlags++; } return memory.share(off, len); }