Welcome to dEViATED. We provide PC trainers, cheats, mods and game trainers and a gamehacking forum for discussions and help. We have pc cheats, cheat engine tables and mods for various old and new single player games.

These are some of the latest trainers released by us and supported fully.
Assassin's Creed Rogue Trainer
Grand Theft Auto 5 Trainer



Sign in to follow this  
Followers 0

Tutorial on Coding a Trainer in Java (Done by me)

32 posts in this topic

Posted

Okay, first off, thank you, finally a trainer skeleton in a location I know :)

Second, Where would I put JNA.Jar I use BlueJ (When I find easier to use that Exlipse) but I can't find where to put it, your default coding (import java.sun.JNA.*:) doesn't work for me

Share this post


Link to post
Share on other sites

Posted

Tabbed Code (BlueJ thankfully uses Spaces(4) for a single tab, so it works on the forum)

To save board space, I have hidden with spoiler code (since codebox/code doesn't use scroll box), to see tabbed code, just click the show button :)


//done by Sharky on http://deviatedhacking.com
//Version 0.9 Beta - Because there is one small thing left concerning the Processfind Method
//i want to try both dll files, but atm if one dll file doesnt contain the desired Function the trainer crashes
//this will be fixed when i have time for it - until then - try wich dll suits your system or make a Trainer for one
//and one Trainer for the other DLL - its only commenting out 3 lines of code 2 times ^^
//download jna.jar from the internet - and include to your project
//i recomm your using eclipse for coding

//Usual Imports
import java.util.Arrays;

//JNA imports - Lets us use Windows dll files
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;

public class trainermain{
//Public Variables for AccessRights
public static final int PROCESS_QUERY_INFORMATION = 0x0400;
public static final int PROCESS_VM_READ = 0x0010;
public static final int PROCESS_VM_WRITE = 0x0020;
public static final int PROCESS_VM_OPERATION = 0x0008;

//Some functions, depending on Windows Version are located in Kernel32.dll, some in Psapi.dll

//Access to external Kernel32.dll
public interface Kernel32 extends StdCallLibrary
{
Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class);
boolean ReadProcessMemory(Pointer hProcess, int inBaseAddress, Pointer outputBuffer, int nSize, IntByReference outNumberOfBytesRead);

public Pointer OpenProcess(int dwDesiredAccess, boolean bInheritHandle, int dwProcessId);


boolean WriteProcessMemory(Pointer hProcess,int AdressToChange,Pointer ValuesToWrite,int nSize, IntByReference irgendwas);

int GetLastError();

//Needed for some Windows 7 Versions
boolean EnumProcesses(int []ProcessIDsOut,int size , int[] BytesReturned);
int GetProcessImageFileNameW(Pointer Process, char[] outputname, int lenght);
}

//Access to external Psapi.dll
public interface Psapi extends StdCallLibrary
{
Psapi INSTANCE = (Psapi) Native.loadLibrary("Psapi", Psapi.class);
//For some Windows 7 Versions and older down to XP
boolean EnumProcesses(int []ProcessIDsOut,int size , int[] BytesReturned);
int GetProcessImageFileNameW(Pointer Process, char[] outputname, int lenght);
}

//Processfinder - returns NULL if Process wasnt found
public static Pointer FindMyProcess(String ProcessNameToFind)
{
//Related to Version we have to use Kernel32.dll OR Psapi.dll to find the Process
Psapi Psapidll = Psapi.INSTANCE;
Kernel32 Kernel32dll = Kernel32.INSTANCE;

//we take an arraysize of 1024 - coz noone will have 1024 Processes running
int[] processlist=new int[1024];
int[] dummylist=new int[1024];

//Lets first try Psapi.dll
try{
Psapidll.EnumProcesses(processlist, 1024, dummylist);
}
catch(Exception e){
}

//Lets now try Kernel32.dll
//try{Kernel32dll.EnumProcesses(processlist, 1024, dummylist);}
//catch(Exception e){
//}
//Ok - we now got our Array with all the ProcessID's from all running Processes in the array processlist
//Time to find out which Processid is our desired one!

//A pointer for our Processfinding mechanism
Pointer tempProcess;
//Pointer for our desired Process
Pointer Process=null;
//Char Array for the path of the processes containing also the filename.exe
char []outputnames = new char[1024];
//A String for easier Comparison - see below
String path="";

for(int processid : processlist){
tempProcess=Kernel32dll.OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION, false, processid);

//Again we have to try both dll files in order to obtain our goal - one will work
try{Psapidll.GetProcessImageFileNameW(tempProcess, outputnames, 1024);}
catch(Exception e){}

//try{Kernel32dll.GetProcessImageFileNameW(tempProcess, outputnames, 1024);}
//catch(Exception e){}

//reset Path String
path="";

for(int k=0; k<1024;k++){
//Convert our Char Array into a nice readable String
if((int) outputnames[k]!=0)
path=path+outputnames[k];
}

if(path.contains(ProcessNameToFind))
{
//If one of the processes found has the desired process exe name in its path its the one we want
Process=tempProcess;
}
//reset char
outputnames = new char[1024];

}

//Finally returning our Process - Null if we didnt find it.
return Process;
}

//ReadProcessMemory ^^
public static int[] ReadMyProcessMemory(Pointer ProcessToReadFrom, int AdressToReadFrom, int NumberOfBytesToRead )
{
//Make the Desired Functions available
Kernel32 Kernel32dll = Kernel32.INSTANCE;

int offset=AdressToReadFrom;
IntByReference baseAddress = new IntByReference();
baseAddress.setValue(offset);
Memory outputBuffer = new Memory(NumberOfBytesToRead);

boolean reader = Kernel32dll.ReadProcessMemory(ProcessToReadFrom, offset, outputBuffer, NumberOfBytesToRead, null);



if(reader)
{
//Process the received Data
byte[] bufferBytes = outputBuffer.getByteArray(0, NumberOfBytesToRead);

//Who wants signed byte? NOONE ! Lets convert it to a nice int !

int[] realvalues=new int[bufferBytes.length];

for(int i=0;i<bufferBytes.length;i++)
{ if(bufferBytes[i]<0)
{
realvalues[i]=256+bufferBytes[i];
}
else
{
realvalues[i]=bufferBytes[i];
}
}
//Conversion done ! lets Return the data (Remember its integer not hex)
return realvalues;

}
else
{
//Reading went wrong - SHIT
return null;
}
}

//WritePprocessMemory
public static boolean WriteMyProcessMemory(Pointer ProcessToWriteTo,int AddressToWriteTo,int[] BytesToWrite)
{
//Gain Access to Kernel32.dll
Kernel32 Kernel32dll = Kernel32.INSTANCE;

int offset=AddressToWriteTo;
IntByReference baseAddress = new IntByReference();
baseAddress.setValue(offset);
Memory inputBuffer = new Memory(BytesToWrite.length);
IntByReference dummy = new IntByReference();

//Convert the Interger Array to an usable Array of type Memory
for(int i=0;i<BytesToWrite.length;i++)
{
inputBuffer.setByte(i, (byte)BytesToWrite[i]);
}

return Kernel32dll.WriteProcessMemory(ProcessToWriteTo, offset,inputBuffer , BytesToWrite.length, dummy);


}

public static void main(String[] args)
{

//Small Example showing how to open and read an anddress in the Game baldursgate 2 - exename BGMain.exe - and then write to it
//Addresses are treated as HEX Values 0xhexvalue ie. 0x00a00

Pointer MyProcess=FindMyProcess("BGMain");
int [] value = ReadMyProcessMemory(MyProcess,0x00913F13,4);
System.out.println(value[0]);
System.out.println(value[1]);
System.out.println(value[2]);
System.out.println(value[3]);


//if you want to write the value 133 (Decimalsystem) just use newvalue[0]=133
//if you want to write Hex Values use newvalue[0]=0x90;where 0xHexValue

int[] newvalue=new int[4];
newvalue[0]=0x90;
newvalue[1]=0x90;
newvalue[2]=0x90;
newvalue[3]=0x90;
WriteMyProcessMemory(MyProcess,0x00913F13,newvalue);

}

}
//Small Code Skeleton for making a Trainer in java

Share this post


Link to post
Share on other sites

Posted

Also, when compiled in Eclipse, theres like 35 errors in the code?

Share this post


Link to post
Share on other sites

Posted

Use JCreator pro

Share this post


Link to post
Share on other sites

Posted

Looks good, and good work. You should put the code between code tags next time, or if you can edit your post.

Share this post


Link to post
Share on other sites

Posted

Ok - Sry for not using the code snippet i was mouch too excited to get this work ^^

Heres a new version taht also includes allocating ram in your process for secure codeave injection


//Small Code Skeleton for making a Trainer in java

//done by Sharky on http://deviatedhacking.com

//Version 0.9.5 Beta - Because there is one small thing left concerning the Processfind Method

//i want to try both dll files, but atm if one dll file doesnt contain the desired Function the trainer crashes

//this will be fixed when i have time for it - until then - try wich dll suits your system or make a Trainer for one

//and one Trainer for the other DLL - its only commenting out 3 lines of code 2 times ^^

//download jna.jar from the internet - and include to your project

//i recomm your using eclipse for coding 




//Usual Imports

import java.util.Arrays;


//JNA imports - Lets us use Windows dll files

import com.sun.jna.Memory;

import com.sun.jna.Native;

import com.sun.jna.Pointer;

import com.sun.jna.ptr.IntByReference;

import com.sun.jna.win32.StdCallLibrary;


public class trainermain

{


	//Public Variables for AccessRights

	public static final int PROCESS_QUERY_INFORMATION = 0x0400;

    public static final int PROCESS_VM_READ = 0x0010;

    public static final int PROCESS_VM_WRITE = 0x0020;

    public static final int PROCESS_VM_OPERATION = 0x0008;

    public static final int ALLOCATION_TYPE_MEM_COMMIT = 0x1000;

    public static final int ALLOCATION_TYPE_MEM_RESERVE = 0x2000;

    //Some functions, depending on Windows Version are located in Kernel32.dll, some in Psapi.dll 


    //Access to external Kernel32.dll

   public interface Kernel32 extends StdCallLibrary

    {

        Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class);

        boolean ReadProcessMemory(Pointer hProcess, int inBaseAddress, Pointer outputBuffer, int nSize, IntByReference outNumberOfBytesRead);


        public Pointer OpenProcess(int dwDesiredAccess, boolean bInheritHandle, int dwProcessId);



        boolean WriteProcessMemory(Pointer hProcess,int AdressToChange,Pointer ValuesToWrite,int nSize, IntByReference irgendwas);


        int GetLastError(); 



        public void  VirtualAllocEx(Pointer ProcessToAllocateRamIn, int AddresToStartAt, int DesiredSizeToAllocate, int AllocationType, int ProtectType);


        //Needed for some Windows 7 Versions

        boolean EnumProcesses(int []ProcessIDsOut,int size , int[] BytesReturned);


        int GetProcessImageFileNameW(Pointer Process, char[] outputname, int lenght);


    }


   //Access to external Psapi.dll

   public interface Psapi extends StdCallLibrary

   {

	   Psapi INSTANCE = (Psapi) Native.loadLibrary("Psapi", Psapi.class);

	   //For some Windows 7 Versions and older down to XP

	   boolean EnumProcesses(int []ProcessIDsOut,int size , int[] BytesReturned);

	   int GetProcessImageFileNameW(Pointer Process, char[] outputname, int lenght);

   }


   //Processfinder - returns NULL if Process wasnt found

   public static Pointer FindMyProcess(String ProcessNameToFind)

   {

	   //Related to Version we have to use Kernel32.dll OR Psapi.dll to find the Process

	   Psapi Psapidll = Psapi.INSTANCE;

	   Kernel32 Kernel32dll = Kernel32.INSTANCE;


	   //we take an arraysize of 1024 - coz noone will have 1024 Processes running 

	   int[] processlist=new int[1024];

       int[] dummylist=new int[1024];


       //Lets first try Psapi.dll

       try{Psapidll.EnumProcesses(processlist, 1024, dummylist);}

       catch(Exception e)

       {


       }


       //Lets now try Kernel32.dll

       //try{Kernel32dll.EnumProcesses(processlist, 1024, dummylist);}

       //catch(Exception e)

      // {


      // }


       //Ok - we now got our Array with all the ProcessID&#39;s from all running Processes in the array processlist

       //Time to find out which Processid is our desired one!


       //A pointer for our Processfinding mechanism

       Pointer tempProcess;

       //Pointer for our desired Process

       Pointer Process=null;

       //Char Array for the path of the processes containing also the filename.exe

       char []outputnames = new char[1024];

       //A String for easier Comparison - see below

       String path="";


       for(int processid : processlist)

       {


    	tempProcess=Kernel32dll.OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION, false, processid);


    	//Again we have to try both dll files in order to obtain our goal - one will work

    	try{Psapidll.GetProcessImageFileNameW(tempProcess, outputnames, 1024);}

       	catch(Exception e){}


       	//try{Kernel32dll.GetProcessImageFileNameW(tempProcess, outputnames, 1024);}

       	//catch(Exception e){}


       	//reset Path String

       	path="";


       	for(int k=0; k<1024;k++)

       	{

       		//Convert our Char Array into a nice readable String

       		if((int) outputnames[k]!=0)

       		path=path+outputnames[k];

       	}


       	if(path.contains(ProcessNameToFind))

       	{

       		//If one of the processes found has the desired process exe name in its path its the one we want 

       		Process=tempProcess;

        }


       	//reset char 

       	outputnames = new char[1024];


       }


       //Finally returning our Process - Null if we didnt find it.

       return Process;

   }


   //ReadProcessMemory ^^

   public static int[] ReadMyProcessMemory(Pointer ProcessToReadFrom, int AdressToReadFrom, int NumberOfBytesToRead )

   {

	   //Make the Desired Functions available

	   Kernel32 Kernel32dll = Kernel32.INSTANCE;


	   int offset=AdressToReadFrom;

	   IntByReference baseAddress = new IntByReference();

       baseAddress.setValue(offset);

       Memory outputBuffer = new Memory(NumberOfBytesToRead);


	   boolean reader = Kernel32dll.ReadProcessMemory(ProcessToReadFrom, offset, outputBuffer, NumberOfBytesToRead, null);




	   if(reader)

	   {

		  //Process the received Data

	       byte[] bufferBytes = outputBuffer.getByteArray(0, NumberOfBytesToRead);


	        //Who wants signed byte? NOONE ! Lets convert it to a nice int !


	        int[] realvalues=new int[bufferBytes.length];


	        for(int i=0;i<bufferBytes.length;i++)

	        {	if(bufferBytes[i]<0)

	      		{       		

	      			realvalues[i]=256+bufferBytes[i];

	      		}

	      		else

	      		{

	      			realvalues[i]=bufferBytes[i];

	      		}

	        }

	        //Conversion done ! lets Return the data (Remember its integer not hex)

	        return realvalues;


	   }

	   else

	   {

		   //Reading went wrong - SHIT

		   return null;

	   }

   }


   //WritePprocessMemory

   public static boolean WriteMyProcessMemory(Pointer ProcessToWriteTo,int AddressToWriteTo,int[] BytesToWrite)

   {

	   //Gain Access to Kernel32.dll

	   Kernel32 Kernel32dll = Kernel32.INSTANCE;


	   int offset=AddressToWriteTo;

	   IntByReference baseAddress = new IntByReference();

       baseAddress.setValue(offset);

       Memory inputBuffer = new Memory(BytesToWrite.length);

       IntByReference dummy = new IntByReference();


       //Convert the Interger Array to an usable Array of type Memory

       for(int i=0;i<BytesToWrite.length;i++)

       {

    	   inputBuffer.setByte(i, (byte)BytesToWrite[i]);

       }


	   return Kernel32dll.WriteProcessMemory(ProcessToWriteTo, offset,inputBuffer , BytesToWrite.length, dummy);



   }


   //AllocateMemory - Especially good for Codecaves ^^

   public static void AllocateMyProcessMemory(Pointer ProcessToAllocateRamIn, int StartingAdress, int SizeToAllocate)

   {

	   //Access to desired functions

	   Kernel32 Kernel32dll = Kernel32.INSTANCE;


	   //Getting our Space

	   Kernel32dll.VirtualAllocEx(ProcessToAllocateRamIn, StartingAdress, SizeToAllocate, ALLOCATION_TYPE_MEM_COMMIT | ALLOCATION_TYPE_MEM_RESERVE, 0x04);


   }


   	public static void main(String[] args)

	{


   		//Small Example showing how to open and read an anddress in the Game baldursgate 2 - exename BGMain.exe - and then write to it

   		//Addresses are treated as HEX Values 0xhexvalue ie. 0x00a00


   		Pointer MyProcess=FindMyProcess("BGMain");

		int [] value = ReadMyProcessMemory(MyProcess,0x00913F13,4);

		System.out.println(value[0]);

		System.out.println(value[1]);

		System.out.println(value[2]);

		System.out.println(value[3]);



		//if you want to write the value 133 (Decimalsystem) just use newvalue[0]=133

		//if you want to write Hex Values use newvalue[0]=0x90;where 0xHexValue


		int[] newvalue=new int[4];

		newvalue[0]=0x90;

		newvalue[1]=0x90;

		newvalue[2]=0x90;

		newvalue[3]=0x90;

		WriteMyProcessMemory(MyProcess,0x00913F13,newvalue);

   		AllocateMyProcessMemory(MyProcess,0x10000000,500);


	}


}


i hope the "insert code snippet" function of the editor is the right one to use :PP

Share this post


Link to post
Share on other sites

Posted

@Zev

i dont know BlueJ and dont know JCreator

ive always programmed in Eclipse

Basically you have to add the jna.jar to your project - there must be an option to add "external jar" to your java build path / librarys.

Once this is imported the imports should work and the code "should" become fine.

Next step i will show here is how to make a simple GUI for our lovely java trainer - but first i need to teach that to myself :)

But - maybe someone else knows a nice tutorial on how to java GUI.

cu ^^

Share this post


Link to post
Share on other sites

Posted

Good tutorial mate :)

Share this post


Link to post
Share on other sites

Posted

You can download the Versions of jna.jar here

https://jna.dev.java.net/servlets/ProjectDocumentList?folderID=12329&expandFolder=12329&folderID=9725

official Homepage

i cant remember which version i took - ill test the latest release now with my trainer code - but it should work :)

Share this post


Link to post
Share on other sites

Posted

Using the latest jna version works - just testet it on my laptop ^^

Share this post


Link to post
Share on other sites

Posted

Basic and small Tutorial telling you how to create the most basic java window and add a Button to it

//our imports to use the swing objects

import javax.swing.JButton;

import javax.swing.JFrame;


//Guide on how to create a GUI in Java

//done by Sharky on http://deviatedhacking.com


public class main {



	public static void main(String[] args)

	{

		//lets create a new Frame first with the window title "Our Main Window Title"  - its the JFrame class of java

		JFrame OurMainWindow = new JFrame("Our Main Window Title");


		//an Optional but for our Trainers Main window neccessary option - what to do when our frame is closed

		//We want the Program to exit on close -coz when the main Trainer window is closed

		//we want out Trainer to shut down  (so this closes the Frame)

		OurMainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);



		//Lets Put some Life to our Frame, Lets add a Button - the class for this is the JButton class

		JButton OurNewButton = new JButton();


		//Lets set our Buttons Properities

		//Firts the Text the Button displays

		OurNewButton.setText("Im a Button - Press me");



		//Tell OurMainWindow that it should use our new created button

		OurMainWindow.add(OurNewButton);


		//Tell Java to arrange all Components

		OurMainWindow.pack();


		//Tell OurMainWindow to be visible, coz java initializes all JFrame objects with visibility set to false

		OurMainWindow.setVisible(true);

	}


}


Share this post


Link to post
Share on other sites

Posted

@sharky - I also imported the jna.jar file into the plugins flie of eclipse(So I can work with it)

But eclipse gives it like 50 errors when compiled, right from your post!

Share this post


Link to post
Share on other sites

Posted

Damnit 2 years ago my java teacher said u cant make game trainers or any other shit with java if i knew theres a way i would continue developing my java skills :) i feel betrayed by world.

Share this post


Link to post
Share on other sites

Posted

@ zev

I can imagine 1 problem which coud make ur code go mad

i completley copied all text / code from my trainermain.java

if you created a new java class called any different as traienrmain.java which has the public static void main method this isnt of course not going to work

(1) make a new project in eclipse

(2) import the jna.jar which i linke above with a download link from the official developers (get the latest version) - add is this way in eclipse:

(a) right click your project and choose properities

(:) choose Java Build Path

© choose librarys on the right tabs

(d) choose add external jars - point it to the location where u saved jna.jar

(3) make a new class called trainermain

(4) completeley kill all code in it and paste my cord - does it work now ? :)

Share this post


Link to post
Share on other sites

Posted

everything works good in JCreator but i get the the error Exception in thread "main" java.lang.NullPointerException

at trainermain.main(trainermain.java:218)

and line 218 is

   System.out.println(value[0]); 

Share this post


Link to post
Share on other sites

Posted

Adding 2 new functions for my trainer Skeleton - why?

As i was making codecaves to point the gamecode to somewhere else so i can get out the address of something i need to know in the game with the code

mov [1000000D],ecx i realized, the real address saved to my specified memorylocation is reversed :)

So - if you use my ReadMemoryProcess Procedure on memory location 1000000D with size 4 (becoz the CPU register is 4 byte long) it will say for example

aa bb cc dd - but the real address we want is dd cc bb aa

so i made a new java function called reversearray which does it for you

Problem Nr.2 - were getting returned an array consisting (in our example here) of 4 bits (after using reversearray) in the right order - how to make an valid offset out of it to red from ?

i made a new function called createoffset which converts this 4 int numbers to a valid memory address which u can Read and write to

but now here my functions !

public static int [] ReverseArray(int [] ArrayIn)

   {

	  int [] myarray=new int[ArrayIn.length];

	  for(int i=0;i<myarray.length;i++)

	  {

		  myarray[myarray.length-i-1]=ArrayIn[i];


	  }


	  return myarray;

   }


   public static int CreateOffset(int[] offsetcontainer)

   {

	   String offset="";

	   for(int i=0;i<offsetcontainer.length;i++)

	   {

		   offset=offset+Integer.toHexString(offsetcontainer[i]);

	   }

	   int returnvalue = Integer.parseInt(offset, 16);

	   return returnvalue;

   }

Good Luck - Shark out ^^

Share this post


Link to post
Share on other sites

Posted

@ Matrix - of course you do :)

As my function ReadProcessMemory says - if reading FAILS due to (1) Process wasnt found or (2) you tried to read an invalid address, my function retuns a null.

so if you try to print out the value[0] u cant do it because value is a nullpointer - there u have your nullpointer exception :)

Before you attempt to read an address - make sure (1) process u want to read from is running (2) reading from a valid memoryaddress :PP

For Example - in my game Baldursgate2

i have some hacks and codecaves concerning charactercreation.

once in charactercreation - u will beguided after some steps to a screen which lets you choose ure characters properities like strengh intelligence and so on.

BUT i cant read that memory value before i actually ENTER that screen - sometimes games do not allocate those areas when you try to read them.

So youre trying to read from something which isnt there - reading fails - nullpointer returned :D

Share this post


Link to post
Share on other sites

Posted

@ Matrix - of course you do :)

As my function ReadProcessMemory says - if reading FAILS due to (1) Process wasnt found or (2) you tried to read an invalid address, my function retuns a null.

so if you try to print out the value[0] u cant do it because value is a nullpointer - there u have your nullpointer exception :)

Before you attempt to read an address - make sure (1) process u want to read from is running (2) reading from a valid memoryaddress :PP

For Example - in my game Baldursgate2

i have some hacks and codecaves concerning charactercreation.

once in charactercreation - u will beguided after some steps to a screen which lets you choose ure characters properities like strengh intelligence and so on.

BUT i cant read that memory value before i actually ENTER that screen - sometimes games do not allocate those areas when you try to read them.

So youre trying to read from something which isnt there - reading fails - nullpointer returned :D

ya so because my game process is not running it cant find it that why it returns and nullpointer?

Share this post


Link to post
Share on other sites

Posted

ya so because my game process is not running it cant find it that why it returns and nullpointer?

As i said - if u try to read from an process which isnt running ull get a nullpointer

if u try to read an address from a running process which is not valid ull get an nullpointer

Share this post


Link to post
Share on other sites

Posted

Found an error in my CreateOffset function, when u got ints lower than 16 - the java function returned 1,...,f instead of 01,....,0f - which resulted in a bad offset

this one now has the error corrected

//Converts the Array from ReverseArray to a valid memoryaddress

   public static int CreateOffset(int[] offsetcontainer)

   {

	   String offset="";

	   for(int i=0;i<offsetcontainer.length;i++)

	   {

		   if(offsetcontainer[i]<16)

		   {

			   offset=offset+"0"+Integer.toHexString(offsetcontainer[i]);

		   }

		   else

		   {

			   offset=offset+Integer.toHexString(offsetcontainer[i]);  

		   }


	   }


	   int returnvalue = Integer.parseInt(offset, 16);

	   return returnvalue;

   }

cu - Sharky

Share this post


Link to post
Share on other sites

Posted

Seems a lot more effort and code to do it in java, even then it seems a bit buggy. I guess i will stick to c++ then, more power and efficient.

Good job on the tut, even as a beginner it didnt took me long to understand it!.

Share this post


Link to post
Share on other sites

Posted

Well, i dont like this c++ ^^ - have to get a goooood book first to learn it - and dont have time for that :)

In my job later i have to do Java anyway so i makes more sense to me to try it that way - and wit works :)

Ill add more functions to my toolkit making the "every day trainer coding" more comfortable ^^

Bugs will be found out and fixed time by time - if they exist ^^

Share this post


Link to post
Share on other sites

Posted

Another new handy function

//Unluckily the ReadMyProcessMemory function returns an array containing the value of each bite read

   //this function converts the returned value into a real in our trainer usable integer value

   //i.e. if you have 65535 livepoints this is a 2 byte value and the reading function returns an array having 255,255 in it

   //this function here will take this int and return 65535

   public static int GetValueOfIntAr(int[] ReadMyProcessMemoryReturnedIntArray)

   {

	   String realvalue="";

	   for(int i=0;i<ReadMyProcessMemoryReturnedIntArray.length;i++)

	   {

		   realvalue=realvalue+Integer.toHexString(ReadMyProcessMemoryReturnedIntArray[i]);

	   }

	   return Integer.parseInt(realvalue, 16);

   }

Share this post


Link to post
Share on other sites

Posted

Yet another handy function ^^

//its easy to write Hex values with the WriteMyProcessMemory function - if we know our hex value is 0a 7b 3c fa - we just make an Array

   //of length 4, put 0a to position 0, 7b to position 1 and so on - but int values are a bit of a problem because the Write Process function

   //-unluckily- uses digned bytes to transfer to out kernel32.dll. so this function takes your integer value i.e. 65535 and conveerts it into an array

   //looking like 255,255 and this u can use with WriteMyProcessMemory

   public static int[] IntegerToArray(int intvalue)

   {

	   //first we make an hex String out of our intvalue

	   String hexstring=Integer.toHexString(intvalue);


	   //unfortunately the hex string can be odd, so we make it even

	   //why? - because we want it like 0a 7a and not a7a

	   if(hexstring.length()%2==1)

	   {

		   hexstring="0"+hexstring;

	   }

	   System.out.println(hexstring);

	   //now we need to build our Array

	   int[] ourArray=new int[hexstring.length()/2];

	   for(int i=0;i<hexstring.length()/2;i++)

	   {

		   ourArray[i]=Integer.parseInt(""+hexstring.charAt(2*i)+hexstring.charAt(2*i+1), 16);

	   }


	   return ourArray;

   }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0