@@ -187,10 +187,9 @@ bool dump_memory_region(
187187
188188 const gchar* chk_str = nullptr ;
189189
190+ addr_t dump_addr = ctx->addr ;
190191 addr_t aligned_addr;
191192 addr_t intra_page_offset;
192- size_t aligned_len;
193- size_t len_remainder;
194193 size_t num_pages;
195194
196195 GChecksum* checksum = nullptr ;
@@ -213,16 +212,9 @@ bool dump_memory_region(
213212 aligned_addr = ctx->addr & ~(VMI_PS_4KB - 1 );
214213 intra_page_offset = ctx->addr & (VMI_PS_4KB - 1 );
215214
216- aligned_len = len_bytes & ~(VMI_PS_4KB - 1 );
217- len_remainder = len_bytes & (VMI_PS_4KB - 1 );
218-
219- if (len_remainder)
220- {
221- aligned_len += VMI_PS_4KB ;
222- }
215+ num_pages = (intra_page_offset + len_bytes + VMI_PS_4KB - 1 ) / VMI_PS_4KB ;
223216
224217 ctx->addr = aligned_addr;
225- num_pages = aligned_len / VMI_PS_4KB ;
226218
227219 access_ptrs = (void **)g_malloc (num_pages * sizeof (void *));
228220
@@ -284,7 +276,7 @@ bool dump_memory_region(
284276 // * de-duplication - sometimes, different heuristics may want to dump the same piece of memory;
285277 // unless there is a change in image base or contents, repeated memory dumps would get exactly
286278 // the same file name
287- if (asprintf (&file, " %llx_%.16s" , (unsigned long long ) ctx-> addr , chk_str) < 0 )
279+ if (asprintf (&file, " %llx_%.16s" , (unsigned long long ) dump_addr , chk_str) < 0 )
288280 goto done;
289281
290282 if (asprintf (&file_path, " %s/%s" , plugin->memdump_dir , file) < 0 )
@@ -298,7 +290,7 @@ bool dump_memory_region(
298290 if (asprintf (&metafile, " %s/memdump.%06d" , plugin->memdump_dir , sequence_number) < 0 )
299291 goto done;
300292
301- save_file_metadata (info, metafile, file, len_bytes, ctx-> addr , info->trap ->name , reason, sequence_number, extras);
293+ save_file_metadata (info, metafile, file, len_bytes, dump_addr , info->trap ->name , reason, sequence_number, extras);
302294
303295 ret = true ;
304296
@@ -309,7 +301,7 @@ bool dump_memory_region(
309301 auto default_print = std::make_tuple (
310302 keyval (" DumpReason" , fmt::Qstr (reason)),
311303 keyval (" DumpPID" , fmt::Nval (info->attached_proc_data .pid )),
312- keyval (" DumpAddr" , fmt::Xval (ctx-> addr , false )),
304+ keyval (" DumpAddr" , fmt::Xval (dump_addr , false )),
313305 keyval (" DumpSize" , fmt::Xval (len_bytes)),
314306 keyval (" DumpFilename" , fmt::Qstr (display_file)),
315307 keyval (" DumpsCount" , fmt::Nval (sequence_number))
0 commit comments