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 @
PsychoBitch 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;
}