Well, yeah I found my code. Please keep in mind that I just did it for that workshop and it's far from perfect, maybe I'll update this as a Java iNHALE template.
You have the basic stuff, OpenProcess finds a window either by ClassName or WindowName and returns the processHandle to you.
Refer to the MSDN WriteProcessMemory documentation for information on the return values of this function. Additionally you should only write n bytes where n%2 == 0. The same goes for ReadProcessMemory you should only read n bytes where n%2 == 0. I may or may not improve this interface in the future, mainly because the use of chars was a nasty fix and I had little time to implement this. (chars are unsigned in Java) :p
Main.java
Process.javaCode:/** * [descripción] * Creado el 2/11/2005 @ 11:47:58 AM * * @author * @version %I%, %G% */ public class Main { public static void main(String[] args) { System.out.println(); Process process = new Process(null, "MSN Messenger"); // WriteProcessMemory if ( process.getpHandle() != 0 ) { System.out.println("MSN Messenger encontrado!"); process.WriteProcessMemory(0x5070ED, new char[] {0x77EB}); } else { System.out.println("Error: MSN Messenger no econtrado!."); } }
SandBox.DLLCode:/** * [descripción] * Creado el 31/10/2005 @ 09:46:47 PM * * @author * @version %I%, %G% */ public class Process { private int pHandle; private static String NULL = ""; private native int OpenProcess(String lpClassName, String lpWindowName); private native int WriteProcessMemory(int pHandle, int lpBaseAddress, char[] lpBuffer); private native char[] ReadProcessMemory(int pHandle, int lpBaseAddress, int nSize); static { System.loadLibrary("SandBox"); } public Process() { } public Process(int pHandle) { this.pHandle = pHandle; } public Process(String lpClassName, String lpWindowName) { this.pHandle = OpenProcess(lpClassName == null ? NULL : lpClassName, lpWindowName == null ? NULL : lpWindowName); } public int getpHandle() { return pHandle; } public void setpHandle(int pHandle) { this.pHandle = pHandle; } public void setpHandle(String lpClassName, String lpWindowName) { this.pHandle = OpenProcess(lpClassName == null ? NULL : lpClassName, lpWindowName == null ? NULL : lpWindowName); } public int WriteProcessMemory(int lpBaseAddress, char[] lpBuffer) { return WriteProcessMemory(pHandle, lpBaseAddress, lpBuffer); } public char[] ReadProcessMemory(int lpBaseAddress, int nSize) { return ReadProcessMemory(pHandle, lpBaseAddress, nSize); } }


LinkBack URL
About LinkBacks





Reply With Quote










