I came here some time ago to ask about javaFX , i solved all my issues and im right now waiting for javaFx tot ake over swing and hmm, im working on learning LIBGDX to create games in java.

However, im in need to create an app to change values of memory to fix a bug in an old program that i have, and the only way until now is using cheatEngine, So i decided to take a tutorial and learn how to do that in java.

Well, im able to read from the memory but the write isnt working somehow... Im posting the code here, if anyone can give me a hint, i would thank and a lot, because theres a community that really needs this app to automate the fix without using cheat engine.

short[] sarray = new short[]{0x2222,0x2222};//notice, that sarray[0] is the lowbyte and sarray[1] the high byte, if you want to store 20 it would be new short[]{20,0} or if you use hex new short[]{0x14,0x00}

The next part is your writeToMemory Method. If I'm right, the method in the tutorial is a little bit wrong. The right version should be this:

You can see some changes. First I changed all address values from int to long, because some addresses are out of range. And with all, i mean all. Not only in writeMemory, but also in readMemory and in your kernel32 Class.

Second I don't use the IntByReference anymore..

To use this method you need to store your data the following way if you would write 4 Byte data:

byte[] values = new byte[]{0x14,0x00,0x00,0x00};

This value would be the number 20. Index 0 will be the lowest byte and index 3 will be the highest byte.

And one more thing I wrote is an method which you can use to calculate your address if you have a baseAddress.

If you restart your program/game your old addresses won't point at the same values of your game. With some research (I use CheatEngine) you can get the baseaddress. This one will alway be the same.