139{
141 vector<UINT64> ValuesToEdit;
155 vector<string> SplitCommandCaseSensitive {
Split(Command,
' ')};
156 UINT32 IndexInCommandCaseSensitive = 0;
158
159
160
161
162
164 {
166 }
167
168 if (SplitCommand.size() <= 4)
169 {
172 return;
173 }
174
175 for (auto Section : SplitCommand)
176 {
177 IndexInCommandCaseSensitive++;
178
179 if (IsFirstCommand ==
TRUE)
180 {
181 if (!Section.compare("!sb"))
182 {
185 }
186 else if (!Section.compare("!sd"))
187 {
190 }
191 else if (!Section.compare("!sq"))
192 {
195 }
196 else if (!Section.compare("sb"))
197 {
200 }
201 else if (!Section.compare("sd"))
202 {
205 }
206 else if (!Section.compare("sq"))
207 {
210 }
211 else
212 {
213
214
215
218 return;
219 }
220
221 IsFirstCommand =
FALSE;
222
223 continue;
224 }
225
226 if (NextIsProcId)
227 {
228
229
230
231 NextIsProcId =
FALSE;
232
234 {
235 ShowMessages(
"please specify a correct hex process id\n\n");
237 return;
238 }
239 else
240 {
241
242
243
244 continue;
245 }
246 }
247
248 if (NextIsLength)
249 {
250
251
252
253 NextIsLength =
FALSE;
254
256 {
257 ShowMessages(
"please specify a correct hex length\n\n");
259 return;
260 }
261 else
262 {
263
264
265
267 continue;
268 }
269 }
270
271
272
273
274 if (!SetProcId && !Section.compare("pid"))
275 {
277 continue;
278 }
279
280
281
282
283 if (!SetLength && !Section.compare("l"))
284 {
286 continue;
287 }
288
289 if (!SetAddress)
290 {
292 {
294 SplitCommandCaseSensitive.at(IndexInCommandCaseSensitive - 1).c_str());
296 return;
297 }
298 else
299 {
300
301
302
304 continue;
305 }
306 }
307
308 if (SetAddress)
309 {
310
311
312
313 if (Section.rfind("0x", 0) == 0 || Section.rfind("0X", 0) == 0 ||
314 Section.rfind("\\x", 0) == 0 || Section.rfind("\\X", 0) == 0)
315 {
316 Section = Section.erase(0, 2);
317 }
318 else if (Section.rfind('x', 0) == 0 || Section.rfind('X', 0) == 0)
319 {
320 Section = Section.erase(0, 1);
321 }
322 Section.erase(remove(Section.begin(), Section.end(), '`'), Section.end());
323
324
325
326
328 {
329 ShowMessages(
"please specify a byte (hex) value for 'sb' or '!sb'\n\n");
330 return;
331 }
333 {
335 "please specify a dword (hex) value for 'sd' or '!sd'\n\n");
336 return;
337 }
339 Section.size() >= 17)
340 {
342 "please specify a qword (hex) value for 'sq' or '!sq'\n\n");
343 return;
344 }
345
346
347
348
349
351 {
352 ShowMessages(
"please specify a correct hex value to search in the "
353 "memory content\n\n");
355 return;
356 }
357 else
358 {
359
360
361
362 ValuesToEdit.push_back(
Value);
363
364
365
366
367 CountOfValues++;
368
370 {
371
372
373
375 }
376 continue;
377 }
378 }
379 }
380
381
382
383
385 {
387 return;
388 }
389
390 if (ProcId == 0)
391 {
392 ProcId = GetCurrentProcessId();
393 }
394
395
396
397
401
402
403
404
405 if (!SetAddress)
406 {
407 ShowMessages(
"please specify a correct hex address\n\n");
409 return;
410 }
412 {
414 "please specify a correct hex value as the content to search\n\n");
416 return;
417 }
418 if (!SetLength)
419 {
420 ShowMessages(
"please specify a correct hex value as the length\n\n");
422 return;
423 }
424 if (NextIsProcId)
425 {
426 ShowMessages(
"please specify a correct hex value as the process id\n\n");
428 return;
429 }
430 if (NextIsLength)
431 {
432 ShowMessages(
"please specify a correct hex length\n\n");
434 return;
435 }
436
437
438
439
441
442
443
444
446
447
448
449
450 SearchMemoryRequest.
Length = Length;
451
453 {
455 }
456
457
458
459
460 FinalBuffer = (
UINT64 *)malloc(FinalSize);
461
462 if (!FinalBuffer)
463 {
465 return;
466 }
467
468
469
470
471 ZeroMemory(FinalBuffer, FinalSize);
472
473
474
475
477
478
479
480
482
483
484
485
487 {
488
489
490
492 }
493 else
494 {
495
496
497
499 }
500
501
502
503
504 free(FinalBuffer);
505}
int BOOL
Definition BasicTypes.h:23
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 int UINT32
Definition BasicTypes.h:48
UINT64 Address
Definition HyperDbgScriptImports.h:67
@ SEARCH_QWORD
Definition RequestStructures.h:518
@ SEARCH_BYTE
Definition RequestStructures.h:516
@ SEARCH_DWORD
Definition RequestStructures.h:517
@ SEARCH_PHYSICAL_MEMORY
Definition RequestStructures.h:504
@ SEARCH_VIRTUAL_MEMORY
Definition RequestStructures.h:505
#define SIZEOF_DEBUGGER_SEARCH_MEMORY
Definition RequestStructures.h:496
VOID SetValue(PGUEST_REGS GuestRegs, SCRIPT_ENGINE_VARIABLES_LIST *VariablesList, PSYMBOL Symbol, UINT64 Value, SYMBOL_BUFFER *StackBuffer, UINT64 *StackIndx, UINT64 *StackBaseIndx, UINT64 *ReturnValue)
Set the value.
Definition ScriptEngineEval.c:184
const vector< string > Split(const string &s, const char &c)
general split command
Definition common.cpp:117
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
BOOLEAN ConvertStringToUInt32(string TextToConvert, PUINT32 Result)
check and convert string to a 32 bit unsigned it and also check for special notations like 0x etc.
Definition common.cpp:347
RequestedActionOfThePacket Value(0x1) 00000000
BOOLEAN KdSendSearchRequestPacketToDebuggee(UINT64 *SearchRequestBuffer, UINT32 SearchRequestBufferSize)
Sends search query request packet to the debuggee.
Definition kd.cpp:1178
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
NULL()
Definition test-case-generator.py:530
VOID CommandSearchSendRequest(UINT64 *BufferToSendAsIoctl, UINT32 BufferToSendAsIoctlSize)
Send the request of search to the kernel.
Definition s.cpp:62
VOID CommandSearchMemoryHelp()
help of !s* s* commands
Definition s.cpp:26
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
Shows if the debugger was connected to remote debuggee over (A remote guest)
Definition globals.h:231
ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
State of active debugging thread.
Definition globals.h:362
UINT32 ProcessId
Definition ud.h:51
BOOLEAN IsActive
Definition ud.h:49
request for searching memory
Definition RequestStructures.h:527
UINT64 Length
Definition RequestStructures.h:529
UINT32 ProcessId
Definition RequestStructures.h:530
UINT32 CountOf64Chunks
Definition RequestStructures.h:533
UINT32 FinalStructureSize
Definition RequestStructures.h:534
UINT64 Address
Definition RequestStructures.h:528
DEBUGGER_SEARCH_MEMORY_BYTE_SIZE ByteSize
Definition RequestStructures.h:532
DEBUGGER_SEARCH_MEMORY_TYPE MemoryType
Definition RequestStructures.h:531
BOOLEAN SymbolConvertNameOrExprToAddress(const string &TextToConvert, PUINT64 Result)
check and convert string to a 64 bit unsigned integer and also check for symbol object names and eval...
Definition symbol.cpp:360