Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CngAsnFormatter.cs
Go to the documentation of this file.
1using System;
5
7
8internal sealed class CngAsnFormatter : AsnFormatter
9{
10 protected unsafe override string FormatNative(Oid oid, byte[] rawData, bool multiLine)
11 {
12 string s = string.Empty;
13 if (oid != null && oid.Value != null)
14 {
15 s = oid.Value;
16 }
17 int dwFormatStrType = (multiLine ? 1 : 0);
18 int pcbFormat = 0;
20 char[] array = null;
21 try
22 {
23 if (global::Interop.Crypt32.CryptFormatObject(1, 0, dwFormatStrType, IntPtr.Zero, (byte*)(void*)intPtr, rawData, rawData.Length, null, ref pcbFormat))
24 {
25 int num = (pcbFormat + 1) / 2;
26 Span<char> span = ((num > 256) ? ((Span<char>)(array = ArrayPool<char>.Shared.Rent(num))) : stackalloc char[256]);
27 Span<char> span2 = span;
28 fixed (char* ptr = span2)
29 {
30 if (global::Interop.Crypt32.CryptFormatObject(1, 0, dwFormatStrType, IntPtr.Zero, (byte*)(void*)intPtr, rawData, rawData.Length, ptr, ref pcbFormat))
31 {
32 return new string(ptr);
33 }
34 }
35 }
36 }
37 finally
38 {
39 Marshal.FreeHGlobal(intPtr);
40 if (array != null)
41 {
43 }
44 }
45 return null;
46 }
47}
unsafe override string FormatNative(Oid oid, byte[] rawData, bool multiLine)
static ArrayPool< T > Shared
Definition ArrayPool.cs:7
static void FreeHGlobal(IntPtr hglobal)
Definition Marshal.cs:1680
static unsafe IntPtr StringToHGlobalAnsi(string? s)
Definition Marshal.cs:1293
static readonly IntPtr Zero
Definition IntPtr.cs:18