Kill one runing program

Windows specific forum
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Kill one runing program

Post by omid-xp »

How we can Force to kill one runing process?
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Post by omid-xp »

Don't know anybody ?
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi omid-xp.

There is probably an example somewhere on this board (find via search).

You are building (or getting people here to build for you) a self-modifying exe that runs in stealth mode, has the ability to install another exe, has the ability to send emails from the installed machine, can kill processes (like anti-virus?) and etc.

I have a favour to ask.

If that thing you are building ever escapes, can it look for purebasic on the machine it lands on and kill itself if it finds pure? That way at least we don't get infected.

This is a fairly relaxed board, and you are getting the benefit of the doubt. On a more responsible board you would have been asked, by now, to show your code and if not shown you would have been banned.

Just out of curiosity - care to post what you have done so far?
cykotic
User
User
Posts: 24
Joined: Wed Nov 12, 2003 6:24 am
Location: Canada
Contact:

Post by cykotic »

to me this sounds very suspicious as I am familiar with how trojans work and every question he has asked is a feature of some of the trojans we have all heard about. if you _are_ writing an ANTI-TROJAN app like you stated in another topic why the need to hide your app's window/process?
why the need to download a picture from a webcam? no anti-trojan program I have used has ever hidden itself from me? why would it do that? Or maybe you _are_ just trying to learn how they work so you can handle them better (with your anti-trojan app) but programming is also about learning on your OWN (it is ok to ask a few questions) but don't make other people give you every single piece of code for you app.

I am not saying it is wrong to code what you *might* be coding.. imo you can do what you want.. just don't bring it here.
cry havoc and let slip the dogs of war...

Image
ColBoy
Enthusiast
Enthusiast
Posts: 143
Joined: Fri Feb 13, 2004 2:37 pm
Location: Ottawa, Canada
Contact:

Post by ColBoy »

I think you need the API command TerminateProcess.
Colin
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Post by omid-xp »

Hi Dare2.

i am sorry for this some topics i making.

but i say before " i am a beginner in PB " need to help for start.

i search the forums for this topic just find one topic , that's kill one process by process id , i want kill by process name.

can you find in this forums one "kill process by name" topic?

i can't can you?

i love purebasic and like write all my apps by this language.

if you or anybody don't like my topics i delete my posts in all topics and don't try send one more topics for my problems. :(
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

It is what you are creating that is the worry.

Post your code here so we can see what we are helping you to create.
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

I have some source code to do what you want but your posts are a little concerning, if you could show us what your tring to do by posting your code i would be glad to help if it's not going to hurt other computers(if your not making a virus) 8) just post what your doing and everyone would be glad to help.



Sean
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Post by omid-xp »

Hi scurrier.

i never before this no making one virus , and don't know how making that.

all my topics not for one app , it's for some app.

i now work on the one email sender program.

users add custom email , smtp and file list and then build it.

server when run send email with attach that files.

it's not virus and not a trojan.

sample of this program is "Beee" ( Better Email Enable Everything ) at http://www.iOpus.com.

but that have very bugs and size is very big.

i now work for make one better email sender.

i like write utilitis in PB but i'm one beginner in PB , and very glad if someone help me in this work.

thank you and all for help to beginners.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

okay maybe no-one on this forum thinked about that you may are programming multible apps. But it is a fact, that if you bring all the functions you are asking for in 1 program, it might become evil...

But okay, splittet up in multible programs (task lister, computer lock, webcam security program, email sender or whatever), it is not evil.

But of course we are worried when a new user come and ask for functions that *might* become a virus/trojan.

But anyway, i see that some/a lot of the things you are asking about might need windows API. I suggest you read about API in the docs of PB, download API-GUIDE from www.allapi.net and looks in the api example in pb's example folder. Maybe that will save you from writing a lot of these posts.
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

ok here is the code to kill a program i use it to kill bearshare at 7:30Am everyday

Code: Select all


Structure PROCESSENTRY32 
    dwSize.l 
    cntUsage.l 
    th32ProcessID.l 
    th32DefaultHeapID.l 
    th32ModuleID.l 
    cntThreads.l 
    th32ParentProcessID.l 
    pcPriClassBase.l 
    dwFlags.l 
    szExeFile.b [#MAX_PATH] 
EndStructure 
;--- Procedures ---
Procedure KillProcess (pid) 
    phandle = OpenProcess_ (#PROCESS_TERMINATE, #FALSE, pid) 
    If phandle <> #NULL 
        If TerminateProcess_ (phandle, 1) 
            result = #TRUE 
        EndIf 
        CloseHandle_ (phandle) 
    EndIf 
    ProcedureReturn result 
EndProcedure 


NewList Process32.PROCESSENTRY32 () 

; Add processes to Process32 () list... 
restart:
If OpenLibrary (#PROCESS32LIB, "kernel32.dll") 

    snap = CallFunction (#PROCESS32LIB, "CreateToolhelp32Snapshot", #TH32CS_SNAPPROCESS, 0) 

    If snap 

        DefType.PROCESSENTRY32 Proc32 
        Proc32\dwSize = SizeOf (PROCESSENTRY32) 
        
        If CallFunction (#PROCESS32LIB, "Process32First", snap, @Proc32) 

            AddElement (Process32 ()) 
            CopyMemory (@Proc32, @Process32 (), SizeOf (PROCESSENTRY32)) 
            
            While CallFunction (#PROCESS32LIB, "Process32Next", snap, @Proc32) 
                AddElement (Process32 ()) 
                CopyMemory (@Proc32, @Process32 (), SizeOf (PROCESSENTRY32)) 
            Wend 
            
        EndIf    
        CloseHandle_ (snap) 
    
    EndIf 

    CloseLibrary (#PROCESS32LIB) 
    
EndIf 


ResetList (Process32 ()) 

While NextElement (Process32 ()) 
;    addtem( PeekS (@Process32 ()\szExeFile)
     proc$=(PeekS (@Process32 ()\szExeFile))
     If proc$="BearShare.exe"
       Threadid = Process32 ()\th32ProcessID
       Debug "Killing Thread "+proc1$+" it's ID is "+Str(Threadid)
       KillProcess (Threadid)
     EndIf
Wend 

End
hope this helps
Sean
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Post by Nico »

Kill a process by knowing only the handle of the main window

GetWindowThreadProcessId(hWnd, nProcessId)
hProcess = OpenProcess_( #PROCESS_ALL_ACCESS, #FALSE, nProcessId )
TerminateProcess_( hProcess, 99 )
CloseHandle_(hProcess)
omid-xp
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Jan 27, 2004 2:17 pm

Post by omid-xp »

Thanks thefool , scurrier and Nico.

i love this forums :D

very thanks scurrier for this code i looking for it.
Post Reply