MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / GetProcessFileName

Method GetProcessFileName

Common/win32.hpp:56–75  ·  view source on GitHub ↗

Gets location of the file of a process

Source from the content-addressed store, hash-verified

54public:
55 // Gets location of the file of a process
56 inline static std::pair<std::filesystem::path, HRESULT> GetProcessFileName(HANDLE process)
57 {
58 std::wstring exeLocation;
59 HRESULT hr = S_OK;
60 exeLocation.resize_and_overwrite(wil::max_extended_path_length, [process, &hr](wchar_t* data, std::size_t count) -> std::size_t
61 {
62 DWORD bufSize = static_cast<DWORD>(count) + 1;
63 if (QueryFullProcessImageName(process, 0, data, &bufSize))
64 {
65 return bufSize;
66 }
67 else
68 {
69 hr = HRESULT_FROM_WIN32(GetLastError());
70 return 0;
71 }
72 });
73
74 return { std::move(exeLocation), hr };
75 }
76
77 // Gets location of current process
78 inline static std::pair<std::filesystem::path, HRESULT> GetExeLocation()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected