;============================================================================================================================================= ; step_32.asm ;This program just shows all the active processes ; Algorithm ;A1: Get module handle ;A2: Create parent window ;A3: Create list box ;A4: Create button ;A5: Create terminate button ;A6: Start message loop ;A7: Clear the list ;A8: Get the processes and show them ;A9: Terminate selected process ;A10: Update list ;A11: Terminate all processes ;(C)I don't take any responsibility for the use of this program ; Zedr0n -- connection closed ;============================================================================================================================================= ;============================================================================================================================================= ; Options/Declarations ;============================================================================================================================================= .386 .model flat, stdcall option casemap:none include windows.inc include kernel32.inc include user32.inc include th32.inc include comdlg32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\user32.lib includelib \masm32\lib\comdlg32.lib ;============================================================================================================================================= ; Data segment ;============================================================================================================================================= .data Filter db "Exe files",0 db "*.exe",0,0 WindowName_L db "List Box",0 WindowName db "Zedr0n's Win Shell",0 ClassName_L db "LISTBOX",0 ClassName db "Zedr0n's Class",0 ClassName_B db "BUTTON",0 WindowName_B db "Update",0 WindowName_BT db "Terminate",0 WindowName_BE db "Execute",0 WindowName_BH db "Halt",0 WindowName_BQ db "Shut down",0 x equ 100 x_l equ x-100 y equ 100 y_l equ y-100 x_b equ x_l+win_width_l+10 y_b equ y_l y_bt equ y_l+50 y_be equ y_bt+50 y_bh equ y_be+50 y_bq equ y_bh+50 win_width equ 600 win_width_l equ win_width-100 win_height equ 400 win_height_l equ win_height-50 win_width_b equ 80 win_height_b equ 30 Err_1 db "Error creating parent window",0 Err_2 db "Error creating a list box",0 Err_3 db "Error creating button",0 Err_4 db "Error making a snapshot",0 Err_5 db "Error receiving process",0 Err_6 db "Error sending message",0 Err_7 db "Select a process!",0 Err_8 db "Error getting text of an item",0 Err_9 db "Error getting handle",0 Err_10 db "Can't create process",0 Caption db "Zedr0n's Win Shell",0 Start_program db "C:\WIN98SE\COMMAND\START.EXE",0 Shell db "D:\SHELL.EXE",0 kernel32 db "C:\WIN98SE\SYSTEM\KERNEL32.DLL",0 halt dd 0 ;============================================================================================================================================ ; Variables segment ;============================================================================================================================================ .data? buffer db 256 dup(?) buffer_e db 256 dup(?) Message MSG <> hModule HANDLE ? hList HWND ? hParent HWND ? hButton HWND ? hButton_T HWND ? hButton_E HANDLE ? hButton_H HANDLE ? hButton_Q HANDLE ? hProcess HANDLE ? hSnap HANDLE ? ident dd ? pe PROCESSENTRY32 <> pe_size equ $-pe wc WNDCLASSEX <> wc_size equ $-wc op OPENFILENAME <> op_size equ $-op pi PROCESS_INFORMATION <> sinfo STARTUPINFO <> sinfo_size equ $-sinfo ;============================================================================================================================================= ; Code segment ;============================================================================================================================================= .code start: A1: invoke GetModuleHandle,NULL mov hModule,eax A2: mov wc.cbSize,wc_size mov wc.style,CS_HREDRAW OR CS_VREDRAW mov wc.lpfnWndProc,offset WndProc mov wc.hInstance,eax mov wc.lpszClassName,offset ClassName mov wc.cbClsExtra,NULL mov wc.cbWndExtra,NULL invoke LoadIcon,NULL,IDI_APPLICATION mov wc.hIcon,eax mov wc.hIconSm,eax invoke LoadCursor,NULL,IDC_ARROW mov wc.hCursor,eax mov wc.hbrBackground,COLOR_GRAYTEXT+1 mov wc.lpszMenuName,NULL invoke RegisterClassEx,addr wc invoke CreateWindowEx,NULL,offset ClassName,offset WindowName,WS_OVERLAPPEDWINDOW,x,y,win_width,win_height,NULL,NULL,hModule,NULL mov hParent,eax .if eax==NULL invoke MessageBox,NULL,offset Err_1,offset Caption,MB_OK invoke ExitProcess,NULL .endif invoke ShowWindow, hParent,SW_SHOWNORMAL invoke UpdateWindow, hParent A3: invoke CreateWindowEx,NULL,offset ClassName_L,offset WindowName_L,WS_CHILD OR WS_BORDER,x_l,y_l,win_width_l,win_height_l,hParent,NULL,hModule,NULL mov hList,eax .if eax==NULL invoke MessageBox,NULL,offset Err_2,offset Caption,MB_OK invoke ExitProcess,NULL .endif invoke ShowWindow,hList,SW_SHOWNORMAL invoke UpdateWindow,hList A4: invoke CreateWindowEx,NULL,offset ClassName_B,offset WindowName_B,WS_CHILD,x_b,y_b,win_width_b,win_height_b,hParent,NULL,hModule,NULL mov hButton,eax .if eax==NULL invoke MessageBox,NULL,offset Err_3,offset Caption,MB_OK invoke ExitProcess,NULL .endif invoke ShowWindow,hButton,SW_SHOWNORMAL invoke UpdateWindow,hButton invoke SendMessage,hParent,WM_COMMAND,NULL,hButton A5: invoke CreateWindowEx,NULL,offset ClassName_B,offset WindowName_BT,WS_CHILD,x_b,y_bt,win_width_b,win_height_b,hParent,NULL,hModule,NULL mov hButton_T,eax .if eax==NULL invoke MessageBox,NULL,offset Err_3,offset Caption,MB_OK invoke ExitProcess,NULL .endif invoke ShowWindow,hButton_T,SW_SHOWNORMAL invoke UpdateWindow,hButton_T invoke CreateWindowEx,NULL,offset ClassName_B,offset WindowName_BE,WS_CHILD,x_b,y_be,win_width_b,win_height_b,hParent,NULL,hModule,NULL mov hButton_E,eax .if eax==NULL invoke MessageBox,NULL,offset Err_3,offset Caption,MB_OK invoke ExitProcess,NULL .endif invoke ShowWindow,hButton_E,SW_SHOWNORMAL invoke UpdateWindow,hButton_E invoke CreateWindowEx,NULL,offset ClassName_B,offset WindowName_BH,WS_CHILD,x_b,y_bh,win_width_b,win_height_b,hParent,NULL,hModule,NULL mov hButton_H,eax .if eax==NULL invoke MessageBox,NULL,offset Err_3,offset Caption,MB_OK invoke ExitProcess,NULL .endif invoke ShowWindow,hButton_H,SW_SHOWNORMAL invoke UpdateWindow,hButton_H invoke SendMessage,hParent,WM_COMMAND,NULL,hButton_H invoke CreateWindowEx,NULL,offset ClassName_B,offset WindowName_BQ,WS_CHILD,x_b,y_bq,win_width_b,win_height_b,hParent,NULL,hModule,NULL mov hButton_Q,eax .if eax==NULL invoke MessageBox,NULL,offset Err_3,offset Caption,MB_OK invoke ExitProcess,NULL .endif invoke ShowWindow,hButton_Q,SW_SHOWNORMAL invoke UpdateWindow,hButton_Q A6: .WHILE TRUE invoke GetMessage, ADDR Message,NULL,0,0 .BREAK .IF (!eax) invoke TranslateMessage, ADDR Message invoke DispatchMessage, ADDR Message .ENDW Exit: invoke ExitProcess,NULL ;============================================================================================================================================ ; Procedures ;============================================================================================================================================ WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM .if uMsg==WM_DESTROY invoke PostQuitMessage,NULL .elseif uMsg==WM_COMMAND mov eax,lParam .if eax==hButton A7: invoke SendMessage,hList,LB_GETCOUNT,NULL,NULL .while eax>0 dec eax invoke SendMessage,hList,LB_DELETESTRING,eax,NULL .endw invoke CreateToolhelp32Snapshot,TH32CS_SNAPPROCESS,NULL mov hSnap,eax .if eax==NULL invoke MessageBox,NULL,offset Err_4,offset Caption,NULL invoke ExitProcess,NULL .endif A8: mov pe.dwSize,pe_size invoke Process32First,hSnap,offset pe .if eax==FALSE invoke MessageBox,NULL,offset Err_5,offset Caption,NULL invoke ExitProcess,NULL .endif mov eax,TRUE .while eax==TRUE invoke lstrcmp,offset buffer,offset pe.szExeFile .if eax==0 mov eax,pe.th32ProcessID mov ident,eax .endif invoke lstrcmp,offset Start_program,offset pe.szExeFile .if eax!=0 invoke lstrcmp,offset Shell,offset pe.szExeFile .if eax!=0 invoke lstrcmp,offset kernel32,offset pe.szExeFile .if eax!=0 invoke SendMessage,hList,LB_ADDSTRING,NULL,offset pe.szExeFile .if eax==LB_ERR invoke MessageBox,NULL,offset Err_6,offset Caption,NULL jmp A6 .endif .endif .endif .endif invoke Process32Next,hSnap,offset pe .endw .elseif eax==hButton_T mov halt,0 A9: invoke SendMessage,hList,LB_GETCURSEL,NULL,NULL .if eax==LB_ERR invoke MessageBox,NULL,offset Err_7,offset Caption,NULL jmp A6 .endif invoke SendMessage,hList,LB_GETTEXT,eax,offset buffer .if eax==LB_ERR invoke MessageBox,NULL,offset Err_8,offset Caption,NULL jmp A6 .endif invoke SendMessage,hParent,WM_COMMAND,NULL,hButton invoke OpenProcess,PROCESS_ALL_ACCESS,TRUE,ident mov hProcess,eax .if eax==NULL invoke MessageBox,NULL,offset Err_9,offset Caption,NULL jmp A6 .endif invoke TerminateProcess,hProcess,NULL invoke CloseHandle,hProcess A10: invoke SendMessage,hList,LB_GETCOUNT,NULL,NULL .if eax>0 .if halt==1 jmp A11 .endif .endif invoke Sleep,2 invoke SendMessage,hParent,WM_COMMAND,NULL,hButton .elseif eax==hButton_E mov op.lpstrFilter,offset Filter mov op.lpstrTitle,offset Caption mov op.lpstrFileTitle,offset buffer_e mov op.hwndOwner,NULL mov op.nMaxFileTitle,256 mov eax,hModule mov op.hInstance,eax mov op.lStructSize,op_size invoke GetOpenFileName,offset op mov sinfo.cb,sinfo_size mov sinfo.lpReserved,NULL mov sinfo.lpTitle,NULL mov sinfo.dwFlags,NULL mov sinfo.cbReserved2,NULL mov sinfo.lpReserved2,NULL invoke CreateProcess,offset buffer_e,NULL,NULL,NULL,FALSE,HIGH_PRIORITY_CLASS,NULL,NULL,offset sinfo,offset pi .if eax==0 invoke MessageBox,NULL,offset Err_10,offset Caption,MB_OK jmp A6 .endif .elseif eax==hButton_H A11: mov halt,1 invoke SendMessage,hList,LB_GETCOUNT,NULL,NULL .while eax>0 invoke SendMessage,hList,LB_GETCOUNT,NULL,NULL dec eax invoke SendMessage,hList,LB_SETCURSEL,eax,NULL jmp A9 .endw .elseif eax==hButton_Q invoke SendMessage,hParent,WM_COMMAND,NULL,hButton_H invoke ExitWindowsEx,EWX_REBOOT,NULL .endif .else invoke DefWindowProc,hWnd,uMsg,wParam,lParam ret .endif xor eax, eax ret WndProc endp end start