Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C++/C Programming › [Source Code] C++ Code Injection

[Source Code] C++ Code Injection

Posts 1–3 of 3 · Page 1 of 1
Matrix_NEO006
Matrix_NEO006
[Source Code] C++ Code Injection
this is not my code credit goes to the guy who included him self in code.

Code:
/************************************************************************************************************************\
\************ [C++ Code-Injection Template] ********* [Tenebricosus] ********* [Released on GameHacking.com] ************/
/************ [GetProcId () Function Coded By Wiccaan a.k.a. Atomos] ********* [Find me @ www.DoxCoding.com] ************\
\************************************************************************************************************************/

//!!Remember!!
//------------
//Jump and Call addresses are relative. They are represented as the number of bytes between them. To calculate the Call/Jump
// opcode, you need to subtract the caller from the callee. E.G. if 0x40000000 contains a jump to 0x50000000, the calculation 
// will be 0x50000000 - 0x40000005. 0x40000000 is the Caller, 0x50000000 is the Callee, and the jump instruction is 5 opcodes long.
//
//In your CodeCave itself you don't have to worry about it, because the number of bytes between the Caller and Callee stays the same
// but when you jump to or from your CodeCave, the number of bytes between Caller and Callee is variable. Because we use VirtualAllocEx
// to get a memory region we can use for our CodeCave.
//
//------------
//When you use this code, without modifications, the last assambly line in your CodeCave should always be jmp 0xXXXXXXXX(X can be any 
// digit, though I prefer using 0x00000000 or 0xFFFFFFFF. Easier to spot when your CodeCave doesn't work :P)

#include <iostream>
#include <windows.h>
#include <tlhelp32.h>


BYTE	dbCode[]			= {0x90, 0x90, 0xe9, 0x00, 0x00, 0x00, 0x00};	//Opcodes you want to write to the CodeCave
BYTE	dbJump[5]			= {0xe9, 0x00, 0x00, 0x00, 0x00};				//The Ju***ode we need to write in the Game to jump to our CodeCave
DWORD	ddJumpAddr			= 0x552086;										//The GameCode address we want to jump from
DWORD	ddJmpBack			= 0x55208C;										//The GameCode address we want to jump back to after running our CodeCave
DWORD	ddSize				= 7;											//The Size of dbCode array(The number of opcodes your CodeCave exists of)
char *	szProcName			= "CoDMP.exe";									//The Processname of the GameProcess(You can find it in your Task Manager (Ctrl+Alt+Del))


DWORD GetProcId( char *szProcName );

void main()
{
	using namespace std;
	HANDLE	hProcess;
	DWORD	ddTemp;
	DWORD	ddOldProt;
	DWORD	ddCodeCave	= NULL;

	hProcess = OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE, FALSE, GetProcId(szProcName));
	if(hProcess == NULL)
	{
		cout << "Error: Couldn't open the Game Process\n";
	}
	else
	{
		cout << "Success: Game Process Opened\n";
		ddCodeCave = (DWORD)VirtualAllocEx(hProcess, NULL, ddSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);

		if(ddCodeCave == NULL)
		{
			cout << "Error: Failed to allocate CodeCave\n";
		}
		else
		{
			cout << "Success: CodeCave Allocated\n";

			ddTemp = ddJmpBack;
			ddTemp -= (ddCodeCave + ddSize);
			memcpy(&dbCode[ddSize - 4], &ddTemp, 4);

			if(WriteProcessMemory(hProcess, (LPVOID)ddCodeCave, dbCode, ddSize, NULL) == FALSE)
			{
				cout << "Error: Writing to the CodeCave Failed!\n";
				cout << GetLastError();
			}
			else
			{
				cout << "Success: Code Written to CodeCave!\n";
				cout << "CodeCave Located at: 0x" << hex << ddCodeCave << endl << endl;

				ddTemp = ddCodeCave;
				ddTemp -= (ddJumpAddr + 5);
				memcpy(&dbJump[1], &ddTemp, 4);

				if(VirtualProtectEx(hProcess, (LPVOID)ddJumpAddr, 5, PAGE_EXECUTE_READWRITE, &ddOldProt) == FALSE)
				{
					cout << "Error: VirtualProtectEx Falied!\n";
				}
				else
				{
					if(WriteProcessMemory(hProcess, (LPVOID)ddJumpAddr, &dbJump, 5, NULL) == FALSE)
					{
						cout << "Error: Couldn't write the Jump!\n";
					}
					else
					{
						cout << "Success: Jump written.\n CodeCave Active!\n";
					}
					VirtualProtectEx(hProcess, (LPVOID)ddJumpAddr, 5, ddOldProt, NULL);
				}
			}
		}
	}
	cin.get();
	return;
}

/* GetProcId: Credits go to Wiccaan, a.k.a. Atomos*/
DWORD GetProcId( char *szProcName )
{
   PROCESSENTRY32   pe32;
   HANDLE         hSnapshot = NULL;

   pe32.dwSize = sizeof( PROCESSENTRY32 );
   hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );

   if( Process32First( hSnapshot, &pe32 ) )
   {
      do{
         if( strcmp( pe32.szExeFile, szProcName ) == 0 )
            break;
      }while( Process32Next( hSnapshot, &pe32 ) );
   }

   if( hSnapshot != INVALID_HANDLE_VALUE )
      CloseHandle( hSnapshot );

   return (strcmp( pe32.szExeFile, szProcName ) == 0) ? pe32.th32ProcessID : 0;
}
#1 · 16y ago
HA
hacker101NUB
doesnt work....
#2 · 16y ago
Matrix_NEO006
Matrix_NEO006
Quote Originally Posted by hacker101NUB View Post
doesnt work....
first: http://www.mpgh.net/forum/31-c-c/873...ml#post1167770

what VC are u using if your using VC++ 2005 or 2008 run it as multibyte meaning
go on Project>>Properties>>Configuration properties>>find character set>>change it to >>Use Multi-Byte Character Set.
#3 · edited 16y ago · 16y ago
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

  • VB injecter Source codeBy Jimmy in Visual Basic Programming
    20Last post 16y ago
  • Real VB injecter Source codeBy Ugleh in Visual Basic Programming
    34Last post 16y ago
  • [HELP]Good injecter source code!By DeathHunter in Programming Tutorial Requests
    7Last post 16y ago
  • [HELP]Good injecter source code!By DeathHunter in Visual Basic Programming
    7Last post 16y ago
  • [Release][Source Code] DLL InjectionBy Tukjedude in C++/C Programming
    12Last post 16y ago

Tags for this Thread

#code#injection#source