Package com.sun.jna

Examples of com.sun.jna.Pointer


     
      ByteBuffer bufSrc = ByteBuffer.allocateDirect(4);
      bufSrc.put(new byte[]{5,10,15,20});
      ByteBuffer bufDest = ByteBuffer.allocateDirect(4);
      bufDest.put(new byte[]{0,1,2,3});
      Pointer ptrSrc = Native.getDirectBufferPointer(bufSrc);
      Pointer ptrDest = Native.getDirectBufferPointer(bufDest);
     
      HANDLE selfHandle = kernel.GetCurrentProcess();
      kernel.ReadProcessMemory(selfHandle, ptrSrc, ptrDest, 3, null);//Read only the first three
     
    assertEquals(bufDest.get(0),5);
View Full Code Here


        public void setValue(HANDLE h) {
            getPointer().setPointer(0, h != null ? h.getPointer() : null);
        }

        public HANDLE getValue() {
            Pointer p = getPointer().getPointer(0);
            if (p == null) {
                return null;
            }
            if (WinBase.INVALID_HANDLE_VALUE.getPointer().equals(p)) {
                return WinBase.INVALID_HANDLE_VALUE;
View Full Code Here

               
                PointerByReference ppbits = new PointerByReference();
                hBitmap = gdi.CreateDIBSection(memDC, bmi, WinGDI.DIB_RGB_COLORS,
                                               ppbits, null, 0);
                oldBitmap = gdi.SelectObject(memDC, hBitmap);
                Pointer pbits = ppbits.getValue();
               
                Raster raster = buf.getData();
                int[] pixel = new int[4];
                int[] bits = new int[w*h];
                for (int y=0;y < h;y++) {
                    for (int x=0;x < w;x++) {
                        raster.getPixel(x, h-y-1, pixel);
                        int alpha = (pixel[3]&0xFF)<<24;
                        int red = (pixel[2]&0xFF);
                        int green = (pixel[1]&0xFF)<<8;
                        int blue = (pixel[0]&0xFF)<<16;
                        bits[x + y * w] = alpha|red|green|blue;
                    }
                }
                pbits.write(0, bits, 0, bits.length);
               
                SIZE size = new SIZE();
                size.cx = w;
                size.cy = h;
                POINT loc = new POINT();
View Full Code Here

                String prop_name = x11.XGetAtomName(display.x11Display, xa_prop_name);
                throw new X11Exception("Cannot get " + prop_name + " property.");
            }

            X11.Atom xa_ret_type = xa_ret_type_ref.getValue();
            Pointer ret_prop = ret_prop_ref.getValue();
           
            if( xa_ret_type == null ){
              //the specified property does not exist for the specified window
              return null;
            }

            if( xa_ret_type == null ){
                //the specified property does not exist for the specified window
                return null;
            }

            if( xa_ret_type == null ){
                //the specified property does not exist for the specified window
                return null;
            }

            if (xa_ret_type == null || xa_prop_type == null ||
                    !xa_ret_type.toNative().equals(xa_prop_type.toNative())) {
                x11.XFree(ret_prop);
                String prop_name = x11.XGetAtomName(display.x11Display, xa_prop_name);
                throw new X11Exception("Invalid type of " + prop_name + " property");
            }

            int ret_format = ret_format_ref.getValue();
            long ret_nitems = ret_nitems_ref.getValue().longValue();

            // null terminate the result to make string handling easier
            int nbytes;
            if (ret_format == 32)
                nbytes = Native.LONG_SIZE;
            else if (ret_format == 16)
                nbytes = Native.LONG_SIZE / 2;
            else if (ret_format == 8)
                nbytes = 1;
            else if (ret_format == 0)
                nbytes = 0;
            else
                throw new X11Exception("Invalid return format");
            int length = Math.min((int) ret_nitems * nbytes, MAX_PROPERTY_VALUE_LEN);

            byte[] ret = ret_prop.getByteArray(0, length);

            x11.XFree(ret_prop);
            return ret;
        }
View Full Code Here

      assertEquals(WinError.S_OK, Ole32.INSTANCE.CLSIDFromProgID("jpegfile", clsid));
      assertEquals("{25336920-03F9-11CF-8FD0-00AA00686F13}", clsid.toGuidString());
  }

    public void testCoTaskMemAlloc() {
        Pointer ptr = Ole32.INSTANCE.CoTaskMemAlloc(256);

        assertTrue(!ptr.equals(Pointer.NULL));

        Ole32.INSTANCE.CoTaskMemFree(ptr);
    }
View Full Code Here

        Ole32.INSTANCE.CoTaskMemFree(ptr);
    }

    public void testCoTaskMemRealloc() {
        Pointer ptr = Ole32.INSTANCE.CoTaskMemAlloc(256);

        assertTrue(!ptr.equals(Pointer.NULL));

        ptr = Ole32.INSTANCE.CoTaskMemRealloc(ptr, 128);

        assertTrue(!ptr.equals(Pointer.NULL));

        Ole32.INSTANCE.CoTaskMemFree(ptr);
    }
View Full Code Here

            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;
View Full Code Here

     * Return a procedure function pointer
     * @param procName the procedure name
     * @return the function
     */
    public static Function wglGetProcAddress(String procName) {
        Pointer funcPointer = OpenGL32.INSTANCE.wglGetProcAddress("wglEnumGpusNV");
        return (funcPointer == null) ? null : Function.getFunction(funcPointer);
    }
View Full Code Here

        GDI32.INSTANCE.SetPixelFormat(hdc, GDI32.INSTANCE.ChoosePixelFormat(hdc, pfd), pfd);

        // create the OpenGL context to get function address
        WinDef.HGLRC hGLRC = OpenGL32.INSTANCE.wglCreateContext(hdc);
        OpenGL32.INSTANCE.wglMakeCurrent(hdc, hGLRC);
        Pointer funcPointer = OpenGL32.INSTANCE.wglGetProcAddress("wglEnumGpusNV");
        Function fncEnumGpusNV = (funcPointer == null) ? null : Function.getFunction(funcPointer);
        OpenGL32.INSTANCE.wglDeleteContext(hGLRC);

        // destroy the window
        User32.INSTANCE.ReleaseDC(hWnd, hdc);
View Full Code Here

  this.code = code;
    }
   
    private static String toErrorString(int code) {
        PointerByReference pMsg=new PointerByReference();
        Pointer msg;
        String out;
        if(null!=win32MlOsMainDll){
            win32MlOsMainDll.err_Msg(code, pMsg);
            msg=pMsg.getValue();
            out=msg.getString(0);
        }else{
            out="Could not retrieve error description, MLOSMAIN Dll not loaded.\nError code="+code;
        }
        return out;
    }
View Full Code Here

TOP

Related Classes of com.sun.jna.Pointer

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.