public unsafe int GetPlayerNameC(int playerid, out string name, int strlen) { var data = stackalloc int[5]; if (strlen <= 0) { throw new ArgumentOutOfRangeException(nameof(strlen)); } var nameBuf = strlen < 128 ? stackalloc byte[strlen] : new Span <byte>(new byte[strlen]); fixed(byte *nameBufPin = &nameBuf.GetPinnableReference()) { data[0] = NativeUtils.IntPointerToInt(data + 3); data[1] = (int)(IntPtr)nameBufPin; data[2] = NativeUtils.IntPointerToInt(data + 4); data[3] = playerid; data[4] = strlen; var result = Interop.FastNativeInvoke(new IntPtr(9999), "dSd", data); name = NativeUtils.GetString(nameBuf); return(result); } }
private unsafe int GetNetworkStats(out string name, int strlen) { var data = stackalloc int[5]; if (strlen <= 0) { throw new ArgumentOutOfRangeException(nameof(strlen)); } var nameBuf = strlen < 128 ? stackalloc byte[strlen] : new Span <byte>(new byte[strlen]); fixed(byte *nameBufPin = nameBuf) { data[0] = (int)(IntPtr)nameBufPin; data[1] = NativeUtils.IntPointerToInt(data + 2); data[2] = strlen; var p = Interop.FastNativeFind("GetNetworkStats"); var result = Interop.FastNativeInvoke(p, "S[*1]d", data); name = NativeUtils.GetString(nameBuf); return(result); } }