Mem.Module Few Arguments Error

Posts 1–3 of 3 · Page 1 of 1
Mem.Module Few Arguments Error
The following piece of code in my program:

Code:
Mem.Process("csgo.exe");
DWORD ClientDLL = Mem.Module("client.dll");
Presents an error on the last bracket of my parameter in Mem.Module, the error stating: too few arguments in function call!

I am currently learning from @Yemiez how to code an external bunny hop in C++, I am really starting to grasp it but this is really confusing me. I am obviously using a modified version of his code including pre defining localPlayer and m_fFlags.
I also created P_ONGROUND outside of the function and that seems to be alright, moving it back in doesn't change anything. Heres the whole source code:

Code:
function.cpp
Code:
#include <iostream>
#include <Windows.h>
#include <string>
#include "declare.h"
#include "Memory.h"

using namespace std;

Memory Mem;

const DWORD localPlayer = 0x00A7AFBC;
const DWORD m_fFlags = 0x00000100;

#define KEY_SPACE 0x20
#define KEY9_SC 0x0A
#define KEY9 0x39
int FL_ONGROUND = 257;

int main()
{
	while (true) {
		bHop();
	}
}

void bHop()
{
	Mem.Process("csgo.exe");
	DWORD ClientDLL = Mem.Module("client.dll");
	if (GetAsyncKeyState(KEY_SPACE) & 0x8000 && m_fFlags == FL_ONGROUND) {
		keybd_event(KEY9, KEY9_SC, 0, 0);
		keybd_event(KEY9, KEY9_SC, KEYEVENTF_KEYUP, 0);
}
declare.h
Code:
#ifndef DECLARE
#define DECLARE

void bhopFunc();

#endif
Memory.h
Code:
#pragma once

#include <Windows.h>


// Basic memory class

class Memory {
public:
	DWORD hPID; // the process id
	HANDLE hProc; // Handle to process


	bool Process(char* ProcessName); // made it a bool incase you want to do something like
									 // while(!memory->Process("csgo.exe") etc
	DWORD Module(LPSTR ModuleName, DWORD&); // Incase you wanna use pattern scanning for your offsets you need the modules size


											// Basic template classes for RPM/WPM
	template <class cData>
	cData Read(DWORD dwAddress)
	{
		cData cRead;
		ReadProcessMemory(hProc, (LPVOID)dwAddress, &cRead, sizeof(cData), NULL);
		return cRead;
	}

	template <class cData>
	void Write(DWORD addr, cData val) {
		WriteProcessMemory(hProc, (LPVOID)addr, &val, sizeof(cData), NULL);
	}
};


// pointer to our object
// its extern because its supposed to be 'initalized' in Memory.cpp (Or any other file, but only once!)
// Then you can just include Memory.h anywhere and do gMemory->Process("ayyy.exe"); or something
extern Memory* gMemory;
Memory.cpp
Code:
#include "Memory.h"
#include <TlHelp32.h> // Has all the CreateToolhelp32Snapshot etc...


// On the heap ayyyyyyyyy
Memory* gMemory = new Memory();


// Basically like every other memory wrapper tbh
// copy pasta erry daaay amirite

bool Memory::Process(char * ProcessName)
{
	HANDLE hhPID = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
	PROCESSENTRY32 ProcEntry;
	ProcEntry.dwSize = sizeof(ProcEntry);


	do
		if (!strcmp(ProcEntry.szExeFile, ProcessName))
		{


			Memory::hPID = ProcEntry.th32ProcessID;
			CloseHandle(hhPID);


			Memory::hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Memory::hPID);
			return true;
		}
	while (Process32Next(hhPID, &ProcEntry));
	return false;
}

DWORD Memory::Module(LPSTR ModuleName, DWORD& modSizeTo)
{
	HANDLE hModule = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, Memory::hPID);
	MODULEENTRY32 mEntry;
	mEntry.dwSize = sizeof(mEntry);


	do
		if (!strcmp(mEntry.szModule, ModuleName))
		{
			CloseHandle(hModule);
			modSizeTo = mEntry.modBaseSize;
			return (DWORD)mEntry.modBaseAddr;
		}
	while (Module32Next(hModule, &mEntry));
	return 0;
}
Quote Originally Posted by GamerTurtle View Post
The following piece of code in my program:

Code:
Mem.Process("csgo.exe");
DWORD ClientDLL = Mem.Module("client.dll");
Presents an error on the last bracket of my parameter in Mem.Module, the error stating: too few arguments in function call!

I am currently learning from @Yemiez how to code an external bunny hop in C++, I am really starting to grasp it but this is really confusing me. I am obviously using a modified version of his code including functions declared in a separate header file and I changed the order of it.
I also created P_ONGROUND outside of the function and that seems to be alright, moving it back in doesn't change anything. Heres the whole source code:

Code:
function.cpp
Code:
#include <iostream>
#include <Windows.h>
#include <string>
#include "declare.h"
#include "Memory.h"

using namespace std;

Memory Mem;

const DWORD localBase;
const DWORD flagOffset;

#define KEY_SPACE 0x20
#define KEY9_SC 0x0A
#define KEY9 0x39
int FL_ONGROUND = 257;

int main()
{
	while (true) {
		bHop();
	}
}

void bHop()
{
	Mem.Process("csgo.exe");
	DWORD ClientDLL = Mem.Module("client.dll");
	DWORD localPlayer = Mem.Read<DWORD>(ClientDLL + localBase);
	int m_fFlags = Mem.Read<DWORD>(localPlayer + flagOffset);

	if (GetAsyncKeyState(KEY_SPACE) & 0x8000 && m_fFlags == FL_ONGROUND) {
		keybd_event(KEY9, KEY9_SC, 0, 0);
		keybd_event(KEY9, KEY9_SC, KEYEVENTF_KEYUP, 0);
	}
}
declare.h
Code:
#ifndef DECLARE
#define DECLARE

void bhopFunc();

#endif
Memory.h
Code:
#pragma once

#include <Windows.h>


// Basic memory class

class Memory {
public:
	DWORD hPID; // the process id
	HANDLE hProc; // Handle to process


	bool Process(char* ProcessName); // made it a bool incase you want to do something like
									 // while(!memory->Process("csgo.exe") etc
	DWORD Module(LPSTR ModuleName, DWORD&); // Incase you wanna use pattern scanning for your offsets you need the modules size


											// Basic template classes for RPM/WPM
	template <class cData>
	cData Read(DWORD dwAddress)
	{
		cData cRead;
		ReadProcessMemory(hProc, (LPVOID)dwAddress, &cRead, sizeof(cData), NULL);
		return cRead;
	}

	template <class cData>
	void Write(DWORD addr, cData val) {
		WriteProcessMemory(hProc, (LPVOID)addr, &val, sizeof(cData), NULL);
	}
};


// pointer to our object
// its extern because its supposed to be 'initalized' in Memory.cpp (Or any other file, but only once!)
// Then you can just include Memory.h anywhere and do gMemory->Process("ayyy.exe"); or something
extern Memory* gMemory;
Memory.cpp
Code:
#include "Memory.h"
#include <TlHelp32.h> // Has all the CreateToolhelp32Snapshot etc...


// On the heap ayyyyyyyyy
Memory* gMemory = new Memory();


// Basically like every other memory wrapper tbh
// copy pasta erry daaay amirite

bool Memory::Process(char * ProcessName)
{
	HANDLE hhPID = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
	PROCESSENTRY32 ProcEntry;
	ProcEntry.dwSize = sizeof(ProcEntry);


	do
		if (!strcmp(ProcEntry.szExeFile, ProcessName))
		{


			Memory::hPID = ProcEntry.th32ProcessID;
			CloseHandle(hhPID);


			Memory::hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Memory::hPID);
			return true;
		}
	while (Process32Next(hhPID, &ProcEntry));
	return false;
}

DWORD Memory::Module(LPSTR ModuleName, DWORD& modSizeTo)
{
	HANDLE hModule = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, Memory::hPID);
	MODULEENTRY32 mEntry;
	mEntry.dwSize = sizeof(mEntry);


	do
		if (!strcmp(mEntry.szModule, ModuleName))
		{
			CloseHandle(hModule);
			modSizeTo = mEntry.modBaseSize;
			return (DWORD)mEntry.modBaseAddr;
		}
	while (Module32Next(hModule, &mEntry));
	return 0;
}
Thats an easy one really... (Which is why I encourage people to learn c++ before you try and hack..)

It takes 2 parameters, 1 is the client name, the second is a variable where you want the modules size to go, I implemented that incase you want pattern scanning for hacks.

And please, read the comments inside the memory class, the Memory class already has a object created (gMemory) which you should use isntead of creating another one (Mem)
try calling the function before your int main or simple add this before main function | void bHop(); | that will "MAKE" the "C++" "REMEMBER" that have a function bHop after main function

----
Edit: don't saw your declare.h sorry, but it's because u don't "send" any arg to the function
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us