Thread.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #include "il2cpp-config.h"
  2. #if IL2CPP_TARGET_WINDOWS
  3. #include "WindowsHeaders.h"
  4. #include "os/Thread.h"
  5. typedef void (WINAPI *GetCurrentThreadStackLimitsPtr)(PULONG_PTR, PULONG_PTR);
  6. static GetCurrentThreadStackLimitsPtr GetCurrentThreadStackLimitsFunc;
  7. namespace il2cpp
  8. {
  9. namespace os
  10. {
  11. bool Thread::GetCurrentThreadStackBounds(void** low, void** high)
  12. {
  13. // On Windows Desktop we still support Windows 7 and GetCurrentThreadStackLimits wasn't added until Windows 8, but GetProcAddress doesn't exist in UWP
  14. #if IL2CPP_TARGET_WINDOWS_DESKTOP
  15. if (GetCurrentThreadStackLimitsFunc == NULL)
  16. GetCurrentThreadStackLimitsFunc = (GetCurrentThreadStackLimitsPtr)GetProcAddress(GetModuleHandle(L"KERNEL32.DLL"), "GetCurrentThreadStackLimits");
  17. if (GetCurrentThreadStackLimitsFunc != NULL)
  18. {
  19. GetCurrentThreadStackLimitsFunc((PULONG_PTR)low, (PULONG_PTR)high);
  20. return true;
  21. }
  22. return false;
  23. #else
  24. return false;
  25. #endif // IL2CPP_TARGET_WINDOWS_DESKTOP
  26. }
  27. }
  28. }
  29. #endif