HyperDbg Debugger
Loading...
Searching...
No Matches
measure.cpp File Reference

!measure command More...

#include "pch.h"

Functions

VOID CommandMeasureHelp ()
 help of the !measure command
 
VOID CommandMeasure (vector< string > SplitCommand, string Command)
 !measure command handler
 

Variables

UINT64 g_CpuidAverage
 The average calculated from the measurements of cpuid '!measure' command.
 
UINT64 g_CpuidStandardDeviation
 The standard deviation calculated from the measurements of cpuid '!measure' command.
 
UINT64 g_CpuidMedian
 The median calculated from the measurements of cpuid '!measure' command.
 
UINT64 g_RdtscAverage
 The average calculated from the measurements of rdtsc/p '!measure' command.
 
UINT64 g_RdtscStandardDeviation
 The standard deviation calculated from the measurements of rdtsc/p '!measure' command.
 
UINT64 g_RdtscMedian
 The median calculated from the measurements of rdtsc/p '!measure' command.
 
BOOLEAN g_TransparentResultsMeasured
 Shows whether the user executed and mesaured '!measure' command or not, it is because we want to use these measurements later in '!hide' command.
 

Detailed Description

!measure command

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2020-08-06

Function Documentation

◆ CommandMeasure()

VOID CommandMeasure ( vector< string > SplitCommand,
string Command )

!measure command handler

Parameters
SplitCommand
Command
Returns
VOID
54{
55 BOOLEAN DefaultMode = FALSE;
56
57 if (SplitCommand.size() >= 3)
58 {
59 ShowMessages("incorrect use of the '!measure'\n\n");
61 return;
62 }
63
64 if (SplitCommand.size() == 2 && SplitCommand.at(1).compare("default"))
65 {
66 ShowMessages("incorrect use of the '!measure'\n\n");
68 return;
69 }
70 else if (SplitCommand.size() == 2 &&
71 !SplitCommand.at(1).compare("default"))
72 {
73 DefaultMode = TRUE;
74 }
75
76 //
77 // Check if debugger is loaded or not
78 //
79 if (g_DeviceHandle && !DefaultMode)
80 {
82 "Debugger is loaded and your machine is already in a hypervisor, you "
83 "should measure the times before 'load'-ing the debugger, please "
84 "'unload' the debugger and use '!measure' again or use '!measure "
85 "default' to use hardcoded measurements\n");
86 return;
87 }
88
89 if (!DefaultMode)
90 {
95 {
97 "we detected that there is a hypervisor, on your system, it "
98 "leads to wrong measurement results for our transparent-mode, please "
99 "make sure that you're not in a hypervisor then measure the result "
100 "again; otherwise the transparent-mode will not work but you can use "
101 "'!measure default' to use the hardcoded measurements !\n\n");
102
103 return;
104 }
105
110 {
112 "we detected that there is a hypervisor, on your system, it "
113 "leads to wrong measurement results for our transparent-mode, please "
114 "make sure that you're not in a hypervisor then measure the result "
115 "again; otherwise the transparent-mode will not work but you can use "
116 "'!measure default' to use the hardcoded measurements !\n\n");
117
118 return;
119 }
120 }
121 else
122 {
123 //
124 // It's a default mode
125 //
126
127 //
128 // Default values for cpuid
129 //
130 g_CpuidAverage = 0x5f;
132 g_CpuidMedian = 0x5f;
133
134 //
135 // Default values for rdtsc/p
136 //
137 g_RdtscAverage = 0x16;
139 g_RdtscMedian = 0x16;
140 }
141
142 ShowMessages("the measurements were successful\nyou can use the '!hide' command now\n");
143
144 //
145 // Indicate that the measurements was successful
146 //
148}
UCHAR BOOLEAN
Definition BasicTypes.h:39
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
HANDLE g_DeviceHandle
Holds the global handle of device which is used to send the request to the kernel by IOCTL,...
Definition globals.h:471
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
UINT64 g_CpuidStandardDeviation
The standard deviation calculated from the measurements of cpuid '!measure' command.
Definition globals.h:532
UINT64 g_RdtscAverage
The average calculated from the measurements of rdtsc/p '!measure' command.
Definition globals.h:544
VOID CommandMeasureHelp()
help of the !measure command
Definition measure.cpp:33
UINT64 g_RdtscMedian
The median calculated from the measurements of rdtsc/p '!measure' command.
Definition globals.h:556
BOOLEAN g_TransparentResultsMeasured
Shows whether the user executed and mesaured '!measure' command or not, it is because we want to use ...
Definition globals.h:520
UINT64 g_CpuidMedian
The median calculated from the measurements of cpuid '!measure' command.
Definition globals.h:538
UINT64 g_RdtscStandardDeviation
The standard deviation calculated from the measurements of rdtsc/p '!measure' command.
Definition globals.h:550
UINT64 g_CpuidAverage
The average calculated from the measurements of cpuid '!measure' command.
Definition globals.h:526
BOOLEAN TransparentModeCheckRdtscpVmexit(UINT64 *Average, UINT64 *StandardDeviation, UINT64 *Median)
compute the average, standard deviation and median if rdtsc+rdtsc
Definition transparency.cpp:224
BOOLEAN TransparentModeCheckHypervisorPresence(UINT64 *Average, UINT64 *StandardDeviation, UINT64 *Median)
compute the average, standard deviation and median if rdtsc+cpuid+rdtsc
Definition transparency.cpp:194

◆ CommandMeasureHelp()

VOID CommandMeasureHelp ( )

help of the !measure command

Returns
VOID
34{
36 "!measure : measures the arguments needs for the '!hide' command.\n\n");
37
38 ShowMessages("syntax : \t!measure [default]\n");
39
40 ShowMessages("\n");
41 ShowMessages("\t\te.g : !measure\n");
42 ShowMessages("\t\te.g : !measure default\n");
43}

Variable Documentation

◆ g_CpuidAverage

UINT64 g_CpuidAverage
extern

The average calculated from the measurements of cpuid '!measure' command.

◆ g_CpuidMedian

UINT64 g_CpuidMedian
extern

The median calculated from the measurements of cpuid '!measure' command.

◆ g_CpuidStandardDeviation

UINT64 g_CpuidStandardDeviation
extern

The standard deviation calculated from the measurements of cpuid '!measure' command.

◆ g_RdtscAverage

UINT64 g_RdtscAverage
extern

The average calculated from the measurements of rdtsc/p '!measure' command.

◆ g_RdtscMedian

UINT64 g_RdtscMedian
extern

The median calculated from the measurements of rdtsc/p '!measure' command.

◆ g_RdtscStandardDeviation

UINT64 g_RdtscStandardDeviation
extern

The standard deviation calculated from the measurements of rdtsc/p '!measure' command.

◆ g_TransparentResultsMeasured

BOOLEAN g_TransparentResultsMeasured
extern

Shows whether the user executed and mesaured '!measure' command or not, it is because we want to use these measurements later in '!hide' command.