-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathXboxStructs.cs
119 lines (107 loc) · 3.22 KB
/
XboxStructs.cs
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace XboxWinFsp
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct CONSOLE_PUBLIC_KEY
{
public uint PublicExponent;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public byte[] Modulus;
public void EndianSwap()
{
PublicExponent = PublicExponent.EndianSwap();
}
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct XE_CONSOLE_CERTIFICATE
{
public ushort CertSize;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public byte[] ConsoleId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
public byte[] ConsolePartNumberBytes;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] Reserved;
public ushort Privileges;
public uint ConsoleType;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] ManufacturingDateBytes;
public CONSOLE_PUBLIC_KEY ConsolePublicKey;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
public byte[] Signature;
public string ConsolePartNumber
{
get
{
return Encoding.ASCII.GetString(ConsolePartNumberBytes);
}
}
public string ManufacturingDate
{
get
{
return Encoding.ASCII.GetString(ManufacturingDateBytes);
}
}
public string ConsoleTypeString
{
get
{
switch(ConsoleType)
{
case 1:
return "DevKit";
case 2:
return "Retail";
case 0x80000001:
return "DevKit (recovered/generated)";
case 0x80000002:
return "BetaKit";
}
return ConsoleType.ToString("X8");
}
}
public bool IsStructureValid
{
get
{
return CertSize == 0x1A8;
}
}
public void EndianSwap()
{
CertSize = CertSize.EndianSwap();
Privileges = Privileges.EndianSwap();
ConsoleType = ConsoleType.EndianSwap();
ConsolePublicKey.EndianSwap();
}
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct XE_CONSOLE_ID
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public byte[] Bytes;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct XE_CONSOLE_SIGNATURE
{
public XE_CONSOLE_CERTIFICATE Cert;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public byte[] Signature;
public bool IsStructureValid
{
get
{
return Cert.IsStructureValid;
}
}
public void EndianSwap()
{
Cert.EndianSwap();
}
}
}