Salve a tutti, se va questa ho finito.. mi serve come impostare la writeprocessmemory xkè come l'ho impostata io restituisce false, questo è il codice che ho fatto io grazie all'aiuto di andbin

codice:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Andrea94
 */
import com.sun.jna.*;
import com.sun.jna.examples.win32.Kernel32;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.*;

public class Main {
      public interface MyUser32Lib extends StdCallLibrary {
        MyUser32Lib INSTANCE = (MyUser32Lib) Native.loadLibrary("user32", MyUser32Lib.class);

        Pointer FindWindowA(String winClass, String title);
        int GetWindowThreadProcessId(Pointer hwnd, PointerByReference refProcessId);
    }
          public interface Kernel32 extends Library {

        Pointer OpenProcess(int dwDesiredAccess, boolean bInheritHandle, Pointer dwProcessId );
        boolean WriteProcessMemory(Pointer hProcess,Pointer lpBaseAddress,Pointer lpBuffer,Pointer nSize,int lpNumberOfBytesWritten);

        public boolean WriteProcessMemory(Pointer handleprocesso, Pointer adr, int i, int i0, int i1);

    }
    public static void main(String[] args) {
        Kernel32 kernel = (Kernel32)
           Native.loadLibrary("kernel32", Kernel32.class);
        Pointer hwnd = MyUser32Lib.INSTANCE.FindWindowA(null, "Prato fiorito");

        System.out.println("Handle finestra: " + hwnd);

        PointerByReference refProcessId = new PointerByReference();

        MyUser32Lib.INSTANCE.GetWindowThreadProcessId(hwnd, refProcessId);

        System.out.println("ID processo: " + refProcessId.getValue());

      Pointer handleprocesso = kernel.OpenProcess(16, false, refProcessId.getValue());
      System.out.println("Handle finestra: " + handleprocesso);
      long address= 0x010056a4;
Pointer adr = new Pointer(address);
Pointer buf = new Pointer (5);
Pointer size = new Pointer (4);
boolean asd = kernel.WriteProcessMemory(handleprocesso,adr,buf,size,4);
System.out.println(asd);
    }

   
}

E l'output è questo


codice:
Handle finestra: native@0x606c2
ID processo: native@0x9b0
Handle finestra: native@0x1634
false
Ringrazio anticipatamente in attesa di risposte