Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


speedhack

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Fri Jan 04, 2008 4:14 pm    Post subject: speedhack Reply with quote

I wwas wondering, for cheatengine's speed hack, how did it work?
What api's did it use to speed up certain processes?
Question


Last edited by slippppppppp on Fri Jan 04, 2008 10:36 pm; edited 2 times in total
Back to top
View user's profile Send private message AIM Address MSN Messenger
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Fri Jan 04, 2008 4:24 pm    Post subject: Reply with quote

Code:

procedure TMainForm.btnSetSpeedhackClick(Sender: TObject);
resourcestring
  strfailuretosetspeed='Failure to set the speed';
  strIncorrectspeed='The speed value is incorrect';
  strCantSetSpeed='I can''t set this speed. (must be bigger than 0)';
  strHyperscanFailed='The hyperthread failed to respond with the right answer';

var x: dword;
    speedf: single;
    speed: dword absolute speedf;
    sleeptime: integer;
    speedtext: string;
    i: integer;
begin
  try
    speedtext:=edit2.Text;
    speedf:=strtofloat(speedtext);
  except
    try
      if pos(',',speedtext)<>0 then
      begin
        //replace the , with a .
        i:=pos(',',speedtext);
        while i<>0 do
        begin
          speedtext[i]:='.';
          i:=pos(',',speedtext);
        end;
      end
      else
      begin
        //replace the . with a ,
        i:=pos('.',speedtext);
        while i<>0 do
        begin
          speedtext[i]:=',';
          i:=pos('.',speedtext);
        end;
      end;

      speedf:=strtofloat(speedtext);
    except
      raise exception.Create(strincorrectspeed);
    end;
  end;

  sleeptime:=strtoint(edit1.text);

  if speedf<=0 then raise exception.Create(strcantsetspeed);
  if speedf*sleeptime<1 then
  begin
    try
      sleeptime:=trunc(roundto(1/speedf,-1));
      if sleeptime=0 then sleeptime:=1;

      edit1.Text:=IntToStr(sleeptime);
    except
      exception.Create(strfailuretosetspeed);
    end;
  end;

  x:=sendmessage(cefuncproc.hypermode.hyperscanwindow,wm_user+6,sleeptime,speed);

  if x<>12345 then raise exception.Create(strHyperscanfailed);


~~~~

sendmessage:

Code:

function SendMessage; external user32 name 'SendMessageA';

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Fri Jan 04, 2008 4:26 pm    Post subject: Reply with quote

Ok, i saw that samurai, but what i want to know is that,

This:

cefuncproc.hypermode.hyperscanwindow

I dont want to strip code from there, but can i replace with that, HWND?
Back to top
View user's profile Send private message AIM Address MSN Messenger
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25827
Location: The netherlands

PostPosted: Fri Jan 04, 2008 4:26 pm    Post subject: Reply with quote

it hooks timeGetTime, GetTickCount and QueryPerformanceCounter and let them return a fake time
The fake time is updated with a thread that is running at maximum priority that increases the timer every few milliseconds (sleeptime) so the speed will be a multiplication of the real time

source: cehook/speedhack.pas

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Fri Jan 04, 2008 4:28 pm    Post subject: Reply with quote

Okay, this is really complicated, how can i get this working without including all those other cheat engine files. I kind of understand speedhack.pas . But how do i use the functions in it? Confused
Back to top
View user's profile Send private message AIM Address MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Jan 04, 2008 6:48 pm    Post subject: Reply with quote

slippppppppp wrote:
Okay, this is really complicated, how can i get this working without including all those other cheat engine files. I kind of understand speedhack.pas . But how do i use the functions in it? Confused


DB gave you the API that is used to create the effect. Look them up on the MSDN if you are unsure of how they work and how to use them.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Fri Jan 04, 2008 9:16 pm    Post subject: Reply with quote

Ok, i know how to hook them, but how would i get them to return a fake value?
Back to top
View user's profile Send private message AIM Address MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Jan 04, 2008 10:38 pm    Post subject: Reply with quote

slippppppppp wrote:
Ok, i know how to hook them, but how would i get them to return a fake value?


If you have them hooked you can rewrite what they do and return any value you want. For example timeGetTime:

Return value is the system time in milliseconds.
Code:
DWORD timeGetTime(VOID);


Once you have it hooked you should basically have a "detoured" function that you can call to be the new function such as:

Code:

DWORD WINAPI mine_timeGetTime(VOID)
{
   // ... code here
}


In your function you can return what ever you want, or make a call to the original function and return the normal value.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Fri Jan 04, 2008 10:43 pm    Post subject: Reply with quote

Okay now wiccan, that isn't really the problem now, what i need help on is the SendMessage Part, when i enable it, i dont get errors, but the process is not different, so nothing really happend, and so far myfunctino looks like so:
sendmessage(WindowHandle,wm_user+6,sleeptime,speed);

WindowHandle Holds the HWND of a selected Window
SleepTime and Speed is modified through edit texts.
But this is still not working Crying or Very sad
Back to top
View user's profile Send private message AIM Address MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Jan 04, 2008 10:59 pm    Post subject: Reply with quote

Not sure why you are using SendMessage, can't say I have seen SendMessage used for a speed hack before. As DB pointed out in the source of CE, you can find the speedhack hook located in cehook/speedhack.pas
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Fri Jan 04, 2008 11:03 pm    Post subject: Reply with quote

Yes, i know that's the hook. But at the end of the button for speed hack, it says
x := SendMessage(CEFUNCPROC.HYPERMODE.something,wm_user+6,sleeptime,speed);

So, im guessing that sendmessage is the indicator to start the speed hack?
Back to top
View user's profile Send private message AIM Address MSN Messenger
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25827
Location: The netherlands

PostPosted: Sat Jan 05, 2008 2:49 am    Post subject: Reply with quote

that sendmessage will only work when the cehook.dll has been injected and the controlwindow has been spawned
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites