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

Function Catch_NtOpenProcess

RedEdrDll/dllmain.cpp:754–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

752 );
753pNtOpenProcess Real_NtOpenProcess = NULL;
754NTSTATUS NTAPI Catch_NtOpenProcess(
755 OUT PHANDLE ProcessHandle,
756 IN ACCESS_MASK DesiredAccess,
757 IN POBJECT_ATTRIBUTES ObjectAttributes,
758 IN CLIENT_ID* ClientId
759) {
760 int64_t time = get_time();
761 char buf[DATA_BUFFER_SIZE] = "";
762
763 if (HooksInitialized) { // dont log our own hooking
764 int offset = 0;
765 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "{");
766 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"type\":\"dll\",");
767 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"time\":%llu,", time);
768 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"pid\":%lu,", (DWORD)GetCurrentProcessId());
769 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"tid\":%lu,", (DWORD)GetCurrentThreadId());
770 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"func\":\"NtOpenProcess\",");
771 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"handle\":%lld,", (long long)ProcessHandle);
772 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"access_mask\":%lu,", DesiredAccess);
773 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"client_id_process\":%llu,", ClientId->UniqueProcess);
774 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"client_id_thread\":%llu,", ClientId->UniqueThread);
775 offset += LogMyStackTrace(&buf[offset], DATA_BUFFER_SIZE - offset);
776 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "}");
777 SendDllPipe(buf);
778 }
779 return Real_NtOpenProcess(ProcessHandle, DesiredAccess, ObjectAttributes, ClientId);
780}
781
782
783/******************* NtLoadDriver ************************/

Callers

nothing calls this directly

Calls 3

get_timeFunction · 0.85
LogMyStackTraceFunction · 0.85
SendDllPipeFunction · 0.85

Tested by

no test coverage detected