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

.start command More...

#include "pch.h"

Functions

VOID CommandStartHelp ()
 help of the .start command
 
VOID CommandStart (vector< string > SplitCommand, string Command)
 .start command handler
 

Variables

std::wstring g_StartCommandPath
 the start path used in .start command
 
std::wstring g_StartCommandPathAndArguments
 the start arguments used in .start command
 
BOOLEAN g_IsSerialConnectedToRemoteDebugger
 Shows if the debugger was connected to remote debugger (A remote host)
 

Detailed Description

.start command

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

Function Documentation

◆ CommandStart()

VOID CommandStart ( vector< string > SplitCommand,
string Command )

.start command handler

Parameters
SplitCommand
Command
Returns
VOID
46{
47 vector<string> PathAndArgs;
48 string Arguments = "";
49
50 //
51 // Disable user-mode debugger in this version
52 //
53#if ActivateUserModeDebugger == FALSE
54
56 {
57 ShowMessages("the user-mode debugger in VMI Mode is still in the beta version and not stable. "
58 "we decided to exclude it from this release and release it in future versions. "
59 "if you want to test the user-mode debugger in VMI Mode, you should build "
60 "HyperDbg with special instructions. But starting processes is fully supported "
61 "in the Debugger Mode.\n"
62 "(it's not recommended to use it in VMI Mode yet!)\n");
63 return;
64 }
65
66#endif // !ActivateUserModeDebugger
67
68 if (SplitCommand.size() <= 2)
69 {
70 ShowMessages("incorrect use of the '.start'\n\n");
72 return;
73 }
74
75 if (!SplitCommand.at(1).compare("path"))
76 {
77 //
78 // *** It's a run of target PE file ***
79 //
80
81 //
82 // Trim the command
83 //
84 Trim(Command);
85
86 //
87 // Remove '.start' or 'start' from it
88 //
89 Command.erase(0, SplitCommand.at(0).size());
90
91 //
92 // Remove path + space
93 //
94 Command.erase(0, 4 + 1);
95
96 //
97 // Trim it again
98 //
99 Trim(Command);
100
101 //
102 // Split Path and args
103 //
104 SplitPathAndArgs(PathAndArgs, Command);
105
106 //
107 // Convert path to wstring
108 //
109 StringToWString(g_StartCommandPath, PathAndArgs.at(0));
110
111 if (PathAndArgs.size() != 1)
112 {
113 //
114 // There are arguments to this command
115 //
116
117 for (auto item : PathAndArgs)
118 {
119 //
120 // Append the arguments
121 //
122 // ShowMessages("Arg : %s\n", item.c_str());
123 Arguments += item + " ";
124 }
125
126 //
127 // Remove the latest space
128 //
129 Arguments.pop_back();
130
131 //
132 // Convert arguments to wstring
133 //
135 }
136 }
137 else
138 {
139 ShowMessages("err, couldn't resolve error at '%s'\n\n",
140 SplitCommand.at(1).c_str());
142 return;
143 }
144
145 //
146 // Perform run of the target file
147 //
148 if (Arguments.empty())
149 {
151 g_StartCommandPath.c_str(),
152 NULL,
153 FALSE);
154 }
155 else
156 {
158 g_StartCommandPath.c_str(),
160 FALSE);
161 }
162}
#define FALSE
Definition BasicTypes.h:54
wchar_t WCHAR
Definition BasicTypes.h:32
VOID StringToWString(std::wstring &ws, const std::string &s)
convert std::string to std::wstring
Definition common.cpp:729
VOID SplitPathAndArgs(std::vector< std::string > &Qargs, const std::string &Command)
Split path and arguments and handle strings between quotes.
Definition common.cpp:744
void Trim(std::string &s)
trim from both ends and start of a string (in place)
Definition common.cpp:594
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
BOOLEAN g_IsSerialConnectedToRemoteDebugger
Shows if the debugger was connected to remote debugger (A remote host)
Definition globals.h:238
std::wstring g_StartCommandPathAndArguments
the start arguments used in .start command
Definition globals.h:653
VOID CommandStartHelp()
help of the .start command
Definition start.cpp:27
std::wstring g_StartCommandPath
the start path used in .start command
Definition globals.h:647
BOOLEAN UdAttachToProcess(UINT32 TargetPid, const WCHAR *TargetFileAddress, const WCHAR *CommandLine, BOOLEAN RunCallbackAtTheFirstInstruction)
Attach to target process.
Definition ud.cpp:349

◆ CommandStartHelp()

VOID CommandStartHelp ( )

help of the .start command

Returns
VOID
28{
29 ShowMessages(".start : runs a user-mode process.\n\n");
30
31 ShowMessages("syntax : \t.start [path Path (string)] [Parameters (string)]\n");
32
33 ShowMessages("\n");
34 ShowMessages("\t\te.g : .start path c:\\reverse eng\\my_file.exe\n");
35}

Variable Documentation

◆ g_IsSerialConnectedToRemoteDebugger

BOOLEAN g_IsSerialConnectedToRemoteDebugger
extern

Shows if the debugger was connected to remote debugger (A remote host)

◆ g_StartCommandPath

std::wstring g_StartCommandPath
extern

the start path used in .start command

◆ g_StartCommandPathAndArguments

std::wstring g_StartCommandPathAndArguments
extern

the start arguments used in .start command