63{
64 wstring Filepath;
69 UINT64 StartAddress = 0;
70 UINT64 EndAddress = 0;
79
80 if (CommandTokens.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 : CommandTokens)
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 }
125 {
127 continue;
128 }
130 {
132 continue;
133 }
134
135
136
137 else if (!IsTheFirstAddr &&
139 {
140 IsTheFirstAddr =
TRUE;
141 }
142
143
144
145 else if (!IsTheSecondAddr &&
147 {
148 IsTheSecondAddr =
TRUE;
149 }
150 else
151 {
152
153
154
155 ShowMessages("err, couldn't resolve error at '%s'\n\n",
158
159 return;
160 }
161 }
162
163
164
165
166 if (NextIsProcId)
167 {
168 ShowMessages("please specify a correct hex value for process id\n\n");
170 return;
171 }
172
173
174
175
176 if (NextIsPath || !IsDumpPathSpecified)
177 {
178 ShowMessages("please specify a correct path for saving the dump\n\n");
180 return;
181 }
182
183
184
185
186 if (!IsTheFirstAddr || !IsTheSecondAddr)
187 {
188 ShowMessages("err, please specify the start and end address in hex format\n");
189 return;
190 }
191
192
193
194
195 if (StartAddress >= EndAddress)
196 {
197 ShowMessages("err, please note that the 'to' address should be greater than the 'from' address\n");
198 return;
199 }
200
201
202
203
205 {
207 return;
208 }
209
210 if (Pid == 0)
211 {
212
213
214
216 }
217
218
219
220
221 if (!FirstCommand.compare("!dump"))
222 {
224 }
225
226
227
228
229
230
231
232
233
234
235
236
237#ifdef __linux__
239#else
241#endif
242
244 {
245 ShowMessages("err, unable to create or open the file\n");
246 return;
247 }
248
249
250
251
252 Length = (
UINT32)(EndAddress - StartAddress);
253
256
257 for (SIZE_T i = 0; i <= Iterator; i++)
258 {
259 UINT64 Address = StartAddress + (i *
PAGE_SIZE);
260
262 {
264 }
265 else
266 {
267 ActualLength = Length;
268 }
269
270 Length -= ActualLength;
271
272 if (ActualLength != 0)
273 {
274
275
278 Address,
279 MemoryType,
281 Pid,
282 ActualLength,
283 NULL);
284 }
285 }
286
287
288
289
291 {
294 }
295
296 ShowMessages("the dump file is saved at: %ls\n", Filepath.c_str());
297}
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
Shows if the debugger was connected to remote debuggee over (A remote guest).
Definition globals.h:253
ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
State of active debugging thread.
Definition globals.h:372
std::string GetCaseSensitiveStringFromCommandToken(CommandToken TargetToken)
Get case sensitive string from command token.
Definition common.cpp:467
VOID StringToWString(std::wstring &ws, const std::string &s)
convert std::string to std::wstring
Definition common.cpp:850
std::string GetLowerStringFromCommandToken(CommandToken TargetToken)
Get lower case string from command token.
Definition common.cpp:484
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
VOID CommandDumpHelp()
help of the .dump command
Definition dump.cpp:36
HANDLE DumpFileHandle
Holds the handle of the dump file.
Definition dump.cpp:28
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
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:359