63{
64 wstring Filepath;
77 string FirstCommand = SplitCommand.front();
79
80 if (SplitCommand.size() <= 4)
81 {
82 ShowMessages(
"err, incorrect use of the '.dump' command\n\n");
84 return;
85 }
86
87
88
89
90
92 {
94 }
95
96 for (auto Section : SplitCommand)
97 {
98 if (IsFirstCommand ==
TRUE)
99 {
100 IsFirstCommand =
FALSE;
101 continue;
102 }
103 else if (NextIsProcId)
104 {
106 {
107 ShowMessages(
"please specify a correct hex value for process id\n\n");
109 return;
110 }
111 NextIsProcId =
FALSE;
112 continue;
113 }
114 else if (NextIsPath)
115 {
116
117
118
120 IsDumpPathSpecified =
TRUE;
121
123 }
124 else if (!Section.compare("pid"))
125 {
127 continue;
128 }
129 else if (!Section.compare("path"))
130 {
132 continue;
133 }
134
135
136
138 {
139 IsTheFirstAddr =
TRUE;
140 }
141
142
143
145 {
146 IsTheSecondAddr =
TRUE;
147 }
148 else
149 {
150
151
152
154 Section.c_str());
156
157 return;
158 }
159 }
160
161
162
163
164 if (NextIsProcId)
165 {
166 ShowMessages(
"please specify a correct hex value for process id\n\n");
168 return;
169 }
170
171
172
173
174 if (NextIsPath || !IsDumpPathSpecified)
175 {
176 ShowMessages(
"please specify a correct path for saving the dump\n\n");
178 return;
179 }
180
181
182
183
184 if (!IsTheFirstAddr || !IsTheSecondAddr)
185 {
186 ShowMessages(
"err, please specify the start and end address in hex format\n");
187 return;
188 }
189
190
191
192
193 if (StartAddress >= EndAddress)
194 {
195 ShowMessages(
"err, please note that the 'to' address should be greater than the 'from' address\n");
196 return;
197 }
198
199
200
201
203 {
205 return;
206 }
207
208 if (Pid == 0)
209 {
210
211
212
213 Pid = GetCurrentProcessId();
214 }
215
216
217
218
219 if (!FirstCommand.compare("!dump"))
220 {
222 }
223
224
225
226
228 Filepath.c_str(),
229 GENERIC_WRITE,
230 0,
231 NULL,
232 CREATE_ALWAYS,
233 FILE_ATTRIBUTE_NORMAL,
234 NULL);
235
237 {
238 ShowMessages(
"err, unable to create or open the file\n");
239 return;
240 }
241
242
243
244
245 Length = (
UINT32)(EndAddress - StartAddress);
246
249
250 for (size_t i = 0; i <= Iterator; i++)
251 {
253
255 {
257 }
258 else
259 {
260 ActualLength = Length;
261 }
262
263 Length -= ActualLength;
264
265 if (ActualLength != 0)
266 {
267
268
272 MemoryType,
274 Pid,
275 ActualLength,
276 NULL);
277 }
278 }
279
280
281
282
284 {
287 }
288
289 ShowMessages(
"the dump file is saved at: %ls\n", Filepath.c_str());
290}
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
@ READ_FROM_KERNEL
Definition RequestStructures.h:219
enum _DEBUGGER_READ_MEMORY_TYPE DEBUGGER_READ_MEMORY_TYPE
different type of addresses
@ DEBUGGER_SHOW_COMMAND_DUMP
Definition RequestStructures.h:258
@ DEBUGGER_READ_PHYSICAL_ADDRESS
Definition RequestStructures.h:229
@ DEBUGGER_READ_VIRTUAL_ADDRESS
Definition RequestStructures.h:230
VOID StringToWString(std::wstring &ws, const std::string &s)
convert std::string to std::wstring
Definition common.cpp:729
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 CommandDumpHelp()
help of the .dump command
Definition dump.cpp:36
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
HANDLE DumpFileHandle
Holds the handle of the dump file.
Definition dump.cpp:28
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
NULL()
Definition test-case-generator.py:530
VOID HyperDbgShowMemoryOrDisassemble(DEBUGGER_SHOW_MEMORY_STYLE Style, UINT64 Address, DEBUGGER_READ_MEMORY_TYPE MemoryType, DEBUGGER_READ_READING_TYPE ReadingType, UINT32 Pid, UINT32 Size, PDEBUGGER_DT_COMMAND_OPTIONS DtDetails)
Show memory or disassembler.
Definition readmem.cpp:193
UINT32 ProcessId
Definition ud.h:51
BOOLEAN IsActive
Definition ud.h:49
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