Source Code Reading Multilevel Pointer (DLL/Console)

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

cascraft

Newbie
Full Member
Jan 30, 2013
36
823
1
Hi,
i wanna share my code here:

C++:
#include <windows.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <iostream>
#include <fstream>
using namespace std;
VOID CreateConsole(VOID)
{
	int  hConHandle;
	long lStdHandle;
	CONSOLE_SCREEN_BUFFER_INFO coninfo;
	FILE *fp;
	AllocConsole();
	GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
	coninfo.dwSize.Y = 1500;
	SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
	lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
	fp = _fdopen(hConHandle, "w");
	*stdout = *fp;
	setvbuf(stdout, NULL, _IONBF, 0);
	lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
	fp = _fdopen(hConHandle, "r");
	*stdin = *fp;
	setvbuf(stdin, NULL, _IONBF, 0);
	lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
	fp = _fdopen(hConHandle, "w");
	*stderr = *fp;
	setvbuf(stderr, NULL, _IONBF, 0);
	std::ios::sync_with_stdio();
}

//Change here:
DWORD Pointer = 0x01296EB0; //Base Adress here
DWORD Offset1 = 0x4;  //  offset 1
DWORD Offset2 = 0x58; //  offset 2
DWORD Offset3 = 0x58; //  offset 3
DWORD Offset4 = 0x58; //  offset 4



DWORD WINAPI Main(LPVOID)
{
	int i;
	cout << "Reading Multilevel Pointer v1.0" << endl;

	cout << "Value: " << (*(WORD*)((*(DWORD*)((*(DWORD*)((*(DWORD*)((*(DWORD*)Pointer) + Offset1)) + Offset2)) + Offset3)) + Offset4));


	return 0;

}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
	switch (fdwReason)
	{
	case DLL_PROCESS_ATTACH:
		CreateConsole();
		CreateThread(NULL, NULL, Main, NULL, NULL, NULL);
		break;
	}
	return TRUE;
}
 

Broihon

edgy 12 y/o
Escobar Tier VIP
Fleep Tier Donator
Dec 22, 2013
1,746
40,528
316
It's a really risky way to calculate a multilevel pointer this way using c-casts only.
I'm not sure why you posted this source. Your thread title refers to one line of code if I'm not mistaken.

Anyway, let me explain why this is a risky way:
The pointer you showed has 4 levels which can mean that it's like a class in a class in a class in a class.
And as soon as one of the levels/classes/members isn't initialized you'll have a problem since you're trying to read/write from/to an invalid/nullptr which will result in a crash.
To read multilevel pointer safely read them level by level and check the accessibility of the current level before using it (for example with VirtualQuery).
 

Obsta

Jr.Hacker
Meme Tier VIP
Jan 27, 2014
394
2,978
17
C++:
	cout << "Value: " << (*(WORD*)((*(DWORD*)((*(DWORD*)((*(DWORD*)((*(DWORD*)Pointer) + Offset1)) + Offset2)) + Offset3)) + Offset4));
Keep in mind this only caters for a static amount of pointers, if someone wanted to add different amount of offsets then they would have to go through that headache of that casting nightmare haha.
I discussed this with till0sch, Broihon & Alex a few days ago and they helped me come up with a solution that i'll post in this thread in a few hours.
 

GozillaMaster

Newbie
Full Member
Jan 21, 2013
17
428
0
Hi,
i wanna share my code here:

C++:
#include <windows.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <iostream>
#include <fstream>
using namespace std;
VOID CreateConsole(VOID)
{
	int  hConHandle;
	long lStdHandle;
	CONSOLE_SCREEN_BUFFER_INFO coninfo;
	FILE *fp;
	AllocConsole();
	GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
	coninfo.dwSize.Y = 1500;
	SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
	lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
	fp = _fdopen(hConHandle, "w");
	*stdout = *fp;
	setvbuf(stdout, NULL, _IONBF, 0);
	lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
	fp = _fdopen(hConHandle, "r");
	*stdin = *fp;
	setvbuf(stdin, NULL, _IONBF, 0);
	lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
	fp = _fdopen(hConHandle, "w");
	*stderr = *fp;
	setvbuf(stderr, NULL, _IONBF, 0);
	std::ios::sync_with_stdio();
}

//Change here:
DWORD Pointer = 0x01296EB0; //Base Adress here
DWORD Offset1 = 0x4;  //  offset 1
DWORD Offset2 = 0x58; //  offset 2
DWORD Offset3 = 0x58; //  offset 3
DWORD Offset4 = 0x58; //  offset 4



DWORD WINAPI Main(LPVOID)
{
	int i;
	cout << "Reading Multilevel Pointer v1.0" << endl;

	cout << "Value: " << (*(WORD*)((*(DWORD*)((*(DWORD*)((*(DWORD*)((*(DWORD*)Pointer) + Offset1)) + Offset2)) + Offset3)) + Offset4));


	return 0;

}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
	switch (fdwReason)
	{
	case DLL_PROCESS_ATTACH:
		CreateConsole();
		CreateThread(NULL, NULL, Main, NULL, NULL, NULL);
		break;
	}
	return TRUE;
}
Thanks You
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods