LoadMethod loads method named @methodName from opened lib. If error is found, @error param will be set, otherwise empty.
| 84 | // LoadMethod loads method named @methodName from opened lib. |
| 85 | // If error is found, @error param will be set, otherwise empty. |
| 86 | void* DynamicLibLoader::LoadMethod(const std::string& methodName, std::string& error) { |
| 87 | error.clear(); |
| 88 | |
| 89 | #if defined(__linux__) |
| 90 | dlerror(); // Clear last error. |
| 91 | auto methodPtr = dlsym(mLibPtr, methodName.c_str()); |
| 92 | error = GetError(); |
| 93 | return methodPtr; |
| 94 | #elif defined(_MSC_VER) |
| 95 | auto methodPtr = GetProcAddress((HINSTANCE)mLibPtr, methodName.c_str()); |
| 96 | if (methodPtr != NULL) |
| 97 | return methodPtr; |
| 98 | error = std::to_string(GetLastError()); |
| 99 | return NULL; |
| 100 | #endif |
| 101 | } |
| 102 | |
| 103 | bool glibc::LoadGlibcFunc() { |
| 104 | if (g_loader == nullptr) { |
no test coverage detected