Skip to content

Commit b921b63

Browse files
committed
Add GetModuleName helper
1 parent 8ff238c commit b921b63

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/helper.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void WritePatchAddressFloat32(uint64_t Patch_Address, const float* Patch_Bytes,
3333
void WritePatchAddressFloat64(uint64_t Patch_Address, const double* Patch_Bytes, const wchar_t* Patch_Name, uint64_t Patch_Offset);
3434
wchar_t* GetRunningPath(wchar_t* output);
3535
wchar_t* GetModuleName(wchar_t* output);
36+
const wchar_t* GetModuleName(const HMODULE hModule);
3637
uintptr_t FindAndPrintPatternW(const wchar_t* Patch_Pattern, const wchar_t* Pattern_Name, size_t offset = 0);
3738
uintptr_t FindAndPrintPatternW(const HMODULE Module, const wchar_t* Patch_Pattern, const wchar_t* Pattern_Name, size_t offset = 0);
3839
uintptr_t FindInt3Jmp(const HMODULE Module);

source/Shared/helper.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,18 @@ wchar_t* GetModuleName(wchar_t* output)
206206
return output;
207207
}
208208

209+
const wchar_t* GetModuleName(const HMODULE hModule)
210+
{
211+
static wchar_t* pModuleName = 0;
212+
static wchar_t ModuleName[MAX_PATH];
213+
ZeroMemory(ModuleName, _countof(ModuleName));
214+
// Attempt to get current exe
215+
GetModuleFileName(hModule ? hModule : GetModuleHandle(0), ModuleName, _countof(ModuleName));
216+
pModuleName = PathFindFileName(ModuleName);
217+
LOG("Obtained module name: %s\n", pModuleName);
218+
return pModuleName;
219+
}
220+
209221
wchar_t* ConvertToWideChar(const char* input)
210222
{
211223
int length = MultiByteToWideChar(CP_UTF8, 0, input, -1, nullptr, 0);

0 commit comments

Comments
 (0)