MCPcopy Create free account
hub / github.com/OpenSteam001/OpenSteamTool / ModuleFilePath

Function ModuleFilePath

src/OSTPlatform/Windows/DynamicLibrary.cpp:24–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24std::filesystem::path ModuleFilePath(HMODULE module, const char* operation) {
25 for (DWORD capacity = MAX_PATH; capacity <= kMaxWin32PathBuffer; capacity *= 2) {
26 std::vector<wchar_t> buffer(capacity);
27 SetLastError(ERROR_SUCCESS);
28 const DWORD len = GetModuleFileNameW(module, buffer.data(), capacity);
29 if (len == 0) {
30 OSTP_LOG_WARN("{}: GetModuleFileNameW failed (error={})", operation, GetLastError());
31 return {};
32 }
33 if (len < capacity) {
34 return std::filesystem::path(std::wstring_view(buffer.data(), len));
35 }
36 }
37
38 OSTP_LOG_WARN("{}: GetModuleFileNameW path exceeds {} wchars", operation, kMaxWin32PathBuffer);
39 return {};
40}
41
42std::string DirectoryFromQuery(DWORD (*query)(DWORD, wchar_t*), const char* operation) {
43 for (DWORD capacity = MAX_PATH; capacity <= kMaxWin32PathBuffer; capacity *= 2) {

Callers 2

GetModuleDirectoryFunction · 0.85
GetMainExecutablePathFunction · 0.85

Calls 1

dataMethod · 0.80

Tested by

no test coverage detected