@@ -11,7 +11,7 @@ template<typename T>
11
11
class FlexibleBuffer
12
12
{
13
13
public:
14
- FlexibleBuffer (std:: size_t initialSize)
14
+ FlexibleBuffer (size_t initialSize)
15
15
: data(initialSize)
16
16
{
17
17
@@ -213,32 +213,37 @@ void EnumerateRemoteSectionsAndModules(RC_Pointer remoteId, const std::function<
213
213
std::vector<HMODULE> modules (needed / sizeof (HMODULE));
214
214
if (EnumProcessModules (remoteId, modules.data (), needed, &needed))
215
215
{
216
- for (HMODULE curModule : modules)
216
+ for (auto module : modules)
217
217
{
218
218
MODULEINFO moduleInfo = {};
219
219
wchar_t modulepath[MAX_PATH] = {};
220
220
221
- if (GetModuleInformation (remoteId, curModule , &moduleInfo, sizeof (moduleInfo)) &&
222
- GetModuleFileNameExW (remoteId, curModule , modulepath, MAX_PATH))
221
+ if (GetModuleInformation (remoteId, module , &moduleInfo, sizeof (moduleInfo)) &&
222
+ GetModuleFileNameExW (remoteId, module , modulepath, MAX_PATH))
223
223
{
224
- moduleCallback ((RC_Pointer)moduleInfo.lpBaseOfDll , (RC_Pointer)moduleInfo.SizeOfImage , modulepath);
224
+ moduleCallback (
225
+ static_cast <RC_Pointer>(moduleInfo.lpBaseOfDll ),
226
+ reinterpret_cast <RC_Pointer>(moduleInfo.SizeOfImage ),
227
+ modulepath
228
+ );
225
229
230
+ const auto it = std::lower_bound (
231
+ std::begin (sections),
232
+ std::end (sections),
233
+ static_cast <LPVOID>(moduleInfo.lpBaseOfDll ),
234
+ [§ions](const auto & lhs, const LPVOID& rhs) { return lhs.BaseAddress < rhs; }
235
+ );
226
236
227
- auto it = std::lower_bound (std::begin (sections), std::end (sections), static_cast <LPVOID>(moduleInfo.lpBaseOfDll ), [§ions](const auto & lhs, const LPVOID& rhs)
228
- {
229
- return lhs.BaseAddress < rhs;
230
- });
231
-
232
- IMAGE_DOS_HEADER DosHdr = {};
233
- IMAGE_NT_HEADERS NtHdr = {};
237
+ IMAGE_DOS_HEADER dosHdr = {};
238
+ IMAGE_NT_HEADERS ntHdr = {};
234
239
235
- ReadProcessMemory (remoteId, (( BYTE*) moduleInfo.lpBaseOfDll ), &DosHdr , sizeof (IMAGE_DOS_HEADER), NULL );
236
- ReadProcessMemory (remoteId, (( BYTE*) moduleInfo.lpBaseOfDll ) + DosHdr .e_lfanew , &NtHdr , sizeof (IMAGE_NT_HEADERS), NULL );
240
+ ReadProcessMemory (remoteId, static_cast < BYTE*>( moduleInfo.lpBaseOfDll ), &dosHdr , sizeof (IMAGE_DOS_HEADER), nullptr );
241
+ ReadProcessMemory (remoteId, static_cast < BYTE*>( moduleInfo.lpBaseOfDll ) + dosHdr .e_lfanew , &ntHdr , sizeof (IMAGE_NT_HEADERS), nullptr );
237
242
238
- std::vector<IMAGE_SECTION_HEADER> sectionHeaders (NtHdr .FileHeader .NumberOfSections );
239
- ReadProcessMemory (remoteId, (( BYTE*) moduleInfo.lpBaseOfDll ) + DosHdr .e_lfanew + sizeof (IMAGE_NT_HEADERS), sectionHeaders.data (), NtHdr .FileHeader .NumberOfSections * sizeof (IMAGE_SECTION_HEADER), NULL );
243
+ std::vector<IMAGE_SECTION_HEADER> sectionHeaders (ntHdr .FileHeader .NumberOfSections );
244
+ ReadProcessMemory (remoteId, static_cast < BYTE*>( moduleInfo.lpBaseOfDll ) + dosHdr .e_lfanew + sizeof (IMAGE_NT_HEADERS), sectionHeaders.data (), ntHdr .FileHeader .NumberOfSections * sizeof (IMAGE_SECTION_HEADER), nullptr );
240
245
241
- for (auto i = 0 ; i < NtHdr .FileHeader .NumberOfSections ; ++i)
246
+ for (auto i = 0 ; i < ntHdr .FileHeader .NumberOfSections ; ++i)
242
247
{
243
248
auto && sectionHeader = sectionHeaders[i];
244
249
@@ -273,7 +278,15 @@ void EnumerateRemoteSectionsAndModules(RC_Pointer remoteId, const std::function<
273
278
274
279
for (auto && section : sections)
275
280
{
276
- sectionCallback (section.BaseAddress , reinterpret_cast <RC_Pointer>(section.Size ), section.Type , section.Category , section.Protection , reinterpret_cast <const WCHAR*>(section.Name ), reinterpret_cast <const WCHAR*>(section.ModulePath ));
281
+ sectionCallback (
282
+ section.BaseAddress ,
283
+ reinterpret_cast <RC_Pointer>(section.Size ),
284
+ section.Type ,
285
+ section.Category ,
286
+ section.Protection ,
287
+ reinterpret_cast <const WCHAR*>(section.Name ),
288
+ reinterpret_cast <const WCHAR*>(section.ModulePath )
289
+ );
277
290
}
278
291
}
279
292
}
0 commit comments