Package com.sun.jna

Examples of com.sun.jna.Memory


            super(memory);
            read();
        }

        public TOKEN_GROUPS(int size) {
            super(new Memory(size));
        }
View Full Code Here


      HANDLE hFile = Kernel32.INSTANCE.CreateFile(tmp.getAbsolutePath(), WinNT.GENERIC_READ, WinNT.FILE_SHARE_READ,
          new WinBase.SECURITY_ATTRIBUTES(), WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, null);
      assertFalse(hFile == WinBase.INVALID_HANDLE_VALUE);

      Memory m = new Memory(2048);
      IntByReference lpNumberOfBytesRead = new IntByReference(0);
      assertTrue(Kernel32.INSTANCE.ReadFile(hFile, m, (int) m.size(), lpNumberOfBytesRead, null));
      int read = lpNumberOfBytesRead.getValue();
      assertEquals(expected.length(), read);
      assertEquals(expected, new String(m.getByteArray(0, read)));

      assertTrue(Kernel32.INSTANCE.CloseHandle(hFile));
    }
View Full Code Here

                }
            }

            X11.XModifierKeymapRef xModifierKeymapRef = new X11.XModifierKeymapRef();
            xModifierKeymapRef.max_keypermod = count;
            xModifierKeymapRef.modifiermap = new Memory(keys.length);
            xModifierKeymapRef.modifiermap.write(0, keys, 0, keys.length);

            return xModifierKeymapRef;
        }
View Full Code Here

        }

        public SECURITY_DESCRIPTOR(byte[] data) {
            super();
            this.data = data;
            useMemory(new Memory(data.length));
        }
View Full Code Here

        public SECURITY_DESCRIPTOR_RELATIVE() {
        }

        public SECURITY_DESCRIPTOR_RELATIVE(byte[] data) {
            super(new Memory(data.length));
            getPointer().write(0, data, 0, data.length);
            setDacl();
        }
View Full Code Here

        // but verifies that the JNA mapping is correct (no exception)
        DWORDByReference pdwCapabilitiesStringLengthInCharacters = new DWORDByReference();
        Dxva2.INSTANCE.GetCapabilitiesStringLength(hPhysicalMonitor, pdwCapabilitiesStringLengthInCharacters);
        DWORD capStrLen = pdwCapabilitiesStringLengthInCharacters.getValue();

        LPSTR pszASCIICapabilitiesString = new LPSTR(new Memory(capStrLen.intValue()));
        Dxva2.INSTANCE.CapabilitiesRequestAndCapabilitiesReply(hPhysicalMonitor, pszASCIICapabilitiesString, capStrLen);
    }
View Full Code Here

                return Pointer.NULL;
            } else if (parameter instanceof RubyString) {
                // Handle a string being used as a inout buffer
                final ByteList bl = ((RubyString) parameter).getByteList();
                final int len = bl.length();
                final Memory memory = new Memory(len);
                memory.write(0, bl.unsafeBytes(), bl.begin(), len);

                //
                // Arrange for the bytes to be copied back after the function is called
                //
                invocation.addPostInvoke(new Runnable() {
                    public void run() {
                        memory.read(0, bl.unsafeBytes(), bl.begin(), len);
                    }
                });
                return memory;
            }
            return Util.convertParameter(parameter, Pointer.class);
View Full Code Here

    private static final class StringMarshaller implements Marshaller {
        public final Object marshal(Invocation invocation, IRubyObject parameter) {
            // Ruby strings are UTF-8, so should be able to just copy directly
            RubyString s = parameter.asString();
            ByteList bl = s.getByteList();
            final Memory memory = new Memory(bl.length() + 1);
            memory.write(0, bl.unsafeBytes(), bl.begin(), bl.length());
            memory.setByte(bl.length(), (byte) 0);
            return memory;
        }
View Full Code Here

    private static final class RbxStringMarshaller implements Marshaller {
        public final Object marshal(Invocation invocation, IRubyObject parameter) {
            // Ruby strings are UTF-8, so should be able to just copy directly
            final ByteList bl = parameter.asString().getByteList();
            final int strlen = bl.length();
            final Memory memory = new Memory(strlen + 1);
            memory.write(0, bl.unsafeBytes(), bl.begin(), strlen);
            memory.setByte(bl.length(), (byte) 0);
           
            //
            // Arrange for the bytes to be copied back after the function is called
            //
            invocation.addPostInvoke(new Runnable() {
                public void run() {
                    memory.read(0, bl.unsafeBytes(), bl.begin(), strlen);
                }
            });
            return memory;
        }
View Full Code Here

            return pbData.getByteArray(0, cbData);
            // XXX how to free pbData? [Kernel32]LocalFree?
        }
        void store(byte[] data) {
            cbData = data.length;
            pbData = new Memory(data.length);
            pbData.write(0, data, 0, cbData);
        }
View Full Code Here

TOP

Related Classes of com.sun.jna.Memory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.