Jump to content

TASM32 TerminateProcess

- - - - -

  • Please log in to reply
1 reply to this topic

#1
JMC31337

JMC31337

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
this code will terminate an open window


















;TASM32 /ml prog
;tlink32 -Tpe -aa -c -x prog ,,, import32
.386P
LOCALS
JUMPS
.MODEL FLAT, STDCALL

INCLUDE windows.inc

extrn GetWindowThreadProcessId:Proc
extrn FindWindowA:PROC    
extrn OpenProcess:PROC
extrn TerminateProcess:PROC
extrn GetWindowThreadProcessId:PROC

;PROCESS_TERMINATE equ 1   ;commented out

.data

PID dd 0
WinName db "Calculator",0

.code
start:

push offset WinName   ;push the value for WinName = CALC
push 0                        ;set lpClass to NULL
call FindWindowA        ;call the API
push offset PID          
push eax                     
call GetWindowThreadProcessId
push PID              ;calc PID value
push 0                   
push 1                    ;1=TERMINATE PROCESS VALUE or PROCESS_TERMINATE equ 1
call OpenProcess        
push 0                      
push eax                     
call TerminateProcess

jmp start   ;ENDLESSLY LOOP

end start
compile params make the program run under win mode NO CONSOLE
we drop Calculator in this example, we could kill task manager with this

WinName db "Windows Task Manager",0

a freshly opned unsaved notepad doc would be killed this way
WinName db "Untitled - Notepad",0

it goes via window handle titles
with the API of FindWindowA we have 2 values lpClass and WinName if lpClass is NULL we search for the WinName. hPid is the PId of the process.. in task manager goto view select columns and check PID if ya wanna see their values...

Edited by JMC31337, 02 July 2010 - 12:17 AM.

"Your Life Is Your Crime, It's Punishment Time"

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,705 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Nice! +rep
sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users