MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / GetFunctionModuleFileName

Function GetFunctionModuleFileName

lib/plugin/plugin.cpp:22–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20#include "system/winapi.h"
21
22static bool GetFunctionModuleFileName(void *FuncPtr,
23 std::filesystem::path &Path) {
24 WasmEdge::winapi::HMODULE_ Module = nullptr;
25
26 if (!WasmEdge::winapi::GetModuleHandleExW(
27 WasmEdge::winapi::GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS_ |
28 WasmEdge::winapi::GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT_,
29 reinterpret_cast<WasmEdge::winapi::LPCWSTR_>(FuncPtr), &Module)) {
30 return false;
31 }
32
33 std::vector<wchar_t> Buffer;
34 WasmEdge::winapi::DWORD_ CopiedSize;
35 do {
36 Buffer.resize(Buffer.size() + WasmEdge::winapi::MAX_PATH_);
37 CopiedSize = WasmEdge::winapi::GetModuleFileNameW(
38 Module, Buffer.data(),
39 static_cast<WasmEdge::winapi::DWORD_>(Buffer.size()));
40 if (CopiedSize == 0) {
41 return false;
42 }
43 } while (CopiedSize >= Buffer.size());
44
45 Path.assign(std::wstring_view(Buffer.data(), CopiedSize));
46 return true;
47}
48#endif
49
50namespace WasmEdge {

Callers 1

getDefaultPluginPathsMethod · 0.85

Calls 4

resizeMethod · 0.80
assignMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected