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

Function Catch_NtQueueApcThread

RedEdrDll/dllmain.cpp:519–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517 );
518pNtQueueApcThread Real_NtQueueApcThread = NULL;
519NTSTATUS NTAPI Catch_NtQueueApcThread(
520 IN HANDLE ThreadHandle,
521 IN PIO_APC_ROUTINE ApcRoutine,
522 IN PVOID ApcRoutineContext OPTIONAL,
523 IN PIO_STATUS_BLOCK ApcStatusBlock OPTIONAL,
524 IN ULONG ApcReserved OPTIONAL
525) {
526 int64_t time = get_time();
527 char buf[DATA_BUFFER_SIZE] = "";
528
529 if (HooksInitialized) { // dont log our own hooking
530 int offset = 0;
531 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "{");
532 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"type\":\"dll\",");
533 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"time\":%llu,", time);
534 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"pid\":%lu,", (DWORD)GetCurrentProcessId());
535 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"tid\":%lu,", (DWORD)GetCurrentThreadId());
536 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"func\":\"NtQueueApcThread\",");
537 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "\"thread_handle\":%lld,", ThreadHandle);
538 offset += LogMyStackTrace(&buf[offset], DATA_BUFFER_SIZE - offset);
539 offset += sprintf_s(buf + offset, DATA_BUFFER_SIZE - offset, "}");
540
541 SendDllPipe(buf);
542 }
543 return Real_NtQueueApcThread(ThreadHandle, ApcRoutine, ApcRoutineContext, ApcStatusBlock, ApcReserved);
544}
545
546
547/******************* NtQueueApcThreadEx ************************/

Callers

nothing calls this directly

Calls 3

get_timeFunction · 0.85
LogMyStackTraceFunction · 0.85
SendDllPipeFunction · 0.85

Tested by

no test coverage detected