MCPcopy Create free account
hub / github.com/ThirteenAG/Ultimate-ASI-Loader / GetModulePath

Function GetModulePath

tests/tests.cpp:9–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7HMODULE hUAL = NULL;
8
9std::filesystem::path GetModulePath(HMODULE hModule)
10{
11 static constexpr auto INITIAL_BUFFER_SIZE = MAX_PATH;
12 static constexpr auto MAX_ITERATIONS = 7;
13
14 std::u16string ret;
15 std::filesystem::path pathret;
16 auto bufferSize = INITIAL_BUFFER_SIZE;
17 for (size_t iterations = 0; iterations < MAX_ITERATIONS; ++iterations)
18 {
19 ret.resize(bufferSize);
20 size_t charsReturned = 0;
21 charsReturned = GetModuleFileNameW(hModule, (LPWSTR)&ret[0], bufferSize);
22 if (charsReturned < ret.length())
23 {
24 ret.resize(charsReturned);
25 pathret = ret;
26 return pathret;
27 }
28 else
29 {
30 bufferSize *= 2;
31 }
32 }
33
34 return {};
35}
36
37void Init()
38{

Callers 1

InitFunction · 0.70

Calls 1

GetModuleFileNameWFunction · 0.85

Tested by

no test coverage detected