NativeMethods.cpp 941 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "il2cpp-config.h"
  2. #if IL2CPP_TARGET_WINDOWS
  3. #include "WindowsHelpers.h"
  4. #include "os/NativeMethods.h"
  5. #include "utils/Expected.h"
  6. #include "utils/Il2CppError.h"
  7. namespace il2cpp
  8. {
  9. namespace os
  10. {
  11. bool NativeMethods::CloseProcess(ProcessHandle* handle)
  12. {
  13. return ::CloseHandle(handle) != FALSE;
  14. }
  15. utils::Expected<bool> NativeMethods::GetExitCodeProcess(ProcessHandle* handle, int32_t* exitCode)
  16. {
  17. #if IL2CPP_TARGET_WINDOWS_DESKTOP
  18. return ::GetExitCodeProcess((HANDLE)handle, (LPDWORD)exitCode);
  19. #else
  20. return utils::Il2CppError(utils::NotSupported, "Getting process exit code is not supported on WinRT based platforms.");
  21. #endif
  22. }
  23. int32_t NativeMethods::GetCurrentProcessId()
  24. {
  25. return ::GetCurrentProcessId();
  26. }
  27. utils::Expected<ProcessHandle*> NativeMethods::GetCurrentProcess()
  28. {
  29. return (ProcessHandle*)::GetCurrentProcess();
  30. }
  31. }
  32. }
  33. #endif