diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..4096055 --- /dev/null +++ b/.clang-format @@ -0,0 +1,101 @@ +AccessModifierOffset: -4 +AlignAfterOpenBracket: AlwaysBreak +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: DontAlign +AlignOperands: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: TopLevel +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: false + AfterStruct: true + AfterUnion: true + AfterExternBlock: false + BeforeCatch: true + BeforeElse: true +BreakBeforeBraces: Custom +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: AfterColon +BreakStringLiterals: false +ColumnLimit: 120 +CommentPragmas: '^begin_wpp|^end_wpp|^FUNC |^USESUFFIX |^USESUFFIX ' +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +ExperimentalAutoDetectBinPacking: false +IndentCaseLabels: false +IndentPPDirectives: AfterHash +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: false +Language: Cpp +MacroBlockBegin: '^BEGIN_MODULE$|^BEGIN_TEST_CLASS$|^BEGIN_TEST_METHOD$' +MacroBlockEnd: '^END_MODULE$|^END_TEST_CLASS$|^END_TEST_METHOD$' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +PointerAlignment: Right +ReflowComments: true +SortIncludes: false +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +StatementMacros: [ + 'EXTERN_C', + 'PAGED', + 'PAGEDX', + 'NONPAGED', + 'PNPCODE', + 'INITCODE', + '_At_', + '_When_', + '_Success_', + '_Check_return_', + '_Must_inspect_result_', + '_IRQL_requires_', + '_IRQL_requires_max_', + '_IRQL_requires_min_', + '_IRQL_saves_', + '_IRQL_restores_', + '_IRQL_saves_global_', + '_IRQL_restores_global_', + '_IRQL_raises_', + '_IRQL_lowers_', + '_Acquires_lock_', + '_Releases_lock_', + '_Acquires_exclusive_lock_', + '_Releases_exclusive_lock_', + '_Acquires_shared_lock_', + '_Releases_shared_lock_', + '_Requires_lock_held_', + '_Use_decl_annotations_', + '_Guarded_by_', + '__drv_preferredFunction', + '__drv_allocatesMem', + '__drv_freesMem', + ] +TabWidth: '4' +UseTab: Never diff --git a/LICENSE b/LICENSE index 2071b23..8acf865 100644 --- a/LICENSE +++ b/LICENSE @@ -1,9 +1,21 @@ MIT License -Copyright (c) +Copyright (c) 2022 gmh -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index ce1bab7..6b7c5c3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ -# AntiKernelDebug-POC +# AntiKernelDebug-poc -POC about how to detect windows kernel debug by pool tag. \ No newline at end of file +## What's this? +A POC about how to detect windows kernel debug by pool tag. + +## How does this poc actually work? +Query system pool tag information matches TagUlong == 'oIdK'. + +Tested in Win10 1809 + + +![image](https://github.com/gmh5225/AntiKernelDebug-poc/blob/main/images/1.png) diff --git a/detect.h b/detect.h new file mode 100644 index 0000000..cbc496e --- /dev/null +++ b/detect.h @@ -0,0 +1,5 @@ +#pragma once +#include + +bool +AntiKernelDbgByPoolTag(); diff --git a/detect.poc.pooltag.cpp b/detect.poc.pooltag.cpp new file mode 100644 index 0000000..7ae394a --- /dev/null +++ b/detect.poc.pooltag.cpp @@ -0,0 +1,40 @@ +#include "detect.h" +#include "util.h" + +bool +AntiKernelDbgByPoolTag() +{ + bool bKdbg = false; + PSYSTEM_POOLTAG_INFORMATION pPoolTagTable = NULL; + + do + { + NTSTATUS lStatus = EnumPoolTagTable(&pPoolTagTable); + if (!NT_SUCCESS(lStatus)) + { + break; + } + + ULONG uCount = pPoolTagTable->Count; + for (ULONG i = 0; i < uCount; ++i) + { + auto pPoolTagInfo = pPoolTagTable->TagInfo[i]; + if (pPoolTagInfo.TagUlong == 'oIdK' && pPoolTagInfo.PagedAllocs == 0 && pPoolTagInfo.PagedFrees == 0 && + pPoolTagInfo.PagedUsed == 0 && pPoolTagInfo.NonPagedUsed >= PAGE_SIZE && + pPoolTagInfo.NonPagedUsed < 10 * PAGE_SIZE && pPoolTagInfo.NonPagedAllocs > 0x30 && + pPoolTagInfo.NonPagedFrees > 0x30) + { + bKdbg = true; + break; + } + } + + } while (0); + + if (pPoolTagTable) + { + ExFreePoolWithTag(pPoolTagTable, 'haha'); + } + + return bKdbg; +} diff --git a/images/1.png b/images/1.png new file mode 100644 index 0000000..29c516c Binary files /dev/null and b/images/1.png differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..51a4aab --- /dev/null +++ b/main.cpp @@ -0,0 +1,18 @@ +#include "detect.h" + +#define dprintf(format, ...) DbgPrintEx(DPFLTR_DEFAULT_ID, DPFLTR_ERROR_LEVEL, (format), __VA_ARGS__) + +EXTERN_C +NTSTATUS +DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath) +{ + dprintf("[Hello]: DriverEntry!\n"); + + bool bDetect = AntiKernelDbgByPoolTag(); + if (bDetect) + { + dprintf("[Detect]: By AntiKernelDbgByPoolTag!\n"); + } + + return STATUS_VIRUS_DELETED; +} diff --git a/poc.sln b/poc.sln new file mode 100644 index 0000000..dc533a5 --- /dev/null +++ b/poc.sln @@ -0,0 +1,51 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31613.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "poc", "poc.vcxproj", "{5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|ARM.ActiveCfg = Debug|ARM + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|ARM.Build.0 = Debug|ARM + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|ARM.Deploy.0 = Debug|ARM + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|ARM64.Build.0 = Debug|ARM64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|x64.ActiveCfg = Debug|x64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|x64.Build.0 = Debug|x64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|x64.Deploy.0 = Debug|x64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|x86.ActiveCfg = Debug|Win32 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|x86.Build.0 = Debug|Win32 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Debug|x86.Deploy.0 = Debug|Win32 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|ARM.ActiveCfg = Release|ARM + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|ARM.Build.0 = Release|ARM + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|ARM.Deploy.0 = Release|ARM + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|ARM64.ActiveCfg = Release|ARM64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|ARM64.Build.0 = Release|ARM64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|ARM64.Deploy.0 = Release|ARM64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|x64.ActiveCfg = Release|x64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|x64.Build.0 = Release|x64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|x64.Deploy.0 = Release|x64 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|x86.ActiveCfg = Release|Win32 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|x86.Build.0 = Release|Win32 + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D}.Release|x86.Deploy.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FB967A48-09F4-457F-A4C4-D809908CA7CE} + EndGlobalSection +EndGlobal diff --git a/poc.vcxproj b/poc.vcxproj new file mode 100644 index 0000000..0f319b0 --- /dev/null +++ b/poc.vcxproj @@ -0,0 +1,295 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + {5DEEDF67-26CB-4AF6-A8B6-96BF7F1F898D} + {1bc93793-694f-48fe-9372-81e2b05556fd} + v4.5 + 12.0 + Debug + Win32 + poc + $(LatestTargetPlatformVersion) + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + + + false + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + KMDF + + + false + + + Windows10 + true + LLVM-MSVC_v142_KernelMode + Driver + KMDF + + + false + + + Windows10 + false + LLVM-MSVC_v142_KernelMode + Driver + KMDF + + + false + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + + + false + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + KMDF + + + false + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + + + false + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + KMDF + + + false + + + + + + + + + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + + Level3 + + + + + false + false + false + + + DriverEntry + + + + + Level3 + + + + + false + false + false + + + DriverEntry + + + + + Level3 + + + + + false + false + false + + + DriverEntry + + + + + Level3 + + + + + false + false + false + + + DriverEntry + + + + + Level3 + + + + + false + false + false + + + DriverEntry + + + + + Level3 + + + + + false + false + false + + + DriverEntry + + + + + Level3 + + + + + false + false + false + + + DriverEntry + + + + + Level3 + + + + + false + false + false + + + DriverEntry + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/poc.vcxproj.filters b/poc.vcxproj.filters new file mode 100644 index 0000000..84a2e20 --- /dev/null +++ b/poc.vcxproj.filters @@ -0,0 +1,28 @@ + + + + + {b893d0be-56c7-46a4-99c3-c8ddaf42d898} + + + {1e45d67b-b380-45b9-abc5-3c0a2803c1cb} + + + + + detect + + + util + + + + + + detect + + + util + + + \ No newline at end of file diff --git a/util.cpp b/util.cpp new file mode 100644 index 0000000..b5da659 --- /dev/null +++ b/util.cpp @@ -0,0 +1,59 @@ +#include "util.h" +///////////////////////////////////////////////////////////////////////////// +// NTAPI +EXTERN_C +NTSTATUS +NTAPI +ZwQuerySystemInformation( + IN SYSTEM_INFORMATION_CLASS SystemInformationClass, + OUT PVOID SystemInformation, + IN ULONG Length, + OUT PULONG ReturnLength); + +///////////////////////////////////////////////////////////////////////////// +// FUNCTION +NTSTATUS +EnumPoolTagTable(OUT PSYSTEM_POOLTAG_INFORMATION *Buffer) +{ + NTSTATUS lStatus; + PVOID pBuffer; + ULONG uBufferSize; + ULONG uAttempts; + + uBufferSize = 0x100; + pBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, uBufferSize, 'haha'); + if (!pBuffer) + { + return STATUS_MEMORY_NOT_ALLOCATED; + } + + lStatus = ZwQuerySystemInformation(SystemPoolTagInformation, pBuffer, uBufferSize, &uBufferSize); + uAttempts = 0; + + while (lStatus == STATUS_INFO_LENGTH_MISMATCH && uAttempts < 8) + { + if (pBuffer) + { + ExFreePoolWithTag(pBuffer, 'haha'); + } + + pBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, uBufferSize, 'haha'); + + lStatus = ZwQuerySystemInformation(SystemPoolTagInformation, pBuffer, uBufferSize, &uBufferSize); + uAttempts++; + } + + if (NT_SUCCESS(lStatus)) + { + *Buffer = (PSYSTEM_POOLTAG_INFORMATION)pBuffer; + } + else + { + if (pBuffer) + { + ExFreePoolWithTag(pBuffer, 'haha'); + } + } + + return lStatus; +} diff --git a/util.h b/util.h new file mode 100644 index 0000000..ca3fa44 --- /dev/null +++ b/util.h @@ -0,0 +1,246 @@ +#pragma once +#include + +///////////////////////////////////////////////////////////////////////////// +// STRUCT +#ifndef _SYSTEM_INFORMATION_CLASS +typedef enum _SYSTEM_INFORMATION_CLASS +{ + SystemBasicInformation = 0, + SystemProcessorInformation = 1, + SystemPerformanceInformation = 2, + SystemTimeOfDayInformation = 3, + SystemPathInformation = 4, + SystemProcessInformation = 5, + SystemCallCountInformation = 6, + SystemDeviceInformation = 7, + SystemProcessorPerformanceInformation = 8, + SystemFlagsInformation = 9, + SystemCallTimeInformation = 10, + SystemModuleInformation = 11, + SystemLocksInformation = 12, + SystemStackTraceInformation = 13, + SystemPagedPoolInformation = 14, + SystemNonPagedPoolInformation = 15, + SystemHandleInformation = 16, + SystemObjectInformation = 17, + SystemPageFileInformation = 18, + SystemVdmInstemulInformation = 19, + SystemVdmBopInformation = 20, + SystemFileCacheInformation = 21, + SystemPoolTagInformation = 22, + SystemInterruptInformation = 23, + SystemDpcBehaviorInformation = 24, + SystemFullMemoryInformation = 25, + SystemLoadGdiDriverInformation = 26, + SystemUnloadGdiDriverInformation = 27, + SystemTimeAdjustmentInformation = 28, + SystemSummaryMemoryInformation = 29, + SystemMirrorMemoryInformation = 30, + SystemPerformanceTraceInformation = 31, + SystemObsolete0 = 32, + SystemExceptionInformation = 33, + SystemCrashDumpStateInformation = 34, + SystemKernelDebuggerInformation = 35, + SystemContextSwitchInformation = 36, + SystemRegistryQuotaInformation = 37, + SystemExtendServiceTableInformation = 38, + SystemPrioritySeperation = 39, + SystemVerifierAddDriverInformation = 40, + SystemVerifierRemoveDriverInformation = 41, + SystemProcessorIdleInformation = 42, + SystemLegacyDriverInformation = 43, + SystemCurrentTimeZoneInformation = 44, + SystemLookasideInformation = 45, + SystemTimeSlipNotification = 46, + SystemSessionCreate = 47, + SystemSessionDetach = 48, + SystemSessionInformation = 49, + SystemRangeStartInformation = 50, + SystemVerifierInformation = 51, + SystemVerifierThunkExtend = 52, + SystemSessionProcessInformation = 53, + SystemLoadGdiDriverInSystemSpace = 54, + SystemNumaProcessorMap = 55, + SystemPrefetcherInformation = 56, + SystemExtendedProcessInformation = 57, + SystemRecommendedSharedDataAlignment = 58, + SystemComPlusPackage = 59, + SystemNumaAvailableMemory = 60, + SystemProcessorPowerInformation = 61, + SystemEmulationBasicInformation = 62, + SystemEmulationProcessorInformation = 63, + SystemExtendedHandleInformation = 64, + SystemLostDelayedWriteInformation = 65, + SystemBigPoolInformation = 66, + SystemSessionPoolTagInformation = 67, + SystemSessionMappedViewInformation = 68, + SystemHotpatchInformation = 69, + SystemObjectSecurityMode = 70, + SystemWatchdogTimerHandler = 71, + SystemWatchdogTimerInformation = 72, + SystemLogicalProcessorInformation = 73, + SystemWow64SharedInformationObsolete = 74, + SystemRegisterFirmwareTableInformationHandler = 75, + SystemFirmwareTableInformation = 76, + SystemModuleInformationEx = 77, + SystemVerifierTriageInformation = 78, + SystemSuperfetchInformation = 79, + SystemMemoryListInformation = 80, + SystemFileCacheInformationEx = 81, + SystemThreadPriorityClientIdInformation = 82, + SystemProcessorIdleCycleTimeInformation = 83, + SystemVerifierCancellationInformation = 84, + SystemProcessorPowerInformationEx = 85, + SystemRefTraceInformation = 86, + SystemSpecialPoolInformation = 87, + SystemProcessIdInformation = 88, + SystemErrorPortInformation = 89, + SystemBootEnvironmentInformation = 90, + SystemHypervisorInformation = 91, + SystemVerifierInformationEx = 92, + SystemTimeZoneInformation = 93, + SystemImageFileExecutionOptionsInformation = 94, + SystemCoverageInformation = 95, + SystemPrefetchPatchInformation = 96, + SystemVerifierFaultsInformation = 97, + SystemSystemPartitionInformation = 98, + SystemSystemDiskInformation = 99, + SystemProcessorPerformanceDistribution = 100, + SystemNumaProximityNodeInformation = 101, + SystemDynamicTimeZoneInformation = 102, + SystemCodeIntegrityInformation = 103, + SystemProcessorMicrocodeUpdateInformation = 104, + SystemProcessorBrandString = 105, + SystemVirtualAddressInformation = 106, + SystemLogicalProcessorAndGroupInformation = 107, + SystemProcessorCycleTimeInformation = 108, + SystemStoreInformation = 109, + SystemRegistryAppendString = 110, + SystemAitSamplingValue = 111, + SystemVhdBootInformation = 112, + SystemCpuQuotaInformation = 113, + SystemNativeBasicInformation = 114, + SystemErrorPortTimeouts = 115, + SystemLowPriorityIoInformation = 116, + SystemBootEntropyInformation = 117, + SystemVerifierCountersInformation = 118, + SystemPagedPoolInformationEx = 119, + SystemSystemPtesInformationEx = 120, + SystemNodeDistanceInformation = 121, + SystemAcpiAuditInformation = 122, + SystemBasicPerformanceInformation = 123, + SystemQueryPerformanceCounterInformation = 124, + SystemSessionBigPoolInformation = 125, + SystemBootGraphicsInformation = 126, + SystemScrubPhysicalMemoryInformation = 127, + SystemBadPageInformation = 128, + SystemProcessorProfileControlArea = 129, + SystemCombinePhysicalMemoryInformation = 130, + SystemEntropyInterruptTimingInformation = 131, + SystemConsoleInformation = 132, + SystemPlatformBinaryInformation = 133, + SystemPolicyInformation = 134, + SystemHypervisorProcessorCountInformation = 135, + SystemDeviceDataInformation = 136, + SystemDeviceDataEnumerationInformation = 137, + SystemMemoryTopologyInformation = 138, + SystemMemoryChannelInformation = 139, + SystemBootLogoInformation = 140, + SystemProcessorPerformanceInformationEx = 141, + SystemSpare0 = 142, + SystemSecureBootPolicyInformation = 143, + SystemPageFileInformationEx = 144, + SystemSecureBootInformation = 145, + SystemEntropyInterruptTimingRawInformation = 146, + SystemPortableWorkspaceEfiLauncherInformation = 147, + SystemFullProcessInformation = 148, + SystemKernelDebuggerInformationEx = 149, + SystemBootMetadataInformation = 150, + SystemSoftRebootInformation = 151, + SystemElamCertificateInformation = 152, + SystemOfflineDumpConfigInformation = 153, + SystemProcessorFeaturesInformation = 154, + SystemRegistryReconciliationInformation = 155, + SystemEdidInformation = 156, + SystemManufacturingInformation = 157, + SystemEnergyEstimationConfigInformation = 158, + SystemHypervisorDetailInformation = 159, + SystemProcessorCycleStatsInformation = 160, + SystemVmGenerationCountInformation = 161, + SystemTrustedPlatformModuleInformation = 162, + SystemKernelDebuggerFlags = 163, + SystemCodeIntegrityPolicyInformation = 164, + SystemIsolatedUserModeInformation = 165, + SystemHardwareSecurityTestInterfaceResultsInformation = 166, + SystemSingleModuleInformation = 167, + SystemAllowedCpuSetsInformation = 168, + SystemVsmProtectionInformation = 169, + SystemInterruptCpuSetsInformation = 170, + SystemSecureBootPolicyFullInformation = 171, + SystemCodeIntegrityPolicyFullInformation = 172, + SystemAffinitizedInterruptProcessorInformation = 173, + SystemRootSiloInformation = 174, + SystemCpuSetInformation = 175, + SystemCpuSetTagInformation = 176, + SystemWin32WerStartCallout = 177, + SystemSecureKernelProfileInformation = 178, + SystemCodeIntegrityPlatformManifestInformation = 179, + SystemInterruptSteeringInformation = 180, + SystemSupportedProcessorArchitectures = 181, + SystemMemoryUsageInformation = 182, + SystemCodeIntegrityCertificateInformation = 183, + SystemPhysicalMemoryInformation = 184, + SystemControlFlowTransition = 185, + SystemKernelDebuggingAllowed = 186, + SystemActivityModerationExeState = 187, + SystemActivityModerationUserSettings = 188, + SystemCodeIntegrityPoliciesFullInformation = 189, + SystemCodeIntegrityUnlockInformation = 190, + SystemIntegrityQuotaInformation = 191, + SystemFlushInformation = 192, + SystemProcessorIdleMaskInformation = 193, + SystemSecureDumpEncryptionInformation = 194, + SystemWriteConstraintInformation = 195, + SystemKernelVaShadowInformation = 196, + SystemHypervisorSharedPageInformation = 197, + SystemFirmwareBootPerformanceInformation = 198, + SystemCodeIntegrityVerificationInformation = 199, + SystemFirmwarePartitionInformation = 200, + SystemSpeculationControlInformation = 201, + SystemDmaGuardPolicyInformation = 202, + SystemEnclaveLaunchControlInformation = 203, + SystemWorkloadAllowedCpuSetsInformation = 204, + SystemCodeIntegrityUnlockModeInformation = 205, + SystemLeapSecondInformation = 206, + SystemFlags2Information = 207, + MaxSystemInfoClass = 208, +} SYSTEM_INFORMATION_CLASS, + *PSYSTEM_INFORMATION_CLASS; +#endif + +typedef struct _SYSTEM_POOLTAG +{ // x86 = 28, x64 = 40 + union + { + UCHAR Tag[4]; // 0x000 0x000 + ULONG TagUlong; // 0x000 0x000 + } DUMMYUNIONNAME; + ULONG PagedAllocs; // 0x004 0x004 + ULONG PagedFrees; // 0x008 0x008 + SIZE_T PagedUsed; // 0x00c 0x010 + ULONG NonPagedAllocs; // 0x010 0x018 + ULONG NonPagedFrees; // 0x014 0x01c + SIZE_T NonPagedUsed; // 0x018 0x020 +} SYSTEM_POOLTAG, *PSYSTEM_POOLTAG; + +typedef struct _SYSTEM_POOLTAG_INFORMATION +{ // x86 = 32, x64 = 48 + ULONG Count; // 0x000 0x000 + SYSTEM_POOLTAG TagInfo[1]; // 0x004 0x008 +} SYSTEM_POOLTAG_INFORMATION, *PSYSTEM_POOLTAG_INFORMATION; + +///////////////////////////////////////////////////////////////////////////// +// FUNCTION +NTSTATUS +EnumPoolTagTable(OUT PSYSTEM_POOLTAG_INFORMATION *Buffer);