My_Code_Start equ this byte
dwProtectID dd ? ;要保护进程的ID
szJmp1 db 0e9h
dwNewText dd ? ;修改API后的内容
szOldText1 db 5 dup(0) ;修改API前的内容
dwMsgBoxAddr dd 77D5058Ah ;MessageBox 地址
dwTerminateProcessAddr dd 7C801E16h ;TerminateProcess 地址
dwWriteProcMemory dd 7C80220Fh ;WriteProcessMemory 地址
dwOpenProcess dd 7C8309E1h ;OpenProcess 地址
dwGetForegroundWndAddr dd 77D1BE4Bh ;GetForegroundWindow 地址
dwCloseHandle dd 7C809B47h ;CloseHandle 地址
dwMyID dd ? ;要远程进程的ID
hMyProcess dd ? ;要远程进程的句柄
dwTerminateID dd ? ;要关闭程序的ID
hTerminateProcess dd ? ;要关闭程序的句柄
szMsgText db 'CIW_BLUE创建的进程,请不要关闭!',0
szMsgCaption db '错误提示',0
_MyEntry:
_MyFun proc
call @F
@@:
pop ebx
sub ebx, offset @B
;************************************************************
mov eax, dword ptr [esp - 010h]
mov [ebx + dwTerminateID], eax ;即将被关闭的程序的ID
.if eax == [ebx + dwProtectID] ;是不是要保护的进程
push MB_ICONERROR
lea eax, [ebx + szMsgCaption]
push eax
lea eax, [ebx + szMsgText]
push eax
call [ebx + dwGetForegroundWndAddr]
push eax
call [ebx + dwMsgBoxAddr] ;弹出对话框
ret
.endif
assume fs:nothing
mov eax, fs:[24]
mov eax, ds:[eax + 32]
mov [ebx + dwMyID], eax ;获取远程进程的ID
push [ebx + dwMyID ]
push TRUE
push PROCESS_ALL_ACCESS
call [ebx + dwOpenProcess]
mov [ebx + hMyProcess], eax ;打开进程
push NULL
push 5
lea eax, [ebx + szOldText1]
push eax
push [ebx + dwTerminateProcessAddr]
push [ebx + hMyProcess]
call [ebx + dwWriteProcMemory] ;写入 TerminateProcess 原来的内容
push [ebx + dwTerminateID]
push TRUE
push PROCESS_ALL_ACCESS
call [ebx + dwOpenProcess] ;打开要关闭的进程
mov [ebx + hTerminateProcess], eax
push 0
push [ebx + hTerminateProcess]
call [ebx + dwTerminateProcessAddr] ;关闭进程
push [ebx + hTerminateProcess]
call [ebx + dwCloseHandle] ;关闭进程句柄
ret
_MyFun endp
My_Code_End equ this byte