Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding > Coding Tutorials
You last visited: Today at 06:00

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C++ Memory Trainer (Copy and Paste Example)

Discussion on C++ Memory Trainer (Copy and Paste Example) within the Coding Tutorials forum part of the General Coding category.

Reply
 
Old   #1
 
GinoGambino's Avatar
 
elite*gold: 0
Join Date: Jan 2008
Posts: 652
Received Thanks: 56
C++ Memory Trainer (Copy and Paste Example)

This is simple C++ code to make an application that can manipulate memory in any program / game, works with all versions of windows.

Simply copy and paste into a new C++ main.c file, build your Form and your good to go.

Code:
#include <windows.h>
#include <tlhelp32.h>
#include "resource.h"



#pragma comment(linker,"/FILEALIGN:512 /MERGE:.rdata=.text /MERGE:.data=.text /SECTION:.text,EWR /IGNORE:4078")
BOOL GameRunning;

/** Start of Declarations here **/
BOOL GetProcessList( );

// Below is the about text that is shown when "About" button is clicked

char *about   =
"C++ Memory Changer /n"
"Vietcong Hud on/off"
"Thanks to Medic and Subsky";
/////////////////////////////////////////////////////////////////////

char *gameWindow = "vietcong.exe"; // exe name here
DWORD pid; HWND hwndWindow; DWORD bytes; HANDLE hand = NULL;



HANDLE pFile; //Used for logging address to file (not implimented in this build)

//below you will list the BOOLs for function toggles
BOOL Ismod-app1On,FirstTime1;
BOOL dlgReadSuccess = FALSE;


///////////////////////////////////////////////////////
////Global Variables
	
	
	Modapp on Code
	BYTE Hud[1] = {0x92}; 
	// add more below here


	Modapp off Code
	BYTE original_code[1] = {0x96};
	// Dont forget to add the original code to turn it off 
	
///////////////////////////////////////////////////////

	/** End of Declarations here **/

void aboutButton(HWND hwnd)
{
	MessageBox(hwnd,about,"About",MB_ICONINFORMATION);
}


	void Initialize(HWND hwnd,WPARAM wParam, LPARAM lParam) {
	GetProcessList();
	if(GameRunning==TRUE)
	{		 
         GetWindowThreadProcessId(hwndWindow, &pid);
		 hand = OpenProcess(PROCESS_ALL_ACCESS,0,pid);
		 SetTimer(hwnd, 1, 200, NULL);	//Timer speed is 200ms, you can change it here
	} 
	else 
	{	//Error message for when game not found in process list
		MessageBox(NULL, "Vietcong not detected. Please run the game before running the trainer", "Error", MB_OK + MB_ICONWARNING);
	}




	FirstTime1=TRUE; //This is the true / false flag for "is this the first time the trainers read the game code

	Ismod-app1On=FALSE; 
	if(GameRunning==TRUE)
	{		 
         GetWindowThreadProcessId(hwndWindow, &pid);
		 hand = OpenProcess(PROCESS_ALL_ACCESS,0,pid);
		 SetTimer(hwnd, 1, 200, NULL);	//Timer speed is 200ms, you can change it here
	} 
	else 
	{ //Error message for when game not found in process list
		MessageBox(NULL, "Vietcong not detected, please run the game before running the trainer", "Error", MB_OK + MB_ICONWARNING);
	}
}

void HookExe() //This function ensures we are attatched to the game at all times
{
	
	CloseHandle(hand);
    GetProcessList( );
    GetWindowThreadProcessId(hwndWindow, &pid);
	hand = OpenProcess(PROCESS_ALL_ACCESS,0,pid);

}

	/*----- Here comes the good stuff -----*/


void timerCall() //functions in here run according to timer above
{
	//char name = (); //this is our buffer to catch the current value
	//int bytes = 0; //used temporarily for Read/WriteProcessMemory functions
	//int prevAccessProtection = 0; //used temporarily for VirtualProtectEx function
		HookExe(); //Call to function above (game always attatched)


/////////////////////////////////////////////////////////////////////////
/////ReadProcMem arrays are used to read and store original code so we 
/////toggle the code on and off


	if(FirstTime1==TRUE) //checks to see if this is the first time its run, if it is continue
	{
		
		ReadProcessMemory(hand, (void*) 0xEB0F44 , &original_code, 1, &bytes); // reads the bytes at address 0xEB0F44 and stores them
	    FirstTime1=FALSE;
	}
	// What we are doing here is reading 3 bytes of the games code for VC Hud and storing them in a variable called "original_code"
	//	The number in sqaure brackets is the number of bytes, this has to match the number after our variable
	// "original_code" in the ReadProcessMemory line.

	// You can add more addresses in, just be sure to have unique varible names and specify the right number of bytes.


///////////////////////////////////////////////////////////////////////////
/////Start Hotkey Functions Below

		/* --Vietcong HUD on/off Example Function----------------------------------------- */



	if(GetAsyncKeyState(VK_NUMPAD1)) // User Pressed the NumPad1 to switch on HUD
	{			
		   
		if(Ismod-app1On==FALSE) //if this modapp is not on do this........
			{  
				WriteProcessMemory(hand, (void*)0xEB0F44, &Hud,1, &bytes);  //Change the memory to activate the Modapp
																			
																			
				Ismod-app1On=TRUE; //Sets our "Is On" flag to "on"
			}
			else // .... do this
			{
				
				WriteProcessMemory(hand, (void*)0xEB0F44, &original_code,1, &bytes); // Write the original code into memory

				Ismod-app1On=FALSE; //Sets our "Is On" flag to "off"
			}




			/// Copy and paste the above function and change the variables to add another modapp
	

		}


	

	//The function above will toggle between mod-app on and mod-app off status. For a list of virtual keys please visit:
	// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/UserInput/VirtualKeyCodes.asp
     		
	/* --Example Function --END------------------------------------ */



	/** End **/
}

// YOU DONT NEED TO EDIT BELOW THIS LINE 

BOOL GetProcessList( )
{
  HANDLE hProcessSnap;
  HANDLE hProcess;
  PROCESSENTRY32 pe32;
  DWORD dwPriorityClass;
  int PidTest;
  GameRunning=FALSE;
 
  
  // Take a snapshot of all processes in the system.
  hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
  if( hProcessSnap == INVALID_HANDLE_VALUE ) return( FALSE );
  

  // Set the size of the structure before using it.
  pe32.dwSize = sizeof( PROCESSENTRY32 );

  // Retrieve information about the first process,
  // and exit if unsuccessful
  if( !Process32First( hProcessSnap, &pe32 ) )
  {
    CloseHandle( hProcessSnap );     // Must clean up the snapshot object!
    return( FALSE );
  }

  // Now walk the snapshot of processes, and
  // display information about each process in turn
  
  do
  {
    // Retrieve the priority class.
    dwPriorityClass = 0;
    hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID );
    if( hProcess != NULL )
    {
      dwPriorityClass = GetPriorityClass( hProcess );
      if( !dwPriorityClass )
        
      CloseHandle( hProcess );
    }

    PidTest=strcmp(gameWindow, pe32.szExeFile);
	if(PidTest==0){ pid=pe32.th32ProcessID; GameRunning=TRUE;}

  } while( Process32Next( hProcessSnap, &pe32 ) );

  // Don't forget to clean up the snapshot object!
  CloseHandle( hProcessSnap );
  return( TRUE );
}

BOOL CALLBACK DialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{

    switch (message)
	{
		case WM_INITDIALOG:
			Initialize(hwnd,wParam,lParam);
			return TRUE;

		case WM_COMMAND:
			switch (LOWORD(wParam))
			{
				case IDC_ABOUT:
					aboutButton(hwnd);
					return TRUE;

				case IDC_EXIT:
					EndDialog (hwnd, 0);
					return TRUE;
			}
		return TRUE;

		case WM_DESTROY:
			CloseHandle(pFile);
			PostQuitMessage(0);
			return TRUE;

		case WM_CLOSE:
			PostQuitMessage(0);
			return TRUE;
		case WM_TIMER:
			timerCall();
			return TRUE;
    }
    return FALSE;
}


 
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{


	DialogBox(hInstance,MAKEINTRESOURCE(IDD_MAINDLG), NULL,DialogProc);
	return 0;
}
Enjoy..

Credits:
ht.t.p://tkc-community.n.e.t/forum/index.php?topic=10051.0
GinoGambino is offline  
Old 10/17/2012, 09:36   #2
 
elite*gold: 42
Join Date: Jun 2008
Posts: 5,425
Received Thanks: 1,888
Worst code I saw this week, yay.
MoepMeep is offline  
Old 10/17/2012, 10:11   #3
 
GinoGambino's Avatar
 
elite*gold: 0
Join Date: Jan 2008
Posts: 652
Received Thanks: 56
Its just an example.and not written by me.
GinoGambino is offline  
Reply


Similar Threads Similar Threads
Copy&Paste
04/29/2010 - Technical Support - 3 Replies
Guten Tag allerseits, mein copy&paste funktioniert nicht mehr, im netz und auch im desktop nicht (ordner verschieben etc). Doch komischerweise funktioniert das kopieren und einfügen beim spielen von diablo2 einwanfrei. Woran liegt es eigentlich ? ich hoffe mir kann jemand helfen :) MfG
SRO Copy&Paste
08/12/2009 - SRO PServer Guides & Releases - 0 Replies
Hey, i've started to try something with AutoIt and I've got an idea. I made a simple script which copies and pastes a text to silkroad chat. Since you can't use Ctrl+v in SRO, i think it's useful. I have 2 files, 1st is for people whose game client is named SRO_Client and another one is for people who are using Loaders and his SRO_Client is named Character - Server etc. DOWNLOAD LINKS: this is for game named SRO_Client copy&paste_SRO_Client.exe this is for another game versions...
Copy Paste
04/20/2009 - Silkroad Online - 5 Replies
Is there any ways to get copy paste thingy in isro by using programs or sometin? Thx. Peace.
Copy Paste?
01/04/2009 - Silkroad Online - 5 Replies
There use to be a program were you can Copy/Paste things online from the internet and then Paste it in sro .. ? does anyone still know the link or something where i could download it? it was a very usefull program ^^.
copy and paste
02/15/2007 - Conquer Online 2 - 2 Replies
anyone know how to copy and paste pass so it works?



All times are GMT +2. The time now is 06:00.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.