| 339 | } |
| 340 | |
| 341 | bool IsSystemModulePath(const std::string& path) { |
| 342 | static const std::string systemDir = [] { |
| 343 | const UINT needed = GetWindowsDirectoryW(nullptr, 0); |
| 344 | if (needed == 0) { |
| 345 | OSTP_LOG_WARN("GetWindowsDirectoryW(size query) failed (error={})", GetLastError()); |
| 346 | return std::string{}; |
| 347 | } |
| 348 | std::wstring dir(needed, L'\0'); |
| 349 | const UINT written = GetWindowsDirectoryW(dir.data(), needed); |
| 350 | if (written == 0 || written >= needed) { |
| 351 | OSTP_LOG_WARN("GetWindowsDirectoryW failed (written={}, error={})", written, GetLastError()); |
| 352 | return std::string{}; |
| 353 | } |
| 354 | dir.resize(written); |
| 355 | std::string normalized = NormalizePathForCompare(Encoding::WideToUtf8(dir)); |
| 356 | if (!normalized.empty() && normalized.back() != '\\') normalized += '\\'; |
| 357 | return normalized; |
| 358 | }(); |
| 359 | |
| 360 | if (systemDir.empty()) return false; |
| 361 | return NormalizePathForCompare(path).starts_with(systemDir); |
| 362 | } |
| 363 | |
| 364 | } // namespace OSTPlatform::Process |
no test coverage detected