Skip to content

Commit 1c9f65e

Browse files
committed
DotNetTools: Don't query block table entry if version mismatched
1 parent 74f4551 commit 1c9f65e

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

plugins/DotNetTools/counters.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -633,13 +633,11 @@ BOOLEAN OpenDotNetPublicControlBlock_V4(
633633
{
634634
PVOID ntdll;
635635

636-
if (ntdll = PhGetDllHandle(L"ntdll.dll"))
637-
{
638-
NtOpenPrivateNamespace_I = PhGetProcedureAddress(ntdll, "NtOpenPrivateNamespace", 0);
639-
RtlCreateBoundaryDescriptor_I = PhGetProcedureAddress(ntdll, "RtlCreateBoundaryDescriptor", 0);
640-
RtlDeleteBoundaryDescriptor_I = PhGetProcedureAddress(ntdll, "RtlDeleteBoundaryDescriptor", 0);
641-
RtlAddSIDToBoundaryDescriptor_I = PhGetProcedureAddress(ntdll, "RtlAddSIDToBoundaryDescriptor", 0);
642-
}
636+
ntdll = PhGetDllHandle(L"ntdll.dll");
637+
NtOpenPrivateNamespace_I = PhGetProcedureAddress(ntdll, "NtOpenPrivateNamespace", 0);
638+
RtlCreateBoundaryDescriptor_I = PhGetProcedureAddress(ntdll, "RtlCreateBoundaryDescriptor", 0);
639+
RtlDeleteBoundaryDescriptor_I = PhGetProcedureAddress(ntdll, "RtlDeleteBoundaryDescriptor", 0);
640+
RtlAddSIDToBoundaryDescriptor_I = PhGetProcedureAddress(ntdll, "RtlAddSIDToBoundaryDescriptor", 0);
643641

644642
PhEndInitOnce(&initOnce);
645643
}
@@ -863,8 +861,7 @@ PPH_LIST QueryDotNetAppDomainsForPid_V2(
863861
AppDomainEnumerationIPCBlock_Wow64* appDomainEnumBlock;
864862

865863
legacyPrivateBlock = (LegacyPrivateIPCControlBlock_Wow64*)ipcControlBlockTable;
866-
appDomainEnumBlock = GetLegacyBlockTableEntry(TRUE, ipcControlBlockTable, eLegacyPrivateIPC_AppDomain);
867-
864+
868865
// NOTE: .NET 2.0 processes do not have the IPC_FLAG_INITIALIZED flag.
869866

870867
// Check the IPCControlBlock version is valid.
@@ -873,6 +870,12 @@ PPH_LIST QueryDotNetAppDomainsForPid_V2(
873870
__leave;
874871
}
875872

873+
appDomainEnumBlock = GetLegacyBlockTableEntry(
874+
Wow64,
875+
ipcControlBlockTable,
876+
eLegacyPrivateIPC_AppDomain
877+
);
878+
876879
appDomainsList = EnumAppDomainIpcBlockWow64(
877880
ProcessHandle,
878881
appDomainEnumBlock
@@ -884,8 +887,7 @@ PPH_LIST QueryDotNetAppDomainsForPid_V2(
884887
AppDomainEnumerationIPCBlock* appDomainEnumBlock;
885888

886889
legacyPrivateBlock = (LegacyPrivateIPCControlBlock*)ipcControlBlockTable;
887-
appDomainEnumBlock = GetLegacyBlockTableEntry(FALSE, ipcControlBlockTable, eLegacyPrivateIPC_AppDomain);
888-
890+
889891
// NOTE: .NET 2.0 processes do not have the IPC_FLAG_INITIALIZED flag.
890892

891893
// Check the IPCControlBlock version is valid.
@@ -894,6 +896,12 @@ PPH_LIST QueryDotNetAppDomainsForPid_V2(
894896
__leave;
895897
}
896898

899+
appDomainEnumBlock = GetLegacyBlockTableEntry(
900+
Wow64,
901+
ipcControlBlockTable,
902+
eLegacyPrivateIPC_AppDomain
903+
);
904+
897905
appDomainsList = EnumAppDomainIpcBlock(
898906
ProcessHandle,
899907
appDomainEnumBlock

0 commit comments

Comments
 (0)