Jump to content

Freeze a Process?


Jussip
 Share

Recommended Posts

Ahoy there,

Is there a way to freeze a process with autoit? Not killing it, freezing. If you try open window of the frozen process it wont open? And a way to unfreeze it?

If there is a way, could you add it to my GUI what i made..

#include <GUIConstants.au3>

$Gui1 = GUICreate("Process Freezer", 397, 133, 211, 154, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_APPWINDOW,$WS_EX_CONTEXTHELP,$WS_EX_LEFTSCROLLBAR,$WS_EX_RIGHT,$WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))
$Freeze = GUICtrlCreateButton("Freeze", 16, 64, 161, 49, 0, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$DeFreeze = GUICtrlCreateButton("DeFreeze", 216, 64, 161, 49, 0, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Input1 = GUICtrlCreateInput("Process to freeze", 56, 16, 297, 28)
GUICtrlSetFont(-1, 12, 400, 2, "Arial Narrow")
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Freeze
Case $DeFreeze
EndSwitch
WEnd
Edited by jiibah
Link to comment
Share on other sites

#include <GUIConstants.au3>
#include <WindowsConstants.au3>

$Gui1 = GUICreate("Process Freezer", 397, 133, 211, 154, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_APPWINDOW,$WS_EX_CONTEXTHELP,$WS_EX_LEFTSCROLLBAR,$WS_EX_RIGHT,$WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))
$Freeze = GUICtrlCreateButton("Freeze", 16, 64, 161, 49, 0, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$DeFreeze = GUICtrlCreateButton("DeFreeze", 216, 64, 161, 49, 0, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Input1 = GUICtrlCreateInput("Process to freeze", 56, 16, 297, 28)
GUICtrlSetFont(-1, 12, 400, 2, "Arial Narrow")
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Freeze
        _ProcessSuspend(GUICtrlRead($Input1))
    Case $DeFreeze
        _ProcessResume(GUICtrlRead($Input1))
EndSwitch
WEnd

Func _ProcessSuspend($process)
$processid = ProcessExists($process)
If $processid Then
    $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $processid)
    $i_sucess = DllCall("ntdll.dll","int","NtSuspendProcess","int",$ai_Handle[0])
    DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle)
    If IsArray($i_sucess) Then
        Return 1
    Else
        SetError(1)
        Return 0
    Endif
Else
    SetError(2)
    Return 0
Endif
EndFunc

Func _ProcessResume($process)
$processid = ProcessExists($process)
If $processid Then
    $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $processid)
    $i_sucess = DllCall("ntdll.dll","int","NtResumeProcess","int",$ai_Handle[0])
    DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle)
    If IsArray($i_sucess) Then
        Return 1
    Else
        SetError(1)
        Return 0
    Endif
Else
    SetError(2)
    Return 0
Endif
EndFunc

When the words fail... music speaks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...