Thanks.
; Stop_Msiexec.asm
; Terminate msiexec.exe when started unnecessarily
;
;
.586
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
.data
AppName db "Terminate",0
Problem_child db "msiexec.exe",0
errSnapshot db "CreateToolhelp32Snapshot failed.",0
errProcFirst db "Process32First failed.",0
.data?
hSnapshot HANDLE ?
ProcEnt PROCESSENTRY32 <?>
.code
start:
invoke CreateToolhelp32Snapshot, TH32CS_SNAPPROCESS,0
.IF (eax != INVALID_HANDLE_VALUE)
mov hSnapshot,eax
mov [ProcEnt.dwSize],SIZEOF ProcEnt
invoke Process32First, hSnapshot,ADDR ProcEnt
.IF (eax)
@@:
invoke lstrcmpi, ADDR Problem_child ,ADDR
[ProcEnt.szExeFile]
.IF (eax == 0)
invoke OpenProcess, PROCESS_TERMINATE,FALSE,
[ProcEnt.th32ProcessID]
.IF (eax)
invoke TerminateProcess, eax,0
.ELSE
;failed for some reason
.ENDIF
.ENDIF
invoke Process32Next, hSnapshot,ADDR ProcEnt
test eax,eax
jnz @B
.ELSE
invoke MessageBox, NULL,ADDR errProcFirst,ADDR
AppName,MB_OK or MB_ICONERROR
.ENDIF
invoke CloseHandle, hSnapshot
.ELSE
invoke MessageBox, NULL,ADDR errSnapshot,ADDR AppName,MB_OK or
MB_ICONERROR
.ENDIF
invoke ExitProcess, NULL
end start