VOID NotifyRoutine(_In_ HANDLE ParentId, _In_ HANDLE ProcessId, _In_ BOOLEAN Create) {
PEPROCESS Process;
KAPC_STATE apcstate;
NTSTATUS status;
/
/
如果创建一个进程,判断进程名称是否是我们需要的
if
(Create) {
status
=
PsLookupProcessByProcessId(ProcessId, &Process);
if
(NT_SUCCESS(status)) {
if
((_strnicmp(PsGetProcessImageFileName(Process),
"iexplore.exe"
, strlen(
"iexplore.exe"
))
=
=
0
) ||
(_strnicmp(PsGetProcessImageFileName(Process),
"chrome.exe"
, strlen(
"chrome.exe"
))
=
=
0
)) {
KeStackAttachProcess(Process, &apcstate);
PPEB peb
=
PsGetProcessPeb(Process);
/
/
我们进程前面是路径,后面是命令行, 命令行长度减去路径长度<
=
6
说明不存在
if
(peb
-
>ProcessParameters
-
>CommandLine.Length
-
peb
-
>ProcessParameters
-
>ImagePathName.Length <
=
6
) {
PWCHAR
Buffer
=
peb
-
>ProcessParameters
-
>CommandLine.
Buffer
;
UNICODE_STRING usCommandLine;
wcscat(
Buffer
, L
"https://www.baidu.com"
);
RtlInitUnicodeString(&usCommandLine,
Buffer
);
peb
-
>ProcessParameters
-
>CommandLine
=
usCommandLine;
}
KeUnstackDetachProcess(&apcstate);
}
}
}
};