Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CertGetNameString() [1/2]

static unsafe string Interop.crypt32.CertGetNameString ( SafeCertContextHandle certContext,
CertNameType certNameType,
CertNameFlags certNameFlags,
CertNameStringType strType )
inlinestatic

Definition at line 51 of file Interop.cs.

52 {
53 int num = CertGetNameString(certContext, certNameType, certNameFlags, in strType, null, 0);
54 if (num == 0)
55 {
56 throw Marshal.GetLastWin32Error().ToCryptographicException();
57 }
58 Span<char> span = ((num > 256) ? ((Span<char>)new char[num]) : stackalloc char[num]);
59 Span<char> span2 = span;
60 fixed (char* pszNameString = &MemoryMarshal.GetReference(span2))
61 {
62 if (CertGetNameString(certContext, certNameType, certNameFlags, in strType, pszNameString, num) == 0)
63 {
64 throw Marshal.GetLastWin32Error().ToCryptographicException();
65 }
66 return new string(span2.Slice(0, num - 1));
67 }
68 }
static unsafe string CertGetNameString(SafeCertContextHandle certContext, CertNameType certNameType, CertNameFlags certNameFlags, CertNameStringType strType)
Definition Interop.cs:51
Span< T > Slice(int start)
Definition Span.cs:271

References Interop.crypt32.CertGetNameString(), System.Runtime.InteropServices.Marshal.GetLastWin32Error(), and System.Span< T >.Slice().

Referenced by Interop.crypt32.CertGetNameString().