MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / DbgkClearProcessDebugObject

Function DbgkClearProcessDebugObject

KernelLibrary/kDbgSys.cpp:1888–1941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1886}
1887
1888NTSTATUS DbgkClearProcessDebugObject(
1889 _In_ PEPROCESS Process,
1890 _In_ PDEBUG_OBJECT SourceDebugObject
1891) {
1892 NTSTATUS status = STATUS_SUCCESS;
1893 PDEBUG_OBJECT DebugObject = nullptr;
1894 PDEBUG_EVENT DebugEvent;
1895 LIST_ENTRY TempList;
1896 PLIST_ENTRY Entry;
1897
1898 ExAcquireFastMutex(g_pDbgkpProcessDebugPortMutex);
1899
1900 auto process = Process;
1901 /*DebugObject = (PDEBUG_OBJECT)process->DebugPort;
1902 if (DebugObject == nullptr || (DebugObject != SourceDebugObject && SourceDebugObject != nullptr)) {
1903 DebugObject = nullptr;
1904 status = STATUS_PORT_NOT_SET;
1905 }
1906 else {
1907 process->DebugPort = nullptr;
1908 status = STATUS_SUCCESS;
1909 }*/
1910 ExReleaseFastMutex(g_pDbgkpProcessDebugPortMutex);
1911
1912 if (NT_SUCCESS(status)) {
1913 DbgkpMarkProcessPeb(Process);
1914 }
1915
1916 if (DebugObject) {
1917 InitializeListHead(&TempList);
1918
1919 ExAcquireFastMutex(&DebugObject->Mutex);
1920 for (Entry = DebugObject->EventList.Flink; Entry != &DebugObject->EventList;) {
1921 DebugEvent = CONTAINING_RECORD(Entry, DEBUG_EVENT, EventList);
1922 Entry = Entry->Flink;
1923 // һ������������ͬʱ���Զ�������Խ���
1924 if (DebugEvent->Process == Process) {
1925 RemoveEntryList(&DebugEvent->EventList);
1926 InsertTailList(&TempList, &DebugEvent->EventList);
1927 }
1928 }
1929 ExReleaseFastMutex(&DebugObject->Mutex);
1930
1931 ObDereferenceObject(DebugObject);
1932
1933 while (!IsListEmpty(&TempList)) {
1934 Entry = RemoveHeadList(&TempList);
1935 DebugEvent = CONTAINING_RECORD(Entry, DEBUG_EVENT, EventList);
1936 DebugEvent->Status = STATUS_DEBUGGER_INACTIVE;
1937 DbgkpWakeTarget(DebugEvent);
1938 }
1939 }
1940 return status;
1941}
1942
1943NTSTATUS NtSetInformationDebugObject(
1944 _In_ HANDLE DebugObjectHandle,

Callers 1

NtRemoveProcessDebugFunction · 0.85

Calls 6

DbgkpMarkProcessPebFunction · 0.85
InitializeListHeadFunction · 0.85
RemoveEntryListFunction · 0.85
InsertTailListFunction · 0.85
IsListEmptyFunction · 0.85
DbgkpWakeTargetFunction · 0.85

Tested by

no test coverage detected