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< string > SplitCommand, string Command)
 .switch command handler
 

Variables

ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
 State of active debugging thread.
 
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
 Shows if the debugger was connected to remote debuggee over (A remote guest)
 

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< string > SplitCommand,
string Command )

.switch command handler

Parameters
SplitCommand
Command
Returns
VOID
50{
51 UINT32 PidOrTid = NULL;
52
53 if (SplitCommand.size() > 3 || SplitCommand.size() == 2)
54 {
55 ShowMessages("incorrect use of the '.switch'\n\n");
57 return;
58 }
59
60 //
61 // .attach and .detach commands are only supported in VMI Mode
62 //
64 {
65 ShowMessages("err, the '.switch' command is only usable in VMI Mode, "
66 "you can use the '.process', or the '.thread' "
67 "in Debugger Mode\n");
68 return;
69 }
70
71 //
72 // Perform switching or listing the threads
73 //
74 if (SplitCommand.size() == 1)
75 {
77 }
78 else if (!SplitCommand.at(1).compare("pid"))
79 {
80 if (!ConvertStringToUInt32(SplitCommand.at(2), &PidOrTid))
81 {
82 ShowMessages("please specify a correct hex value for process id\n\n");
83 return;
84 }
85
86 //
87 // Switch by pid
88 //
90 {
91 ShowMessages("switched to process id: %x\n", PidOrTid);
92 }
93 }
94 else if (!SplitCommand.at(1).compare("tid"))
95 {
96 if (!ConvertStringToUInt32(SplitCommand.at(2), &PidOrTid))
97 {
98 ShowMessages("please specify a correct hex value for thread id\n\n");
99 return;
100 }
101
102 //
103 // Switch by tid
104 //
106 {
107 ShowMessages("switched to thread id: %x\n", PidOrTid);
108 }
109 }
110 else
111 {
112 ShowMessages("err, couldn't resolve error at '%s'\n",
113 SplitCommand.at(1).c_str());
114 return;
115 }
116}
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned int UINT32
Definition BasicTypes.h:48
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
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
NULL()
Definition test-case-generator.py:530
VOID CommandSwitchHelp()
help of the .switch command
Definition switch.cpp:26
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
Shows if the debugger was connected to remote debuggee over (A remote guest)
Definition globals.h:231
BOOLEAN UdSetActiveDebuggingThreadByPidOrTid(UINT32 TargetPidOrTid, BOOLEAN IsTid)
Set the active debugging thread by process id or thread id.
Definition ud.cpp:1037
BOOLEAN UdShowListActiveDebuggingProcessesAndThreads()
Show list of active debugging processes and threads.
Definition ud.cpp:1119

◆ CommandSwitchHelp()

VOID CommandSwitchHelp ( )

help of the .switch command

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

Variable Documentation

◆ g_ActiveProcessDebuggingState

ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
extern

State of active debugging thread.

362{0};

◆ g_IsSerialConnectedToRemoteDebuggee

BOOLEAN g_IsSerialConnectedToRemoteDebuggee
extern

Shows if the debugger was connected to remote debuggee over (A remote guest)