2021-04-07 14:19:02 +02:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.Common.GraphicsDriver.NVAPI
|
|
|
|
|
{
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
|
|
|
|
public unsafe struct NvapiUnicodeString
|
|
|
|
|
{
|
2021-04-15 00:27:12 +02:00
|
|
|
|
private fixed byte _data[4096];
|
2021-04-07 14:19:02 +02:00
|
|
|
|
|
|
|
|
|
public NvapiUnicodeString(string text)
|
|
|
|
|
{
|
|
|
|
|
Set(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Get()
|
|
|
|
|
{
|
2021-04-15 00:27:12 +02:00
|
|
|
|
fixed (byte* data = _data)
|
2021-04-07 14:19:02 +02:00
|
|
|
|
{
|
|
|
|
|
string text = Encoding.Unicode.GetString(data, 4096);
|
|
|
|
|
|
|
|
|
|
int index = text.IndexOf('\0');
|
|
|
|
|
if (index > -1)
|
|
|
|
|
{
|
|
|
|
|
text = text.Remove(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Set(string text)
|
|
|
|
|
{
|
|
|
|
|
text += '\0';
|
|
|
|
|
fixed (char* textPtr = text)
|
2021-04-15 00:27:12 +02:00
|
|
|
|
fixed (byte* data = _data)
|
2021-04-07 14:19:02 +02:00
|
|
|
|
{
|
|
|
|
|
int written = Encoding.Unicode.GetBytes(textPtr, text.Length, data, 4096);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|