blob: 4a71ce70b5569a1d81e3c4c09668dc8c10a44f05 (
plain) (
blame)
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
|
using System.Runtime.InteropServices;
using System.Text;
namespace Ryujinx.Common.GraphicsDriver.NVAPI
{
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public unsafe struct NvapiUnicodeString
{
private fixed byte _data[4096];
public NvapiUnicodeString(string text)
{
Set(text);
}
public readonly string Get()
{
fixed (byte* data = _data)
{
string text = Encoding.Unicode.GetString(data, 4096);
int index = text.IndexOf('\0');
if (index > -1)
{
text = text.Remove(index);
}
return text;
}
}
public readonly void Set(string text)
{
text += '\0';
fixed (char* textPtr = text)
fixed (byte* data = _data)
{
int written = Encoding.Unicode.GetBytes(textPtr, text.Length, data, 4096);
}
}
}
}
|