Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SafePasswordHandle.cs
Go to the documentation of this file.
1using System;
5
7
9{
10 [CompilerGenerated]
12
13 private int Length
14 {
15 [CompilerGenerated]
16 set
17 {
19 }
20 }
21
23 {
24 handle = (IntPtr)(-1)
25 });
26
27 public SafePasswordHandle(string password)
28 : base(ownsHandle: true)
29 {
30 if (password != null)
31 {
33 Length = password.Length;
34 }
35 }
36
37 public unsafe SafePasswordHandle(ReadOnlySpan<char> password)
38 : base(ownsHandle: true)
39 {
40 checked
41 {
42 if (password != default(ReadOnlySpan<char>))
43 {
44 int num = password.Length + 1;
45 handle = Marshal.AllocHGlobal(num * 2);
46 Span<char> destination = new Span<char>((void*)handle, num);
47 password.CopyTo(destination);
48 destination[password.Length] = '\0';
49 Length = password.Length;
50 }
51 }
52 }
53
55 : base(ownsHandle: true)
56 {
57 if (password != null)
58 {
60 Length = password.Length;
61 }
62 }
63
64 protected override bool ReleaseHandle()
65 {
67 SetHandle((IntPtr)(-1));
68 Length = 0;
69 return true;
70 }
71
72 protected override void Dispose(bool disposing)
73 {
74 if (!disposing || !Microsoft.Win32.SafeHandles.SafeHandleCache<SafePasswordHandle>.IsCachedInvalidHandle(this))
75 {
76 base.Dispose(disposing);
77 }
78 }
79}
unsafe SafePasswordHandle(ReadOnlySpan< char > password)
static unsafe void ZeroFreeGlobalAllocUnicode(IntPtr s)
Definition Marshal.cs:1522
static IntPtr SecureStringToGlobalAllocUnicode(SecureString s)
Definition Marshal.cs:1284
static unsafe IntPtr StringToHGlobalUni(string? s)
Definition Marshal.cs:1310
static IntPtr AllocHGlobal(int cb)
Definition Marshal.cs:625
void CopyTo(Span< T > destination)