Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Interop.cs
Go to the documentation of this file.
1using System;
5
6internal static class Interop
7{
8 internal static class Crypt32
9 {
10 [DllImport("crypt32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
11 internal static extern bool CertFreeCertificateContext(IntPtr pCertContext);
12 }
13
14 internal enum SECURITY_STATUS
15 {
16 OK = 0,
17 ContinueNeeded = 590610,
18 CompleteNeeded = 590611,
19 CompAndContinue = 590612,
20 ContextExpired = 590615,
21 CredentialsNeeded = 590624,
22 Renegotiate = 590625,
23 OutOfMemory = -2146893056,
24 InvalidHandle = -2146893055,
25 Unsupported = -2146893054,
26 TargetUnknown = -2146893053,
27 InternalError = -2146893052,
28 PackageNotFound = -2146893051,
29 NotOwner = -2146893050,
30 CannotInstall = -2146893049,
31 InvalidToken = -2146893048,
32 CannotPack = -2146893047,
33 QopNotSupported = -2146893046,
34 NoImpersonation = -2146893045,
35 LogonDenied = -2146893044,
36 UnknownCredentials = -2146893043,
37 NoCredentials = -2146893042,
38 MessageAltered = -2146893041,
39 OutOfSequence = -2146893040,
40 NoAuthenticatingAuthority = -2146893039,
41 IncompleteMessage = -2146893032,
42 IncompleteCredentials = -2146893024,
43 BufferNotEnough = -2146893023,
44 WrongPrincipal = -2146893022,
45 TimeSkew = -2146893020,
46 UntrustedRoot = -2146893019,
47 IllegalMessage = -2146893018,
48 CertUnknown = -2146893017,
49 CertExpired = -2146893016,
50 DecryptFailure = -2146893008,
51 AlgorithmMismatch = -2146893007,
52 SecurityQosFailed = -2146893006,
53 SmartcardLogonRequired = -2146892994,
54 UnsupportedPreauth = -2146892989,
55 BadBinding = -2146892986,
56 DowngradeDetected = -2146892976,
57 ApplicationProtocolMismatch = -2146892953,
58 NoRenegotiation = 590688
59 }
60
61 internal static class SspiCli
62 {
63 [StructLayout(LayoutKind.Sequential, Pack = 1)]
64 internal struct CredHandle
65 {
66 private IntPtr dwLower;
67
68 private IntPtr dwUpper;
69
70 public bool IsZero
71 {
72 [MethodImpl(MethodImplOptions.AggressiveInlining)]
73 get
74 {
75 if (dwLower == IntPtr.Zero)
76 {
77 return dwUpper == IntPtr.Zero;
78 }
79 return false;
80 }
81 }
82
83 internal void SetToInvalid()
84 {
87 }
88
89 public override string ToString()
90 {
91 return dwLower.ToString("x") + ":" + dwUpper.ToString("x");
92 }
93 }
94
118
119 [Flags]
120 internal enum ContextFlags
121 {
122 Zero = 0,
123 Delegate = 1,
124 MutualAuth = 2,
125 ReplayDetect = 4,
126 SequenceDetect = 8,
127 Confidentiality = 0x10,
128 UseSessionKey = 0x20,
129 AllocateMemory = 0x100,
130 Connection = 0x800,
131 InitExtendedError = 0x4000,
132 AcceptExtendedError = 0x8000,
133 InitStream = 0x8000,
134 AcceptStream = 0x10000,
135 InitIntegrity = 0x10000,
136 AcceptIntegrity = 0x20000,
137 InitManualCredValidation = 0x80000,
139 InitIdentify = 0x20000,
140 AcceptIdentify = 0x80000,
141 ProxyBindings = 0x4000000,
142 AllowMissingBindings = 0x10000000,
143 UnverifiedTargetName = 0x20000000
144 }
145
146 internal enum Endianness
147 {
150 }
151
152 internal enum CredentialUse
153 {
157 }
158
159 internal struct SecBuffer
160 {
161 public int cbBuffer;
162
164
165 public IntPtr pvBuffer;
166
167 public unsafe static readonly int Size = sizeof(SecBuffer);
168 }
169
170 internal struct SecBufferDesc
171 {
172 public readonly int ulVersion;
173
174 public readonly int cBuffers;
175
176 public unsafe void* pBuffers;
177
178 public unsafe SecBufferDesc(int count)
179 {
180 ulVersion = 0;
181 cBuffers = count;
182 pBuffers = null;
183 }
184 }
185
186 [DllImport("sspicli.dll", ExactSpelling = true, SetLastError = true)]
187 internal static extern int EncryptMessage(ref CredHandle contextHandle, [In] uint qualityOfProtection, [In][Out] ref SecBufferDesc inputOutput, [In] uint sequenceNumber);
188
189 [DllImport("sspicli.dll", ExactSpelling = true, SetLastError = true)]
190 internal unsafe static extern int DecryptMessage([In] ref CredHandle contextHandle, [In][Out] ref SecBufferDesc inputOutput, [In] uint sequenceNumber, uint* qualityOfProtection);
191
192 [DllImport("sspicli.dll", ExactSpelling = true, SetLastError = true)]
193 internal static extern int FreeContextBuffer([In] IntPtr contextBuffer);
194
195 [DllImport("sspicli.dll", ExactSpelling = true, SetLastError = true)]
196 internal static extern int FreeCredentialsHandle(ref CredHandle handlePtr);
197
198 [DllImport("sspicli.dll", ExactSpelling = true, SetLastError = true)]
199 internal static extern int DeleteSecurityContext(ref CredHandle handlePtr);
200
201 [DllImport("sspicli.dll", ExactSpelling = true, SetLastError = true)]
202 internal unsafe static extern int AcceptSecurityContext(ref CredHandle credentialHandle, [In] void* inContextPtr, [In] SecBufferDesc* inputBuffer, [In] ContextFlags inFlags, [In] Endianness endianness, ref CredHandle outContextPtr, [In][Out] ref SecBufferDesc outputBuffer, [In][Out] ref ContextFlags attributes, out long timeStamp);
203
204 [DllImport("sspicli.dll", ExactSpelling = true, SetLastError = true)]
205 internal unsafe static extern int QueryContextAttributesW(ref CredHandle contextHandle, [In] ContextAttribute attribute, [In] void* buffer);
206
207 [DllImport("sspicli.dll", ExactSpelling = true, SetLastError = true)]
209
210 [DllImport("sspicli.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
211 internal unsafe static extern int AcquireCredentialsHandleW([In] string principal, [In] string moduleName, [In] int usage, [In] void* logonID, [In] IntPtr zero, [In] void* keyCallback, [In] void* keyArgument, ref CredHandle handlePtr, out long timeStamp);
212
213 [DllImport("sspicli.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
214 internal unsafe static extern int AcquireCredentialsHandleW([In] string principal, [In] string moduleName, [In] int usage, [In] void* logonID, [In] System.Net.Security.SafeSspiAuthDataHandle authdata, [In] void* keyCallback, [In] void* keyArgument, ref CredHandle handlePtr, out long timeStamp);
215
216 [DllImport("sspicli.dll", ExactSpelling = true, SetLastError = true)]
217 internal unsafe static extern int InitializeSecurityContextW(ref CredHandle credentialHandle, [In] void* inContextPtr, [In] byte* targetName, [In] ContextFlags inFlags, [In] int reservedI, [In] Endianness endianness, [In] SecBufferDesc* inputBuffer, [In] int reservedII, ref CredHandle outContextPtr, [In][Out] ref SecBufferDesc outputBuffer, [In][Out] ref ContextFlags attributes, out long timeStamp);
218
219 [DllImport("sspicli.dll", ExactSpelling = true, SetLastError = true)]
220 internal unsafe static extern int CompleteAuthToken([In] void* inContextPtr, [In][Out] ref SecBufferDesc inputBuffers);
221
222 [DllImport("sspicli.dll", ExactSpelling = true, SetLastError = true)]
223 internal static extern SECURITY_STATUS SspiFreeAuthIdentity([In] IntPtr authData);
224
225 [DllImport("sspicli.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
226 internal static extern SECURITY_STATUS SspiEncodeStringsAsAuthIdentity([In] string userName, [In] string domainName, [In] string password, out System.Net.Security.SafeSspiAuthDataHandle authData);
227 }
228}
static bool CertFreeCertificateContext(IntPtr pCertContext)
static SECURITY_STATUS SspiEncodeStringsAsAuthIdentity([In] string userName, [In] string domainName, [In] string password, out System.Net.Security.SafeSspiAuthDataHandle authData)
static unsafe int AcceptSecurityContext(ref CredHandle credentialHandle, [In] void *inContextPtr, [In] SecBufferDesc *inputBuffer, [In] ContextFlags inFlags, [In] Endianness endianness, ref CredHandle outContextPtr, [In][Out] ref SecBufferDesc outputBuffer, [In][Out] ref ContextFlags attributes, out long timeStamp)
static unsafe int AcquireCredentialsHandleW([In] string principal, [In] string moduleName, [In] int usage, [In] void *logonID, [In] System.Net.Security.SafeSspiAuthDataHandle authdata, [In] void *keyCallback, [In] void *keyArgument, ref CredHandle handlePtr, out long timeStamp)
static int FreeContextBuffer([In] IntPtr contextBuffer)
static unsafe int QueryContextAttributesW(ref CredHandle contextHandle, [In] ContextAttribute attribute, [In] void *buffer)
static unsafe int AcquireCredentialsHandleW([In] string principal, [In] string moduleName, [In] int usage, [In] void *logonID, [In] IntPtr zero, [In] void *keyCallback, [In] void *keyArgument, ref CredHandle handlePtr, out long timeStamp)
static SECURITY_STATUS SspiFreeAuthIdentity([In] IntPtr authData)
static unsafe int CompleteAuthToken([In] void *inContextPtr, [In][Out] ref SecBufferDesc inputBuffers)
static unsafe int DecryptMessage([In] ref CredHandle contextHandle, [In][Out] ref SecBufferDesc inputOutput, [In] uint sequenceNumber, uint *qualityOfProtection)
static int EnumerateSecurityPackagesW(out int pkgnum, out System.Net.Security.SafeFreeContextBuffer_SECURITY handle)
static int DeleteSecurityContext(ref CredHandle handlePtr)
static int EncryptMessage(ref CredHandle contextHandle, [In] uint qualityOfProtection, [In][Out] ref SecBufferDesc inputOutput, [In] uint sequenceNumber)
static unsafe int InitializeSecurityContextW(ref CredHandle credentialHandle, [In] void *inContextPtr, [In] byte *targetName, [In] ContextFlags inFlags, [In] int reservedI, [In] Endianness endianness, [In] SecBufferDesc *inputBuffer, [In] int reservedII, ref CredHandle outContextPtr, [In][Out] ref SecBufferDesc outputBuffer, [In][Out] ref ContextFlags attributes, out long timeStamp)
static int FreeCredentialsHandle(ref CredHandle handlePtr)
SECURITY_STATUS
Definition Interop.cs:98
override string ToString()
Definition Interop.cs:89
unsafe SecBufferDesc(int count)
Definition Interop.cs:178
static unsafe readonly int Size
Definition Interop.cs:226
System.Net.Security.SecurityBufferType BufferType
Definition Interop.cs:222
unsafe override string ToString()
Definition IntPtr.cs:247
static readonly IntPtr Zero
Definition IntPtr.cs:18