| 49 | |
| 50 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 51 | std::string getErrorMessage(const char* function) { |
| 52 | LPSTR messageBuffer = nullptr; |
| 53 | size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 54 | NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL); |
| 55 | std::string message(messageBuffer, size); |
| 56 | LocalFree(messageBuffer); |
| 57 | return std::string(function) + std::string(": ") + message; |
| 58 | } |
| 59 | |
| 60 | void setPrivilege(const char* pszPrivilege, BOOL bEnable) { |
| 61 | HANDLE hToken; |
no outgoing calls
no test coverage detected