Solved Module Handle 64 Bit

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Clarityworld

Jr.Coder
Full Member
Nobleman
Feb 20, 2015
71
523
2
I have been using Fleeps Hackprocess.h for a while now the problem is it only works on 32bit programms.
I have set my compiler to 64bit, but it still don't work.

Example hackprocess.h
C++:
#pragma once
 
#include <Windows.h>
#include <TlHelp32.h>
 
class CHackProcess
{
public:
 
	PROCESSENTRY32 __gameProcess;
	HANDLE __HandleProcess;
	HWND __HWNDCss; 
	DWORD __dwordClient;
	DWORD __dwordEngine;
	DWORD __dwordOverlay;
	DWORD __dwordVGui;
	DWORD __dwordLibCef;
	DWORD __dwordSteam; 
	DWORD FindProcessName(const char *__ProcessName, PROCESSENTRY32 *pEntry)
	{	 
		PROCESSENTRY32 __ProcessEntry;
		__ProcessEntry.dwSize = sizeof(PROCESSENTRY32);
		HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
		if (hSnapshot == INVALID_HANDLE_VALUE) return 0;        if (!Process32First(hSnapshot, &__ProcessEntry))
		{
			CloseHandle(hSnapshot);
			return 0;
		}
		do{if (!_strcmpi(__ProcessEntry.szExeFile, __ProcessName))
		{
			memcpy((void *)pEntry, (void *)&__ProcessEntry, sizeof(PROCESSENTRY32));
			CloseHandle(hSnapshot);
			return __ProcessEntry.th32ProcessID;
		}} while (Process32Next(hSnapshot, &__ProcessEntry));
		CloseHandle(hSnapshot);
        return 0;
}
	DWORD getThreadByProcess(DWORD __DwordProcess)
	{	 
		THREADENTRY32 __ThreadEntry;
		__ThreadEntry.dwSize = sizeof(THREADENTRY32);
		HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
		if (hSnapshot == INVALID_HANDLE_VALUE) return 0;
 
		if (!Thread32First(hSnapshot, &__ThreadEntry)) {CloseHandle(hSnapshot); return 0; }
 
        do {if (__ThreadEntry.th32OwnerProcessID == __DwordProcess)
		{
			CloseHandle(hSnapshot);
			return __ThreadEntry.th32ThreadID;
		}} while (Thread32Next(hSnapshot, &__ThreadEntry)); 
		CloseHandle(hSnapshot);       
		return 0;
}
	DWORD GetModuleNamePointer(LPSTR LPSTRModuleName, DWORD __DwordProcessId)
	{ 
		MODULEENTRY32 lpModuleEntry = {0};
		HANDLE hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, __DwordProcessId);
		if(!hSnapShot)
			return NULL;  
		lpModuleEntry.dwSize = sizeof(lpModuleEntry);
		BOOL __RunModule = Module32First( hSnapShot, &lpModuleEntry );
		while(__RunModule)
		{
			if(!strcmp(lpModuleEntry.szModule, LPSTRModuleName ) )
			{CloseHandle( hSnapShot );
			return (DWORD)lpModuleEntry.modBaseAddr;
			}
			__RunModule = Module32Next( hSnapShot, &lpModuleEntry );
		}
		CloseHandle( hSnapShot );
		return NULL;
	}
	void runSetDebugPrivs() 
	{
		HANDLE __HandleProcess=GetCurrentProcess(), __HandleToken;
		TOKEN_PRIVILEGES priv;
	LUID __LUID; 
	OpenProcessToken(__HandleProcess, TOKEN_ADJUST_PRIVILEGES, &__HandleToken);
	LookupPrivilegeValue(0, "seDebugPrivilege", &__LUID);
    priv.PrivilegeCount = 1;
	priv.Privileges[0].Luid = __LUID;
	priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    AdjustTokenPrivileges(__HandleToken, false, &priv, 0, 0, 0);
	CloseHandle(__HandleToken);
	CloseHandle(__HandleProcess);
}
	void RunProcess()
	{
	runSetDebugPrivs();
	while (!FindProcessName("hl2.exe", &__gameProcess)) Sleep(12);
	while (!(getThreadByProcess(__gameProcess.th32ProcessID))) Sleep(12);
	__HandleProcess = OpenProcess(PROCESS_ALL_ACCESS, false, __gameProcess.th32ProcessID); 
	while(__dwordClient == 0x0) __dwordClient = GetModuleNamePointer("client.dll", __gameProcess.th32ProcessID);
	while(__dwordEngine == 0x0) __dwordEngine = GetModuleNamePointer("engine.dll", __gameProcess.th32ProcessID);
	while(__dwordOverlay == 0x0) __dwordOverlay = GetModuleNamePointer("gameoverlayrenderer.dll", __gameProcess.th32ProcessID);
	while(__dwordVGui == 0x0) __dwordVGui = GetModuleNamePointer("vguimatsurface.dll", __gameProcess.th32ProcessID);
	while(__dwordLibCef == 0x0) __dwordLibCef = GetModuleNamePointer("libcef.dll", __gameProcess.th32ProcessID);
	while(__dwordSteam == 0x0) __dwordSteam = GetModuleNamePointer("steam.dll", __gameProcess.th32ProcessID); 
	__HWNDCss = FindWindow(NULL, "Counter-Strike Source"); 
	}
};
 
extern CHackProcess fProcess;


Maybe DWord is not allowed only QWord ? I don't know.
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,118
78,998
2,392
Seems to be like that :/
Process32Next returns ERROR_SUCCESS when it is finished enumerating the processes in the snapshot, make sure it breaks out of the loop when that happens

Do this tutorial!:
 
Last edited:

Broihon

edgy 12 y/o
Escobar Tier VIP
Fleep Tier Donator
Dec 22, 2013
1,745
40,528
316
Change the DWORDs to a 64 bit type like ULONG_PTR or DWORD64.
 

Clarityworld

Jr.Coder
Full Member
Nobleman
Feb 20, 2015
71
523
2
Вroihon;41729 said:
Change the DWORDs to a 64 bit type like ULONG_PTR or DWORD64.
C++:
#pragma once

#include <Windows.h>
#include <TlHelp32.h>

//THIS FILE SIMPLY DOES MOST OF THE BACKEND WORK FOR US, 
//FROM FINDING THE PROCESS TO SETTING UP CORRECT ACCESS FOR US 
//TO EDIT MEMORY 
//IN MOST GAMES, A SIMPLER VERSION OF THIS CAN BE USED, or if you're injecting then its often not necessary
//This file has been online for quite a while so credits should be shared but im using this from NubTIK
//So Credits to him and thanks

class CHackProcess
{
public:

	PROCESSENTRY32 __gameProcess;
	HANDLE __HandleProcess;
	HWND __HWNDCss;
	DWORD64 __dwordClient;
	
	DWORD64 FindProcessName(const char *__ProcessName, PROCESSENTRY32 *pEntry)
	{
		PROCESSENTRY32 __ProcessEntry;
		__ProcessEntry.dwSize = sizeof(PROCESSENTRY32);
		HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
		if (hSnapshot == INVALID_HANDLE_VALUE) return 0;        if (!Process32First(hSnapshot, &__ProcessEntry))
		{
			CloseHandle(hSnapshot);
			return 0;
		}
		do{
			if (!_strcmpi(__ProcessEntry.szExeFile, __ProcessName))
			{
				memcpy((void *)pEntry, (void *)&__ProcessEntry, sizeof(PROCESSENTRY32));
				CloseHandle(hSnapshot);
				return __ProcessEntry.th32ProcessID;
			}
		} while (Process32Next(hSnapshot, &__ProcessEntry));
		CloseHandle(hSnapshot);
		return 0;
	}


	DWORD64 getThreadByProcess(DWORD64 __DwordProcess)
	{
		THREADENTRY32 __ThreadEntry;
		__ThreadEntry.dwSize = sizeof(THREADENTRY32);
		HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
		if (hSnapshot == INVALID_HANDLE_VALUE) return 0;

		if (!Thread32First(hSnapshot, &__ThreadEntry)) { CloseHandle(hSnapshot); return 0; }

		do {
			if (__ThreadEntry.th32OwnerProcessID == __DwordProcess)
			{
				CloseHandle(hSnapshot);
				return __ThreadEntry.th32ThreadID;
			}
		} while (Thread32Next(hSnapshot, &__ThreadEntry));
		CloseHandle(hSnapshot);
		return 0;
	}

	DWORD64 GetModuleNamePointer(LPSTR LPSTRModuleName, DWORD64 __DwordProcessId)
	{
		MODULEENTRY32 lpModuleEntry = { 0 };
		HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, __DwordProcessId);
		if (!hSnapShot)
			return NULL;
		lpModuleEntry.dwSize = sizeof(lpModuleEntry);
		BOOL __RunModule = Module32First(hSnapShot, &lpModuleEntry);
		while (__RunModule)
		{
			if (!strcmp(lpModuleEntry.szModule, LPSTRModuleName))
			{
				CloseHandle(hSnapShot);
				return (DWORD64)lpModuleEntry.modBaseAddr;
			}
			__RunModule = Module32Next(hSnapShot, &lpModuleEntry);
		}
		CloseHandle(hSnapShot);
		return NULL;
	}


	void runSetDebugPrivs()
	{
		HANDLE __HandleProcess = GetCurrentProcess(), __HandleToken;
		TOKEN_PRIVILEGES priv;
		LUID __LUID;
		OpenProcessToken(__HandleProcess, TOKEN_ADJUST_PRIVILEGES, &__HandleToken);
		LookupPrivilegeValue(0, "seDebugPrivilege", &__LUID);
		priv.PrivilegeCount = 1;
		priv.Privileges[0].Luid = __LUID;
		priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
		AdjustTokenPrivileges(__HandleToken, false, &priv, 0, 0, 0);
		CloseHandle(__HandleToken);
		CloseHandle(__HandleProcess);
	}



	void RunProcess()
	{
		
		runSetDebugPrivs();
		while (!FindProcessName("war.exe", &__gameProcess)) Sleep(12);
		while (!(getThreadByProcess(__gameProcess.th32ProcessID))) Sleep(12);
		__HandleProcess = OpenProcess(PROCESS_ALL_ACCESS, false, __gameProcess.th32ProcessID);
		while (__dwordClient == 0x0) __dwordClient = GetModuleNamePointer("Game.dll", __gameProcess.th32ProcessID);
	
		__HWNDCss = FindWindow(NULL, "War Online");
	}
};

extern CHackProcess fProcess;


I changed them but the programm still stuck when I run

C++:
	fProcess.RunProcess();
 

Broihon

edgy 12 y/o
Escobar Tier VIP
Fleep Tier Donator
Dec 22, 2013
1,745
40,528
316
What exactly happens? Does it crash? What part of RunProcess() crashes?
 

Clarityworld

Jr.Coder
Full Member
Nobleman
Feb 20, 2015
71
523
2
Вroihon;41737 said:
What exactly happens? Does it crash? What part of RunProcess() crashes?
I debug it step by step it the Console don't crash but it gets stuck and jumps from Line 34 to 40 - 40 to 34 endless :(
 

MasterG

Coder
Dank Tier Donator
Nobleman
Mar 14, 2015
102
888
1
I debug it step by step it the Console don't crash but it gets stuck and jumps from Line 34 to 40 - 40 to 34 endless :(
Are you stuck into an endless loop or what?
C++:
   while (Process32Next(hSnapshot, &__ProcessEntry));
        CloseHandle(hSnapshot);
        return 0;
Check if everithing goes right here.
 
Last edited:

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
1. Why does your function take a process entry pointer?
2. Print out all found processes for some quick debug.
3. you should use _stricmp instead of that string compare function, its deprecated and im not even able to find docs on it ( didnt try very hard tho ), not really important but ayy, fuck deprecated functions
 

PwndDepot

I has a status
Dank Tier VIP
Trump Tier Donator
Dank Tier Donator
Nov 5, 2014
239
7,748
19
Вroihon;41729 said:
Change the DWORDs to a 64 bit type like ULONG_PTR or DWORD64.
Would QWORD work in this situation as well?
 
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