Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 15:51

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

Advertisement



C++ Memory Offsets

Discussion on C++ Memory Offsets within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1

 
Hupfi10's Avatar
 
elite*gold: 76
Join Date: Aug 2011
Posts: 2,548
Received Thanks: 1,442
C++ Memory Offsets

Hallo Com,


ich habe mir zum Üben eine HackMe.exe (C++ | Console) geschrieben und eine hack.dll zum injecten.

Meine HackMe.exe
Code:
int _tmain(int argc, _TCHAR* argv[])
{

	static int* myptr;
	int Holz = 100;
	myptr = &Holz;
	for (;;){
		cout << "Holz: " << *myptr << "\n";
		cout << "Address: " << *&myptr << "\n";
		Holtz = Holtz + 1;
		getchar(); 
	}
}

Meine hack.dll
Code:
void RewriteValues(){
	HANDLE hd = GetCurrentProcess();
	int *holzpointer = (int *)hd + 0x1F354;
	*holzpointer = 2000;

}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD Reason, LPVOID Reserved){
		switch (Reason){
		case DLL_PROCESS_ATTACH:
			RewriteValues();
			break;
		}
		return TRUE;
	}
Injecte ich nun meine .dll in meine HackMe.exe gibt diese den Geist auf
Das Memory Offset in der .dll habe mittels CheatEngine ermittelt, jedoch sind her Fehler nicht ausschließbar.

Würde mich über einige Anregungen sehr freuen.
Danke
Hupfi10 is offline  
Old 11/01/2014, 19:33   #2


 
Jeoni's Avatar
 
elite*gold: 966
Join Date: Apr 2010
Posts: 1,105
Received Thanks: 681
Schau dir mal an, was GetCurrentProcess zurückliefert. Das ist ein Pseudohandle, was als (HANDLE)-1 definiert ist (mehr dazu ). Sollte klar sein, dass du dann irgendeinen Mist versuchst du verändern.
Du meinst vermutlich die Adresse des Hauptmoduls im Prozess, welche du mit GetModuleHandle(nullptr) bekommst.
Abgesehen davon ist hier aufgrund der Pointerarithmetik ein fehler drin:
Code:
int *holzpointer = (int *)hd + 0x1F354;
Erst wird hd in einen int* gecastet und dann wird was draufaddiert. Was dann in holzpointer steht, lässt sich mathematisch (ohne Pointerarithmetik oder Typen) so ausdrücken: holzpointer = hd + 0x1F354 * sizeof(int)
Zum rechnen solltest du also einen integralen Typ ausreichender Größe (bspw. uintptr_t) oder einen Pointertyp, dessen Basistyp nur 1 byte groß ist (bspw. uint8_t*).
Insgesamt könnte man also deine RewriteValues funktion korrekterweise so (oder nach belieben auch in mehr als einer Zeile) schreiben:
Code:
*((int*)((uintptr_t)GetModuleHandle(nullptr) + 0x1F354)) = 2000;
Ob das Offset von 0x1F354 korrekt ist, kann ich dabei natürlich auch nicht sagen, da musste ich mich jetzt auf deine Angaben verlassen.
Ich hoffe, dass das hilft
Jeoni
Jeoni is offline  
Old 11/02/2014, 15:00   #3

 
Hupfi10's Avatar
 
elite*gold: 76
Join Date: Aug 2011
Posts: 2,548
Received Thanks: 1,442
Danke erstmal an Jeoni,


der Fehler bestand zum einen in dem genanntem Punkt rund um GetModuleHandle statt GetCurrentProcess :|
Die Pointer Arithmetik um den Integer Pointer war ebenfalls ein Knackpunkt.
Mein logischer Fehler bestand jedoch darin, dass die DLL das Offset des statischen Pointers, der wiederum auf die Adresse von Holz in meiner HackMe.exe zeigt beinhaltet und man deshalb doppelt dereferenzieren muss. In Code ausgedrückt sieht das wie folgt aus:
Code:
void RewriteValues(){
	uintptr_t lePointer = (uintptr_t)GetModuleHandle(nullptr) + 0x1F354;
	int* myPtr = *(int **)lePointer;
	*myPtr = 2000;
}
Hupfi10 is offline  
Reply


Similar Threads Similar Threads
Memory Offsets
03/22/2013 - Tera - 0 Replies
Hey! Somebody can show me how i can get the offsets? Because i tried but the game closed itself all the time or just link me a guide please. Thank you!
Memory & Offsets
08/24/2010 - AutoIt - 4 Replies
what i want to do? i want to get the current value of MP / HP. but my code doesnt give me the correct value, its always = 0 here is my own code though the $Addr_CheckLogin, $Addr_CheckCharName is static so no problem with that.. but my problem is with the dynamic addresses that need offset and base address stuff. #include <NomadMemory.au3>
Aktuellen memory offsets aoc
10/17/2009 - General Gaming Releases - 1 Replies
Hat hier einer die aktuellen pointer und offsets von ageofconan?
New offsets - memory issue
10/09/2009 - GW Bots - 7 Replies
I wonder if Anet shifted some offsets by +4 Can any1 could confirm it So far new offsets works for me Max_Kurzick = 0x744 (old 740) Max_Luxon = 0x748 (old 744) Max_Balthazar = 0x74c (old 748)
Finding Memory Offsets in WoW?
07/12/2007 - World of Warcraft - 3 Replies
Hey people, i make bots, and so far i had some guy finding the offsets for me. how to do? do u know?



All times are GMT +1. The time now is 15:51.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

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