Interpret commands.
281{
284 CommandType::iterator Iterator;
285
286
287
288
289
291 {
292
293
294
296
298 }
299
300
301
302
304 {
307 }
308
309
310
311
313
314
315
316
317 string CommandString(Command);
318
319
320
321
322
323
324
325
326 transform(CommandString.begin(), CommandString.end(), CommandString.begin(), [](unsigned char c) { return std::tolower(c); });
327
328 vector<string> SplitCommand {
Split(CommandString,
' ')};
329
330
331
332
333 if (SplitCommand.empty())
334 {
336 return 0;
337 }
338
339 string FirstCommand = SplitCommand.front();
340
341
342
343
345
346
347
348
350 {
352 }
353 else
354 {
356 }
357
358
359
360
361
362
363
366 {
367
368
369
370
371
372
374 {
376 }
377
378
379
380
382
384
385
386
387
388 return 2;
389 }
391 !(CommandAttributes &
393 {
394
395
396
397
399 {
401
402
403
404
406 }
407 else
408 {
409
410
411
415 }
416
417
418
419
420 return 2;
421 }
422
423
424
425
426 if (!FirstCommand.compare(".help") || !FirstCommand.compare("help") ||
427 !FirstCommand.compare(".hh"))
428 {
429 if (SplitCommand.size() == 2)
430 {
431
432
433
435 FirstCommand = SplitCommand.at(1);
436 }
437 else
438 {
439 ShowMessages(
"incorrect use of the '%s'\n", FirstCommand.c_str());
441 return 0;
442 }
443 }
444
445
446
447
449
451 {
452
453
454
455 string CaseSensitiveCommandString(Command);
456 vector<string> CaseSensitiveSplitCommand {
Split(CaseSensitiveCommandString,
' ')};
457
458 if (!HelpCommand)
459 {
460 ShowMessages(
"err, couldn't resolve command at '%s'\n", CaseSensitiveSplitCommand.front().c_str());
461 }
462 else
463 {
464 ShowMessages(
"err, couldn't find the help for the command at '%s'\n",
465 CaseSensitiveSplitCommand.at(1).c_str());
466 }
467 }
468 else
469 {
470 if (HelpCommand)
471 {
472 Iterator->second.CommandHelpFunction();
473 }
474 else
475 {
476
477
478
479 if ((Iterator->second.CommandAttrib &
481 {
482 string CaseSensitiveCommandString(Command);
483 Iterator->second.CommandFunction(SplitCommand, CaseSensitiveCommandString);
484 }
485 else
486 {
487 Iterator->second.CommandFunction(SplitCommand, CommandString);
488 }
489 }
490 }
491
492
493
494
496 {
498 }
499
500 return 0;
501}
UCHAR BOOLEAN
Definition BasicTypes.h:39
unsigned __int64 UINT64
Definition BasicTypes.h:21
unsigned int UINT32
Definition BasicTypes.h:48
@ TEST_BREAKPOINT_TURN_ON_BPS_AND_EVENTS_FOR_COMMANDS_IN_REMOTE_COMPUTER
Definition RequestStructures.h:319
@ TEST_BREAKPOINT_TURN_OFF_BPS_AND_EVENTS_FOR_COMMANDS_IN_REMOTE_COMPUTER
Definition RequestStructures.h:318
#define DEBUGGER_COMMAND_ATTRIBUTE_WONT_STOP_DEBUGGER_AGAIN
Definition commands.h:195
#define DEBUGGER_COMMAND_ATTRIBUTE_LOCAL_COMMAND_IN_DEBUGGER_MODE
Definition commands.h:191
#define DEBUGGER_COMMAND_ATTRIBUTE_REPEAT_ON_ENTER
Definition commands.h:194
#define DEBUGGER_COMMAND_ATTRIBUTE_LOCAL_COMMAND_IN_REMOTE_CONNECTION
Definition commands.h:192
#define DEBUGGER_COMMAND_ATTRIBUTE_LOCAL_CASE_SENSITIVE
Definition commands.h:193
const vector< string > Split(const string &s, const char &c)
general split command
Definition common.cpp:117
VOID CommandHelpHelp()
help of the help command :)
Definition help.cpp:22
BOOLEAN g_IsConnectedToRemoteDebuggee
Shows whether the current debugger is the host and connected to a remote debuggee (guest)
Definition globals.h:74
BOOLEAN g_LogOpened
Shows whether the '.logopen' command is executed and the log file is open or not.
Definition globals.h:478
BOOLEAN g_ShouldPreviousCommandBeContinued
Shows whether the previous command should be continued or not.
Definition globals.h:318
VOID InterpreterRemoveComments(char *CommandText)
Remove batch comments.
Definition interpreter.cpp:509
BOOLEAN g_IsCommandListInitialized
Is list of command initialized.
Definition globals.h:348
UINT64 GetCommandAttributes(const string &FirstCommand)
Get Command Attributes.
Definition interpreter.cpp:734
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
Shows if the debugger was connected to remote debuggee over (A remote guest)
Definition globals.h:231
BOOLEAN g_BreakPrintingOutput
Shows whether the pause command or CTRL+C or CTRL+Break is executed or not.
Definition globals.h:499
VOID InitializeDebugger()
Initialize the debugger and adjust commands for the first run.
Definition interpreter.cpp:767
BOOLEAN g_ExecutingScript
Shows whether the target is executing a script form '.script' command or executing script by an argum...
Definition globals.h:492
CommandType g_CommandsList
List of command and attributes.
Definition globals.h:324
BOOLEAN KdSendUserInputPacketToDebuggee(const char *Sendbuf, int Len, BOOLEAN IgnoreBreakingAgain)
Sends user input packet to the debuggee.
Definition kd.cpp:1120
BOOLEAN KdSendTestQueryPacketToDebuggee(DEBUGGER_TEST_QUERY_STATE Type)
Send a test query request to the debuggee.
Definition kd.cpp:425
VOID LogopenSaveToFile(const char *Text)
Append text to the file object.
Definition logopen.cpp:119
int RemoteConnectionSendCommand(const char *sendbuf, int len)
send the command as a client (debugger, host) to the server (debuggee, guest)
Definition remote-connection.cpp:445