host_environment.cpp 621 B

123456789101112131415161718
  1. #include "host_environment.h"
  2. #include <Windows.h>
  3. namespace sunrise::core::runtime {
  4. /** @return True when the loaded ntdll exports Wine's own version entry point. */
  5. bool is_wine() noexcept {
  6. // Wine exports this from ntdll to name itself and Windows never does. The host cannot change
  7. // while the process lives, so the answer is resolved once.
  8. static const bool underWine = [] {
  9. const HMODULE ntdll = GetModuleHandleW(L"ntdll.dll");
  10. return ntdll != nullptr && GetProcAddress(ntdll, "wine_get_version") != nullptr;
  11. }();
  12. return underWine;
  13. }
  14. } // namespace sunrise::core::runtime