| View previous topic :: View next topic |
| Author |
Message |
Special11 Cheater
Reputation: 0
Joined: 20 Dec 2009 Posts: 28
|
Posted: Sun Feb 13, 2011 11:28 am Post subject: [C++] Process Speed Hack crashes game |
|
|
Hi all, I'm not sure if it's good section, if it isn't, can some Admin/Mod move it to General Programming? Well guys I tried to do a basic Process Speed Hack..yep it work's but at 90% of time it crashes my game..however the Cheat Engine SpeedHack work's always..idk what's wrong. I'm hooking GetTickCount function with Trampoline Detour, my code:
| Code: | #include "detours.h"
DWORD WINAPI GetTickCount_Detour(void);
DETOUR_TRAMPOLINE(DWORD WINAPI GetTickCount_Trampoline(void),GetTickCount);
DWORD WINAPI GetTickCount_Detour()
{
return GetTickCount_Trampoline();
}
BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved )
{
DisableThreadLibraryCalls(hDll);
if (dwReason == DLL_PROCESS_ATTACH) {
DetourFunctionWithTrampoline((PBYTE)GetTickCount_Trampoline,(PBYTE)GetTickCount_Detour);
}
if (dwReason == DLL_PROCESS_DETACH) {
DetourRemove((PBYTE)GetTickCount_Trampoline,(PBYTE)GetTickCount_Detour);
}
return TRUE;
}
|
Even if it's empty and returns to original function it crashes my game :/
Update: soz I posted old code
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 25985 Location: The netherlands
|
Posted: Sun Feb 13, 2011 11:45 am Post subject: |
|
|
no idea. Perhaps the detours version you use has trouble with hooking it ?
(gettickcount is not like any other win api. for example it doesn't have the usual hook position in place that most other win apis do)
But I've got no experience with detours. Might as well be a parameter you're giving wrong . (The DETOUR_TRAMPOLINE macro call is correct ?)
_________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Sun Feb 13, 2011 1:52 pm Post subject: |
|
|
Detouring without actually having code inside the hook sometimes has issues and can cause crashes because you aren't actually doing anything. (v1.5 of Detours was known to have this issue.)
Also hooking an API and doing nothing to alter it kinda has no point to be hooked, you haven't actually done anything to manipulate the API so there isn't a reason to hook it.
Keep in mind since you hooked with DetourFunctionWithTrampoline, if you plan to allow unhooking of it you need to use DetourRemoveWithTrampoline.
_________________
- Retired. |
|
| Back to top |
|
 |
Special11 Cheater
Reputation: 0
Joined: 20 Dec 2009 Posts: 28
|
Posted: Sun Feb 13, 2011 2:33 pm Post subject: |
|
|
Hmm well Im using exactly MS Detours v1.5 :S I don't know why but ppl don't use newest MS Detours v2.1, should I try?
DetourRemoveWithTrampoline and DetourRemove is the same.
Ok so you suggest me to put there some code?
BTW. Dark how did you then made a speed hack in CE? U are unhooking it or what?
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Sun Feb 13, 2011 3:18 pm Post subject: |
|
|
Cheat Engines speedhack hooks GetTickCount and QueryPerformanceCounter. But you have to alter their operation in order to achieve the actual speed hack result. Just hooking onto them doesn't make it happen.
You can view the speed hack source of Cheat Engine here:
http://ce.colddot.nl/browser/Cheat%20Engine%206/speedhack
Most people don't use Detours 2.1 because of the updated EULA. Mainly due to the requirement of detoured.dll having to be released with all packages.
_________________
- Retired. |
|
| Back to top |
|
 |
Special11 Cheater
Reputation: 0
Joined: 20 Dec 2009 Posts: 28
|
Posted: Sun Feb 13, 2011 4:07 pm Post subject: |
|
|
Thx for help. Yep I know that I need to return fake results, well I found this code on Google:
| Code: |
DWORD gtc_last_real, gtc_last_fake;
DWORD increasefactor = 200;
DWORD speedenabled = 1;
DWORD WINAPI GetTickCount_Detour()
{
DWORD ret = GetTickCount_Trampoline();
DWORD nReal = ret;
DWORD dReal = nReal - gtc_last_real;
DWORD dFake = (increasefactor/100) * dReal;
if (speedenabled == 1)
{
ret = gtc_last_fake + dFake;
gtc_last_fake += dFake;
}
else
{
ret = gtc_last_fake + dReal;
gtc_last_fake += dReal;
}
gtc_last_real += dReal;
return ret;
}
|
But still crashes game :/
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Sun Feb 13, 2011 5:12 pm Post subject: |
|
|
You'll need to debug then to further diagnose the actual cause of the crash.
_________________
- Retired. |
|
| Back to top |
|
 |
|