33
44#include " blook/blook.h"
55
6+ #include " blook/utils.h"
67#include " windows.h"
78
89#include " psapi.h"
@@ -36,8 +37,7 @@ static HMODULE GetProcessBaseAddress(HANDLE processHandle,
3637 HMODULE *moduleArray;
3738 LPBYTE moduleArrayBytes;
3839 DWORD bytesRequired;
39- std::transform (modulename.begin (), modulename.end (), modulename.begin (),
40- [](unsigned char c) { return std::tolower (c); });
40+ modulename = blook::utils::to_lower (modulename);
4141
4242 if (processHandle) {
4343 if (EnumProcessModules (processHandle, NULL , 0 , &bytesRequired)) {
@@ -57,10 +57,7 @@ static HMODULE GetProcessBaseAddress(HANDLE processHandle,
5757 char name[MAX_PATH];
5858 if (GetModuleFileNameA (module , name, MAX_PATH)) {
5959 auto filename = std::filesystem::path (name).filename ().string ();
60-
61- std::transform (filename.begin (), filename.end (),
62- filename.begin (),
63- [](unsigned char c) { return std::tolower (c); });
60+ filename = blook::utils::to_lower (filename);
6461 if (modulename == filename) {
6562 baseAddress = module ;
6663 break ;
@@ -181,7 +178,8 @@ std::expected<void, std::string> Process::try_write(void *dst, const void *src,
181178 if (safe_memcpy (dst, src, size)) {
182179 return {};
183180 } else {
184- return std::unexpected (std::format (" Failed to write memory {:p}: access violation" , dst));
181+ return std::unexpected (
182+ std::format (" Failed to write memory {:p}: access violation" , dst));
185183 }
186184 } else {
187185 SIZE_T written = 0 ;
@@ -369,7 +367,7 @@ Process::module(const std::string &name) {
369367 return {};
370368 } else {
371369 auto modules = this ->modules ();
372- auto it = modules.find (name);
370+ auto it = modules.find (blook::utils::to_lower ( name) );
373371 if (it != modules.end ())
374372 return it->second ;
375373 return {};
@@ -449,8 +447,7 @@ std::map<std::string, std::shared_ptr<Module>> Process::modules() {
449447 if (GetModuleFileNameExA (this ->h , hMods[i], szModName,
450448 sizeof (szModName))) {
451449 auto name = std::filesystem::path (szModName).filename ().string ();
452- std::transform (name.begin (), name.end (), name.begin (),
453- [](unsigned char c) { return std::tolower (c); });
450+ name = blook::utils::to_lower (name);
454451 modules[name] = Module::make (
455452 const_cast <Process *>(this )->shared_from_this (), hMods[i]);
456453 }
0 commit comments