MCPcopy Create free account
hub / github.com/dobin/RedEdr / Catch_NtCreateProcess

Function Catch_NtCreateProcess

RedEdrDll/dllmain.cpp:605–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603 );
604pNtCreateProcess Real_NtCreateProcess = NULL;
605NTSTATUS NTAPI Catch_NtCreateProcess(
606 OUT PHANDLE ProcessHandle,
607 IN ACCESS_MASK DesiredAccess,
608 IN POBJECT_ATTRIBUTES ObjectAttributes,
609 IN HANDLE ParentProcess,
610 IN BOOLEAN InheritObjectTable,
611 IN HANDLE SectionHandle,
612 IN HANDLE DebugPort,
613 IN HANDLE ExceptionPort
614) {
615 int64_t time = get_time();
616 char buf[DATA_BUFFER_SIZE] = "";
617
618 if (HooksInitialized) { // dont log our own hooking
619 int offset = 0;
620 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "{");
621 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"type\":\"dll\",");
622 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"time\":%llu,", time);
623 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"pid\":%lu,", (DWORD)GetCurrentProcessId());
624 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"tid\":%lu,", (DWORD)GetCurrentThreadId());
625 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"func\":\"NtCreateProcess\",");
626 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"handle\":%lld,", (long long)ProcessHandle);
627 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"access_mask\":%u,", DesiredAccess);
628 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"parent_process\":%llu,", ParentProcess);
629 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"inherit_table\":%d,", InheritObjectTable);
630 offset += LogMyStackTrace(&buf[offset], DATA_BUFFER_SIZE - offset);
631 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "}");
632 SendDllPipe(buf);
633 }
634 return Real_NtCreateProcess(ProcessHandle, DesiredAccess, ObjectAttributes, ParentProcess, InheritObjectTable, SectionHandle, DebugPort, ExceptionPort);
635}
636
637
638/******************* NtCreateThread ************************/

Callers

nothing calls this directly

Calls 3

get_timeFunction · 0.85
LogMyStackTraceFunction · 0.85
SendDllPipeFunction · 0.85

Tested by

no test coverage detected