Ciao a tutti mi dispiace rompere ancora nel forum, ma mi serve urgentemente una mano, sono arrivato a questo punto nel source, ma la writeprocessmemory continua a non funzionare, confido in qualche anima buona che mi dica come sbaglio, grazie in anticipo
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, IntByReference refProcessId); } public interface Kernel32 extends Library { Pointer OpenProcess(int dwDesiredAccess, boolean bInheritHandle, int dwProcessId ); boolean WriteProcessMemory(Pointer hProcess,Pointer lpBaseAddress,Pointer lpBuffer,int nSize,IntByReference 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); IntByReference refProcessId = new IntByReference(); MyUser32Lib.INSTANCE.GetWindowThreadProcessId(hwnd, refProcessId); System.out.println("ID processo: " + refProcessId.getValue()); Pointer handleprocesso = kernel.OpenProcess(16, true, refProcessId.getValue()); System.out.println("Handle processo: " + handleprocesso); long address= 0x010056a4; Pointer adr = new Pointer(address); Memory buf = new Memory(4); long assdd= 0; buf.setInt(assdd, 40); int size = 4; IntByReference asdd= new IntByReference (); boolean asd = kernel.WriteProcessMemory(handleprocesso,adr,buf,size,asdd); System.out.println(asdd.getValue()); System.out.println(asd); } }

Rispondi quotando
).
