forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess.cpp
More file actions
57 lines (44 loc) · 1.36 KB
/
Process.cpp
File metadata and controls
57 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "il2cpp-config.h"
#if IL2CPP_TARGET_WINRT || IL2CPP_TARGET_XBOXONE
#include "os/Win32/WindowsHeaders.h"
#include "il2cpp-vm-support.h"
#include "os/Process.h"
#include "utils/StringUtils.h"
struct ProcessHandle
{
HANDLE handle;
};
namespace il2cpp
{
namespace os
{
int Process::GetCurrentProcessId()
{
return ::GetCurrentProcessId();
}
ProcessHandle* Process::GetProcess(int processId)
{
if (processId == GetCurrentProcessId())
return (ProcessHandle*)::GetCurrentProcess();
IL2CPP_VM_RAISE_PLATFORM_NOT_SUPPORTED_EXCEPTION(L"It is not possible to interact with other system processes on current platform.");
return NULL;
}
void Process::FreeProcess(ProcessHandle* handle)
{
// We have nothing to do here.
}
std::string Process::GetProcessName(ProcessHandle* handle)
{
if (handle == ::GetCurrentProcess())
{
wchar_t path[MAX_PATH + 1];
SetLastError(ERROR_SUCCESS);
DWORD pathLength = GetModuleFileNameW(NULL, path, MAX_PATH + 1);
return utils::StringUtils::Utf16ToUtf8(path, static_cast<int>(pathLength));
}
IL2CPP_VM_RAISE_PLATFORM_NOT_SUPPORTED_EXCEPTION(L"It is not possible to interact with other system processes on current platform.");
return std::string();
}
}
}
#endif