From d18ee31facdf341aa2e79a782e4701d46c57621c Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Thu, 26 Sep 2019 09:22:09 +0200 Subject: added explicit struct constructor --- MemDriverLib/PatternScanner.cpp | 13 ++++--------- include/PatternScanner.h | 6 ++++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/MemDriverLib/PatternScanner.cpp b/MemDriverLib/PatternScanner.cpp index 1b2a493..3e1b8ee 100644 --- a/MemDriverLib/PatternScanner.cpp +++ b/MemDriverLib/PatternScanner.cpp @@ -20,13 +20,8 @@ static bool map_file_kmem(MODULE_DATA& module, PVOID * const buffer, static bool map_file_kmem_cleanup(MODULE_DATA& module, PVOID buffer, PVOID const user_ptr); -const struct map_file_data map_loadlib = { - map_file_loadlib, map_file_loadlib_cleanup, true -}; - -const struct map_file_data map_kmem = { - map_file_kmem, map_file_kmem_cleanup, false -}; +const struct map_file_data map_loadlib = map_file_data(map_file_loadlib, map_file_loadlib_cleanup, true); +const struct map_file_data map_kmem = map_file_data(map_file_kmem, map_file_kmem_cleanup, false); bool map_file_loadlib(MODULE_DATA& module, PVOID * const buffer, SIZE_T * const size, PVOID const user_ptr) @@ -161,7 +156,7 @@ bool PatternScanner::Scan(MODULE_DATA& module, const char * const pattern) return false; } - if (!mfd->map_file(module, (PVOID *)&mappedBuffer, &mappedSize, map_file_user_data)) + if (!mfd->mapfile(module, (PVOID *)&mappedBuffer, &mappedSize, map_file_user_data)) { return false; } @@ -190,7 +185,7 @@ bool PatternScanner::Scan(MODULE_DATA& module, const char * const pattern) doScan(mappedBuffer, mappedSize, foundOffsets); } - if (!mfd->map_file_cleanup(module, mappedBuffer, map_file_user_data)) + if (!mfd->mapcleanup(module, mappedBuffer, map_file_user_data)) { return false; } diff --git a/include/PatternScanner.h b/include/PatternScanner.h index 7a661aa..1c53349 100644 --- a/include/PatternScanner.h +++ b/include/PatternScanner.h @@ -12,8 +12,10 @@ typedef bool(*map_file_cleanup_cb)(IN MODULE_DATA&, IN PVOID, IN PVOID const); struct map_file_data { - map_file_cb map_file; - map_file_cleanup_cb map_file_cleanup; + explicit map_file_data(map_file_cb _mapfile, map_file_cleanup_cb _mapcleanup, bool _in_memory_module) + : mapfile(_mapfile), mapcleanup(_mapcleanup), in_memory_module(_in_memory_module) {} + map_file_cb mapfile; + map_file_cleanup_cb mapcleanup; bool in_memory_module; }; -- cgit v1.2.3