NativeMethods.cpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include "il2cpp-config.h"
  2. #include "NativeMethods.h"
  3. #include "os/NativeMethods.h"
  4. #include "os/Process.h"
  5. #include "vm/Exception.h"
  6. namespace il2cpp
  7. {
  8. namespace icalls
  9. {
  10. namespace System
  11. {
  12. namespace Microsoft
  13. {
  14. namespace Win32
  15. {
  16. bool NativeMethods::CloseProcess(intptr_t handle)
  17. {
  18. return os::NativeMethods::CloseProcess((il2cpp::os::ProcessHandle*)handle);
  19. }
  20. bool NativeMethods::GetExitCodeProcess(intptr_t processHandle, int32_t* exitCode)
  21. {
  22. auto result = os::NativeMethods::GetExitCodeProcess((il2cpp::os::ProcessHandle*)processHandle, exitCode);
  23. vm::Exception::RaiseIfError(result.GetError());
  24. return result.Get();
  25. }
  26. bool NativeMethods::GetProcessTimes(intptr_t handle, int64_t* creation, int64_t* exit, int64_t* kernel, int64_t* user)
  27. {
  28. NOT_SUPPORTED_IL2CPP(NativeMethods::SetPriorityClass, "IL2CPP does not support process times");
  29. return false;
  30. }
  31. bool NativeMethods::GetProcessWorkingSetSize(intptr_t handle, intptr_t* min, intptr_t* max)
  32. {
  33. NOT_SUPPORTED_IL2CPP(NativeMethods::SetPriorityClass, "IL2CPP does not support process working set size");
  34. return false;
  35. }
  36. bool NativeMethods::SetPriorityClass(intptr_t handle, int32_t priorityClass)
  37. {
  38. NOT_SUPPORTED_IL2CPP(NativeMethods::SetPriorityClass, "IL2CPP does not support process priority");
  39. return false;
  40. }
  41. bool NativeMethods::SetProcessWorkingSetSize(intptr_t handle, intptr_t min, intptr_t max)
  42. {
  43. NOT_SUPPORTED_IL2CPP(NativeMethods::SetPriorityClass, "IL2CPP does not support process working set size");
  44. return false;
  45. }
  46. bool NativeMethods::TerminateProcess(intptr_t processHandle, int32_t exitCode)
  47. {
  48. NOT_SUPPORTED_IL2CPP(NativeMethods::SetPriorityClass, "IL2CPP does not support process termination");
  49. return false;
  50. }
  51. int32_t NativeMethods::GetCurrentProcessId()
  52. {
  53. return os::NativeMethods::GetCurrentProcessId();
  54. }
  55. int32_t NativeMethods::GetPriorityClass(intptr_t handle)
  56. {
  57. NOT_SUPPORTED_IL2CPP(NativeMethods::GetPriorityClass, "IL2CPP does not support process priority");
  58. return 0;
  59. }
  60. int32_t NativeMethods::WaitForInputIdle(intptr_t handle, int32_t milliseconds)
  61. {
  62. NOT_SUPPORTED_IL2CPP(NativeMethods::GetPriorityClass, "IL2CPP does not support waiting for input idle for a process");
  63. return 0;
  64. }
  65. intptr_t NativeMethods::GetCurrentProcess()
  66. {
  67. auto currentProcess = os::NativeMethods::GetCurrentProcess();
  68. vm::Exception::RaiseIfError(currentProcess.GetError());
  69. return reinterpret_cast<intptr_t>(currentProcess.Get());
  70. }
  71. } // namespace Win32
  72. } // namespace Microsoft
  73. } // namespace System
  74. } // namespace icalls
  75. } // namespace il2cpp