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

.switch command More...

#include "pch.h"

Functions

VOID CommandSwitchHelp ()
 help of the .switch command
VOID CommandSwitch (vector< CommandToken > CommandTokens, string Command)
 .switch command handler

Detailed Description

.switch command

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2022-01-31

Function Documentation

◆ CommandSwitch()

VOID CommandSwitch ( vector< CommandToken > CommandTokens,
string Command )

.switch command handler

Parameters
CommandTokens
Command
Returns
VOID
46{
47 UINT32 PidOrTid = NULL;
48
49 if (CommandTokens.size() > 3)
50 {
51 ShowMessages("incorrect use of the '%s'\n\n",
52 GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
54 return;
55 }
56
57 //
58 // Perform switching or listing the threads
59 //
60 if (CommandTokens.size() == 1 || (CommandTokens.size() == 2 && CompareLowerCaseStrings(CommandTokens.at(1), "list")))
61 {
63 }
64 else if (CompareLowerCaseStrings(CommandTokens.at(1), "pid"))
65 {
66 if (!ConvertTokenToUInt32(CommandTokens.at(2), &PidOrTid))
67 {
68 ShowMessages("please specify a correct hex value for process id\n\n");
69 return;
70 }
71
72 //
73 // Switch by pid
74 //
76 {
77 ShowMessages("switched to process id: %x\n", PidOrTid);
78 }
79 }
80 else if (CompareLowerCaseStrings(CommandTokens.at(1), "tid"))
81 {
82 if (!ConvertTokenToUInt32(CommandTokens.at(2), &PidOrTid))
83 {
84 ShowMessages("please specify a correct hex value for thread id\n\n");
85 return;
86 }
87
88 //
89 // Switch by tid
90 //
92 {
93 ShowMessages("switched to thread id: %x\n", PidOrTid);
94 }
95 }
96 else
97 {
98 ShowMessages("err, couldn't resolve error at '%s'\n",
99 GetCaseSensitiveStringFromCommandToken(CommandTokens.at(1)).c_str());
100 return;
101 }
102}
#define TRUE
Definition BasicTypes.h:114
#define FALSE
Definition BasicTypes.h:113
unsigned int UINT32
Definition BasicTypes.h:54
std::string GetCaseSensitiveStringFromCommandToken(CommandToken TargetToken)
Get case sensitive string from command token.
Definition common.cpp:467
BOOLEAN CompareLowerCaseStrings(CommandToken TargetToken, const CHAR *StringToCompare)
Compare lower case strings.
Definition common.cpp:503
BOOLEAN ConvertTokenToUInt32(CommandToken TargetToken, PUINT32 Result)
check and convert command token to a 32 bit unsigned integer
Definition common.cpp:546
NULL()
Definition test-case-generator.py:530
VOID CommandSwitchHelp()
help of the .switch command
Definition switch.cpp:20
BOOLEAN UdSetActiveDebuggingThreadByPidOrTid(UINT32 TargetPidOrTid, BOOLEAN IsTid)
Set the active debugging thread by process id or thread id.
Definition ud.cpp:1314
BOOLEAN UdShowListActiveDebuggingProcessesAndThreads()
Show list of active debugging processes and threads.
Definition ud.cpp:1397

◆ CommandSwitchHelp()

VOID CommandSwitchHelp ( )

help of the .switch command

Returns
VOID
21{
22 ShowMessages(".switch : shows the list of active debugging threads and switches "
23 "between processes and threads in VMI Mode.\n\n");
24
25 ShowMessages("syntax : \t.switch \n");
26 ShowMessages("syntax : \t.switch [pid ProcessId (hex)]\n");
27 ShowMessages("syntax : \t.switch [tid ThreadId (hex)]\n");
28
29 ShowMessages("\n");
30 ShowMessages("\t\te.g : .switch\n");
31 ShowMessages("\t\te.g : .switch list\n");
32 ShowMessages("\t\te.g : .switch pid b60 \n");
33 ShowMessages("\t\te.g : .switch tid b60 \n");
34}