mirror of
https://github.com/HyperDbg/HyperDbg.git
synced 2026-07-10 01:29:59 +00:00
Compare commits
21 commits
v0.20-beta
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf974ffcc2 | ||
|
|
a90513c71d | ||
|
|
27838bf4e0 | ||
|
|
9f113278ee | ||
|
|
5739d0ee4c | ||
|
|
ace4b331e7 | ||
|
|
ee01458bc4 | ||
|
|
16aebb0c5d | ||
|
|
43cea334c2 | ||
|
|
561ce0d559 | ||
|
|
5bccbff58b | ||
|
|
72a8aa325f | ||
|
|
2b0cc18899 | ||
|
|
2b818a5116 | ||
|
|
19e47c804f | ||
|
|
b537e36696 | ||
|
|
e7cef36819 | ||
|
|
a0973894e8 | ||
|
|
edf9f269d4 | ||
|
|
c17ebc09c4 | ||
|
|
7dfe5be985 |
76 changed files with 3458 additions and 533 deletions
18
CHANGELOG.md
18
CHANGELOG.md
|
|
@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.21.0.0] - 2026-07-05
|
||||
New release of the HyperDbg Debugger.
|
||||
|
||||
### Added
|
||||
- Added structure for the hyperperf (Hardware Performance Counter) project ([link](https://github.com/HyperDbg/HyperDbg/commit/c17ebc09c4d199a642352e66feebb3159582196c))
|
||||
- The 'unload' command checks whether any module is loaded or not ([link](https://docs.hyperdbg.org/commands/debugging-commands/unload))
|
||||
- Exported SDK API for checking whether any module is loaded or not ([link](https://github.com/HyperDbg/HyperDbg/commit/19e47c804f50f5dbb698f314e66b7d685a87ac1f))
|
||||
- Added user mode and kernel mode PT parameter parser ([link](https://github.com/HyperDbg/HyperDbg/pull/631))
|
||||
- Added thread (TID) and process (PID) helper functions for Intel PT ([link](https://github.com/HyperDbg/HyperDbg/pull/633))
|
||||
|
||||
### Changed
|
||||
- Separated SDK libraries for user mode and kernel mode modules ([link](https://github.com/HyperDbg/HyperDbg/commit/c17ebc09c4d199a642352e66feebb3159582196c))
|
||||
- Added hypertrace, hyperevade, and hyperperf DLL files to SDK ([link](https://github.com/HyperDbg/HyperDbg/commit/c17ebc09c4d199a642352e66feebb3159582196c))
|
||||
- Fix pool manager uninitialize list corruption ([link](https://github.com/HyperDbg/HyperDbg/pull/629))
|
||||
- Fix 'access denied' error on loading all modules using 'load all' ([link](https://docs.hyperdbg.org/commands/debugging-commands/load))([link](https://github.com/HyperDbg/HyperDbg/commit/2b818a5116d80d466aab7b343d4aa9d1d640f082))
|
||||
- Fix the concatenation error for the "hyperkd" string on the hypertrace project (https://github.com/HyperDbg/HyperDbg/commit/2b0cc18899ff532d9d590a71bf880fee5456c15f))
|
||||
- Organized header files for the libhyperdbg project ([link](https://github.com/HyperDbg/HyperDbg/pull/632))
|
||||
|
||||
## [0.20.0.0-beta] - 2026-06-21
|
||||
New release of the HyperDbg Debugger.
|
||||
|
||||
|
|
|
|||
|
|
@ -155,23 +155,23 @@ PtFilter(UINT32 ProcessId, UINT64 Start, UINT64 End)
|
|||
HYPERTRACE_PT_OPERATION_PACKETS Op = {};
|
||||
|
||||
Op.PtOperationType = HYPERTRACE_PT_OPERATION_REQUEST_TYPE_FILTER;
|
||||
Op.TraceUser = 1;
|
||||
Op.TargetProcessId = ProcessId;
|
||||
Op.FilterOptions.TraceUser = 1;
|
||||
Op.EnableOptions.Pid = ProcessId;
|
||||
|
||||
if (End > Start)
|
||||
{
|
||||
Op.NumAddrRanges = 1;
|
||||
Op.AddrRanges[0].Start = Start;
|
||||
Op.AddrRanges[0].End = End;
|
||||
Op.FilterOptions.NumAddrRanges = 1;
|
||||
Op.FilterOptions.AddrRanges[0].Start = Start;
|
||||
Op.FilterOptions.AddrRanges[0].End = End;
|
||||
}
|
||||
|
||||
if (!hyperdbg_u_pt_operation(&Op))
|
||||
return FALSE;
|
||||
|
||||
printf("[+] PT filter: cr3=0x%llx traceuser=%u ranges=%u buffer=0x%llx\n",
|
||||
(unsigned long long)Op.TargetCr3,
|
||||
Op.TraceUser,
|
||||
Op.NumAddrRanges,
|
||||
(unsigned long long)Op.EnableOptions.Cr3,
|
||||
Op.FilterOptions.TraceUser,
|
||||
Op.FilterOptions.NumAddrRanges,
|
||||
(unsigned long long)Op.BufferSize);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,14 +84,19 @@
|
|||
xcopy /E /I /Y "$(SolutionDir)include\SDK" "$(OutDir)SDK"
|
||||
xcopy /E /I /Y "$(SolutionDir)..\examples" "$(OutDir)SDK\examples"
|
||||
mkdir "$(OutDir)SDK\libraries"
|
||||
copy "$(OutDir)pdbex.lib" "$(OutDir)SDK\libraries\pdbex.lib"
|
||||
copy "$(OutDir)kdserial.lib" "$(OutDir)SDK\libraries\kdserial.lib"
|
||||
copy "$(OutDir)libhyperdbg.dll" "$(OutDir)SDK\libraries\libhyperdbg.dll"
|
||||
copy "$(OutDir)script-engine.dll" "$(OutDir)SDK\libraries\script-engine.dll"
|
||||
copy "$(OutDir)symbol-parser.dll" "$(OutDir)SDK\libraries\symbol-parser.dll"
|
||||
copy "$(OutDir)hyperlog.dll" "$(OutDir)SDK\libraries\hyperlog.dll"
|
||||
copy "$(OutDir)hyperhv.dll" "$(OutDir)SDK\libraries\hyperhv.dll"
|
||||
copy "$(OutDir)libipt.dll" "$(OutDir)SDK\libraries\libipt.dll"
|
||||
mkdir "$(OutDir)SDK\libraries\kernel"
|
||||
mkdir "$(OutDir)SDK\libraries\user"
|
||||
copy "$(OutDir)pdbex.dll" "$(OutDir)SDK\libraries\user\pdbex.dll"
|
||||
copy "$(OutDir)libipt.dll" "$(OutDir)SDK\libraries\user\libipt.dll"
|
||||
copy "$(OutDir)script-engine.dll" "$(OutDir)SDK\libraries\user\script-engine.dll"
|
||||
copy "$(OutDir)symbol-parser.dll" "$(OutDir)SDK\libraries\user\symbol-parser.dll"
|
||||
copy "$(OutDir)libhyperdbg.dll" "$(OutDir)SDK\libraries\user\libhyperdbg.dll"
|
||||
copy "$(OutDir)hyperlog.dll" "$(OutDir)SDK\libraries\kernel\hyperlog.dll"
|
||||
copy "$(OutDir)hyperhv.dll" "$(OutDir)SDK\libraries\kernel\hyperhv.dll"
|
||||
copy "$(OutDir)hypertrace.dll" "$(OutDir)SDK\libraries\kernel\hyperevade.dll"
|
||||
copy "$(OutDir)hypertrace.dll" "$(OutDir)SDK\libraries\kernel\hypertrace.dll"
|
||||
copy "$(OutDir)hyperperf.dll" "$(OutDir)SDK\libraries\kernel\hyperperf.dll"
|
||||
copy "$(OutDir)kdserial.dll" "$(OutDir)SDK\libraries\kernel\kdserial.dll"
|
||||
if exist "$(OutDir)constants\" rd /q /s "$(OutDir)constants\"
|
||||
mkdir "$(OutDir)constants"
|
||||
copy "$(SolutionDir)miscellaneous\constants\pciid\pci.ids" "$(OutDir)constants\pci.ids"</Command>
|
||||
|
|
@ -129,14 +134,19 @@ copy "$(SolutionDir)miscellaneous\constants\pciid\pci.ids" "$(OutDir)constants\p
|
|||
xcopy /E /I /Y "$(SolutionDir)include\SDK" "$(OutDir)SDK"
|
||||
xcopy /E /I /Y "$(SolutionDir)..\examples" "$(OutDir)SDK\examples"
|
||||
mkdir "$(OutDir)SDK\libraries"
|
||||
copy "$(OutDir)pdbex.lib" "$(OutDir)SDK\libraries\pdbex.lib"
|
||||
copy "$(OutDir)kdserial.lib" "$(OutDir)SDK\libraries\kdserial.lib"
|
||||
copy "$(OutDir)libhyperdbg.dll" "$(OutDir)SDK\libraries\libhyperdbg.dll"
|
||||
copy "$(OutDir)script-engine.dll" "$(OutDir)SDK\libraries\script-engine.dll"
|
||||
copy "$(OutDir)symbol-parser.dll" "$(OutDir)SDK\libraries\symbol-parser.dll"
|
||||
copy "$(OutDir)hyperlog.dll" "$(OutDir)SDK\libraries\hyperlog.dll"
|
||||
copy "$(OutDir)hyperhv.dll" "$(OutDir)SDK\libraries\hyperhv.dll"
|
||||
copy "$(OutDir)libipt.dll" "$(OutDir)SDK\libraries\libipt.dll"
|
||||
mkdir "$(OutDir)SDK\libraries\kernel"
|
||||
mkdir "$(OutDir)SDK\libraries\user"
|
||||
copy "$(OutDir)pdbex.dll" "$(OutDir)SDK\libraries\user\pdbex.dll"
|
||||
copy "$(OutDir)libipt.dll" "$(OutDir)SDK\libraries\user\libipt.dll"
|
||||
copy "$(OutDir)script-engine.dll" "$(OutDir)SDK\libraries\user\script-engine.dll"
|
||||
copy "$(OutDir)symbol-parser.dll" "$(OutDir)SDK\libraries\user\symbol-parser.dll"
|
||||
copy "$(OutDir)libhyperdbg.dll" "$(OutDir)SDK\libraries\user\libhyperdbg.dll"
|
||||
copy "$(OutDir)hyperlog.dll" "$(OutDir)SDK\libraries\kernel\hyperlog.dll"
|
||||
copy "$(OutDir)hyperhv.dll" "$(OutDir)SDK\libraries\kernel\hyperhv.dll"
|
||||
copy "$(OutDir)hypertrace.dll" "$(OutDir)SDK\libraries\kernel\hyperevade.dll"
|
||||
copy "$(OutDir)hypertrace.dll" "$(OutDir)SDK\libraries\kernel\hypertrace.dll"
|
||||
copy "$(OutDir)hyperperf.dll" "$(OutDir)SDK\libraries\kernel\hyperperf.dll"
|
||||
copy "$(OutDir)kdserial.dll" "$(OutDir)SDK\libraries\kernel\kdserial.dll"
|
||||
if exist "$(OutDir)constants\" rd /q /s "$(OutDir)constants\"
|
||||
mkdir "$(OutDir)constants"
|
||||
copy "$(SolutionDir)miscellaneous\constants\pciid\pci.ids" "$(OutDir)constants\pci.ids"</Command>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32602.215
|
||||
# Visual Studio Version 18
|
||||
VisualStudioVersion = 18.7.11911.148
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hyperdbg-cli", "hyperdbg-cli\hyperdbg-cli.vcxproj", "{FBCBBBAD-4EAE-469E-827F-F59FE9E7375B}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
|
|
@ -90,6 +90,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "imports", "imports", "{B3D9
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hyperkd", "hyperkd\hyperkd.vcxproj", "{AFDD7028-1ED9-442E-8A3D-01CFA3AA1CAA}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{360E54B1-0B92-4BCA-8111-4BF384292621} = {360E54B1-0B92-4BCA-8111-4BF384292621}
|
||||
{9FA45E25-DAEB-4C2D-806C-7908A180195D} = {9FA45E25-DAEB-4C2D-806C-7908A180195D}
|
||||
{AFDE69E9-EE3D-470E-8407-C1F0D98F9E3D} = {AFDE69E9-EE3D-470E-8407-C1F0D98F9E3D}
|
||||
{BB17323A-2460-4AE1-8AFE-B367400B934F} = {BB17323A-2460-4AE1-8AFE-B367400B934F}
|
||||
|
|
@ -101,6 +102,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "modules", "modules", "{13E4
|
|||
ProjectSection(SolutionItems) = preProject
|
||||
include\SDK\modules\HyperEvade.h = include\SDK\modules\HyperEvade.h
|
||||
include\SDK\Modules\HyperLog.h = include\SDK\Modules\HyperLog.h
|
||||
include\SDK\modules\HyperPerf.h = include\SDK\modules\HyperPerf.h
|
||||
include\SDK\modules\HyperTrace.h = include\SDK\modules\HyperTrace.h
|
||||
include\SDK\Modules\VMM.h = include\SDK\Modules\VMM.h
|
||||
EndProjectSection
|
||||
|
|
@ -207,6 +209,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "kernel", "kernel", "{947577
|
|||
include\SDK\imports\kernel\HyperDbgHyperEvade.h = include\SDK\imports\kernel\HyperDbgHyperEvade.h
|
||||
include\SDK\Imports\Kernel\HyperDbgHyperLogImports.h = include\SDK\Imports\Kernel\HyperDbgHyperLogImports.h
|
||||
include\SDK\Imports\Kernel\HyperDbgHyperLogIntrinsics.h = include\SDK\Imports\Kernel\HyperDbgHyperLogIntrinsics.h
|
||||
include\SDK\imports\kernel\HyperDbgHyperPerf.h = include\SDK\imports\kernel\HyperDbgHyperPerf.h
|
||||
include\SDK\imports\kernel\HyperDbgHyperTrace.h = include\SDK\imports\kernel\HyperDbgHyperTrace.h
|
||||
include\SDK\Imports\Kernel\HyperDbgVmmImports.h = include\SDK\Imports\Kernel\HyperDbgVmmImports.h
|
||||
EndProjectSection
|
||||
|
|
@ -327,6 +330,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "header", "header", "{CA2D9C
|
|||
include\components\pe\header\pe-image-reader.h = include\components\pe\header\pe-image-reader.h
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hyperperf", "hyperperf\hyperperf.vcxproj", "{360E54B1-0B92-4BCA-8111-4BF384292621}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
debug|x64 = debug|x64
|
||||
|
|
@ -384,6 +389,10 @@ Global
|
|||
{9FA45E25-DAEB-4C2D-806C-7908A180195D}.debug|x64.Build.0 = debug|x64
|
||||
{9FA45E25-DAEB-4C2D-806C-7908A180195D}.release|x64.ActiveCfg = release|x64
|
||||
{9FA45E25-DAEB-4C2D-806C-7908A180195D}.release|x64.Build.0 = release|x64
|
||||
{360E54B1-0B92-4BCA-8111-4BF384292621}.debug|x64.ActiveCfg = debug|x64
|
||||
{360E54B1-0B92-4BCA-8111-4BF384292621}.debug|x64.Build.0 = debug|x64
|
||||
{360E54B1-0B92-4BCA-8111-4BF384292621}.release|x64.ActiveCfg = release|x64
|
||||
{360E54B1-0B92-4BCA-8111-4BF384292621}.release|x64.Build.0 = release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ static const PWCH HV_FILES[] = {
|
|||
// HyperDbg Files
|
||||
//
|
||||
L"hyperhv",
|
||||
L"hyperkd"
|
||||
L"hyperkd",
|
||||
L"hyperlog",
|
||||
L"libhyperdbg",
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ PoolManagerInitialize()
|
|||
VOID
|
||||
PoolManagerUninitialize()
|
||||
{
|
||||
PLIST_ENTRY ListTemp = &g_ListOfAllocatedPoolsHead;
|
||||
PLIST_ENTRY Link;
|
||||
|
||||
//
|
||||
// Pool manager is not initialized anymore
|
||||
|
|
@ -101,14 +101,16 @@ PoolManagerUninitialize()
|
|||
|
||||
SpinlockLock(&LockForReadingPool);
|
||||
|
||||
while (&g_ListOfAllocatedPoolsHead != ListTemp->Flink)
|
||||
Link = g_ListOfAllocatedPoolsHead.Flink;
|
||||
|
||||
while (Link != &g_ListOfAllocatedPoolsHead)
|
||||
{
|
||||
ListTemp = ListTemp->Flink;
|
||||
PLIST_ENTRY Next = Link->Flink;
|
||||
|
||||
//
|
||||
// Get the head of the record
|
||||
//
|
||||
PPOOL_TABLE PoolTable = (PPOOL_TABLE)CONTAINING_RECORD(ListTemp, POOL_TABLE, PoolsList);
|
||||
PPOOL_TABLE PoolTable = (PPOOL_TABLE)CONTAINING_RECORD(Link, POOL_TABLE, PoolsList);
|
||||
|
||||
//
|
||||
// Free the alloocated buffer (if not already changed)
|
||||
|
|
@ -121,14 +123,20 @@ PoolManagerUninitialize()
|
|||
//
|
||||
// Unlink the PoolTable
|
||||
//
|
||||
RemoveEntryList(&PoolTable->PoolsList);
|
||||
RemoveEntryList(Link);
|
||||
|
||||
//
|
||||
// Free the record itself
|
||||
//
|
||||
PlatformMemFreePool(PoolTable);
|
||||
|
||||
Link = Next;
|
||||
}
|
||||
|
||||
InitializeListHead(&g_ListOfAllocatedPoolsHead);
|
||||
g_IsNewRequestForDeAllocation = FALSE;
|
||||
g_IsNewRequestForAllocationReceived = FALSE;
|
||||
|
||||
SpinlockUnlock(&LockForReadingPool);
|
||||
|
||||
PlmgrFreeRequestNewAllocation();
|
||||
|
|
@ -311,8 +319,7 @@ PoolManagerAllocateAndAddToPoolTable(SIZE_T Size, UINT32 Count, POOL_ALLOCATION_
|
|||
BOOLEAN
|
||||
PoolManagerCheckAndPerformAllocationAndDeallocation()
|
||||
{
|
||||
BOOLEAN Result = TRUE;
|
||||
PLIST_ENTRY ListTemp = 0;
|
||||
BOOLEAN Result = TRUE;
|
||||
|
||||
//
|
||||
// Make sure we're on vmx non-root and also we have new allocation
|
||||
|
|
@ -364,16 +371,16 @@ PoolManagerCheckAndPerformAllocationAndDeallocation()
|
|||
//
|
||||
if (g_IsNewRequestForDeAllocation)
|
||||
{
|
||||
ListTemp = &g_ListOfAllocatedPoolsHead;
|
||||
PLIST_ENTRY Link = g_ListOfAllocatedPoolsHead.Flink;
|
||||
|
||||
while (&g_ListOfAllocatedPoolsHead != ListTemp->Flink)
|
||||
while (Link != &g_ListOfAllocatedPoolsHead)
|
||||
{
|
||||
ListTemp = ListTemp->Flink;
|
||||
PLIST_ENTRY Next = Link->Flink;
|
||||
|
||||
//
|
||||
// Get the head of the record
|
||||
//
|
||||
PPOOL_TABLE PoolTable = (PPOOL_TABLE)CONTAINING_RECORD(ListTemp, POOL_TABLE, PoolsList);
|
||||
PPOOL_TABLE PoolTable = (PPOOL_TABLE)CONTAINING_RECORD(Link, POOL_TABLE, PoolsList);
|
||||
|
||||
//
|
||||
// Check whether this pool should be freed or not and
|
||||
|
|
@ -394,13 +401,15 @@ PoolManagerCheckAndPerformAllocationAndDeallocation()
|
|||
//
|
||||
// Now we should remove the entry from the g_ListOfAllocatedPoolsHead
|
||||
//
|
||||
RemoveEntryList(&PoolTable->PoolsList);
|
||||
RemoveEntryList(Link);
|
||||
|
||||
//
|
||||
// Free the structure pool
|
||||
//
|
||||
PlatformMemFreePool(PoolTable);
|
||||
}
|
||||
|
||||
Link = Next;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1670,13 +1670,13 @@ DrvDispatchHyperTraceIoControl(PIRP Irp, PIO_STACK_LOCATION IrpStack, BOOLEAN *
|
|||
// kernel/user CR3 is chosen based on the requested trace mode so
|
||||
// it works whether or not KVA shadowing (KPTI) is enabled.
|
||||
//
|
||||
if (HyperTracePtOperationRequest->TargetProcessId != 0 &&
|
||||
HyperTracePtOperationRequest->TargetCr3 == 0)
|
||||
if (HyperTracePtOperationRequest->EnableOptions.Pid != 0 &&
|
||||
HyperTracePtOperationRequest->EnableOptions.Cr3 == 0)
|
||||
{
|
||||
HyperTracePtOperationRequest->TargetCr3 =
|
||||
DrvResolvePtTargetCr3(HyperTracePtOperationRequest->TargetProcessId,
|
||||
(BOOLEAN)(HyperTracePtOperationRequest->TraceUser != 0),
|
||||
(BOOLEAN)(HyperTracePtOperationRequest->TraceKernel != 0));
|
||||
HyperTracePtOperationRequest->EnableOptions.Cr3 =
|
||||
DrvResolvePtTargetCr3(HyperTracePtOperationRequest->EnableOptions.Pid,
|
||||
(BOOLEAN)(HyperTracePtOperationRequest->FilterOptions.TraceUser != 0),
|
||||
(BOOLEAN)(HyperTracePtOperationRequest->FilterOptions.TraceKernel != 0));
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
22
hyperdbg/hyperperf/CMakeLists.txt
Normal file
22
hyperdbg/hyperperf/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Code generated by Visual Studio kit, DO NOT EDIT.
|
||||
set(SourceFiles
|
||||
"../include/components/spinlock/code/Spinlock.c"
|
||||
"../include/platform/kernel/code/PlatformMem.c"
|
||||
"code/Logging.c"
|
||||
"code/UnloadDll.c"
|
||||
"../include/components/spinlock/header/Spinlock.h"
|
||||
"../include/platform/kernel/header/Environment.h"
|
||||
"../include/platform/kernel/header/PlatformMem.h"
|
||||
"header/Logging.h"
|
||||
"header/pch.h"
|
||||
"header/UnloadDll.h"
|
||||
"hyperperf.def"
|
||||
)
|
||||
include_directories(
|
||||
"../include"
|
||||
"header"
|
||||
)
|
||||
wdk_add_library(hyperperf SHARED
|
||||
KMDF 1.15
|
||||
${SourceFiles}
|
||||
)
|
||||
84
hyperdbg/hyperperf/code/api/PerfApi.c
Normal file
84
hyperdbg/hyperperf/code/api/PerfApi.c
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/**
|
||||
* @file PerfApi.c
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief PMU routines for HyperPerf module
|
||||
* @details
|
||||
* @version 0.21
|
||||
* @date 2026-06-22
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*/
|
||||
#include "pch.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the hyperperf module callbacks
|
||||
* @details This only for callback initialization, not for PMU, etc. initialization
|
||||
*
|
||||
* @param HyperPerfCallbacks Pointer to the HyperPerf callbacks structure to be registered
|
||||
* @param RunningOnHypervisorEnvironment Whether the initialization is being done for hypervisor environment or not,
|
||||
* it can be used to skip some of the initialization steps if it is not for hypervisor environment and behave differently based on that
|
||||
*
|
||||
* @return BOOLEAN
|
||||
*/
|
||||
BOOLEAN
|
||||
HyperPerfInitCallback(HYPERPERF_CALLBACKS * HyperPerfCallbacks,
|
||||
BOOLEAN RunningOnHypervisorEnvironment)
|
||||
{
|
||||
//
|
||||
// Check if any of the required callbacks are NULL
|
||||
//
|
||||
for (UINT32 i = 0; i < sizeof(HYPERPERF_CALLBACKS) / sizeof(UINT64); i++)
|
||||
{
|
||||
if (((PVOID *)HyperPerfCallbacks)[i] == NULL)
|
||||
{
|
||||
//
|
||||
// The callback has null entry, so we cannot proceed
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Save the callbacks
|
||||
//
|
||||
PlatformWriteMemory(&g_Callbacks, HyperPerfCallbacks, sizeof(HYPERPERF_CALLBACKS));
|
||||
|
||||
//
|
||||
// Set the flag to indicate whether the initialization is being done for hypervisor environment or not
|
||||
//
|
||||
g_RunningOnHypervisorEnvironment = RunningOnHypervisorEnvironment;
|
||||
|
||||
//
|
||||
// Enable callbacks and set the initialized flag
|
||||
//
|
||||
g_HyperPerfCallbacksInitialized = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Uninitialize the hypertrace module
|
||||
*
|
||||
* @return VOID
|
||||
*/
|
||||
VOID
|
||||
HyperPerfUninit()
|
||||
{
|
||||
//
|
||||
// Check if the callbacks are initialized, if not, we don't need to handle anymore
|
||||
//
|
||||
if (!g_HyperPerfCallbacksInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Reset the environment flag to default value
|
||||
//
|
||||
g_RunningOnHypervisorEnvironment = FALSE;
|
||||
|
||||
//
|
||||
// Set callbacks to not initialized
|
||||
//
|
||||
g_HyperPerfCallbacksInitialized = FALSE;
|
||||
}
|
||||
26
hyperdbg/hyperperf/code/broadcast/Broadcast.c
Normal file
26
hyperdbg/hyperperf/code/broadcast/Broadcast.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* @file Broadcast.c
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief Broadcasting functions
|
||||
* @details
|
||||
* @version 0.21
|
||||
* @date 2026-06-22
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
|
||||
/**
|
||||
* @brief Routines to enable LBR on all cores
|
||||
*
|
||||
* @return VOID
|
||||
*/
|
||||
VOID
|
||||
BroadcastEnableLbrOnAllCores()
|
||||
{
|
||||
//
|
||||
// Broadcast to all cores
|
||||
//
|
||||
KeGenericCallDpc(DpcRoutineTestPmu, NULL);
|
||||
}
|
||||
35
hyperdbg/hyperperf/code/broadcast/DpcRoutines.c
Normal file
35
hyperdbg/hyperperf/code/broadcast/DpcRoutines.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* @file DpcRoutines.c
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief DPC routines
|
||||
* @details
|
||||
* @version 0.21
|
||||
* @date 2026-06-22
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
|
||||
/**
|
||||
* @brief Broadcast enabling LBR
|
||||
*
|
||||
* @param Dpc
|
||||
* @param DeferredContext
|
||||
* @param SystemArgument1
|
||||
* @param SystemArgument2
|
||||
* @return BOOLEAN
|
||||
*/
|
||||
BOOLEAN
|
||||
DpcRoutineTestPmu(KDPC * Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(Dpc);
|
||||
UNREFERENCED_PARAMETER(DeferredContext);
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Synchronize the end of this routine with the caller
|
||||
//
|
||||
PlatformBroadcastSynchronizeEndOfRoutine(SystemArgument1, SystemArgument2);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
45
hyperdbg/hyperperf/code/common/UnloadDll.c
Normal file
45
hyperdbg/hyperperf/code/common/UnloadDll.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* @file UnloadDll.c
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief Unloading DLL in the target Windows
|
||||
* @details
|
||||
* @version 0.4
|
||||
* @date 2023-07-06
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
|
||||
//
|
||||
// We'll add these functions, so whenever HyperDbg's driver is unloaded
|
||||
// DllUnload will be called to unload this dll from the memory.
|
||||
// this way we can remove the HyperDbg after unloading as there is no
|
||||
// other module remains loaded in the memory.
|
||||
//
|
||||
|
||||
/**
|
||||
* @brief Routine called on DLL initialization
|
||||
*
|
||||
* @param RegistryPath The registry path of the driver
|
||||
* @return NTSTATUS
|
||||
*/
|
||||
NTSTATUS
|
||||
DllInitialize(
|
||||
_In_ PUNICODE_STRING RegistryPath)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(RegistryPath);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Routine called on DLL unload
|
||||
*
|
||||
* @return NTSTATUS
|
||||
*/
|
||||
NTSTATUS
|
||||
DllUnload(VOID)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
19
hyperdbg/hyperperf/header/api/PerfApi.h
Normal file
19
hyperdbg/hyperperf/header/api/PerfApi.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* @file PerfApi.h
|
||||
* @author
|
||||
* @brief Header for general PMU routines for HyperPerf module
|
||||
* @details
|
||||
* @version 0.21
|
||||
* @date 2026-06-22
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Functions //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Most of the functions are defined and exported
|
||||
//
|
||||
20
hyperdbg/hyperperf/header/broadcast/Broadcast.h
Normal file
20
hyperdbg/hyperperf/header/broadcast/Broadcast.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
/**
|
||||
* @file Broadcast.h
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief Headers for broadcasting functions
|
||||
* @details
|
||||
* @version 0.21
|
||||
* @date 2026-06-22
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Functions //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
VOID
|
||||
BroadcastTestPmuOnAllCores();
|
||||
20
hyperdbg/hyperperf/header/broadcast/DpcRoutines.h
Normal file
20
hyperdbg/hyperperf/header/broadcast/DpcRoutines.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
/**
|
||||
* @file DpcRoutines.h
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief Definition for DPC functions
|
||||
* @details
|
||||
* @version 0.21
|
||||
* @date 2026-06-22
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Functions //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
BOOLEAN
|
||||
DpcRoutineTestPmu(KDPC * Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2);
|
||||
22
hyperdbg/hyperperf/header/common/UnloadDll.h
Normal file
22
hyperdbg/hyperperf/header/common/UnloadDll.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* @file UnloadDll.h
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief Headers for unloading DLL in the target Windows
|
||||
*
|
||||
* @version 0.4
|
||||
* @date 2023-07-06
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Exported Functions //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
__declspec(dllexport) NTSTATUS
|
||||
DllInitialize(_In_ PUNICODE_STRING RegistryPath);
|
||||
|
||||
__declspec(dllexport) NTSTATUS
|
||||
DllUnload(VOID);
|
||||
35
hyperdbg/hyperperf/header/globals/GlobalVariables.h
Normal file
35
hyperdbg/hyperperf/header/globals/GlobalVariables.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
/**
|
||||
* @file GlobalVariables.h
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief Definition for global variables
|
||||
* @details
|
||||
* @version 0.21
|
||||
* @date 2026-06-22
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Global Variables //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @brief List of callbacks
|
||||
*
|
||||
*/
|
||||
HYPERPERF_CALLBACKS g_Callbacks;
|
||||
|
||||
/**
|
||||
* @brief The flag indicating whether the hyperperf module callbacks is initialized or not
|
||||
*
|
||||
*/
|
||||
BOOLEAN g_HyperPerfCallbacksInitialized;
|
||||
|
||||
/**
|
||||
* @brief The flag indicating whether the initialization is being done for hypervisor environment or not
|
||||
*
|
||||
*/
|
||||
BOOLEAN g_RunningOnHypervisorEnvironment;
|
||||
111
hyperdbg/hyperperf/header/pch.h
Normal file
111
hyperdbg/hyperperf/header/pch.h
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
|
||||
/**
|
||||
* @file pch.h
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief Headers of Message logging and tracing
|
||||
* @details
|
||||
* @version 0.21
|
||||
* @date 2026-06-22
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define _NO_CRT_STDIO_INLINE
|
||||
|
||||
#pragma warning(disable : 4201) // Suppress nameless struct/union warning
|
||||
|
||||
//
|
||||
// Environment headers
|
||||
//
|
||||
#include "platform/general/header/Environment.h"
|
||||
|
||||
#ifdef HYPERDBG_ENV_WINDOWS
|
||||
|
||||
//
|
||||
// Windows defined functions
|
||||
//
|
||||
# include <ntddk.h>
|
||||
# include <ntstrsafe.h>
|
||||
# include <Windef.h>
|
||||
|
||||
#endif // HYPERDBG_ENV_WINDOWS
|
||||
|
||||
//
|
||||
// Scope definitions
|
||||
//
|
||||
#define HYPERDBG_KERNEL_MODE
|
||||
#define HYPERDBG_HYPERPERF
|
||||
|
||||
//
|
||||
// Add ia32-doc
|
||||
//
|
||||
#include "ia32-doc/out/ia32.h"
|
||||
|
||||
//
|
||||
// SDK headers
|
||||
//
|
||||
#include "SDK/HyperDbgSdk.h"
|
||||
|
||||
//
|
||||
// Configuration
|
||||
//
|
||||
#include "config/Configuration.h"
|
||||
|
||||
//
|
||||
// Platform independent headers
|
||||
//
|
||||
#include "platform/kernel/header/PlatformMem.h"
|
||||
#include "platform/kernel/header/PlatformIntrinsics.h"
|
||||
#include "platform/kernel/header/PlatformBroadcast.h"
|
||||
#include "platform/kernel/header/PlatformCpu.h"
|
||||
#include "platform/kernel/header/PlatformSpinlock.h"
|
||||
#include "platform/kernel/header/PlatformIrql.h"
|
||||
#include "platform/kernel/header/PlatformDpc.h"
|
||||
#include "platform/kernel/header/PlatformTime.h"
|
||||
#include "platform/kernel/header/PlatformDbg.h"
|
||||
#include "platform/kernel/header/PlatformIo.h"
|
||||
#include "platform/kernel/header/PlatformEvent.h"
|
||||
|
||||
//
|
||||
// Unload function (to be called when the driver is unloaded)
|
||||
//
|
||||
#include "common/UnloadDll.h"
|
||||
|
||||
//
|
||||
// Hyperlog headers
|
||||
//
|
||||
#include "components/callback/header/HyperLogCallback.h"
|
||||
#include "SDK/imports/kernel/HyperDbgHyperLogIntrinsics.h"
|
||||
|
||||
//
|
||||
// Spinlock headers
|
||||
//
|
||||
#include "components/spinlock/header/Spinlock.h"
|
||||
|
||||
//
|
||||
// HyperPerf Callbacks
|
||||
//
|
||||
#include "SDK/modules/HyperPerf.h"
|
||||
|
||||
//
|
||||
// Definition of general tracing types
|
||||
//
|
||||
#include "api/PerfApi.h"
|
||||
|
||||
//
|
||||
// DPC and broadcasting function headers
|
||||
//
|
||||
#include "broadcast/DpcRoutines.h"
|
||||
#include "broadcast/Broadcast.h"
|
||||
|
||||
//
|
||||
// Export functions
|
||||
//
|
||||
#include "SDK/imports/kernel/HyperDbgHyperPerf.h"
|
||||
|
||||
//
|
||||
// Global variables
|
||||
//
|
||||
#include "globals/GlobalVariables.h"
|
||||
167
hyperdbg/hyperperf/header/pt/Pt.h
Normal file
167
hyperdbg/hyperperf/header/pt/Pt.h
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
/**
|
||||
* @file Pt.h
|
||||
* @author Masoud Rahimi Jafari (Masoodrahimy1379@gmail.com)
|
||||
* @brief Header for Processor Trace (PT) tracing routines for HyperTrace module
|
||||
* @details Engine that programs Intel PT MSRs from VMX root or kernel context.
|
||||
* Buffer / ToPA management is kept here; user-visible PT structures
|
||||
* live in the SDK header [PtDefinitions.h].
|
||||
* @version 0.19
|
||||
* @date 2026-04-29
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Constants //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Pool tag for PT contiguous allocations (ASCII "PtHd")
|
||||
//
|
||||
#define POOL_TAG_PT 'dHtP'
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Structures //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @brief Narrow input descriptor for PtFilter.
|
||||
*
|
||||
* These are the only fields a caller is allowed to set per-CPU
|
||||
* when reconfiguring an active PT trace. Engine-internal options
|
||||
* (BranchEn, TscEn, MtcEn, CycEn, RetCompression, *Freq, etc.)
|
||||
* stay under the engine's control and are NOT exposed here.
|
||||
*
|
||||
* BufferSize == 0 means "keep whatever the per-CPU slot already
|
||||
* has" — pure filter changes don't touch the ToPA / output /
|
||||
* overflow buffers and can run from a DPC.
|
||||
*/
|
||||
typedef struct _PT_FILTER_OPTIONS
|
||||
{
|
||||
BOOLEAN TraceUser;
|
||||
BOOLEAN TraceKernel;
|
||||
UINT64 TargetCr3;
|
||||
UINT64 BufferSize;
|
||||
UINT32 NumAddrRanges;
|
||||
PT_ADDR_RANGE AddrRanges[PT_MAX_ADDR_RANGES];
|
||||
|
||||
} PT_FILTER_OPTIONS, *PPT_FILTER_OPTIONS;
|
||||
|
||||
/**
|
||||
* @brief Per-CPU bookkeeping for the user-mode mmap surface.
|
||||
*
|
||||
* One MDL + user VA per CPU describes the main output buffer
|
||||
* immediately followed by the 4 KB overflow page as a single
|
||||
* virtually contiguous region in the mapping process. Lives in
|
||||
* g_PtUserMappings; lifetime tied to the PT enable cycle.
|
||||
*/
|
||||
typedef struct _PT_USER_MAPPING
|
||||
{
|
||||
PMDL Mdl;
|
||||
PVOID UserVa;
|
||||
|
||||
} PT_USER_MAPPING, *PPT_USER_MAPPING;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Functions //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// HyperDbg-style wrappers (mirroring Lbr*)
|
||||
//
|
||||
|
||||
BOOLEAN
|
||||
PtCheck();
|
||||
|
||||
BOOLEAN
|
||||
PtStart();
|
||||
|
||||
VOID
|
||||
PtStop();
|
||||
|
||||
VOID
|
||||
PtPause();
|
||||
|
||||
VOID
|
||||
PtResume();
|
||||
|
||||
UINT64
|
||||
PtSize();
|
||||
|
||||
VOID
|
||||
PtDump();
|
||||
|
||||
VOID
|
||||
PtFlush();
|
||||
|
||||
//
|
||||
// LBR-style filter wrapper, one CPU at a time. Mirrors LbrFilter in shape:
|
||||
// caller passes a PT_FILTER_OPTIONS describing only the user-tunable bits
|
||||
// (TraceUser, TraceKernel, TargetCr3, BufferSize, NumAddrRanges, AddrRanges),
|
||||
// and PtFilter handles the stop / config-update / start sequence on the
|
||||
// CURRENT CPU. Engine-internal config (BranchEn, TscEn, etc.) is left
|
||||
// untouched in the per-CPU PT_TRACE_CONFIG.
|
||||
//
|
||||
VOID
|
||||
PtFilter(const PT_FILTER_OPTIONS * FilterOptions);
|
||||
|
||||
//
|
||||
// PASSIVE_LEVEL helpers — call before / after the per-core DPC broadcasts.
|
||||
// Required because MmAllocateContiguousMemorySpecifyCache and
|
||||
// MmFreeContiguousMemory must run at IRQL == PASSIVE_LEVEL.
|
||||
//
|
||||
|
||||
BOOLEAN
|
||||
PtAllocateAllCpuBuffers();
|
||||
|
||||
VOID
|
||||
PtFreeAllCpuBuffers();
|
||||
|
||||
//
|
||||
// User-mode mmap surface: map every per-CPU main output + overflow
|
||||
// buffer into the calling user process. Idempotent within an enable
|
||||
// cycle; torn down by PtFreeAllCpuBuffers (i.e. PT disable / flush).
|
||||
//
|
||||
INT32
|
||||
PtMmapAllCpuBuffersToUser(PT_USER_BUFFER_DESC * OutDescs, UINT32 MaxDescs, UINT32 * OutNumCpus);
|
||||
|
||||
VOID
|
||||
PtUnmapAllCpuBuffersFromUser();
|
||||
|
||||
//
|
||||
// Engine routines (operate on a specific PT_PER_CPU instance)
|
||||
//
|
||||
|
||||
INT32
|
||||
PtEngineQueryCapabilities(PT_CAPABILITIES * OutCaps);
|
||||
|
||||
VOID
|
||||
PtEngineInitDefaultConfig(PT_TRACE_CONFIG * Config);
|
||||
|
||||
INT32
|
||||
PtEngineAllocateBuffers(PT_PER_CPU * Cpu, const PT_TRACE_CONFIG * Config);
|
||||
|
||||
VOID
|
||||
PtEngineFreeBuffers(PT_PER_CPU * Cpu);
|
||||
|
||||
INT32
|
||||
PtEngineStart(PT_PER_CPU * Cpu);
|
||||
|
||||
UINT64
|
||||
PtEngineStop(PT_PER_CPU * Cpu, PT_OUTPUT_BUFFER * Out);
|
||||
|
||||
INT32
|
||||
PtEnginePause(PT_PER_CPU * Cpu);
|
||||
|
||||
INT32
|
||||
PtEngineResume(PT_PER_CPU * Cpu);
|
||||
|
||||
UINT64
|
||||
PtEngineHandlePmi(PT_PER_CPU * Cpu, PT_OUTPUT_BUFFER * Out);
|
||||
|
||||
BOOLEAN
|
||||
PtEngineIsPtPmi();
|
||||
|
||||
INT32
|
||||
PtEngineSizeToTopaEncoding(UINT64 SizeInBytes);
|
||||
6
hyperdbg/hyperperf/hyperperf.def
Normal file
6
hyperdbg/hyperperf/hyperperf.def
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
LIBRARY hyperperf
|
||||
|
||||
EXPORTS
|
||||
|
||||
DllInitialize PRIVATE
|
||||
DllUnload PRIVATE
|
||||
145
hyperdbg/hyperperf/hyperperf.vcxproj
Normal file
145
hyperdbg/hyperperf/hyperperf.vcxproj
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.Windows.SDK.CPP.x64.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.x64.props" Condition="Exists('..\packages\Microsoft.Windows.SDK.CPP.x64.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.x64.props')" />
|
||||
<Import Project="..\packages\Microsoft.Windows.SDK.CPP.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.props" Condition="Exists('..\packages\Microsoft.Windows.SDK.CPP.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.props')" />
|
||||
<Import Project="..\packages\Microsoft.Windows.WDK.x64.10.0.28000.1839\build\native\Microsoft.Windows.WDK.x64.props" Condition="Exists('..\packages\Microsoft.Windows.WDK.x64.10.0.28000.1839\build\native\Microsoft.Windows.WDK.x64.props')" />
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="debug|x64">
|
||||
<Configuration>debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release|x64">
|
||||
<Configuration>release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{360E54B1-0B92-4BCA-8111-4BF384292621}</ProjectGuid>
|
||||
<TemplateGuid>{1bc93793-694f-48fe-9372-81e2b05556fd}</TemplateGuid>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform Condition="'$(Platform)' == ''">x64</Platform>
|
||||
<RootNamespace>hyperperf</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'" Label="Configuration">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<DriverType>KMDF</DriverType>
|
||||
<DriverTargetPlatform>Desktop</DriverTargetPlatform>
|
||||
<Driver_SpectreMitigation>false</Driver_SpectreMitigation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'" Label="Configuration">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<DriverType>KMDF</DriverType>
|
||||
<DriverTargetPlatform>Desktop</DriverTargetPlatform>
|
||||
<Driver_SpectreMitigation>false</Driver_SpectreMitigation>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
|
||||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
|
||||
<OutDir>$(SolutionDir)build\bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)build\obj\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||
<EnableInf2cat>false</EnableInf2cat>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
|
||||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
|
||||
<OutDir>$(SolutionDir)build\bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)build\obj\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||
<EnableInf2cat>false</EnableInf2cat>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\include;$(ProjectDir)header;$(SolutionDir)dependencies;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||
<EntryPointSymbol />
|
||||
<NoEntryPoint>true</NoEntryPoint>
|
||||
<ModuleDefinitionFile>hyperperf.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\include;$(ProjectDir)header;$(SolutionDir)dependencies;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<Optimization>Full</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||
<EntryPointSymbol />
|
||||
<NoEntryPoint>true</NoEntryPoint>
|
||||
<ModuleDefinitionFile>hyperperf.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<FilesToPackage Include="$(TargetPath)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\include\components\callback\code\HyperLogCallback.c" />
|
||||
<ClCompile Include="..\include\platform\kernel\code\PlatformBroadcast.c" />
|
||||
<ClCompile Include="..\include\platform\kernel\code\PlatformCpu.c" />
|
||||
<ClCompile Include="..\include\platform\kernel\code\PlatformIntrinsics.c" />
|
||||
<ClCompile Include="..\include\platform\kernel\code\PlatformMem.c" />
|
||||
<ClCompile Include="code\api\PerfApi.c" />
|
||||
<ClCompile Include="code\broadcast\Broadcast.c" />
|
||||
<ClCompile Include="code\broadcast\DpcRoutines.c" />
|
||||
<ClCompile Include="code\common\UnloadDll.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\components\callback\header\HyperLogCallback.h" />
|
||||
<ClInclude Include="..\include\platform\kernel\header\PlatformBroadcast.h" />
|
||||
<ClInclude Include="..\include\platform\kernel\header\PlatformCpu.h" />
|
||||
<ClInclude Include="..\include\platform\kernel\header\PlatformIntrinsics.h" />
|
||||
<ClInclude Include="..\include\platform\kernel\header\PlatformMem.h" />
|
||||
<ClInclude Include="header\api\PerfApi.h" />
|
||||
<ClInclude Include="header\broadcast\Broadcast.h" />
|
||||
<ClInclude Include="header\broadcast\DpcRoutines.h" />
|
||||
<ClInclude Include="header\common\UnloadDll.h" />
|
||||
<ClInclude Include="header\globals\GlobalVariables.h" />
|
||||
<ClInclude Include="header\pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\packages\Microsoft.Windows.SDK.CPP.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.targets" Condition="Exists('..\packages\Microsoft.Windows.SDK.CPP.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.WDK.x64.10.0.28000.1839\build\native\Microsoft.Windows.WDK.x64.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.WDK.x64.10.0.28000.1839\build\native\Microsoft.Windows.WDK.x64.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.SDK.CPP.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.SDK.CPP.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.SDK.CPP.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.SDK.CPP.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.SDK.CPP.x64.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.x64.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.SDK.CPP.x64.10.0.28000.1839\build\native\Microsoft.Windows.SDK.cpp.x64.props'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
119
hyperdbg/hyperperf/hyperperf.vcxproj.filters
Normal file
119
hyperdbg/hyperperf/hyperperf.vcxproj.filters
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="code">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="header">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="header\platform">
|
||||
<UniqueIdentifier>{1ab177b4-9e6c-460e-834a-8fced04b42a3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="code\platform">
|
||||
<UniqueIdentifier>{21f0281e-fc2a-4e13-97ac-e4b35a05a31e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="code\api">
|
||||
<UniqueIdentifier>{09d5457a-bade-4a3f-a171-641110492d57}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="code\broadcast">
|
||||
<UniqueIdentifier>{b8b32a09-61fb-433a-ad79-eb7cfc5f3437}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="code\common">
|
||||
<UniqueIdentifier>{32ea8333-847b-443d-8992-4140d54dc1d3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\api">
|
||||
<UniqueIdentifier>{df6eb164-34b2-4f2a-9530-b88443662fb7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\broadcast">
|
||||
<UniqueIdentifier>{cb4e742a-6e43-4798-af4a-72bcb11089c9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\common">
|
||||
<UniqueIdentifier>{ab21116d-5f5b-4ef8-82bb-6585ac3dec95}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\globals">
|
||||
<UniqueIdentifier>{57d56081-eede-41a3-b9f0-e7019d32c986}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="code\components">
|
||||
<UniqueIdentifier>{4f62540b-d186-479e-83a0-1b550134f487}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="code\components\callback">
|
||||
<UniqueIdentifier>{9fe877a7-e261-4579-9752-a3156b6e69d9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\components">
|
||||
<UniqueIdentifier>{8bc2336a-b1c5-4e93-9793-23a5cfdc741d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\components\callback">
|
||||
<UniqueIdentifier>{fc73555b-2be3-4898-bcdb-df83fa3e1388}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\include\platform\kernel\code\PlatformMem.c">
|
||||
<Filter>code\platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="code\broadcast\Broadcast.c">
|
||||
<Filter>code\broadcast</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="code\broadcast\DpcRoutines.c">
|
||||
<Filter>code\broadcast</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="code\common\UnloadDll.c">
|
||||
<Filter>code\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="code\api\PerfApi.c">
|
||||
<Filter>code\api</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\include\platform\kernel\code\PlatformIntrinsics.c">
|
||||
<Filter>code\platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\include\platform\kernel\code\PlatformBroadcast.c">
|
||||
<Filter>code\broadcast</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\include\platform\kernel\code\PlatformCpu.c">
|
||||
<Filter>code\platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\include\components\callback\code\HyperLogCallback.c">
|
||||
<Filter>code\components\callback</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\platform\kernel\header\PlatformMem.h">
|
||||
<Filter>header\platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\broadcast\Broadcast.h">
|
||||
<Filter>header\broadcast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\broadcast\DpcRoutines.h">
|
||||
<Filter>header\broadcast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\common\UnloadDll.h">
|
||||
<Filter>header\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\globals\GlobalVariables.h">
|
||||
<Filter>header\globals</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\api\PerfApi.h">
|
||||
<Filter>header\api</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\platform\kernel\header\PlatformIntrinsics.h">
|
||||
<Filter>header\platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\platform\kernel\header\PlatformBroadcast.h">
|
||||
<Filter>header\platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\platform\kernel\header\PlatformCpu.h">
|
||||
<Filter>header\platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\components\callback\header\HyperLogCallback.h">
|
||||
<Filter>header\components\callback</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\pch.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
6
hyperdbg/hyperperf/packages.config
Normal file
6
hyperdbg/hyperperf/packages.config
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Windows.SDK.CPP" version="10.0.28000.1839" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.SDK.CPP.x64" version="10.0.28000.1839" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.WDK.x64" version="10.0.28000.1839" targetFramework="native" />
|
||||
</packages>
|
||||
|
|
@ -36,26 +36,26 @@ HyperTracePtBuildConfig(const HYPERTRACE_PT_OPERATION_PACKETS * Req,
|
|||
// If the request specifies neither user nor kernel, default to both
|
||||
// (matches LBR behaviour when filter is empty).
|
||||
//
|
||||
if (Req->TraceUser || Req->TraceKernel)
|
||||
if (Req->FilterOptions.TraceUser || Req->FilterOptions.TraceKernel)
|
||||
{
|
||||
OutCfg->TraceUser = (Req->TraceUser != 0) ? TRUE : FALSE;
|
||||
OutCfg->TraceKernel = (Req->TraceKernel != 0) ? TRUE : FALSE;
|
||||
OutCfg->TraceUser = (Req->FilterOptions.TraceUser != 0) ? TRUE : FALSE;
|
||||
OutCfg->TraceKernel = (Req->FilterOptions.TraceKernel != 0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
OutCfg->TargetCr3 = Req->TargetCr3;
|
||||
OutCfg->TargetCr3 = Req->EnableOptions.Cr3;
|
||||
|
||||
if (Req->BufferSize != 0)
|
||||
{
|
||||
OutCfg->BufferSize = Req->BufferSize;
|
||||
}
|
||||
|
||||
OutCfg->NumAddrRanges = Req->NumAddrRanges;
|
||||
OutCfg->NumAddrRanges = Req->FilterOptions.NumAddrRanges;
|
||||
if (OutCfg->NumAddrRanges > PT_MAX_ADDR_RANGES)
|
||||
OutCfg->NumAddrRanges = PT_MAX_ADDR_RANGES;
|
||||
|
||||
for (Copy = 0; Copy < OutCfg->NumAddrRanges; Copy++)
|
||||
{
|
||||
OutCfg->AddrRanges[Copy] = Req->AddrRanges[Copy];
|
||||
OutCfg->AddrRanges[Copy] = Req->FilterOptions.AddrRanges[Copy];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -284,6 +284,7 @@ HyperTracePtSize(HYPERTRACE_PT_OPERATION_PACKETS * HyperTraceOperationRequest)
|
|||
return FALSE;
|
||||
|
||||
ProcessorsCount = KeQueryActiveProcessorCount(0);
|
||||
|
||||
if (ProcessorsCount > PT_MAX_CPUS_FOR_MMAP)
|
||||
ProcessorsCount = PT_MAX_CPUS_FOR_MMAP;
|
||||
|
||||
|
|
@ -405,37 +406,37 @@ HyperTracePtFlush(HYPERTRACE_PT_OPERATION_PACKETS * HyperTraceOperationRequest)
|
|||
BOOLEAN
|
||||
HyperTracePtFilter(HYPERTRACE_PT_OPERATION_PACKETS * Req)
|
||||
{
|
||||
PT_FILTER_OPTIONS FilterOptions = {0};
|
||||
BOOLEAN WasEnabled = g_ProcessorTraceEnabled;
|
||||
BOOLEAN BufferChanged = FALSE;
|
||||
UINT64 ExistingSize = 0;
|
||||
UINT32 Copy;
|
||||
PT_APPLY_CORE_FILTER_REQUEST ApplyCoreFilterReq = {0};
|
||||
BOOLEAN WasEnabled = g_ProcessorTraceEnabled;
|
||||
BOOLEAN BufferChanged = FALSE;
|
||||
UINT64 ExistingSize = 0;
|
||||
|
||||
//
|
||||
// Translate the user-mode packet into PT_FILTER_OPTIONS — the narrow
|
||||
// Copy the user-mode request into a kernel-mode PT_APPLY_CORE_FILTER_REQUEST
|
||||
//
|
||||
memcpy(&ApplyCoreFilterReq.FilterOptions, &Req->FilterOptions, sizeof(PT_FILTER_OPTIONS));
|
||||
memcpy(&ApplyCoreFilterReq.EnableOptions, &Req->EnableOptions, sizeof(PT_ENABLE_OPTIONS));
|
||||
ApplyCoreFilterReq.BufferSize = Req->BufferSize;
|
||||
|
||||
//
|
||||
// Translate the user-mode packet into PT_FILTER_OPTIONS - the narrow
|
||||
// surface PtFilter operates on. Default to user+kernel when the
|
||||
// caller specified neither (matches LBR's empty-filter behaviour).
|
||||
//
|
||||
if (Req->TraceUser || Req->TraceKernel)
|
||||
if (Req->FilterOptions.TraceUser || Req->FilterOptions.TraceKernel)
|
||||
{
|
||||
FilterOptions.TraceUser = (Req->TraceUser != 0) ? TRUE : FALSE;
|
||||
FilterOptions.TraceKernel = (Req->TraceKernel != 0) ? TRUE : FALSE;
|
||||
ApplyCoreFilterReq.FilterOptions.TraceUser = (Req->FilterOptions.TraceUser != 0) ? TRUE : FALSE;
|
||||
ApplyCoreFilterReq.FilterOptions.TraceKernel = (Req->FilterOptions.TraceKernel != 0) ? TRUE : FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
FilterOptions.TraceUser = TRUE;
|
||||
FilterOptions.TraceKernel = TRUE;
|
||||
}
|
||||
FilterOptions.TargetCr3 = Req->TargetCr3;
|
||||
FilterOptions.BufferSize = Req->BufferSize;
|
||||
FilterOptions.NumAddrRanges = Req->NumAddrRanges;
|
||||
if (FilterOptions.NumAddrRanges > PT_MAX_ADDR_RANGES)
|
||||
FilterOptions.NumAddrRanges = PT_MAX_ADDR_RANGES;
|
||||
for (Copy = 0; Copy < FilterOptions.NumAddrRanges; Copy++)
|
||||
{
|
||||
FilterOptions.AddrRanges[Copy] = Req->AddrRanges[Copy];
|
||||
ApplyCoreFilterReq.FilterOptions.TraceUser = TRUE;
|
||||
ApplyCoreFilterReq.FilterOptions.TraceKernel = TRUE;
|
||||
}
|
||||
|
||||
if (Req->FilterOptions.NumAddrRanges > PT_MAX_ADDR_RANGES)
|
||||
ApplyCoreFilterReq.FilterOptions.NumAddrRanges = PT_MAX_ADDR_RANGES;
|
||||
|
||||
//
|
||||
// Decide between fast (filter-only) and slow (buffer-resize) paths.
|
||||
//
|
||||
|
|
@ -443,7 +444,8 @@ HyperTracePtFilter(HYPERTRACE_PT_OPERATION_PACKETS * Req)
|
|||
{
|
||||
ExistingSize = g_PtStateList[0].Config.BufferSize;
|
||||
}
|
||||
if (FilterOptions.BufferSize != 0 && FilterOptions.BufferSize != ExistingSize)
|
||||
|
||||
if (ApplyCoreFilterReq.BufferSize != 0 && ApplyCoreFilterReq.BufferSize != ExistingSize)
|
||||
{
|
||||
BufferChanged = TRUE;
|
||||
}
|
||||
|
|
@ -495,8 +497,8 @@ HyperTracePtFilter(HYPERTRACE_PT_OPERATION_PACKETS * Req)
|
|||
// unchanged. Force FilterOptions.BufferSize=0 so PtFilter on each core
|
||||
// keeps the buffer that's already allocated, then broadcast.
|
||||
//
|
||||
FilterOptions.BufferSize = 0;
|
||||
BroadcastFilterPtOnAllCores(&FilterOptions);
|
||||
ApplyCoreFilterReq.BufferSize = 0;
|
||||
BroadcastFilterPtOnAllCores(&ApplyCoreFilterReq);
|
||||
}
|
||||
|
||||
if (Req != NULL)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include "pch.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the hyper trace module callbacks
|
||||
* @brief Initialize the hypertrace module callbacks
|
||||
* @details This only for callback initialization, not for LBR, PT, etc. initialization
|
||||
*
|
||||
* @param HyperTraceCallbacks Pointer to the HyperTrace callbacks structure to be registered
|
||||
|
|
|
|||
|
|
@ -153,10 +153,12 @@ BroadcastFlushPtOnAllCores()
|
|||
* pointer is passed to every per-core DPC; KeGenericCallDpc is
|
||||
* synchronous so the caller's storage is valid throughout.
|
||||
*
|
||||
* @param FilterRequest Pointer to a PT_APPLY_CORE_FILTER_REQUEST structure containing the filter options to apply on all cores
|
||||
*
|
||||
* @return VOID
|
||||
*/
|
||||
VOID
|
||||
BroadcastFilterPtOnAllCores(PT_FILTER_OPTIONS * FilterOptions)
|
||||
BroadcastFilterPtOnAllCores(PT_APPLY_CORE_FILTER_REQUEST * FilterRequest)
|
||||
{
|
||||
KeGenericCallDpc(DpcRoutineFilterPt, (PVOID)FilterOptions);
|
||||
KeGenericCallDpc(DpcRoutineFilterPt, (PVOID)FilterRequest);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,8 +198,11 @@ DpcRoutineEnablePt(KDPC * Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO
|
|||
//
|
||||
PtStart();
|
||||
|
||||
KeSignalCallDpcSynchronize(SystemArgument2);
|
||||
KeSignalCallDpcDone(SystemArgument1);
|
||||
// ------------------------------------------------------------------------------
|
||||
// Synchronize the end of this routine with the caller
|
||||
//
|
||||
PlatformBroadcastSynchronizeEndOfRoutine(SystemArgument1, SystemArgument2);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -214,8 +217,11 @@ DpcRoutineDisablePt(KDPC * Dpc, PVOID DeferredContext, PVOID SystemArgument1, PV
|
|||
|
||||
PtStop();
|
||||
|
||||
KeSignalCallDpcSynchronize(SystemArgument2);
|
||||
KeSignalCallDpcDone(SystemArgument1);
|
||||
// ------------------------------------------------------------------------------
|
||||
// Synchronize the end of this routine with the caller
|
||||
//
|
||||
PlatformBroadcastSynchronizeEndOfRoutine(SystemArgument1, SystemArgument2);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -230,8 +236,11 @@ DpcRoutinePausePt(KDPC * Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOI
|
|||
|
||||
PtPause();
|
||||
|
||||
KeSignalCallDpcSynchronize(SystemArgument2);
|
||||
KeSignalCallDpcDone(SystemArgument1);
|
||||
// ------------------------------------------------------------------------------
|
||||
// Synchronize the end of this routine with the caller
|
||||
//
|
||||
PlatformBroadcastSynchronizeEndOfRoutine(SystemArgument1, SystemArgument2);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -246,8 +255,11 @@ DpcRoutineResumePt(KDPC * Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO
|
|||
|
||||
PtResume();
|
||||
|
||||
KeSignalCallDpcSynchronize(SystemArgument2);
|
||||
KeSignalCallDpcDone(SystemArgument1);
|
||||
// ------------------------------------------------------------------------------
|
||||
// Synchronize the end of this routine with the caller
|
||||
//
|
||||
PlatformBroadcastSynchronizeEndOfRoutine(SystemArgument1, SystemArgument2);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -269,8 +281,11 @@ DpcRoutineSizePt(KDPC * Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID
|
|||
if (Sizes != NULL && Core < PT_MAX_CPUS_FOR_MMAP)
|
||||
Sizes[Core] = PtSize();
|
||||
|
||||
KeSignalCallDpcSynchronize(SystemArgument2);
|
||||
KeSignalCallDpcDone(SystemArgument1);
|
||||
// ------------------------------------------------------------------------------
|
||||
// Synchronize the end of this routine with the caller
|
||||
//
|
||||
PlatformBroadcastSynchronizeEndOfRoutine(SystemArgument1, SystemArgument2);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -285,8 +300,11 @@ DpcRoutineDumpPt(KDPC * Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID
|
|||
|
||||
PtDump();
|
||||
|
||||
KeSignalCallDpcSynchronize(SystemArgument2);
|
||||
KeSignalCallDpcDone(SystemArgument1);
|
||||
// ------------------------------------------------------------------------------
|
||||
// Synchronize the end of this routine with the caller
|
||||
//
|
||||
PlatformBroadcastSynchronizeEndOfRoutine(SystemArgument1, SystemArgument2);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -301,15 +319,18 @@ DpcRoutineFlushPt(KDPC * Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOI
|
|||
|
||||
PtFlush();
|
||||
|
||||
KeSignalCallDpcSynchronize(SystemArgument2);
|
||||
KeSignalCallDpcDone(SystemArgument1);
|
||||
// ------------------------------------------------------------------------------
|
||||
// Synchronize the end of this routine with the caller
|
||||
//
|
||||
PlatformBroadcastSynchronizeEndOfRoutine(SystemArgument1, SystemArgument2);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Broadcast applying a PT filter to all cores.
|
||||
*
|
||||
* DeferredContext carries the PT_FILTER_OPTIONS * supplied by the
|
||||
* DeferredContext carries the PT_APPLY_CORE_FILTER_REQUEST * supplied by the
|
||||
* broadcaster; PtFilter writes the user-tunable fields into the
|
||||
* current CPU's per-CPU PT_TRACE_CONFIG and reprograms PT MSRs.
|
||||
*/
|
||||
|
|
@ -318,9 +339,12 @@ DpcRoutineFilterPt(KDPC * Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO
|
|||
{
|
||||
UNREFERENCED_PARAMETER(Dpc);
|
||||
|
||||
PtFilter((const PT_FILTER_OPTIONS *)DeferredContext);
|
||||
PtFilter((const PT_APPLY_CORE_FILTER_REQUEST *)DeferredContext);
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Synchronize the end of this routine with the caller
|
||||
//
|
||||
PlatformBroadcastSynchronizeEndOfRoutine(SystemArgument1, SystemArgument2);
|
||||
|
||||
KeSignalCallDpcSynchronize(SystemArgument2);
|
||||
KeSignalCallDpcDone(SystemArgument1);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -639,9 +639,9 @@ PtEngineStart(PT_PER_CPU * Cpu)
|
|||
if (g_RunningOnHypervisorEnvironment)
|
||||
{
|
||||
IsOnVmxRootMode = g_Callbacks.VmFuncVmxGetCurrentExecutionMode();
|
||||
LogInfo("PT: PtEngineStart on core %u (vmx-root=%u)\n",
|
||||
KeGetCurrentProcessorNumberEx(NULL),
|
||||
(UINT32)IsOnVmxRootMode);
|
||||
// LogInfo("PT: PtEngineStart on core %u (vmx-root=%u)\n",
|
||||
// KeGetCurrentProcessorNumberEx(NULL),
|
||||
// (UINT32)IsOnVmxRootMode);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -826,9 +826,9 @@ PtEngineStop(PT_PER_CPU * Cpu, PT_OUTPUT_BUFFER * Out)
|
|||
if (g_RunningOnHypervisorEnvironment)
|
||||
{
|
||||
IsOnVmxRootMode = g_Callbacks.VmFuncVmxGetCurrentExecutionMode();
|
||||
LogInfo("PT: PtEngineStop on core %u (vmx-root=%u)\n",
|
||||
KeGetCurrentProcessorNumberEx(NULL),
|
||||
(UINT32)IsOnVmxRootMode);
|
||||
// LogInfo("PT: PtEngineStop on core %u (vmx-root=%u)\n",
|
||||
// KeGetCurrentProcessorNumberEx(NULL),
|
||||
// (UINT32)IsOnVmxRootMode);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -1027,9 +1027,9 @@ PtCheck()
|
|||
|
||||
if (g_RunningOnHypervisorEnvironment && !Caps.VmxSupport)
|
||||
{
|
||||
LogInfo("PT: IA32_VMX_MISC[14] is clear — Intel PT in VMX is not "
|
||||
"advertised on this CPU. Direct MSR programming still works "
|
||||
"from VMX non-root because PT MSRs are not trapped.\n");
|
||||
// LogInfo("PT: IA32_VMX_MISC[14] is clear - Intel PT in VMX is not "
|
||||
// "advertised on this CPU. Direct MSR programming still works "
|
||||
// "from VMX non-root because PT MSRs are not trapped.\n");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
@ -1071,7 +1071,7 @@ PtAllocateAllCpuBuffers()
|
|||
|
||||
if (PtEngineAllocateBuffers(Cpu, &Cfg) != 0)
|
||||
{
|
||||
LogInfo("PT: buffer allocation failed on core %u\n", i);
|
||||
// LogInfo("PT: buffer allocation failed on core %u\n", i);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -1233,13 +1233,13 @@ PtStart()
|
|||
// Allocating from a DPC is unsafe (MmAllocateContiguousMemory* is
|
||||
// a paged routine) so just bail out.
|
||||
//
|
||||
LogInfo("PT: buffers not allocated for core %u\n", CurrentCore);
|
||||
// LogInfo("PT: buffers not allocated for core %u\n", CurrentCore);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (PtEngineStart(Cpu) != 0)
|
||||
{
|
||||
LogInfo("PT: PtEngineStart failed on core %u (state=%d)\n", CurrentCore, Cpu->State);
|
||||
// LogInfo("PT: PtEngineStart failed on core %u (state=%d)\n", CurrentCore, Cpu->State);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1263,7 +1263,7 @@ PtStop()
|
|||
CurrentCore = KeGetCurrentProcessorNumberEx(NULL);
|
||||
Cpu = &g_PtStateList[CurrentCore];
|
||||
|
||||
LogInfo("PT: stopping trace on core %d\n", CurrentCore);
|
||||
// LogInfo("PT: stopping trace on core %d\n", CurrentCore);
|
||||
|
||||
PtEngineStop(Cpu, NULL);
|
||||
}
|
||||
|
|
@ -1284,7 +1284,7 @@ PtPause()
|
|||
CurrentCore = KeGetCurrentProcessorNumberEx(NULL);
|
||||
Cpu = &g_PtStateList[CurrentCore];
|
||||
|
||||
LogInfo("PT: pausing trace on core %u\n", CurrentCore);
|
||||
// LogInfo("PT: pausing trace on core %u\n", CurrentCore);
|
||||
|
||||
PtEnginePause(Cpu);
|
||||
}
|
||||
|
|
@ -1304,7 +1304,7 @@ PtResume()
|
|||
CurrentCore = KeGetCurrentProcessorNumberEx(NULL);
|
||||
Cpu = &g_PtStateList[CurrentCore];
|
||||
|
||||
LogInfo("PT: resuming trace on core %u\n", CurrentCore);
|
||||
// LogInfo("PT: resuming trace on core %u\n", CurrentCore);
|
||||
|
||||
PtEngineResume(Cpu);
|
||||
}
|
||||
|
|
@ -1399,14 +1399,14 @@ PtDump()
|
|||
* handles that case before broadcasting.
|
||||
*/
|
||||
VOID
|
||||
PtFilter(const PT_FILTER_OPTIONS * FilterOptions)
|
||||
PtFilter(const PT_APPLY_CORE_FILTER_REQUEST * FilterRequest)
|
||||
{
|
||||
UINT32 CurrentCore;
|
||||
PT_PER_CPU * Cpu;
|
||||
UINT32 i;
|
||||
PT_CAPABILITIES Caps = {0};
|
||||
|
||||
if (g_PtStateList == NULL || FilterOptions == NULL)
|
||||
if (g_PtStateList == NULL || FilterRequest == NULL)
|
||||
return;
|
||||
|
||||
if (PtEngineQueryCapabilities(&Caps) != 0)
|
||||
|
|
@ -1415,7 +1415,7 @@ PtFilter(const PT_FILTER_OPTIONS * FilterOptions)
|
|||
CurrentCore = KeGetCurrentProcessorNumberEx(NULL);
|
||||
Cpu = &g_PtStateList[CurrentCore];
|
||||
|
||||
LogInfo("PT: applying filter on core %u\n", CurrentCore);
|
||||
// LogInfo("PT: applying filter on core %u\n", CurrentCore);
|
||||
|
||||
//
|
||||
// Stop tracing on this CPU first so we can safely mutate Cpu->Config
|
||||
|
|
@ -1429,42 +1429,42 @@ PtFilter(const PT_FILTER_OPTIONS * FilterOptions)
|
|||
//
|
||||
// Apply only the user-tunable fields to this CPU's per-CPU config.
|
||||
//
|
||||
Cpu->Config.TraceUser = FilterOptions->TraceUser;
|
||||
Cpu->Config.TraceKernel = FilterOptions->TraceKernel;
|
||||
Cpu->Config.TraceUser = (BOOLEAN)FilterRequest->FilterOptions.TraceUser;
|
||||
Cpu->Config.TraceKernel = (BOOLEAN)FilterRequest->FilterOptions.TraceKernel;
|
||||
|
||||
if (FilterOptions->TargetCr3 != 0 && !Caps.Cr3Filtering)
|
||||
if (FilterRequest->EnableOptions.Cr3 != 0 && !Caps.Cr3Filtering)
|
||||
{
|
||||
LogInfo("PT: CR3 filtering requested but not supported by CPU\n");
|
||||
// LogInfo("PT: CR3 filtering requested but not supported by CPU\n");
|
||||
Cpu->Config.TargetCr3 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cpu->Config.TargetCr3 = FilterOptions->TargetCr3;
|
||||
Cpu->Config.TargetCr3 = FilterRequest->EnableOptions.Cr3;
|
||||
}
|
||||
|
||||
if (FilterOptions->NumAddrRanges > Caps.NumAddrRanges)
|
||||
if (FilterRequest->FilterOptions.NumAddrRanges > Caps.NumAddrRanges)
|
||||
{
|
||||
LogInfo("PT: requested %u IP filter ranges, but CPU only supports %u\n", FilterOptions->NumAddrRanges, Caps.NumAddrRanges);
|
||||
// LogInfo("PT: requested %u IP filter ranges, but CPU only supports %u\n", FilterRequest->FilterOptions.NumAddrRanges, Caps.NumAddrRanges);
|
||||
Cpu->Config.NumAddrRanges = Caps.NumAddrRanges;
|
||||
}
|
||||
else if (FilterOptions->NumAddrRanges > 0 && !Caps.IpFiltering)
|
||||
else if (FilterRequest->FilterOptions.NumAddrRanges > 0 && !Caps.IpFiltering)
|
||||
{
|
||||
LogInfo("PT: IP filtering requested but not supported by CPU\n");
|
||||
// LogInfo("PT: IP filtering requested but not supported by CPU\n");
|
||||
Cpu->Config.NumAddrRanges = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cpu->Config.NumAddrRanges = FilterOptions->NumAddrRanges;
|
||||
Cpu->Config.NumAddrRanges = FilterRequest->FilterOptions.NumAddrRanges;
|
||||
}
|
||||
|
||||
if (FilterOptions->BufferSize != 0)
|
||||
if (FilterRequest->BufferSize != 0)
|
||||
{
|
||||
Cpu->Config.BufferSize = FilterOptions->BufferSize;
|
||||
Cpu->Config.BufferSize = FilterRequest->BufferSize;
|
||||
}
|
||||
|
||||
for (i = 0; i < PT_MAX_ADDR_RANGES; i++)
|
||||
{
|
||||
Cpu->Config.AddrRanges[i] = FilterOptions->AddrRanges[i];
|
||||
Cpu->Config.AddrRanges[i] = FilterRequest->FilterOptions.AddrRanges[i];
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -1499,7 +1499,7 @@ PtFlush()
|
|||
CurrentCore = KeGetCurrentProcessorNumberEx(NULL);
|
||||
Cpu = &g_PtStateList[CurrentCore];
|
||||
|
||||
LogInfo("PT: flush on core %u\n", CurrentCore);
|
||||
// LogInfo("PT: flush on core %u\n", CurrentCore);
|
||||
|
||||
if (Cpu->State == PT_STATE_TRACING || Cpu->State == PT_STATE_PAUSED)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,4 +50,4 @@ VOID
|
|||
BroadcastFlushPtOnAllCores();
|
||||
|
||||
VOID
|
||||
BroadcastFilterPtOnAllCores(PT_FILTER_OPTIONS * FilterOptions);
|
||||
BroadcastFilterPtOnAllCores(PT_APPLY_CORE_FILTER_REQUEST * FilterRequest);
|
||||
|
|
|
|||
|
|
@ -12,42 +12,10 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Constants //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Pool tag for PT contiguous allocations (ASCII "PtHd")
|
||||
//
|
||||
#define POOL_TAG_PT 'dHtP'
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Structures //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @brief Narrow input descriptor for PtFilter.
|
||||
*
|
||||
* These are the only fields a caller is allowed to set per-CPU
|
||||
* when reconfiguring an active PT trace. Engine-internal options
|
||||
* (BranchEn, TscEn, MtcEn, CycEn, RetCompression, *Freq, etc.)
|
||||
* stay under the engine's control and are NOT exposed here.
|
||||
*
|
||||
* BufferSize == 0 means "keep whatever the per-CPU slot already
|
||||
* has" — pure filter changes don't touch the ToPA / output /
|
||||
* overflow buffers and can run from a DPC.
|
||||
*/
|
||||
typedef struct _PT_FILTER_OPTIONS
|
||||
{
|
||||
BOOLEAN TraceUser;
|
||||
BOOLEAN TraceKernel;
|
||||
UINT64 TargetCr3;
|
||||
UINT64 BufferSize;
|
||||
UINT32 NumAddrRanges;
|
||||
PT_ADDR_RANGE AddrRanges[PT_MAX_ADDR_RANGES];
|
||||
|
||||
} PT_FILTER_OPTIONS, *PPT_FILTER_OPTIONS;
|
||||
|
||||
/**
|
||||
* @brief Per-CPU bookkeeping for the user-mode mmap surface.
|
||||
*
|
||||
|
|
@ -63,6 +31,17 @@ typedef struct _PT_USER_MAPPING
|
|||
|
||||
} PT_USER_MAPPING, *PPT_USER_MAPPING;
|
||||
|
||||
/**
|
||||
* @brief PT apply core filter requests.
|
||||
*/
|
||||
typedef struct _PT_APPLY_CORE_FILTER_REQUEST
|
||||
{
|
||||
PT_FILTER_OPTIONS FilterOptions;
|
||||
PT_ENABLE_OPTIONS EnableOptions;
|
||||
UINT64 BufferSize; /* Output buffer size (0 = default / PT_DEFAULT_BUFFER_SIZE) */
|
||||
|
||||
} PT_APPLY_CORE_FILTER_REQUEST, *PPT_APPLY_CORE_FILTER_REQUEST;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Functions //
|
||||
//////////////////////////////////////////////////
|
||||
|
|
@ -97,14 +76,14 @@ PtFlush();
|
|||
|
||||
//
|
||||
// LBR-style filter wrapper, one CPU at a time. Mirrors LbrFilter in shape:
|
||||
// caller passes a PT_FILTER_OPTIONS describing only the user-tunable bits
|
||||
// caller passes a PT_APPLY_CORE_FILTER_REQUEST describing only the user-tunable bits
|
||||
// (TraceUser, TraceKernel, TargetCr3, BufferSize, NumAddrRanges, AddrRanges),
|
||||
// and PtFilter handles the stop / config-update / start sequence on the
|
||||
// CURRENT CPU. Engine-internal config (BranchEn, TscEn, etc.) is left
|
||||
// untouched in the per-CPU PT_TRACE_CONFIG.
|
||||
//
|
||||
VOID
|
||||
PtFilter(const PT_FILTER_OPTIONS * FilterOptions);
|
||||
PtFilter(const PT_APPLY_CORE_FILTER_REQUEST * FilterRequest);
|
||||
|
||||
//
|
||||
// PASSIVE_LEVEL helpers — call before / after the per-core DPC broadcasts.
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@
|
|||
//////////////////////////////////////////////////
|
||||
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 20
|
||||
#define VERSION_MINOR 21
|
||||
#define VERSION_PATCH 0
|
||||
|
||||
#define BETA_VERSION TRUE
|
||||
#define BETA_VERSION FALSE
|
||||
|
||||
//
|
||||
// Example of __DATE__ string: "Jul 27 2012"
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@
|
|||
//////////////////////////////////////////////////
|
||||
|
||||
#define PT_PAGE_SIZE 0x1000ULL /* 4 KB */
|
||||
#define PT_DEFAULT_BUFFER_SIZE 0x200000ULL /* 2 MB */
|
||||
#define PT_OVERFLOW_SIZE PT_PAGE_SIZE /* 4 KB overflow landing zone */
|
||||
#define PT_MAX_ADDR_RANGES 4
|
||||
|
||||
|
|
|
|||
|
|
@ -1356,27 +1356,78 @@ typedef enum _HYPERTRACE_PT_OPERATION_REQUEST_TYPE
|
|||
HYPERTRACE_PT_OPERATION_REQUEST_TYPE_PAUSE,
|
||||
HYPERTRACE_PT_OPERATION_REQUEST_TYPE_RESUME,
|
||||
HYPERTRACE_PT_OPERATION_REQUEST_TYPE_SIZE,
|
||||
HYPERTRACE_PT_OPERATION_REQUEST_TYPE_DUMP,
|
||||
HYPERTRACE_PT_OPERATION_REQUEST_TYPE_FLUSH,
|
||||
HYPERTRACE_PT_OPERATION_REQUEST_TYPE_DUMP,
|
||||
HYPERTRACE_PT_OPERATION_REQUEST_TYPE_FILTER,
|
||||
HYPERTRACE_PT_OPERATION_REQUEST_TYPE_PACKET,
|
||||
|
||||
} HYPERTRACE_PT_OPERATION_REQUEST_TYPE;
|
||||
|
||||
/**
|
||||
* @brief The maximum buffer size for PT
|
||||
*
|
||||
*/
|
||||
#define PT_DEFAULT_BUFFER_SIZE 0x200000 // 2 MB
|
||||
|
||||
/**
|
||||
* @brief The default core for PT
|
||||
*
|
||||
*/
|
||||
#define PT_DEFAULT_PINNING_CORE 0x0 // 0th core
|
||||
|
||||
/**
|
||||
* @brief PT enable options structure
|
||||
*
|
||||
*/
|
||||
typedef struct _PT_ENABLE_OPTIONS
|
||||
{
|
||||
UINT32 EnableByCr3 : 1; // Enable by CR3
|
||||
UINT32 EnableByPid : 1; // Enable by PID
|
||||
UINT32 EnableByTid : 1; // Enable by TID
|
||||
UINT32 EnableByPname : 1; // Enable by process name
|
||||
|
||||
UINT32 Pid;
|
||||
UINT32 Tid;
|
||||
UINT64 Cr3;
|
||||
CHAR ProcessName[256];
|
||||
|
||||
} PT_ENABLE_OPTIONS, *PPT_ENABLE_OPTIONS;
|
||||
|
||||
/**
|
||||
* @brief PT filter options structure
|
||||
*
|
||||
*/
|
||||
typedef struct _PT_FILTER_OPTIONS
|
||||
{
|
||||
UINT32 TraceUser : 1; // Trace user mode
|
||||
UINT32 TraceKernel : 1; // Trace kernel mode
|
||||
|
||||
UINT8 NumAddrRanges; /* Number of valid AddrRanges entries */
|
||||
PT_ADDR_RANGE AddrRanges[PT_MAX_ADDR_RANGES]; // Address ranges to filter by
|
||||
|
||||
} PT_FILTER_OPTIONS, *PPT_FILTER_OPTIONS;
|
||||
|
||||
/**
|
||||
* @brief PT packet options structure
|
||||
*
|
||||
*/
|
||||
typedef struct _PT_PACKET_OPTIONS
|
||||
{
|
||||
UINT32 PSB : 1; // PSB packet
|
||||
UINT32 PIP : 1; // PIP packet
|
||||
UINT32 TSC : 1; // TSC packet
|
||||
UINT32 MTC : 1; // MTC packet
|
||||
UINT32 CYC : 1; // CYC packet
|
||||
UINT32 TNT : 1; // TNT packet
|
||||
UINT32 TIP : 1; // TIP packet
|
||||
UINT32 FUP : 1; // FUP packet
|
||||
UINT32 MODE : 1; // MODE packet
|
||||
|
||||
} PT_PACKET_OPTIONS, *PPT_PACKET_OPTIONS;
|
||||
|
||||
/**
|
||||
* @brief The structure of HyperTrace PT result packet in HyperDbg
|
||||
*
|
||||
* Configuration fields (TraceUser/TraceKernel/TargetCr3/BufferSize/
|
||||
* NumAddrRanges/AddrRanges) are populated by the caller for ENABLE
|
||||
* and FILTER operations. For other operations they are ignored.
|
||||
*
|
||||
* BufferSize must be a power of two multiple of 4 KB (4KB ... 128MB).
|
||||
* Pass 0 to keep the existing per-CPU value (default 2 MB on first
|
||||
* enable).
|
||||
*
|
||||
* For SIZE operations the kernel fills NumCpus and BytesPerCpu[]
|
||||
* with each CPU's current PT output position, i.e. how many bytes
|
||||
* of valid trace data are currently sitting in that CPU's main +
|
||||
* overflow buffer; the rest of the packet is unused on output.
|
||||
*/
|
||||
typedef struct _HYPERTRACE_PT_OPERATION_PACKETS
|
||||
{
|
||||
|
|
@ -1384,23 +1435,26 @@ typedef struct _HYPERTRACE_PT_OPERATION_PACKETS
|
|||
UINT32 KernelStatus;
|
||||
|
||||
//
|
||||
// Filter / config (used by FILTER and ENABLE)
|
||||
// Enable
|
||||
//
|
||||
UINT32 TraceUser; /* Boolean: trace CPL > 0 */
|
||||
UINT32 TraceKernel; /* Boolean: trace CPL == 0 */
|
||||
UINT64 TargetCr3; /* CR3 to filter by (0 = no filter) */
|
||||
UINT64 BufferSize; /* Output buffer size (0 = keep current) */
|
||||
UINT32 NumAddrRanges; /* Number of valid AddrRanges entries */
|
||||
UINT32 TargetProcessId; /* Process to trace; kernel resolves it
|
||||
to TargetCr3 when TargetCr3 == 0
|
||||
(0 = no PID-based CR3 filter) */
|
||||
PT_ADDR_RANGE AddrRanges[PT_MAX_ADDR_RANGES];
|
||||
UINT64 BufferSize; /* Output buffer size (0 = default / PT_DEFAULT_BUFFER_SIZE) */
|
||||
PT_ENABLE_OPTIONS EnableOptions; /* Options for enabling PT (CPL, CR3, PID, TID, Pname) */
|
||||
UINT32 CoreId; /* Core ID for running (pinning) process/thread */
|
||||
|
||||
//
|
||||
// SIZE output: per-CPU bytes-written snapshot
|
||||
// Filter
|
||||
//
|
||||
UINT32 NumCpus; /* CPUs populated in BytesPerCpu */
|
||||
UINT32 Reserved2; /* Padding to 8-align the array */
|
||||
PT_FILTER_OPTIONS FilterOptions; /* Options for filtering PT (CPL, AddrRanges) */
|
||||
|
||||
//
|
||||
// Packet
|
||||
//
|
||||
PT_PACKET_OPTIONS PacketOptions; /* Options for PT packets */
|
||||
|
||||
//
|
||||
// Size
|
||||
//
|
||||
UINT32 NumCpus; /* CPUs populated in BytesPerCpu */
|
||||
UINT64 BytesPerCpu[PT_MAX_CPUS_FOR_MMAP];
|
||||
|
||||
} HYPERTRACE_PT_OPERATION_PACKETS, *PHYPERTRACE_PT_OPERATION_PACKETS;
|
||||
|
|
|
|||
33
hyperdbg/include/SDK/imports/kernel/HyperDbgHyperPerf.h
Normal file
33
hyperdbg/include/SDK/imports/kernel/HyperDbgHyperPerf.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* @file HyperDbgHyperPerf.h
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief Headers relating exported functions from hyperperf (pmu) module
|
||||
* @version 0.21
|
||||
* @date 2026-06-22
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef HYPERDBG_HYPERPERF
|
||||
# define IMPORT_EXPORT_HYPERPERF __declspec(dllexport)
|
||||
#else
|
||||
# define IMPORT_EXPORT_HYPERPERF __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// HyperPerf Functions //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Initialize the hyperperf module with the provided callbacks
|
||||
//
|
||||
IMPORT_EXPORT_HYPERPERF BOOLEAN
|
||||
HyperPerfInitCallback(HYPERPERF_CALLBACKS * HyperPerfCallbacks, BOOLEAN RunningOnHypervisorEnvironment);
|
||||
|
||||
//
|
||||
// Uninitialize the HyperPerf module
|
||||
//
|
||||
IMPORT_EXPORT_HYPERPERF VOID
|
||||
HyperPerfUninit();
|
||||
|
|
@ -49,6 +49,9 @@ hyperdbg_u_get_processor_vendor();
|
|||
//
|
||||
// All Modules
|
||||
//
|
||||
IMPORT_EXPORT_LIBHYPERDBG BOOLEAN
|
||||
hyperdbg_u_is_any_module_loaded();
|
||||
|
||||
IMPORT_EXPORT_LIBHYPERDBG INT
|
||||
hyperdbg_u_load_all_modules();
|
||||
|
||||
|
|
|
|||
80
hyperdbg/include/SDK/modules/HyperPerf.h
Normal file
80
hyperdbg/include/SDK/modules/HyperPerf.h
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* @file HyperPerf.h
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief HyperDbg's SDK for hyperperf project
|
||||
* @details This file contains definitions of HyperPerf routines
|
||||
* @version 0.21
|
||||
* @date 2026-06-22
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Callback Types //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @brief A function from the message tracer that send the inputs to the
|
||||
* queue of the messages
|
||||
*
|
||||
*/
|
||||
typedef BOOLEAN (*LOG_CALLBACK_PREPARE_AND_SEND_MESSAGE_TO_QUEUE)(UINT32 OperationCode,
|
||||
BOOLEAN IsImmediateMessage,
|
||||
BOOLEAN ShowCurrentSystemTime,
|
||||
BOOLEAN Priority,
|
||||
const CHAR * Fmt,
|
||||
va_list ArgList);
|
||||
|
||||
/**
|
||||
* @brief A function that sends the messages to message tracer buffers
|
||||
*
|
||||
*/
|
||||
typedef BOOLEAN (*LOG_CALLBACK_SEND_MESSAGE_TO_QUEUE)(UINT32 OperationCode, BOOLEAN IsImmediateMessage, CHAR * LogMessage, UINT32 BufferLen, BOOLEAN Priority);
|
||||
|
||||
/**
|
||||
* @brief A function that sends the messages to message tracer buffers
|
||||
*
|
||||
*/
|
||||
typedef BOOLEAN (*LOG_CALLBACK_SEND_BUFFER)(_In_ UINT32 OperationCode,
|
||||
_In_reads_bytes_(BufferLength) PVOID Buffer,
|
||||
_In_ UINT32 BufferLength,
|
||||
_In_ BOOLEAN Priority);
|
||||
|
||||
/**
|
||||
* @brief A function that checks whether the priority or regular buffer is full or not
|
||||
*
|
||||
*/
|
||||
typedef BOOLEAN (*LOG_CALLBACK_CHECK_IF_BUFFER_IS_FULL)(BOOLEAN Priority);
|
||||
|
||||
/**
|
||||
* @brief A function that checks whether the current execution mode is VMX-root mode or not
|
||||
*
|
||||
*/
|
||||
typedef BOOLEAN (*VM_FUNC_VMX_GET_CURRENT_EXECUTION_MODE)();
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Callback Structure //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @brief Prototype of each function needed by hyperperf module
|
||||
*
|
||||
*/
|
||||
typedef struct _HYPERPERF_CALLBACKS
|
||||
{
|
||||
//
|
||||
// *** Log (Hyperlog) callbacks ***
|
||||
//
|
||||
LOG_CALLBACK_PREPARE_AND_SEND_MESSAGE_TO_QUEUE LogCallbackPrepareAndSendMessageToQueueWrapper;
|
||||
LOG_CALLBACK_SEND_MESSAGE_TO_QUEUE LogCallbackSendMessageToQueue;
|
||||
LOG_CALLBACK_SEND_BUFFER LogCallbackSendBuffer;
|
||||
LOG_CALLBACK_CHECK_IF_BUFFER_IS_FULL LogCallbackCheckIfBufferIsFull;
|
||||
|
||||
//
|
||||
// *** Hypervisor (Hyperhv) callbacks ***
|
||||
//
|
||||
VM_FUNC_VMX_GET_CURRENT_EXECUTION_MODE VmFuncVmxGetCurrentExecutionMode;
|
||||
|
||||
} HYPERPERF_CALLBACKS, *PHYPERPERF_CALLBACKS;
|
||||
|
|
@ -595,6 +595,29 @@ HyperDbgUnloadKd()
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief check if any module is loaded (KD, VMM, HyperTrace, etc.)
|
||||
*
|
||||
* @return BOOLEAN return TRUE if any module is loaded, otherwise return FALSE
|
||||
*/
|
||||
BOOLEAN
|
||||
HyperDbgIsAnyModuleLoaded()
|
||||
{
|
||||
INT RetVal = 0;
|
||||
|
||||
//
|
||||
// Check if any module is loaded (KD, VMM, HyperTrace, etc.)
|
||||
//
|
||||
if (g_IsKdModuleLoaded || g_IsVmmModuleLoaded || g_IsHyperTraceModuleLoaded)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief unload all modules (KD, VMM, HyperTrace, etc.)
|
||||
*
|
||||
|
|
@ -654,6 +677,18 @@ HyperDbgLoadKdModule()
|
|||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Enable Debug privilege to the current token
|
||||
//
|
||||
if (!WindowsSetDebugPrivilege())
|
||||
{
|
||||
ShowMessages("err, couldn't set debug privilege\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Create handle from the KD module
|
||||
//
|
||||
if (HyperDbgCreateHandleFromKdModule() == 1)
|
||||
{
|
||||
//
|
||||
|
|
@ -740,15 +775,6 @@ HyperDbgLoadVmmModule()
|
|||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Enable Debug privilege to the current token
|
||||
//
|
||||
if (!WindowsSetDebugPrivilege())
|
||||
{
|
||||
ShowMessages("err, couldn't set debug privilege\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if the processor is a genuine Intel processor (required for VT-x)
|
||||
//
|
||||
|
|
|
|||
|
|
@ -167,6 +167,15 @@ CommandUnload(vector<CommandToken> CommandTokens, string Command)
|
|||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if any module is loaded
|
||||
//
|
||||
if (!HyperDbgIsAnyModuleLoaded())
|
||||
{
|
||||
ShowMessages("no module is loaded\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ShowMessages("unloading all modules\n");
|
||||
|
||||
//
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
432
hyperdbg/libhyperdbg/code/debugger/misc/pt-helper.cpp
Normal file
432
hyperdbg/libhyperdbg/code/debugger/misc/pt-helper.cpp
Normal file
|
|
@ -0,0 +1,432 @@
|
|||
/**
|
||||
* @file pt-help.cpp
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief PT helper functions
|
||||
* @details
|
||||
* @version 0.21
|
||||
* @date 2026-07-03
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
|
||||
/**
|
||||
* @brief Read the process image for PT decoding
|
||||
*
|
||||
* @param Buffer
|
||||
* @param Size
|
||||
* @param Asid
|
||||
* @param Ip
|
||||
* @param Context
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int
|
||||
PtHelperReadImage(UINT8 * Buffer, SIZE_T Size, const struct pt_asid * Asid, UINT64 Ip, VOID * Context)
|
||||
{
|
||||
(VOID) Asid;
|
||||
|
||||
IMAGE_SYMBOL_CONTEXT * Ctx = (IMAGE_SYMBOL_CONTEXT *)Context;
|
||||
|
||||
if (Ctx == NULL || Ctx->Code == NULL || Ip < Ctx->CodeBase || Ip >= Ctx->CodeBase + Ctx->CodeSize)
|
||||
return -pte_nomap;
|
||||
|
||||
UINT64 Available = Ctx->CodeBase + Ctx->CodeSize - Ip;
|
||||
SIZE_T Count = (Size < Available) ? Size : (SIZE_T)Available;
|
||||
|
||||
memcpy(Buffer, Ctx->Code + (Ip - Ctx->CodeBase), Count);
|
||||
return (int)Count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Capture the .text section of a process image
|
||||
*
|
||||
* @param Process
|
||||
* @param TextStart
|
||||
* @param TextEnd
|
||||
* @param Ctx
|
||||
*
|
||||
* @return BOOLEAN
|
||||
*/
|
||||
BOOLEAN
|
||||
PtHelperCaptureImage(HANDLE Process, UINT64 * TextStart, UINT64 * TextEnd, IMAGE_SYMBOL_CONTEXT * Ctx)
|
||||
{
|
||||
HMODULE Ntdll = GetModuleHandleA("ntdll.dll");
|
||||
PFN_NT_QIP NtQip = Ntdll ? (PFN_NT_QIP)GetProcAddress(Ntdll, "NtQueryInformationProcess") : NULL;
|
||||
PROC_BASIC_INFO Pbi = {0};
|
||||
ULONG Ret = 0;
|
||||
SIZE_T Got = 0;
|
||||
UINT64 Base = 0;
|
||||
IMAGE_DOS_HEADER Dos;
|
||||
IMAGE_NT_HEADERS64 Nt;
|
||||
UINT64 SectionBase;
|
||||
|
||||
if (NtQip == NULL || NtQip(Process, 0, &Pbi, sizeof(Pbi), &Ret) < 0 || Pbi.PebBaseAddress == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!ReadProcessMemory(Process, (PBYTE)Pbi.PebBaseAddress + 0x10, &Base, sizeof(Base), &Got) || Base == 0)
|
||||
return FALSE;
|
||||
|
||||
if (!ReadProcessMemory(Process, (PVOID)Base, &Dos, sizeof(Dos), &Got) || Dos.e_magic != IMAGE_DOS_SIGNATURE)
|
||||
return FALSE;
|
||||
|
||||
if (!ReadProcessMemory(Process, (PBYTE)Base + Dos.e_lfanew, &Nt, sizeof(Nt), &Got) || Nt.Signature != IMAGE_NT_SIGNATURE)
|
||||
return FALSE;
|
||||
|
||||
Ctx->ImageBase = Base;
|
||||
SectionBase = Base + Dos.e_lfanew + FIELD_OFFSET(IMAGE_NT_HEADERS64, OptionalHeader) + Nt.FileHeader.SizeOfOptionalHeader;
|
||||
|
||||
for (WORD i = 0; i < Nt.FileHeader.NumberOfSections; i++)
|
||||
{
|
||||
IMAGE_SECTION_HEADER Section;
|
||||
|
||||
if (!ReadProcessMemory(Process, (PBYTE)SectionBase + (UINT64)i * sizeof(Section), &Section, sizeof(Section), &Got))
|
||||
return FALSE;
|
||||
|
||||
if (memcmp(Section.Name, ".text", 6) != 0)
|
||||
continue;
|
||||
|
||||
UINT64 Start = Base + Section.VirtualAddress;
|
||||
UINT64 Size = Section.Misc.VirtualSize ? Section.Misc.VirtualSize : Section.SizeOfRawData;
|
||||
|
||||
if (Size == 0)
|
||||
return FALSE;
|
||||
|
||||
Ctx->Code = (UINT8 *)malloc((SIZE_T)Size);
|
||||
if (Ctx->Code == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!ReadProcessMemory(Process, (PVOID)Start, Ctx->Code, (SIZE_T)Size, &Got) || Got != Size)
|
||||
{
|
||||
free(Ctx->Code);
|
||||
Ctx->Code = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Ctx->CodeBase = Start;
|
||||
Ctx->CodeSize = Size;
|
||||
*TextStart = Start;
|
||||
*TextEnd = Start + Size - 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Resolve function address using symbol information
|
||||
*
|
||||
* @param Process
|
||||
* @param Path
|
||||
* @param Name
|
||||
* @param ImageBase
|
||||
* @param Start
|
||||
* @param End
|
||||
*
|
||||
* @return BOOLEAN
|
||||
*/
|
||||
BOOLEAN
|
||||
PtHelperResolveFunction(HANDLE Process, const CHAR * Path, const CHAR * Name, UINT64 ImageBase, UINT64 * Start, UINT64 * End)
|
||||
{
|
||||
union
|
||||
{
|
||||
SYMBOL_INFO Info;
|
||||
BYTE Buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
|
||||
} Symbol = {0};
|
||||
BOOLEAN Ok = FALSE;
|
||||
|
||||
SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS);
|
||||
if (!SymInitialize(Process, NULL, FALSE))
|
||||
return FALSE;
|
||||
|
||||
if (SymLoadModuleEx(Process, NULL, Path, NULL, (DWORD64)ImageBase, 0, NULL, 0) != 0)
|
||||
{
|
||||
Symbol.Info.SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||
Symbol.Info.MaxNameLen = MAX_SYM_NAME;
|
||||
|
||||
if (SymFromName(Process, Name, &Symbol.Info) && Symbol.Info.Address != 0)
|
||||
{
|
||||
*Start = Symbol.Info.Address;
|
||||
*End = Symbol.Info.Address + (Symbol.Info.Size ? Symbol.Info.Size : 0x200) - 1;
|
||||
Ok = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
SymCleanup(Process);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get PT packet name
|
||||
*
|
||||
* @param Type
|
||||
*
|
||||
* @return const CHAR *
|
||||
*/
|
||||
const CHAR *
|
||||
PtHelperPacketName(enum pt_packet_type Type)
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case ppt_psb:
|
||||
return "PSB";
|
||||
case ppt_psbend:
|
||||
return "PSBEND";
|
||||
case ppt_pad:
|
||||
return "PAD";
|
||||
case ppt_fup:
|
||||
return "FUP";
|
||||
case ppt_tip:
|
||||
return "TIP";
|
||||
case ppt_tip_pge:
|
||||
return "TIP.PGE";
|
||||
case ppt_tip_pgd:
|
||||
return "TIP.PGD";
|
||||
case ppt_tnt_8:
|
||||
return "TNT8";
|
||||
case ppt_tnt_64:
|
||||
return "TNT64";
|
||||
case ppt_mode:
|
||||
return "MODE";
|
||||
case ppt_pip:
|
||||
return "PIP";
|
||||
case ppt_vmcs:
|
||||
return "VMCS";
|
||||
case ppt_cbr:
|
||||
return "CBR";
|
||||
case ppt_tsc:
|
||||
return "TSC";
|
||||
case ppt_tma:
|
||||
return "TMA";
|
||||
case ppt_mtc:
|
||||
return "MTC";
|
||||
case ppt_cyc:
|
||||
return "CYC";
|
||||
case ppt_ovf:
|
||||
return "OVF";
|
||||
case ppt_stop:
|
||||
return "STOP";
|
||||
case ppt_exstop:
|
||||
return "EXSTOP";
|
||||
case ppt_mnt:
|
||||
return "MNT";
|
||||
case ppt_ptw:
|
||||
return "PTW";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reconstruct IP from PT packet
|
||||
*
|
||||
* @param Packet
|
||||
* @param LastIp
|
||||
*
|
||||
* @return UINT64
|
||||
*/
|
||||
UINT64
|
||||
PtHelperReconstructIp(const struct pt_packet_ip * Packet, UINT64 * LastIp)
|
||||
{
|
||||
UINT64 Value = *LastIp;
|
||||
|
||||
switch (Packet->ipc)
|
||||
{
|
||||
case pt_ipc_update_16:
|
||||
Value = (Value & ~0xffffull) | (Packet->ip & 0xffffull);
|
||||
break;
|
||||
case pt_ipc_update_32:
|
||||
Value = (Value & ~0xffffffffull) | (Packet->ip & 0xffffffffull);
|
||||
break;
|
||||
case pt_ipc_update_48:
|
||||
Value = (Value & ~0xffffffffffffull) | (Packet->ip & 0xffffffffffffull);
|
||||
break;
|
||||
case pt_ipc_sext_48:
|
||||
Value = Packet->ip & 0xffffffffffffull;
|
||||
if (Value & 0x800000000000ull)
|
||||
Value |= 0xffff000000000000ull;
|
||||
break;
|
||||
default:
|
||||
Value = Packet->ip;
|
||||
break;
|
||||
}
|
||||
|
||||
*LastIp = Value;
|
||||
return Value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode PT packets
|
||||
*
|
||||
* @param Cpu
|
||||
* @param Buffer
|
||||
* @param Size
|
||||
* @param ImageBase
|
||||
*
|
||||
* @return UINT64
|
||||
*/
|
||||
UINT64
|
||||
PtHelperDecodeCorePackets(UINT32 Cpu, const UINT8 * Buffer, UINT64 Size, UINT64 ImageBase)
|
||||
{
|
||||
struct pt_config Config;
|
||||
struct pt_packet_decoder * Decoder;
|
||||
UINT64 Count = 0;
|
||||
UINT64 LastIp = 0;
|
||||
int Status;
|
||||
|
||||
pt_config_init(&Config);
|
||||
Config.begin = (UINT8 *)Buffer;
|
||||
Config.end = (UINT8 *)Buffer + Size;
|
||||
|
||||
Decoder = pt_pkt_alloc_decoder(&Config);
|
||||
if (Decoder == NULL)
|
||||
{
|
||||
ShowMessages("[-] core %u: cannot allocate packet decoder\n", Cpu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
Status = pt_pkt_sync_forward(Decoder);
|
||||
if (Status < 0)
|
||||
break;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
struct pt_packet Packet;
|
||||
|
||||
Status = pt_pkt_next(Decoder, &Packet, sizeof(Packet));
|
||||
if (Status < 0)
|
||||
break;
|
||||
|
||||
Count++;
|
||||
|
||||
switch (Packet.type)
|
||||
{
|
||||
case ppt_tnt_8:
|
||||
case ppt_tnt_64:
|
||||
ShowMessages(" %-8s %2u ", PtHelperPacketName(Packet.type), Packet.payload.tnt.bit_size);
|
||||
for (UINT8 Bit = 0; Bit < Packet.payload.tnt.bit_size && Bit < 64; Bit++)
|
||||
putchar(((Packet.payload.tnt.payload >> (Packet.payload.tnt.bit_size - 1 - Bit)) & 1) ? 'T' : 'N');
|
||||
putchar('\n');
|
||||
break;
|
||||
|
||||
case ppt_tip:
|
||||
case ppt_fup:
|
||||
case ppt_tip_pge:
|
||||
case ppt_tip_pgd:
|
||||
if (Packet.payload.ip.ipc == pt_ipc_suppressed)
|
||||
ShowMessages(" %-8s (ip suppressed)\n", PtHelperPacketName(Packet.type));
|
||||
else
|
||||
{
|
||||
UINT64 Ip = PtHelperReconstructIp(&Packet.payload.ip, &LastIp);
|
||||
ShowMessages(" %-8s 0x%016llx exe+0x%llx\n",
|
||||
PtHelperPacketName(Packet.type),
|
||||
(UINT64)Ip,
|
||||
(UINT64)(Ip - ImageBase));
|
||||
}
|
||||
break;
|
||||
|
||||
case ppt_pip:
|
||||
ShowMessages(" %-8s cr3=0x%llx\n", PtHelperPacketName(Packet.type), (UINT64)Packet.payload.pip.cr3);
|
||||
break;
|
||||
|
||||
case ppt_cbr:
|
||||
// ShowMessages(" %-8s ratio=%u\n", PtHelperPacketName(Packet.type), Packet.payload.cbr.ratio);
|
||||
break;
|
||||
|
||||
case ppt_tsc:
|
||||
ShowMessages(" %-8s tsc=0x%llx\n", PtHelperPacketName(Packet.type), (UINT64)Packet.payload.tsc.tsc);
|
||||
break;
|
||||
|
||||
default:
|
||||
// ShowMessages(" %-8s\n", PtHelperPacketName(Packet.type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pt_pkt_free_decoder(Decoder);
|
||||
return Count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode PT instructions
|
||||
*
|
||||
* @param Cpu
|
||||
* @param Buffer
|
||||
* @param Size
|
||||
* @param Ctx
|
||||
*
|
||||
* @return UINT64
|
||||
*/
|
||||
UINT64
|
||||
PtHelperDecodeCore(UINT32 Cpu, const UINT8 * Buffer, UINT64 Size, IMAGE_SYMBOL_CONTEXT * Ctx)
|
||||
{
|
||||
struct pt_config Config;
|
||||
struct pt_insn_decoder * Decoder;
|
||||
struct pt_image * Image;
|
||||
UINT64 Count = 0;
|
||||
int Status;
|
||||
|
||||
pt_config_init(&Config);
|
||||
Config.begin = (UINT8 *)Buffer;
|
||||
Config.end = (UINT8 *)Buffer + Size;
|
||||
|
||||
Decoder = pt_insn_alloc_decoder(&Config);
|
||||
if (Decoder == NULL)
|
||||
{
|
||||
ShowMessages("[-] core %u: cannot allocate instruction decoder\n", Cpu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Image = pt_insn_get_image(Decoder);
|
||||
pt_image_set_callback(Image, PtHelperReadImage, Ctx);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
Status = pt_insn_sync_forward(Decoder);
|
||||
if (Status < 0)
|
||||
break;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
struct pt_insn Insn;
|
||||
|
||||
while (Status & pts_event_pending)
|
||||
{
|
||||
struct pt_event Event;
|
||||
Status = pt_insn_event(Decoder, &Event, sizeof(Event));
|
||||
if (Status < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (Status < 0 || (Status & pts_eos))
|
||||
break;
|
||||
|
||||
Status = pt_insn_next(Decoder, &Insn, sizeof(Insn));
|
||||
if (Status < 0)
|
||||
break;
|
||||
|
||||
ZydisDisassembledInstruction Disasm;
|
||||
ZydisMachineMode Mode = (Insn.mode == ptem_32bit) ? ZYDIS_MACHINE_MODE_LEGACY_32 : ZYDIS_MACHINE_MODE_LONG_64;
|
||||
|
||||
if (ZYAN_SUCCESS(ZydisDisassembleIntel(Mode, Insn.ip, Insn.raw, Insn.size, &Disasm)))
|
||||
ShowMessages(" 0x%016llx exe+0x%-6llx %s\n",
|
||||
(UINT64)Insn.ip,
|
||||
(UINT64)(Insn.ip - Ctx->ImageBase),
|
||||
Disasm.text);
|
||||
else
|
||||
ShowMessages(" 0x%016llx (undecodable)\n", (UINT64)Insn.ip);
|
||||
|
||||
Count++;
|
||||
}
|
||||
|
||||
if (Status >= 0 && (Status & pts_eos))
|
||||
break;
|
||||
}
|
||||
|
||||
pt_insn_free_decoder(Decoder);
|
||||
return Count;
|
||||
}
|
||||
|
|
@ -53,6 +53,17 @@ hyperdbg_u_load_vmm()
|
|||
return HyperDbgLoadVmmModule();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if any module is loaded
|
||||
*
|
||||
* @return BOOLEAN Returns true if any module is loaded and false if no module is loaded
|
||||
*/
|
||||
BOOLEAN
|
||||
hyperdbg_u_is_any_module_loaded()
|
||||
{
|
||||
return HyperDbgIsAnyModuleLoaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Unload all modules
|
||||
*
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@
|
|||
// Functions //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
BOOLEAN
|
||||
HyperDbgIsAnyModuleLoaded();
|
||||
|
||||
INT
|
||||
HyperDbgUnloadAllModules();
|
||||
|
||||
|
|
@ -46,6 +46,7 @@ typedef struct Vendor
|
|||
//////////////////////////////////////////////////
|
||||
// Functions //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
Vendor *
|
||||
GetVendorById(UINT16 VendorId);
|
||||
void
|
||||
28
hyperdbg/libhyperdbg/header/debugger/misc/pt-helper.h
Normal file
28
hyperdbg/libhyperdbg/header/debugger/misc/pt-helper.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* @file pt-helper.h
|
||||
* @author Sina Karvandi (sina@hyperdbg.org)
|
||||
* @brief Headers for PT helper functions
|
||||
* @details
|
||||
* @version 0.21
|
||||
* @date 2026-07-03
|
||||
*
|
||||
* @copyright This project is released under the GNU Public License v3.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Functions //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
UINT64
|
||||
PtHelperDecodeCorePackets(UINT32 Cpu, const UINT8 * Buffer, UINT64 Size, UINT64 ImageBase);
|
||||
|
||||
UINT64
|
||||
PtHelperDecodeCore(UINT32 Cpu, const UINT8 * Buffer, UINT64 Size, IMAGE_SYMBOL_CONTEXT * Ctx);
|
||||
|
||||
BOOLEAN
|
||||
PtHelperCaptureImage(HANDLE Process, UINT64 * TextStart, UINT64 * TextEnd, IMAGE_SYMBOL_CONTEXT * Ctx);
|
||||
|
||||
BOOLEAN
|
||||
PtHelperResolveFunction(HANDLE Process, const CHAR * Path, const CHAR * Name, UINT64 ImageBase, UINT64 * Start, UINT64 * End);
|
||||
|
|
@ -26,6 +26,53 @@ typedef struct _LOCAL_FUNCTION_DESCRIPTION
|
|||
|
||||
} LOCAL_FUNCTION_DESCRIPTION, *PLOCAL_FUNCTION_DESCRIPTION;
|
||||
|
||||
/**
|
||||
* @brief Save the local module symbols' description
|
||||
*
|
||||
*/
|
||||
typedef struct _IMAGE_SYMBOL_CONTEXT
|
||||
{
|
||||
UINT64 ImageBase;
|
||||
UINT64 CodeBase;
|
||||
UINT64 CodeSize;
|
||||
UINT8 * Code;
|
||||
} IMAGE_SYMBOL_CONTEXT;
|
||||
|
||||
/*
|
||||
* @brief Process basic information structure
|
||||
*/
|
||||
typedef struct _PROC_BASIC_INFO
|
||||
{
|
||||
LONG ExitStatus;
|
||||
PVOID PebBaseAddress;
|
||||
ULONG_PTR Reserved[4];
|
||||
} PROC_BASIC_INFO;
|
||||
|
||||
/**
|
||||
* @brief Thread basic information
|
||||
*
|
||||
*/
|
||||
typedef struct _THREAD_BASIC_INFO_EX
|
||||
{
|
||||
LONG ExitStatus;
|
||||
PVOID TebBaseAddress;
|
||||
struct
|
||||
{
|
||||
HANDLE UniqueProcess;
|
||||
HANDLE UniqueThread;
|
||||
} ClientId;
|
||||
ULONG_PTR AffinityMask;
|
||||
LONG Priority;
|
||||
LONG BasePriority;
|
||||
} THREAD_BASIC_INFO_EX;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Function Defs //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
typedef LONG(NTAPI * PFN_NT_QIP)(HANDLE, ULONG, PVOID, ULONG, PULONG);
|
||||
typedef LONG(NTAPI * PFN_NT_QIT)(HANDLE, ULONG, PVOID, ULONG, PULONG);
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Pdbex //
|
||||
//////////////////////////////////////////////////
|
||||
|
|
@ -78,7 +78,7 @@
|
|||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>$(SolutionDir)libraries\zydis\user\Zycore.lib;$(SolutionDir)libraries\zydis\user\Zydis.lib;$(SolutionDir)build\bin\$(Configuration)\script-engine.lib;$(SolutionDir)libraries\keystone\$(Configuration)-lib\keystone.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>$(SolutionDir)libraries\zydis\user\Zycore.lib;$(SolutionDir)libraries\zydis\user\Zydis.lib;$(SolutionDir)build\bin\$(Configuration)\script-engine.lib;$(SolutionDir)libraries\keystone\$(Configuration)-lib\keystone.lib;$(SolutionDir)libraries\libipt\libipt.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<TreatLinkerWarningAsErrors>false</TreatLinkerWarningAsErrors>
|
||||
</Link>
|
||||
|
|
@ -116,7 +116,7 @@ msbuild "$(SolutionDir)dependencies\zydis\msvc\Zydis.sln" /m /p:Configuration="R
|
|||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>$(SolutionDir)libraries\zydis\user\Zycore.lib;$(SolutionDir)libraries\zydis\user\Zydis.lib;$(SolutionDir)build\bin\$(Configuration)\script-engine.lib;$(SolutionDir)libraries\keystone\$(Configuration)-lib\keystone.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>$(SolutionDir)libraries\zydis\user\Zycore.lib;$(SolutionDir)libraries\zydis\user\Zydis.lib;$(SolutionDir)build\bin\$(Configuration)\script-engine.lib;$(SolutionDir)libraries\keystone\$(Configuration)-lib\keystone.lib;$(SolutionDir)libraries\libipt\libipt.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||
</Link>
|
||||
|
|
@ -140,35 +140,36 @@ msbuild "$(SolutionDir)dependencies\zydis\msvc\Zydis.sln" /m /p:Configuration="R
|
|||
<ClInclude Include="..\include\platform\general\header\nt-list.h" />
|
||||
<ClInclude Include="..\include\platform\user\header\windows-only\windows-privilege.h" />
|
||||
<ClInclude Include="..\include\platform\user\header\Windows.h" />
|
||||
<ClInclude Include="header\assembler.h" />
|
||||
<ClInclude Include="header\commands.h" />
|
||||
<ClInclude Include="header\common.h" />
|
||||
<ClInclude Include="header\communication.h" />
|
||||
<ClInclude Include="header\debugger.h" />
|
||||
<ClInclude Include="header\export.h" />
|
||||
<ClInclude Include="header\forwarding.h" />
|
||||
<ClInclude Include="header\globals.h" />
|
||||
<ClInclude Include="header\help.h" />
|
||||
<ClInclude Include="header\hwdbg-interpreter.h" />
|
||||
<ClInclude Include="header\hwdbg-scripts.h" />
|
||||
<ClInclude Include="header\inipp.h" />
|
||||
<ClInclude Include="header\install.h" />
|
||||
<ClInclude Include="header\kd.h" />
|
||||
<ClInclude Include="header\libhyperdbg.h" />
|
||||
<ClInclude Include="header\list.h" />
|
||||
<ClInclude Include="header\messaging.h" />
|
||||
<ClInclude Include="header\namedpipe.h" />
|
||||
<ClInclude Include="header\objects.h" />
|
||||
<ClInclude Include="header\packets.h" />
|
||||
<ClInclude Include="header\pci-id.h" />
|
||||
<ClInclude Include="header\pe-parser.h" />
|
||||
<ClInclude Include="header\rev-ctrl.h" />
|
||||
<ClInclude Include="header\script-engine.h" />
|
||||
<ClInclude Include="header\steppings.h" />
|
||||
<ClInclude Include="header\symbol.h" />
|
||||
<ClInclude Include="header\tests.h" />
|
||||
<ClInclude Include="header\transparency.h" />
|
||||
<ClInclude Include="header\ud.h" />
|
||||
<ClInclude Include="header\app\libhyperdbg.h" />
|
||||
<ClInclude Include="header\app\messaging.h" />
|
||||
<ClInclude Include="header\app\packets.h" />
|
||||
<ClInclude Include="header\common\common.h" />
|
||||
<ClInclude Include="header\common\list.h" />
|
||||
<ClInclude Include="header\debugger\commands\commands.h" />
|
||||
<ClInclude Include="header\debugger\commands\help.h" />
|
||||
<ClInclude Include="header\debugger\communication\communication.h" />
|
||||
<ClInclude Include="header\debugger\communication\forwarding.h" />
|
||||
<ClInclude Include="header\debugger\communication\namedpipe.h" />
|
||||
<ClInclude Include="header\debugger\core\debugger.h" />
|
||||
<ClInclude Include="header\debugger\core\steppings.h" />
|
||||
<ClInclude Include="header\debugger\driver-loader\install.h" />
|
||||
<ClInclude Include="header\debugger\kernel-level\kd.h" />
|
||||
<ClInclude Include="header\debugger\misc\assembler.h" />
|
||||
<ClInclude Include="header\debugger\misc\inipp.h" />
|
||||
<ClInclude Include="header\debugger\misc\pci-id.h" />
|
||||
<ClInclude Include="header\debugger\misc\pt-helper.h" />
|
||||
<ClInclude Include="header\debugger\script-engine\script-engine.h" />
|
||||
<ClInclude Include="header\debugger\script-engine\symbol.h" />
|
||||
<ClInclude Include="header\debugger\tests\tests.h" />
|
||||
<ClInclude Include="header\debugger\transparency\transparency.h" />
|
||||
<ClInclude Include="header\debugger\user-level\pe-parser.h" />
|
||||
<ClInclude Include="header\debugger\user-level\ud.h" />
|
||||
<ClInclude Include="header\export\export.h" />
|
||||
<ClInclude Include="header\globals\globals.h" />
|
||||
<ClInclude Include="header\hwdbg\hwdbg-interpreter.h" />
|
||||
<ClInclude Include="header\hwdbg\hwdbg-scripts.h" />
|
||||
<ClInclude Include="header\objects\objects.h" />
|
||||
<ClInclude Include="header\rev\rev-ctrl.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
@ -231,6 +232,7 @@ msbuild "$(SolutionDir)dependencies\zydis\msvc\Zydis.sln" /m /p:Configuration="R
|
|||
<ClCompile Include="code\debugger\misc\callstack.cpp" />
|
||||
<ClCompile Include="code\debugger\misc\disassembler.cpp" />
|
||||
<ClCompile Include="code\debugger\misc\pci-id.cpp" />
|
||||
<ClCompile Include="code\debugger\misc\pt-helper.cpp" />
|
||||
<ClCompile Include="code\debugger\misc\readmem.cpp" />
|
||||
<ClCompile Include="code\debugger\script-engine\script-engine-wrapper.cpp" />
|
||||
<ClCompile Include="code\debugger\script-engine\script-engine.cpp" />
|
||||
|
|
|
|||
|
|
@ -102,95 +102,68 @@
|
|||
<Filter Include="header\components\pe">
|
||||
<UniqueIdentifier>{da7e68cc-540c-4efc-b4de-c23b4b13e2ec}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\app">
|
||||
<UniqueIdentifier>{d6010267-4888-46f5-9bdb-2339565710d2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\common">
|
||||
<UniqueIdentifier>{e81c07d3-5e98-4bdb-a00b-2b99e023553c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\debugger">
|
||||
<UniqueIdentifier>{477d3059-08d7-433b-83c3-bbf57658deaf}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\export">
|
||||
<UniqueIdentifier>{559b68f3-8bf0-447a-a714-0e355c22516f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\globals">
|
||||
<UniqueIdentifier>{88de3dbf-90ab-47ef-94fe-8c21ce73c9f1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\hwdbg">
|
||||
<UniqueIdentifier>{c1f438ff-fd3b-4fb4-989b-f145290e3837}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\objects">
|
||||
<UniqueIdentifier>{c5b26259-abcc-459f-9b7e-fd90c34ad646}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\rev">
|
||||
<UniqueIdentifier>{99425a01-168c-4b6b-a53f-d62fbb7c8cab}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\debugger\commands">
|
||||
<UniqueIdentifier>{c7f85132-1802-4462-990f-3fffb0365dbc}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\debugger\communication">
|
||||
<UniqueIdentifier>{4f4eca9f-c1f6-4342-91ef-2b533292e238}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\debugger\core">
|
||||
<UniqueIdentifier>{bde7408e-fad9-4329-98ac-e604674f7bbf}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\debugger\driver-loader">
|
||||
<UniqueIdentifier>{06e9888f-57f0-4d59-8f7e-1fdd336be9cc}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\debugger\misc">
|
||||
<UniqueIdentifier>{0d88d581-8ff4-40f2-8585-3fdb97d4d211}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\debugger\script-engine">
|
||||
<UniqueIdentifier>{439dcb49-1825-4076-affe-17b505e4033a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\debugger\tests">
|
||||
<UniqueIdentifier>{16331b3c-c8fd-4b12-abb4-7617d21db9d0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\debugger\transparency">
|
||||
<UniqueIdentifier>{2d2c16a6-3fdc-4b63-a282-f2762a1f340d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\debugger\user-level">
|
||||
<UniqueIdentifier>{9dcff6b3-9ebd-46f3-a0c5-c69d06357949}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="header\debugger\kernel-level">
|
||||
<UniqueIdentifier>{3e4dda9f-6050-409f-85e2-4cf7c8a95743}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\commands.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\common.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\communication.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\forwarding.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\globals.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\help.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\inipp.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\install.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\kd.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\list.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\namedpipe.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\script-engine.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\symbol.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\tests.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\transparency.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\pe-parser.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\ud.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\objects.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\rev-ctrl.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\hwdbg-interpreter.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\platform\user\header\Windows.h">
|
||||
<Filter>header\platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\export.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\libhyperdbg.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\assembler.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\steppings.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\hwdbg-scripts.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\pci-id.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\platform\user\header\platform-intrinsics.h">
|
||||
<Filter>header\platform</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -209,18 +182,102 @@
|
|||
<ClInclude Include="..\include\platform\general\header\nt-list.h">
|
||||
<Filter>header\platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\messaging.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\packets.h">
|
||||
<Filter>header</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\platform\user\header\windows-only\windows-privilege.h">
|
||||
<Filter>header\platform\windows-only</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\components\pe\header\pe-image-reader.h">
|
||||
<Filter>header\components\pe</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\app\libhyperdbg.h">
|
||||
<Filter>header\app</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\app\messaging.h">
|
||||
<Filter>header\app</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\app\packets.h">
|
||||
<Filter>header\app</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\common\common.h">
|
||||
<Filter>header\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\common\list.h">
|
||||
<Filter>header\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\export\export.h">
|
||||
<Filter>header\export</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\globals\globals.h">
|
||||
<Filter>header\globals</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\hwdbg\hwdbg-interpreter.h">
|
||||
<Filter>header\hwdbg</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\hwdbg\hwdbg-scripts.h">
|
||||
<Filter>header\hwdbg</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\rev\rev-ctrl.h">
|
||||
<Filter>header\rev</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\objects\objects.h">
|
||||
<Filter>header\objects</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\commands\commands.h">
|
||||
<Filter>header\debugger\commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\commands\help.h">
|
||||
<Filter>header\debugger\commands</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\communication\communication.h">
|
||||
<Filter>header\debugger\communication</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\communication\forwarding.h">
|
||||
<Filter>header\debugger\communication</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\communication\namedpipe.h">
|
||||
<Filter>header\debugger\communication</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\core\debugger.h">
|
||||
<Filter>header\debugger\core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\core\steppings.h">
|
||||
<Filter>header\debugger\core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\driver-loader\install.h">
|
||||
<Filter>header\debugger\driver-loader</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\kernel-level\kd.h">
|
||||
<Filter>header\debugger\kernel-level</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\misc\assembler.h">
|
||||
<Filter>header\debugger\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\misc\inipp.h">
|
||||
<Filter>header\debugger\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\misc\pci-id.h">
|
||||
<Filter>header\debugger\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\user-level\pe-parser.h">
|
||||
<Filter>header\debugger\user-level</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\user-level\ud.h">
|
||||
<Filter>header\debugger\user-level</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\transparency\transparency.h">
|
||||
<Filter>header\debugger\transparency</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\tests\tests.h">
|
||||
<Filter>header\debugger\tests</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\script-engine\script-engine.h">
|
||||
<Filter>header\debugger\script-engine</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\script-engine\symbol.h">
|
||||
<Filter>header\debugger\script-engine</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="header\debugger\misc\pt-helper.h">
|
||||
<Filter>header\debugger\misc</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp">
|
||||
|
|
@ -676,6 +733,9 @@
|
|||
<ClCompile Include="..\include\components\pe\code\pe-image-reader.cpp">
|
||||
<Filter>code\components\pe</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="code\debugger\misc\pt-helper.cpp">
|
||||
<Filter>code\debugger\misc</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MASM Include="code\assembly\asm-vmx-checks.asm">
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
//
|
||||
// Global variables
|
||||
//
|
||||
#include "header/globals.h"
|
||||
#include "header/globals/globals.h"
|
||||
|
||||
//
|
||||
// When you are using pre-compiled headers, this source file is necessary for
|
||||
|
|
|
|||
|
|
@ -41,30 +41,29 @@ typedef RFLAGS * PRFLAGS;
|
|||
#define USE_NATIVE_SDK_HEADERS
|
||||
#define _AMD64_
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(USE__NATIVE_PHNT_HEADERS)
|
||||
# if defined(USE__NATIVE_PHNT_HEADERS)
|
||||
|
||||
//
|
||||
// Dirty fix: the "PCWCHAR" in undefined in "ntrtl.h" so I deifined it here.
|
||||
//
|
||||
typedef const wchar_t *LPCWCHAR, *PCWCHAR;
|
||||
|
||||
# define PHNT_MODE PHNT_MODE_USER
|
||||
# define PHNT_VERSION PHNT_WIN11 // Windows 11
|
||||
# define PHNT_PATCH_FOR_HYPERDBG TRUE
|
||||
# define PHNT_MODE PHNT_MODE_USER
|
||||
# define PHNT_VERSION PHNT_WIN11 // Windows 11
|
||||
# define PHNT_PATCH_FOR_HYPERDBG TRUE
|
||||
|
||||
# include <phnt/phnt_windows.h>
|
||||
# include <phnt/phnt.h>
|
||||
# include <phnt/phnt_windows.h>
|
||||
# include <phnt/phnt.h>
|
||||
|
||||
#elif defined(USE_NATIVE_SDK_HEADERS)
|
||||
# elif defined(USE_NATIVE_SDK_HEADERS)
|
||||
|
||||
# include <winternl.h>
|
||||
# include <Windows.h>
|
||||
# include <winioctl.h>
|
||||
# include <platform/user/header/Windows.h>
|
||||
# include <winternl.h>
|
||||
# include <Windows.h>
|
||||
# include <winioctl.h>
|
||||
# include <platform/user/header/Windows.h>
|
||||
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#endif //_WIN32
|
||||
|
||||
|
|
@ -108,6 +107,7 @@ typedef const wchar_t *LPCWCHAR, *PCWCHAR;
|
|||
#include <cstring>
|
||||
#include <unordered_set>
|
||||
#include <regex>
|
||||
#include <dbghelp.h>
|
||||
|
||||
//
|
||||
// Scope definitions
|
||||
|
|
@ -187,50 +187,61 @@ typedef const wchar_t *LPCWCHAR, *PCWCHAR;
|
|||
//
|
||||
// PCI IDs
|
||||
//
|
||||
#include "header/pci-id.h"
|
||||
#include "header/debugger/misc/pci-id.h"
|
||||
|
||||
//
|
||||
// Intel PT
|
||||
//
|
||||
#include "../dependencies/libipt/intel-pt.h"
|
||||
|
||||
//
|
||||
// General
|
||||
//
|
||||
#include "header/libhyperdbg.h"
|
||||
#include "header/export.h"
|
||||
#include "header/inipp.h"
|
||||
#include "header/commands.h"
|
||||
#include "header/common.h"
|
||||
#include "header/symbol.h"
|
||||
#include "header/debugger.h"
|
||||
#include "header/script-engine.h"
|
||||
#include "header/help.h"
|
||||
#include "header/app/libhyperdbg.h"
|
||||
#include "header/export/export.h"
|
||||
#include "header/debugger/misc/inipp.h"
|
||||
#include "header/debugger/commands/commands.h"
|
||||
#include "header/common/common.h"
|
||||
#include "header/debugger/script-engine/symbol.h"
|
||||
#include "header/debugger/misc/pt-helper.h"
|
||||
#include "header/debugger/core/debugger.h"
|
||||
#include "header/debugger/script-engine/script-engine.h"
|
||||
#include "header/debugger/commands/help.h"
|
||||
#ifdef _WIN32
|
||||
# include "header/install.h"
|
||||
# include "header/debugger/driver-loader/install.h"
|
||||
#endif
|
||||
#include "header/list.h"
|
||||
#include "header/tests.h"
|
||||
#include "header/messaging.h"
|
||||
#include "header/packets.h"
|
||||
#include "header/transparency.h"
|
||||
#include "header/communication.h"
|
||||
#include "header/namedpipe.h"
|
||||
#include "header/forwarding.h"
|
||||
#include "header/kd.h"
|
||||
#include "header/common/list.h"
|
||||
#include "header/debugger/tests/tests.h"
|
||||
#include "header/app/messaging.h"
|
||||
#include "header/app/packets.h"
|
||||
#include "header/debugger/transparency/transparency.h"
|
||||
#include "header/debugger/communication/communication.h"
|
||||
#include "header/debugger/communication/namedpipe.h"
|
||||
#include "header/debugger/communication/forwarding.h"
|
||||
#include "header/debugger/kernel-level/kd.h"
|
||||
|
||||
//
|
||||
// Components
|
||||
//
|
||||
#include "../include/components/pe/header/pe-image-reader.h"
|
||||
|
||||
#include "header/pe-parser.h"
|
||||
#include "header/ud.h"
|
||||
#include "header/objects.h"
|
||||
#include "header/steppings.h"
|
||||
#include "header/rev-ctrl.h"
|
||||
#include "header/assembler.h"
|
||||
#include "header/debugger/user-level/pe-parser.h"
|
||||
#include "header/debugger/user-level/ud.h"
|
||||
#include "header/objects/objects.h"
|
||||
#include "header/debugger/core/steppings.h"
|
||||
#include "header/rev/rev-ctrl.h"
|
||||
#include "header/debugger/misc/assembler.h"
|
||||
|
||||
//
|
||||
// hwdbg
|
||||
//
|
||||
#include "header/hwdbg-interpreter.h"
|
||||
#include "header/hwdbg-scripts.h"
|
||||
#include "header/hwdbg/hwdbg-interpreter.h"
|
||||
#include "header/hwdbg/hwdbg-scripts.h"
|
||||
|
||||
//
|
||||
// Zydis headers
|
||||
//
|
||||
#include <Zydis/Zydis.h>
|
||||
|
||||
//
|
||||
// Libraries
|
||||
|
|
@ -261,4 +272,9 @@ typedef const wchar_t *LPCWCHAR, *PCWCHAR;
|
|||
# pragma comment(lib, "Psapi.lib")
|
||||
# pragma comment(lib, "Kernel32.lib")
|
||||
|
||||
//
|
||||
// For resolving symbols on Intel PT
|
||||
//
|
||||
# pragma comment(lib, "dbghelp.lib")
|
||||
|
||||
#endif // HYPERDBG_ENV_WINDOWS
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ TARGET_PROJECTS = [
|
|||
"hypertrace.vcxproj",
|
||||
"hyperlog.vcxproj",
|
||||
"hyperevade.vcxproj",
|
||||
"hyperperf.vcxproj",
|
||||
"kdserial.vcxproj",
|
||||
"hyperdbg_driver.vcxproj",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue