少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
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
58
59
60
61
62
#include "il2cpp-config.h"
 
#if IL2CPP_TARGET_DARWIN
 
#include <sys/types.h>
#if !IL2CPP_TARGET_IOS
#include <libproc.h>
#endif
#include <unistd.h>
#include <stdlib.h>
 
#include "os/Process.h"
#include "il2cpp-vm-support.h"
 
struct ProcessHandle
{
    pid_t pid;
};
 
namespace il2cpp
{
namespace os
{
    int Process::GetCurrentProcessId()
    {
        return getpid();
    }
 
    ProcessHandle* Process::GetProcess(int processId)
    {
        // If/when we implement the CreateProcess_internal icall we will likely
        // need to so something smarter here to find the process if we did
        // not create it and return a known pseudo-handle. For now this
        // is sufficient though.
        return (ProcessHandle*)(intptr_t)processId;
    }
 
    void Process::FreeProcess(ProcessHandle* handle)
    {
        // We have nothing to do here.
    }
 
    std::string Process::GetProcessName(ProcessHandle* handle)
    {
#if !IL2CPP_TARGET_IOS
        const size_t bufferLength = 256;
        char buf[bufferLength];
        int length = proc_name((int)((intptr_t)handle), buf, bufferLength);
 
        if (length <= 0)
            return std::string();
 
        return std::string(buf, length);
#else
        IL2CPP_VM_NOT_SUPPORTED(Process::GetProcessName, "GetProcessName is not supported for non-Windows/OSX desktop platforms");
        return std::string();
#endif
    }
}
}
 
#endif