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 


[Delphi] Looping

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Wed Aug 13, 2008 2:51 pm    Post subject: [Delphi] Looping Reply with quote

Edit2: The thing on the web didn't really work.


Ok so I am program a dll in delphi. (To Inject into another process)

I am process information with a huge loop. How do I prevent the host application from freezing because of the loop?

The example I found on the web said use

Application.ProcessMessages;
But it didn't work. My app still froze.
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Wed Aug 13, 2008 3:34 pm    Post subject: Reply with quote

create the loop in a new thread?
_________________
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Wed Aug 13, 2008 3:48 pm    Post subject: Reply with quote

If you're injecting a DLL, it would automatically create a new thread for your program to run in and it shouldn't affect the host at all. Post the code so we can see what's wrong.
Also, I'm not entirely sure how a delphi DL will interact with a program written in a nother language. Might work fine, but I have no idea.

_________________
Back to top
View user's profile Send private message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Wed Aug 13, 2008 4:44 pm    Post subject: Reply with quote

avoid using "repeat"
_________________

Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Wed Aug 13, 2008 4:46 pm    Post subject: Reply with quote

IM not using repeat.

Here:

While 1=1 do
begin
//my script here
end;
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Wed Aug 13, 2008 5:11 pm    Post subject: Reply with quote

You're probably fucking something up with your script.
_________________
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Wed Aug 13, 2008 5:13 pm    Post subject: Reply with quote

dnsi0 wrote:
IM not using repeat.

Here:

While 1=1 do
begin
//my script here
end;


Why... use.... a.... loop.... inside.... a.... dll..... ? (Unless you're checking for key state)

@In Delphi you don't have to use CreateThread (BeginThread wrapper) in order to inject and modify crap.

look here - http://rot1blg.wordpress.com/2008/05/08/coding-a-win32-console-trainer-for-ms-minesweeper/

scroll down a bit.
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Wed Aug 13, 2008 5:17 pm    Post subject: Reply with quote

You have to call sleep for at least 10 miliseconds

Same thing in C or any language.

And rot1, sometimes you have to constantly change a value...What do you think CEF's freeze state does? It just constantly changes the value using a loop

_________________
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Wed Aug 13, 2008 5:22 pm    Post subject: Reply with quote

I did sleep(100);
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Wed Aug 13, 2008 6:57 pm    Post subject: Reply with quote

100 might be too much if your loop is completely empty I'd go with something like 10 or so.. just to keep the CPU usage down to 0-1%.

100 is like 10 times per second it will create some kind of lag.. but it wont freeze up application so I don't know
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Wed Aug 13, 2008 7:13 pm    Post subject: Reply with quote

Do you have any idea what you just said? 100 milliseconds is more than 10 ms so the loop will be run less times per second.
_________________
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Wed Aug 13, 2008 7:17 pm    Post subject: Reply with quote

^ Shocked
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Wed Aug 13, 2008 7:20 pm    Post subject: Reply with quote

Your loop design fails.

Code:

while 1=1 do
begin
    //This always evaluates to true so thread gets "locked" processing this
    //You can add a 'break' to get the loop to stop
end;


A much better design would be a for-loop, or a while/repeat by testing something that is not always true.
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Wed Aug 13, 2008 7:23 pm    Post subject: Reply with quote

Sleep(10) sleeps for 10 ms, 100 loops per sec
Sleep(100) sleeps for 100 ms, 10 loops per sec.

_________________
Back to top
View user's profile Send private message
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