Solved My first :)

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

vmv

Newbie
Full Member
May 26, 2013
14
188
0
Hello folks,
I'm very new in this business and like all of you i want to learn everything :)

I have this code...made from scratch...from here and there...and it is working nice but its crashing the game very often:

C++:
#include "stdafx.h"
#include <Windows.h>
#include <tlHelp32.h>
#include <stdio.h>
#include <iostream>
using namespace std;

DWORD GetAddress (int PointerLevel, HANDLE hProcess, DWORD Offsets[], DWORD BaseAddress)
{
DWORD pTemp; DWORD PointerAddress; DWORD Pointer = BaseAddress;
for(int c = 0; c < PointerLevel; c++) { if(c == 0) {
ReadProcessMemory(hProcess, (LPCVOID)Pointer, &pTemp, sizeof(pTemp), NULL); }
PointerAddress = pTemp + Offsets[c];
ReadProcessMemory(hProcess, (LPCVOID)PointerAddress, &pTemp, sizeof(pTemp), NULL); }
return PointerAddress;
}

DWORD_PTR dwGetModuleBaseAddress(DWORD dwPid, TCHAR *szModuleName)
{
   DWORD_PTR dwModuleBaseAddress = 0;
   HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, dwPid);
   if (hSnapshot != INVALID_HANDLE_VALUE)
   {
	  MODULEENTRY32 ModuleEntry32;
	  ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
	  if (Module32First(hSnapshot, &ModuleEntry32))
	  {
		 do
		 {
		    if (_tcscmp(ModuleEntry32.szModule, szModuleName) == 0)
		    {
			   dwModuleBaseAddress = (DWORD_PTR)ModuleEntry32.modBaseAddr;
			   break;
		    }
		 }
		 while (Module32Next(hSnapshot, &ModuleEntry32));
	  }
	  CloseHandle(hSnapshot);
   }
   return dwModuleBaseAddress;
}

int _tmain(int argc, _TCHAR* argv[])
{
HWND hwnd = FindWindow (0, _T("Dishonored"));
HANDLE hProcess;
DWORD dwPid;
if(!hwnd) cout << "Error: Cannot find the game\n";
GetWindowThreadProcessId(hwnd, &dwPid);
hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, dwPid);
if(!hProcess) cout << "Error: Cannot open process\n";
    DWORD baseAddress = dwGetModuleBaseAddress(dwPid, "NxCharacter.dll");
    DWORD staticOffset = 0x001A6563;
    DWORD ammoAddress = baseAddress + staticOffset;
    DWORD ammoPointers[] = {0xbc, 0x0, 0x4, 0x4e9};
    DWORD Address = GetAddress (4, hProcess, ammoPointers, ammoAddress);

int arrows;
int newValue = 999;
if(!ReadProcessMemory (hProcess, (BYTE*)Address, &arrows, sizeof(arrows), NULL))
cout << "Error: Failed to read memory\n"; else cout << "Value found: " << arrows << "\n";
while(1) { Sleep(1);
if(!WriteProcessMemory (hProcess, (BYTE*)Address, &newValue, sizeof(newValue), NULL))
cout << "Error: Failed to write to memory\n"; else Sleep(600000); cout << "New Value: " << arrows << "\n";
}
std::cin.get();
return 0;
}

What is wrong with it ?
Thank you,
 

Rake

I'm not your friend
Administrator
Jan 21, 2014
12,508
78,998
2,419
you need to resolve the pointer chain inside your while loop and you need to check if this pointer is valid before continuing to process the multi level pointer
baseAddress + staticOffset

that will solve your problem
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
19,938
76
Attach a debugger to your cheat, catch exceptions and see where it goes wrong :)
 

vmv

Newbie
Full Member
May 26, 2013
14
188
0
The error comes always with that dll..... "NxCharacter.dll".
If i try to attach any debugger...the game closes.

edit: it's weird...but this error is coming only if i go to a specific place.
 
Last edited:

Xenon

Banned
Silenced
Jun 4, 2013
5
171
0
Use Visual Studios debugger. Attach it, and inject to the game. Remember the bp's.
 

vmv

Newbie
Full Member
May 26, 2013
14
188
0
Are this 2 codes doing the same thing ? :

C++:
HMODULE RemoteGetModuleHandle(HANDLE hProcess, LPSTR lpszModuleName) // by Napalm
{
	HMODULE hModule = NULL;
	if(hProcess != NULL){
		DWORD dwSize = lstrlen(lpszModuleName) + 1;
		LPBYTE lpszModuleRemoteName = (LPBYTE)VirtualAllocEx(hProcess, NULL, dwSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
		if(lpszModuleRemoteName != NULL){
			WriteProcessMemory(hProcess, lpszModuleRemoteName, lpszModuleName, dwSize, NULL);
			HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0,
				(LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandleA("kernel32.dll"),
				"GetModuleHandleA"), lpszModuleRemoteName, 0, NULL);
			if(hThread != NULL)
			{
				DWORD dwWaitResult = WaitForSingleObject(hThread, 1000);
				if(dwWaitResult != WAIT_TIMEOUT)
					GetExitCodeThread(hThread, (LPDWORD)&hModule);
				CloseHandle(hThread);
			}
			VirtualFreeEx(hProcess, lpszModuleRemoteName, dwSize, MEM_RELEASE);
		}
	}
	return hModule;
}
C++:
DWORD_PTR dwGetModuleBaseAddress(DWORD dwPid, TCHAR *szModuleName)
{
   DWORD_PTR dwModuleBaseAddress = 0;
   HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, dwPid);
   if (hSnapshot != INVALID_HANDLE_VALUE)
   {
      MODULEENTRY32 ModuleEntry32;
      ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
      if (Module32First(hSnapshot, &ModuleEntry32))
      {
         do
         {
            if (_tcscmp(ModuleEntry32.szModule, szModuleName) == 0)
            {
               dwModuleBaseAddress = (DWORD_PTR)ModuleEntry32.modBaseAddr;
               break;
            }
         }
         while (Module32Next(hSnapshot, &ModuleEntry32));
      }
      CloseHandle(hSnapshot);
   }
   return dwModuleBaseAddress;
}
I will try to attach the debugger to the game and write here the results.

Thank you,
 

vmv

Newbie
Full Member
May 26, 2013
14
188
0
Ok, this is my final work....my brain doesn't helping me anymore :|

C++:
#include "stdafx.h"
#include <windows.h>
#include <tlHelp32.h>
#include <stdio.h>
#include <iostream>
using namespace std;

int privileges(){ HANDLE Token; TOKEN_PRIVILEGES tp;
    if(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,&Token)){
	LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tp.Privileges[0].Luid);tp.PrivilegeCount = 1;
	tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
	if (AdjustTokenPrivileges(Token, 0, &tp, sizeof(tp), NULL, NULL)==0){
   	return 1;}else{return 0;}}return 1;}

DWORD GetAddress (int PointerLevel, HANDLE hProcess, DWORD BaseAddress, DWORD Offsets[]){
	DWORD pTemp;  DWORD PointerAddress;  DWORD Pointer = BaseAddress;
	for(int c = 0; c < PointerLevel; c++) {	if(c == 0) { 
	ReadProcessMemory(hProcess, (LPCVOID)Pointer, &pTemp, sizeof(pTemp), NULL); }
	PointerAddress = pTemp + Offsets[c];
	ReadProcessMemory(hProcess, (LPCVOID)PointerAddress, &pTemp, sizeof(pTemp), NULL); }
	return PointerAddress; }

DWORD GetModuleBase (DWORD dwPid, TCHAR *szModuleName) { DWORD dwModuleBase = 0;
   HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, dwPid);
   if (hSnapshot != INVALID_HANDLE_VALUE) {  MODULEENTRY32 ModuleEntry32;  ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
   if (Module32First(hSnapshot, &ModuleEntry32)) { do { if (_tcscmp(ModuleEntry32.szModule, szModuleName) == 0) {
   dwModuleBase = (DWORD)ModuleEntry32.modBaseAddr; break; }} while (Module32Next(hSnapshot, &ModuleEntry32)); }
   CloseHandle(hSnapshot); } return dwModuleBase; }

int _tmain(int argc, _TCHAR* argv[]) {

	HWND hwnd = FindWindow (0, _T("GAME"));
	HANDLE hProcess;  DWORD dwPid;  int privileges();
	GetWindowThreadProcessId(hwnd, &dwPid);
	hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, dwPid);
	if(!hProcess) cout << "error: cannot open process\n";

    DWORD dllBase        = GetModuleBase(dwPid, _T("base.dll"));
    DWORD atkAddress     = dllBase + 0x001C1568;
    DWORD atkPointer[]   = {0xdc, 0x0, 0x254, 0x4ea};
    DWORD rwAddress      = GetAddress (4, hProcess, atkAddress, atkPointer);
	
	int atk; int atkNew = 1200;

	if(!ReadProcessMemory (hProcess, (BYTE*)rwAddress, &atk, sizeof(atk), NULL)) 
	cout << "error: failed to read the memory\n";	else cout << "value found: " << atk << "\n";

	while(1) { Sleep(1);
	WriteProcessMemory (hProcess, (BYTE*)rwAddress, &atkNew, sizeof(atkNew), NULL); }

	CloseHandle(hProcess);
	std::cin.get(); 
	return 0;
}
The code is working fine and gives no errors.
The game also its working fine until ...i change the place...or teleport somewhere else.
Also the hack it's stopping when i do that and i have to restart it to work again.
The game is online. And when i move to other map the address is changing always. So there must be something with the way is getting to the base address+pointers....
Often the game and only the game is crashing.
So in my humble opinion....there is something wrong with the code or is not what i need...:(

I can't attach any debugger to the game because it's just closing instantly.

Any idea ?

Thank 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