mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
Initial commit
This commit is contained in:
55
VRChatRPC.cs
Normal file
55
VRChatRPC.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright(c) 2019 pypy. All rights reserved.
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace VRCX
|
||||
{
|
||||
public static class VRChatRPC
|
||||
{
|
||||
[DllImport("VRChatRPC", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern bool VRChatRPC_000();
|
||||
|
||||
[DllImport("VRChatRPC", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int VRChatRPC_001([Out] byte[] data, int size);
|
||||
|
||||
[DllImport("VRChatRPC", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr VRChatRPC_002();
|
||||
|
||||
public static bool Update()
|
||||
{
|
||||
return VRChatRPC_000();
|
||||
}
|
||||
|
||||
public static string GetAuthSessionTicket()
|
||||
{
|
||||
var a = new byte[1024];
|
||||
var n = VRChatRPC_001(a, 1024);
|
||||
return BitConverter.ToString(a, 0, n).Replace("-", string.Empty);
|
||||
}
|
||||
|
||||
public static string GetPersonaName()
|
||||
{
|
||||
var ptr = VRChatRPC_002();
|
||||
if (ptr != IntPtr.Zero)
|
||||
{
|
||||
int n = 0;
|
||||
while (Marshal.ReadByte(ptr, n) != 0)
|
||||
{
|
||||
++n;
|
||||
}
|
||||
if (n > 0)
|
||||
{
|
||||
var a = new byte[n];
|
||||
Marshal.Copy(ptr, a, 0, a.Length);
|
||||
return Encoding.UTF8.GetString(a);
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user