Results 1 to 7 of 7
  1. #1
    OhStarQ's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Location
    engine.dll
    Posts
    54
    Reputation
    10
    Thanks
    368

    Internal bhop not doing anything

    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.

  2. #2
    WasserEsser's Avatar
    Join Date
    Jul 2015
    Gender
    male
    Posts
    735
    Reputation
    174
    Thanks
    677
    My Mood
    Busy
    Okay, first things first. You've included a precompiled header but you aren't using it properly.
    Put the include for iostream inside of stdafx.h as i told you your other thread already.

    Try changing
    Code:
    if (*reinterpret_cast<BYTE*>(*LocalPlayer + 0x100) & 1 && GetAsyncKeyState(VK_SPACE) & (1 << 15)) *Jump = 6;
    to
    Code:
    if ((*reinterpret_cast<BYTE*>(*LocalPlayer + 0x100)) & 1 && GetAsyncKeyState(VK_SPACE) & (1 << 15)) *Jump = 6;
    Also, stop calling WaitForSingleObject(bhop, INFINITE);, the thread will NEVER finish, it's completely useless to wait for the thread.
    Last edited by WasserEsser; 06-18-2016 at 08:36 AM.

  3. #3
    OhStarQ's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Location
    engine.dll
    Posts
    54
    Reputation
    10
    Thanks
    368
    Quote Originally Posted by WasserEsser View Post
    Okay, first things first. You've included a precompiled header but you aren't using it properly.
    Put the include for iostream inside of stdafx.h as i told you your other thread already.

    Try changing
    Code:
    if (*reinterpret_cast<BYTE*>(*LocalPlayer + 0x100) & 1 && GetAsyncKeyState(VK_SPACE) & (1 << 15)) *Jump = 6;
    to
    Code:
    if ((*reinterpret_cast<BYTE*>(*LocalPlayer + 0x100)) & 1 && GetAsyncKeyState(VK_SPACE) & (1 << 15)) *Jump = 6;
    Also, stop calling WaitForSingleObject(bhop, INFINITE);, the thread will NEVER finish, it's completely useless to wait for the thread.
    I got this working but how would I implement a NoFlash into this code? I have tried many different methods such as the following:

    Code:
    if (*reinterpret_cast<float*>(FlashDuration) > 0.f)
        *reinterpret_cast<float*>(FlashDuration) = 0.f;
    Code:
    DWORD Offsets::GetFlashDuration() {
    	FlashDuration = (reinterpret_cast<DWORD>(LocalPlayer + FlashDurationOffset));
    	return(FlashDuration);
    }
    That did not work.

    I also tried this:

    Code:
     float* Offsets::GetFlashDuration() {
    	FlashDuration = (reinterpret_cast<float*>(LocalPlayer + FlashDurationOffset));
    	return(FlashDuration);
    }
    But that also didn't work (Along with the function above this). Is there anyway I can implement FlashDuration offset into my offset class like this? It just does nothing in game when I do it. The only way I got it too work is like this:

    Code:
    if (*reinterpret_cast<float*>(*LocalPlayer + 0xA2F8) > 0.f)
        *reinterpret_cast<float*>(*LocalPlayer + 0xA2F8) = 0.f;
    I only want to use a single thing like "FlashDuration". The only reason I want this is too build a sort of framework as said in my main post.

  4. #4
    WasserEsser's Avatar
    Join Date
    Jul 2015
    Gender
    male
    Posts
    735
    Reputation
    174
    Thanks
    677
    My Mood
    Busy
    Quote Originally Posted by OhStarQ View Post
    I got this working but how would I implement a NoFlash into this code? I have tried many different methods such as the following:

    Code:
    if (*reinterpret_cast<float*>(FlashDuration) > 0.f)
        *reinterpret_cast<float*>(FlashDuration) = 0.f;
    Code:
    DWORD Offsets::GetFlashDuration() {
    	FlashDuration = (reinterpret_cast<DWORD>(LocalPlayer + FlashDurationOffset));
    	return(FlashDuration);
    }
    That did not work.

    I also tried this:

    Code:
     float* Offsets::GetFlashDuration() {
    	FlashDuration = (reinterpret_cast<float*>(LocalPlayer + FlashDurationOffset));
    	return(FlashDuration);
    }
    But that also didn't work (Along with the function above this). Is there anyway I can implement FlashDuration offset into my offset class like this? It just does nothing in game when I do it. The only way I got it too work is like this:

    Code:
    if (*reinterpret_cast<float*>(*LocalPlayer + 0xA2F8) > 0.f)
        *reinterpret_cast<float*>(*LocalPlayer + 0xA2F8) = 0.f;
    I only want to use a single thing like "FlashDuration". The only reason I want this is too build a sort of framework as said in my main post.
    The reason why your previous attempts didn't work is because you didn't dereference LocalPlayer, which is a pointer itself which points to the base address of the class which contains the member variable m_flFlashDuration.

    You can just add this into your offset class:

    Code:
    float* FlashDuration = nullptr;
    
    float* GetFlashDuration( )
    {
        return reinterpret_cast<float*>(*LocalPlayer + 0xA2F8);
    }
    and then use it:

    Code:
    if (*FlashDuration > 0.f) *FlashDuration = 0.f;

  5. #5
    OhStarQ's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Location
    engine.dll
    Posts
    54
    Reputation
    10
    Thanks
    368
    Quote Originally Posted by WasserEsser View Post
    The reason why your previous attempts didn't work is because you didn't dereference LocalPlayer, which is a pointer itself which points to the base address of the class which contains the member variable m_flFlashDuration.

    You can just add this into your offset class:

    Code:
    float* FlashDuration = nullptr;
    
    float* GetFlashDuration( )
    {
        return reinterpret_cast<float*>(*LocalPlayer + 0xA2F8);
    }
    and then use it:

    Code:
    if (*FlashDuration > 0.f) *FlashDuration = 0.f;
    Ok I got this too work but there is another issue that has arrived. If I get all my offsets at the menu then the game will crash when I get into a game. If I get them when I am ingame then it works fine.

    I am guessing this is because when I get the offset at the menu LocalPlayer is a nullptr and adding 0xA2F8 too it is just 0xA2F8? To fix this I had to add:

    Code:
     if (*LocalPlayer) {
         FlashDuration = offset.GetFlashDuration();
    Is there anyway round this or do I just have to do when I am ingame?

  6. #6
    WasserEsser's Avatar
    Join Date
    Jul 2015
    Gender
    male
    Posts
    735
    Reputation
    174
    Thanks
    677
    My Mood
    Busy
    Quote Originally Posted by OhStarQ View Post
    Ok I got this too work but there is another issue that has arrived. If I get all my offsets at the menu then the game will crash when I get into a game. If I get them when I am ingame then it works fine.

    I am guessing this is because when I get the offset at the menu LocalPlayer is a nullptr and adding 0xA2F8 too it is just 0xA2F8? To fix this I had to add:

    Code:
     if (*LocalPlayer) {
         FlashDuration = offset.GetFlashDuration();
    Is there anyway round this or do I just have to do when I am ingame?
    You have to do it ingame. Do it everytime you want to use it or else you might not get the right addresses.

  7. #7
    Hunter's Avatar
    Join Date
    Dec 2013
    Gender
    male
    Location
    Depths Of My Mind.
    Posts
    17,468
    Reputation
    3771
    Thanks
    6,159
    My Mood
    Cheerful
    1 week has passed and no further replies have been made by the OP. Assuming solved.

    /Closed.

Similar Threads

  1. [Help] Writing but not actually doing anything ingame...
    By OhStarQ in forum Counter-Strike 2 Coding & Resources
    Replies: 2
    Last Post: 06-09-2016, 09:31 AM
  2. WarRock for international is not made.
    By wrhcks in forum WarRock Help
    Replies: 5
    Last Post: 04-10-2011, 04:10 AM
  3. the pub hack not workin, anything new?
    By hahaaha in forum CrossFire Discussions
    Replies: 29
    Last Post: 04-21-2010, 11:04 PM
  4. Do Not Download Anything /Without a virus scan.
    By Greg in forum Knight Online Hacks
    Replies: 0
    Last Post: 12-08-2009, 11:42 AM