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 


[Question] Freeze Process

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

Joined: 11 Jul 2007
Posts: 1579

PostPosted: Sat May 24, 2008 12:06 pm    Post subject: [Question] Freeze Process Reply with quote

Is there a way to freeze a process?
I think you all know what I mean by freezing.
I've searched, but had no results.
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Sat May 24, 2008 1:04 pm    Post subject: Reply with quote

Freeze all the threads?
Back to top
View user's profile Send private message
NothingToShow
Grandmaster Cheater Supreme
Reputation: 0

Joined: 11 Jul 2007
Posts: 1579

PostPosted: Sat May 24, 2008 1:56 pm    Post subject: Reply with quote

Uhm, I don't really know much of threads.
What I'm asking is, if there's a way to freeze a process, and if possible, unfreeze it again.
Like appalsap's "Buy Time". (http://forum.cheatengine.org/viewtopic.php?t=164934 check under tools)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sat May 24, 2008 2:02 pm    Post subject: Reply with quote

if you're on windows XP or later you can use SuspendProcess
_________________
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
NothingToShow
Grandmaster Cheater Supreme
Reputation: 0

Joined: 11 Jul 2007
Posts: 1579

PostPosted: Sat May 24, 2008 2:08 pm    Post subject: Reply with quote

Dark Byte wrote:
if you're on windows XP or later you can use SuspendProcess

You've got any snippets?
Thanks for the "hint" btw.

EDIT:
Found this, can you use that aswell?
Code:
DWORD WINAPI WaitForSingleObject(
  __in  HANDLE hHandle,
  __in  DWORD dwMilliseconds
);


I'm trying to do this in delphi.


Last edited by NothingToShow on Sat May 24, 2008 2:19 pm; edited 2 times in total
Back to top
View user's profile Send private message
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Sat May 24, 2008 2:16 pm    Post subject: Reply with quote

Get the target process' ID, use it to create a thread snapshot using CreateToolHelp32Snapshot, then use OpenThread, and then, SuspenThread\ResumeThread.
Back to top
View user's profile Send private message
NothingToShow
Grandmaster Cheater Supreme
Reputation: 0

Joined: 11 Jul 2007
Posts: 1579

PostPosted: Sat May 24, 2008 2:19 pm    Post subject: Reply with quote

DoomsDay wrote:
Get the target process' ID, use it to create a thread snapshot using CreateToolHelp32Snapshot, then use OpenThread, and then, SuspenThread\ResumeThread.

I'll "mess around". Sounds a bit confusing since I've never messed with all that.
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Sat May 24, 2008 3:08 pm    Post subject: Reply with quote

Windows is thread-based. A process is simply a group of threads. It is like a container. The threads do all the execution of code. In order to "freeze" a process, you must suspend all of the process's threads. Use CreateToolhelp32Snapshot, OpenThread, and SuspendThread.

Btw, SuspendProcess simply does the mentioned above.
Back to top
View user's profile Send private message
NothingToShow
Grandmaster Cheater Supreme
Reputation: 0

Joined: 11 Jul 2007
Posts: 1579

PostPosted: Sat May 24, 2008 3:13 pm    Post subject: Reply with quote

rapion124 wrote:
Windows is thread-based. A process is simply a group of threads. It is like a container. The threads do all the execution of code. In order to "freeze" a process, you must suspend all of the process's threads. Use CreateToolhelp32Snapshot, OpenThread, and SuspendThread.

Btw, SuspendProcess simply does the mentioned above.

I can't find anything about SuspendProcess.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sat May 24, 2008 3:43 pm    Post subject: Reply with quote

You have to suspend all of the thread's within a process.
Using CreateToolhelp32Snapshot, Thread32First and Thread32Next

_________________
Back to top
View user's profile Send private message
NothingToShow
Grandmaster Cheater Supreme
Reputation: 0

Joined: 11 Jul 2007
Posts: 1579

PostPosted: Sat May 24, 2008 4:12 pm    Post subject: Reply with quote

x0r wrote:
Code:
VOID SuspendProcess(HANDLE hProcess)
{
    HANDLE hSnapshot, hThread;

    hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, GetProcessId(hProcess));
    if (hSnapshot != NULL)
    {
        THREADENTRY32 ThreadEntry;
        ThreadEntry.dwSize = sizeof(THREADENTRY32);
        if (Thread32First(hSnapshot, &ThreadEntry))
        {
            do
            {
                hThread = OpenThread(THREAD_SUSPEND_RESUME, NULL, ThreadEntry.th32ThreadID);
                if (hThread != NULL)
                {
                    SuspendThread(hThread);
                    CloseHandle(hThread);
                }
            } while (Thread32Next(hSnapshot, &ThreadEntry));
        }
        CloseHandle(hSnapshot);
    }
}

Thanks, I'll try to convert it to Delphi.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sat May 24, 2008 4:52 pm    Post subject: Reply with quote

I meant ntSuspendProcess (a function in ntdll.dll)

takes a processhandle

_________________
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
NothingToShow
Grandmaster Cheater Supreme
Reputation: 0

Joined: 11 Jul 2007
Posts: 1579

PostPosted: Sun May 25, 2008 7:25 am    Post subject: Reply with quote

Thanks for all the help, I'll have to mess around with it.

I have anothe question, not regarding this, but I didn't want to create a new topic for it.
In Flash you've got ._X and ._Y, what have you got in Delphi?
I think it's .top and .left, but is there a way to make it x and y.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sun May 25, 2008 8:12 am    Post subject: Reply with quote

a new topic would be better.
anyhow, create this unit:
Code:

unit newform;

interface

uses classes,forms;

type TForm=class(forms.TForm) //override TForm class
  private
    function getTop: integer;
    procedure setTop(y: integer);
    function getLeft: integer;
    procedure setLeft(x: integer);
  public
    property _x: integer read getLeft write setLeft;
    property _y: integer read getTop write setTop;
  end;

implementation

function TForm.getTop: integer;
begin
  result:=top;
end;

procedure TForm.setTop(y: integer);
begin
  top:=y;
end;

function TForm.getLeft: integer;
begin
  result:=left;
end;

procedure TForm.setLeft(x: integer);
begin
  left:=x;
end;

end.

and add this unit to your form's uses list.

Now you can use _x:=value and _y:=value to set top and left


(if your formclass is a different name, eg inherited form, you'll havwe to make some minor changes)

_________________
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


Last edited by Dark Byte on Sun May 25, 2008 6:00 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
NothingToShow
Grandmaster Cheater Supreme
Reputation: 0

Joined: 11 Jul 2007
Posts: 1579

PostPosted: Sun May 25, 2008 9:02 am    Post subject: Reply with quote

Thanks! Smile
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