-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.cpp
More file actions
33 lines (29 loc) · 695 Bytes
/
utils.cpp
File metadata and controls
33 lines (29 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
THIS FILE IS A PART OF GTA V SCRIPT HOOK SDK
http://dev-c.com
(C) Alexander Blade 2015
*/
#include "utils.h"
#include <windows.h>
extern "C" IMAGE_DOS_HEADER __ImageBase; // MSVC specific, with other compilers use HMODULE from DllMain
std::string cachedModulePath;
std::string GetCurrentModulePath()
{
if (cachedModulePath.empty())
{
// get module path
char modPath[MAX_PATH];
memset(modPath, 0, sizeof(modPath));
GetModuleFileNameA((HMODULE)&__ImageBase, modPath, sizeof(modPath));
for (size_t i = strlen(modPath); i > 0; i--)
{
if (modPath[i - 1] == '\\')
{
modPath[i] = 0;
break;
}
}
cachedModulePath = modPath;
}
return cachedModulePath;
}