61{
65 BOOLEAN TrueIfProcessIdAndFalseIfProcessName;
68 size_t RequestBufferSize = 0;
69
70 if (SplitCommand.size() <= 2 && SplitCommand.size() != 1)
71 {
74 return;
75 }
76
77
78
79
80 if (SplitCommand.size() == 1)
81 {
83 {
84 TrueIfProcessIdAndFalseIfProcessName =
TRUE;
86 }
87 else
88 {
89
90
91
92 ShowMessages(
"you're not attached to any user-mode process, "
93 "please explicitly specify the process id or process name\n");
94 return;
95 }
96 }
97 else if (!SplitCommand.at(1).compare("pid"))
98 {
99 TrueIfProcessIdAndFalseIfProcessName =
TRUE;
100
101
102
103
104 if (SplitCommand.size() != 3)
105 {
108 return;
109 }
110
111
112
113
115 {
117 return;
118 }
119 }
120 else if (!SplitCommand.at(1).compare("name"))
121 {
122 TrueIfProcessIdAndFalseIfProcessName =
FALSE;
123
124
125
126
128
129
130
131
132 Command.erase(0, SplitCommand.at(0).size());
133
134
135
136
137 Command.erase(0, 4 + 1);
138
139
140
141
143 }
144 else
145 {
146
147
148
151 return;
152 }
153
154
155
156
159 {
160 ShowMessages(
"the average, median and standard deviation is not measured. "
161 "Did you use '!measure' command?\n");
162 return;
163 }
164
165
166
167
169
170
171
172
174
175
176
177
181
182
183
184
188
190 TrueIfProcessIdAndFalseIfProcessName;
191
192 if (TrueIfProcessIdAndFalseIfProcessName)
193 {
194
195
196
198
200 }
201 else
202 {
203
204
205
208 }
209
210
211
212
213 FinalRequestBuffer =
215
216 if (FinalRequestBuffer == NULL)
217 {
219 return;
220 }
221
222
223
224
225 RtlZeroMemory(FinalRequestBuffer, RequestBufferSize);
226
227
228
229
230
232
233
234
235
238 Command.c_str(),
239 Command.size());
240
241
242
243
244
245 Status = DeviceIoControl(
248
249 FinalRequestBuffer,
250 (
DWORD)RequestBufferSize,
251 FinalRequestBuffer,
253
254 &ReturnedLength,
255 NULL
256 );
257
258 if (!Status)
259 {
260 ShowMessages(
"ioctl failed with code 0x%x\n", GetLastError());
261 free(FinalRequestBuffer);
262 return;
263 }
264
266 {
267 ShowMessages(
"transparent debugging successfully enabled :)\n");
268 }
271 {
272 ShowMessages(
"unable to hide the debugger (transparent-debugging) :(\n");
273 free(FinalRequestBuffer);
274 return;
275 }
276 else
277 {
279 free(FinalRequestBuffer);
280 return;
281 }
282
283
284
285
286 free(FinalRequestBuffer);
287}
UCHAR BOOLEAN
Definition BasicTypes.h:39
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned __int64 UINT64
Definition BasicTypes.h:21
unsigned long DWORD
Definition BasicTypes.h:22
unsigned int UINT32
Definition BasicTypes.h:48
unsigned long ULONG
Definition BasicTypes.h:37
#define DEBUGGER_ERROR_UNABLE_TO_HIDE_OR_UNHIDE_DEBUGGER
error, unable to hide the debugger and enter to transparent-mode
Definition ErrorCodes.h:87
#define DEBUGGER_OPERATION_WAS_SUCCESSFUL
General value to indicate that the operation or request was successful.
Definition ErrorCodes.h:23
#define IOCTL_DEBUGGER_HIDE_AND_UNHIDE_TO_TRANSPARENT_THE_DEBUGGER
ioctl, request to enable or disable transparent-mode
Definition Ioctls.h:120
struct _DEBUGGER_HIDE_AND_TRANSPARENT_DEBUGGER_MODE * PDEBUGGER_HIDE_AND_TRANSPARENT_DEBUGGER_MODE
#define SIZEOF_DEBUGGER_HIDE_AND_TRANSPARENT_DEBUGGER_MODE
Definition RequestStructures.h:541
struct _DEBUGGER_HIDE_AND_TRANSPARENT_DEBUGGER_MODE DEBUGGER_HIDE_AND_TRANSPARENT_DEBUGGER_MODE
request for enable or disable transparent-mode
BOOLEAN ConvertStringToUInt64(string TextToConvert, PUINT64 Result)
check and convert string to a 64 bit unsigned integer and also check for special notations like 0x,...
Definition common.cpp:240
void Trim(std::string &s)
trim from both ends and start of a string (in place)
Definition common.cpp:594
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
ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
State of active debugging thread.
Definition globals.h:362
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
VOID CommandHideHelp()
help of the !hide command
Definition hide.cpp:34
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
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
UINT32 ProcessId
Definition ud.h:51
BOOLEAN IsActive
Definition ud.h:49
request for enable or disable transparent-mode
Definition RequestStructures.h:549
UINT64 CpuidStandardDeviation
Definition RequestStructures.h:553
UINT64 RdtscStandardDeviation
Definition RequestStructures.h:557
UINT64 CpuidAverage
Definition RequestStructures.h:552
UINT64 KernelStatus
Definition RequestStructures.h:565
UINT64 RdtscAverage
Definition RequestStructures.h:556
BOOLEAN IsHide
Definition RequestStructures.h:550
UINT64 CpuidMedian
Definition RequestStructures.h:554
UINT64 RdtscMedian
Definition RequestStructures.h:558
UINT32 LengthOfProcessName
Definition RequestStructures.h:562
BOOLEAN TrueIfProcessIdAndFalseIfProcessName
Definition RequestStructures.h:560
UINT32 ProcId
Definition RequestStructures.h:561