@@ -32,7 +32,7 @@ struct ArgumentManager {
3232 void validateArguments (int argc, char * argv[]) {
3333
3434 namespace po = boost::program_options;
35- std::string version = " v1.0.7 " ;
35+ std::string version = " v1.0.8 " ;
3636 po::options_description description (" Windows memory extractor " + version + " \n Usage" );
3737
3838 description.add_options ()
@@ -499,7 +499,15 @@ struct MemoryExtractionManager {
499499 if (argumentManager.getIsJoinOptionSupplied ()) {
500500 std::string fullModuleFilePath = directoryName + " /" + " joinedModuleContents.dmp" ;
501501 std::ofstream fullModuleDataFile (fullModuleFilePath, std::ofstream::app | std::ofstream::binary);
502+ if (nextAddressAfterModuleRegion != 0 && nextAddressAfterModuleRegion < reinterpret_cast <std::uintptr_t >(memInfo.BaseAddress )) {
503+ // Insert padding if memory regions are not contiguous
504+ SIZE_T paddingSize = reinterpret_cast <std::uintptr_t >(memInfo.BaseAddress ) - nextAddressAfterModuleRegion;
505+ auto padding = std::make_unique<char []>(paddingSize);
506+ memset (padding.get (), 0 , paddingSize);
507+ fullModuleDataFile.write (padding.get (), paddingSize);
508+ }
502509 fullModuleDataFile.write (memoryContents.get (), memInfo.RegionSize );
510+ nextAddressAfterModuleRegion = reinterpret_cast <std::uintptr_t >(memInfo.BaseAddress ) + memInfo.RegionSize ;
503511 fullModuleDataFile.close ();
504512 }
505513 }
@@ -657,6 +665,7 @@ struct MemoryExtractionManager {
657665 std::string directoryName; // The directory where the memory data files will be placed
658666 bool isDirectoryCreated;
659667 unsigned int dmpFilesGeneratedCount;
668+ SIZE_T nextAddressAfterModuleRegion;
660669
661670};
662671
0 commit comments