So just before I show this to everyone, I have tried this on my laptop and somehow I got it too work. My laptop uses a different version of CS because I have not updated it. I updated the offsets using two different dumpers (Zat and Y3..Whatever the name is). They gave the same offsets so I assume they are accurate.
I also want to say that this is shit code, I understand. I am just learning and trying to make a "framework" I suppose that I can use for making hacks easier and create a better learning environment myself. I have classes set up for getting simple offsets etc. Can we just leave that as it is unless that is the underlying problem. Just don't flame basically.
My issue is that the bhop function gets past the nullptr check for LocalPlayer and then just doesn't work! Here is my mass amounts of code:
dllmain
Code:
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include "offsets.h"
#include <iostream>
using namespace std;
DWORD Client;
DWORD* LocalPlayer;
int* Jump;
void init();
void createConsole();
void setupOffsets();
void errorAbort(LPCSTR reason);
DWORD WINAPI bhop(LPVOID lpParam);
Offsets offset;
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
init();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
void errorAbort(LPCSTR reason) {
cout << "ERROR: " << reason << endl;;
cout << "Quiting program for safety reasons!\n\n\n";
Sleep(5000);
exit(0);
}
void init() {
createConsole();
setupOffsets();
CreateThread(0, 0, bhop, 0, 0, 0);
WaitForSingleObject(bhop, INFINITE);
}
void createConsole() {
AllocConsole();
freopen("CONOUT$", "wb", stdout);
system("cls");
SetConsoleTitle("StarHack Internal - (DO NOT CLOSE)");
}
void consoleStub() { return; }
void setupOffsets() {
Client = offset.GetClient();
LocalPlayer = offset.GetLocalPlayer();
Jump = offset.GetJump();
if (Client) cout << "Found Client.dll at 0x" << Client << endl;
else errorAbort("Client.DLL NULL");
if (LocalPlayer) cout << "Found LocalPlayer at 0x" << LocalPlayer << endl;
else errorAbort("LocalPlayer NULL");
if (Jump) cout << "Found ForceJump at 0x" << Jump << "\n\n\n";
else errorAbort("Jump NULL");
}
void offsetStub() { return; }
DWORD WINAPI bhop(LPVOID lpParam) {
while (true) {
if (*LocalPlayer) {
if (*reinterpret_cast<BYTE*>(*LocalPlayer + 0x100) & 1 && GetAsyncKeyState(VK_SPACE) & (1 << 15)) *Jump = 6;
}
Sleep(1000);
}
}
I think this code is alright, @WasserEsser helped me out with it. I admit I haven't used his exact methods that he told me to use but I just kinda did why I do when coding :/
Here is the offsets header:
Code:
#pragma once
#include "stdafx.h"
class Offsets {
public:
DWORD GetClient();
DWORD* GetLocalPlayer();
int* GetJump();
DWORD Client;
DWORD* LocalPlayer;
int* Jump;
//Offsets
DWORD LocalPlayerOffset = 0xA30504;
DWORD JumpOffset = 0x4EE0E50;
};
DWORD Offsets::GetClient() {
Client = reinterpret_cast<DWORD>(GetModuleHandle("client"));
return(Client);
}
DWORD* Offsets::GetLocalPlayer() {
LocalPlayer = reinterpret_cast<DWORD*>(Client + LocalPlayerOffset);
return(LocalPlayer);
}
int* Offsets::GetJump() {
Jump = reinterpret_cast<int*>(Client + JumpOffset);
return(Jump);
}
The console currently outputs this (I understand it is different when I run it sometimes but this sorta represents all outputs:
Code:
Found Client.dll at 0x427491328
Found LocalPlayer at 0x1A1E0504
Found ForceJump at 0x1E690E50
At this point the program is in the bhop loop so thats why nothing else is printed. If I add a print statement to the bhop loop after the nullptr check it does reach that point so I know it goes well until this point:
Code:
if (*reinterpret_cast<BYTE*>(*LocalPlayer + 0x100) & 1 && GetAsyncKeyState(VK_SPACE) & (1 << 15)) *Jump = 6;
The bhop delay is at 1000 for testing purposes when I was printing in the loop (too stop the spam). It does not work at normal timing so I know that is also not an issue.
Any help would be great or if I am doing things wrong feel free to correct it.