AutoIt: Замразяване на процес

Публикувано: 15.12.14, 13:15:11 | Автор: ArMeN | Видяна: 995 | Редактирано: 19.07.16, 21:07:09

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

Global $fSuspended = 0, $sToCombo
$aProcessList = ProcessList()
For $i = 1 To $aProcessList[0][0]
If StringRight($aProcessList[$i][0], 3) == 'exe' Then
$sToCombo &= $aProcessList[$i][0] & '|'
EndIf
Next

$hGui = GUICreate('Заморозка процесса', 290, 57)
$nCombo = GUICtrlCreateCombo('', 8, 16, 140, 21, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetBkColor(-1, 0xDCDFE4)
GUICtrlSetData(-1, $sToCombo)
$nButton1 = GUICtrlCreateButton('Заморозить процесс', 156, 16, 126, 21)
GUICtrlSetState(-1, $GUI_FOCUS)
GUISetState()

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $nButton1
$sProcess = GUICtrlRead($nCombo)
If $sProcess Then
_ProcSuspendResume($sProcess)
If $fSuspended Then
GUICtrlSetData($nButton1, 'Разморозить процесс')
Else
GUICtrlSetData($nButton1, 'Заморозить процесс')
EndIf
EndIf
EndSwitch
WEnd

Func _ProcSuspendResume($process)
$processid = ProcessExists($process)
If $processid Then
If $fSuspended 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
$fSuspended = 0
Return 1
Else
SetError(1)
Return 0
EndIf
Else
$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
$fSuspended = 1
Return 1
Else
SetError(1)
Return 0
EndIf
EndIf
Else
SetError(2)
Return 0
EndIf
EndFunc ;==>_ProcSuspendResume


Източник

Не сте влезли в акаунта си за да коментирате.


 

Няма коментари.