| View previous topic :: View next topic |
| Author |
Message |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Mon May 26, 2008 11:26 pm Post subject: [Help] C++ SpeedHack |
|
|
I am currently trying to program a SpeedHack Dll, that hooks QueryPerformanceCounter, and making it return a fake value. But whenever I inject the dll into a process, the process reaches an exception and closes, and although, the process still works if you dont click any button on the error.
But, the speedhack doesn't kick in, can anyone help? And yes, I looked at the cheatengine source, and didnt find whatsoever what i needed.
| Code: |
// SpeedHack.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "windows.h"
//Variables.start//
bool isON = false;
double SpeedChoice = 1.0;
static LONGLONG oldfakevalue = 0;
static LONGLONG oldrealvalue = 0;
BOOL ret;
BOOL Stored;
LONGLONG NewValue;
LARGE_INTEGER *lpPerformanceCount;
//Variables.End//
BOOL WINAPI hook_QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
{
Stored = QueryPerformanceCounter(lpPerformanceCount);
ret = QueryPerformanceCounter(lpPerformanceCount);
NewValue = lpPerformanceCount->QuadPart;
if(oldfakevalue == 0 || oldrealvalue == 0)
{
oldfakevalue = lpPerformanceCount->QuadPart;
oldrealvalue = lpPerformanceCount->QuadPart;
}
NewValue = oldfakevalue + (LONGLONG)((NewValue - oldrealvalue) * SpeedChoice);
oldrealvalue = lpPerformanceCount->QuadPart;
oldfakevalue = NewValue;
lpPerformanceCount->QuadPart = NewValue;
return ret;
}
void Handle_SpeedHack()
{
while(0 == 0)
{
if(isON == false)
{
if(GetAsyncKeyState(VK_F12))
{
isON = true;
MessageBox(0, "Speed Hack Enabled", "Speed Hack", 0);
SpeedChoice = 50.0;
}
}
if(isON == true)
{
if(GetAsyncKeyState(VK_F12))
{
isON = false;
MessageBox(0, "Speed Hack Disabled", "Speed Hack", 0);
SpeedChoice = Stored;
}
}
}
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hModule);
CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)hook_QueryPerformanceCounter, lpPerformanceCount, 0, 0 );
CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)Handle_SpeedHack, 0, 0, 0 );
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
} |
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Tue May 27, 2008 2:41 am Post subject: |
|
|
| I don't see the hooking part anywhere? (I mean the part where you overwrite the IAT or the first 5 bytes of the api to point to you're function)
|
|
| Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Tue May 27, 2008 10:58 am Post subject: |
|
|
QueryPerformanceCounter only gives you the value of the counter. When you change the value of lpPerformanceCount, you're only changing the value of your variable, not the counter.
And I see no loop. your counter thread goes through only once.
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
|
| Back to top |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Tue May 27, 2008 5:37 pm Post subject: |
|
|
| @HalfPrime, i dont think i need a loop, because, isnt queryperformancecounter called several times, depending on what it's injected into?
|
|
| Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Tue May 27, 2008 6:04 pm Post subject: |
|
|
Just looked at wiccaan's link and now I understand how it's supposed to work. Instead of creating the thread, you have to actually make a hook for when the app calls the function.
_________________
|
|
| Back to top |
|
 |
|