Join us at IRC!
Imagination is more valuable than knowledge - Albert Einstein
Wednesday, May 23, 2012
Navigation
Members Online
Total Online: 39
Web Spiders: 16
Guests Online: 36
Members Online: 3

Registered Members: 70173
Newest Member: TheGreek
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

RE: disable "end task" for my program

god
Member



Posts: 349
Location: I bet you're too scared to look behind you..
Joined: 23.01.05
Rank:
God
Posted on 09-09-05 19:27
i know a line of code that prevents the user from opening the task manager.. lemme check ......
oooo i seem to have lost it :P Check codeguru.com, u can find sthg like app.taskvisible = false I THINK , n a shell command (i call it like that cz it has the word shell in it's code) that prevents alt+ctrl+del from opening the TM
but this code can still close an app:
(that's a VB module --not-written-by-me--)
Attribute VB_Name = "MProcessStop"
Option Explicit
'on win2k you need the following:
Private Const PROCESS_TERMINATE = &H1

'On nt 9X the following could be enough:
Private Const PROCESS_ALL_ACCESS = &H1F0FFF

'in any case, let us use both...

'I thought this was 255, but was wrong...
Private Const MAX_PATH As Integer = 260


Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32moduleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type

Private Declare Function CreateToolHelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long

Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long

Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long





Public Function KillApp(myName As String) As Boolean

Dim uProcess As PROCESSENTRY32
Dim rProcessFound As Long
Dim hSnapShot As Long
Dim szExename As String
Dim exitCode As Long
Dim myProcess As Long
Dim iFound As Integer

On Error GoTo ErrHandler

Const TH32CS_SNAPPROCESS As Long = 2&

uProcess.dwSize = Len(uProcess)
hSnapShot = CreateToolHelpSnapshot(TH32CS_SNAPPROCESS, 0&)
rProcessFound = ProcessFirst(hSnapShot, uProcess)


Do While rProcessFound
iFound = InStr(1, uProcess.szExeFile, Chr(0)) - 1
If iFound > 0 Then
szExename = LCase$(Left$(uProcess.szExeFile, iFound))

If Right$(szExename, Len(myName)) = LCase$(myName) Then

myProcess = OpenProcess(PROCESS_ALL_ACCESS Or PROCESS_TERMINATE, False, uProcess.th32ProcessID)
KillApp = TerminateProcess(myProcess, exitCode)
Call CloseHandle(myProcess)


'if you have only one, exit here:
'Exit Function
'if you think you may have more than one,
'let this go on
End If
rProcessFound = ProcessNext(hSnapShot, uProcess)
End If
Loop
Call CloseHandle(hSnapShot)
Exit Function
ErrHandler:
'something went wrong. Let us exit
MsgBox Err.Descblockedription
End Function

It's from a guy from planetsourcecode..



pm me for it pm me for it pm me for it
Author

RE: disable "end task" for my program

n3w7yp3
Member

Posts: 358
Location: USA
Joined: 19.03.05
Rank:
Mad User
Posted on 10-09-05 15:25
in Perl you can eaisly have your program ignore signals by doing somehting like:


$SIG{'INT'} = 'IGNORE';
$SIG{'HUP'} = 'IGNORE';
$SIG{'TERM'} = 'IGNORE';
$SIG{'CHLD'} = 'IGNORE';
$SIG{'PS'} = 'IGNORE';


note that there is no way to stop SIGKILL (kill -9).

edit: gah, looks like from your post you're on Windows, and this is for *nix. oh well, its still good to know ;)


"Root is a state of mind" -- K0resh

Edited by n3w7yp3 on 10-09-05 15:26
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.