@@ -361,7 +361,7 @@ namespace Memory {
361361 void Modules::PopulateModules () {
362362#ifdef _WIN32
363363 HMODULE modules[1024 ];
364- auto processHandle = GetCurrentProcess ();
364+ const auto processHandle = GetCurrentProcess ();
365365 DWORD modulesNeeded;
366366 if (EnumProcessModules (processHandle, modules, sizeof (modules), &modulesNeeded)) {
367367 for (DWORD i = 0 ; i < (modulesNeeded / sizeof (HMODULE)); i++) {
@@ -374,7 +374,7 @@ namespace Memory {
374374 std::make_pair (
375375 modulePath.stem ().string (),
376376 std::span<uint8_t >(
377- reinterpret_cast <uint8_t *>(moduleInfo.lpBaseOfDll ),
377+ static_cast <uint8_t *>(moduleInfo.lpBaseOfDll ),
378378 static_cast <size_t >(moduleInfo.SizeOfImage )
379379 )
380380 )
@@ -385,7 +385,7 @@ namespace Memory {
385385#endif
386386 }
387387
388- std::span<uint8_t > Modules::Get (std::string name) {
388+ std::span<uint8_t > Modules::Get (const std::string& name) {
389389 if (loadedModules.empty ()) {
390390 PopulateModules ();
391391 }
@@ -398,31 +398,31 @@ namespace Memory {
398398 }
399399 }
400400
401- void ReplacePattern (std::string target_module, std::string patternBytes, std::string replace_with )
401+ void ReplacePattern (const std::string& targetModule, const std::string& patternBytes, const std::string& replaceWith )
402402 {
403- void * addr = Memory::Scanner::Scan<void *>(Memory::Modules::Get (target_module ), patternBytes);
403+ void * addr = Memory::Scanner::Scan<void *>(Memory::Modules::Get (targetModule ), patternBytes);
404404 if (!addr)
405405 {
406406 Log (WARNING, false , " Failed to replace pattern! Turn on p2sm_developer for more info..." );
407- Log (WARNING, true , " Target Module: %s" , target_module .c_str ());
407+ Log (WARNING, true , " Target Module: %s" , targetModule .c_str ());
408408 Log (WARNING, true , " Pattern Bytes To Find: %s" , patternBytes.c_str ());
409- Log (WARNING, true , " Bytes To Replace Pattern Bytes With: %s" , replace_with .c_str ());
409+ Log (WARNING, true , " Bytes To Replace Pattern Bytes With: %s" , replaceWith .c_str ());
410410 return ;
411411 }
412412
413413 std::vector<uint8_t > replace;
414414
415- std::istringstream patternStream (replace_with );
415+ std::istringstream patternStream (replaceWith );
416416 std::string patternByte;
417417 while (patternStream >> patternByte)
418418 {
419- replace.push_back (( uint8_t ) std::stoul (patternByte, nullptr , 16 ));
419+ replace.push_back (static_cast < uint8_t >( std::stoul (patternByte, nullptr , 16 ) ));
420420 }
421421
422- DWORD oldprotect = 0 ;
423- DWORD newprotect = PAGE_EXECUTE_READWRITE;
424- VirtualProtect (addr, replace.size (), newprotect , &oldprotect );
422+ DWORD oldProtect = 0 ;
423+ DWORD newProtect = PAGE_EXECUTE_READWRITE;
424+ VirtualProtect (addr, replace.size (), newProtect , &oldProtect );
425425 memcpy_s (addr, replace.size (), replace.data (), replace.size ());
426- VirtualProtect (addr, replace.size (), oldprotect , &newprotect );
426+ VirtualProtect (addr, replace.size (), oldProtect , &newProtect );
427427 }
428428};
0 commit comments