Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SafeProvHandle.cs
Go to the documentation of this file.
2
4
6{
7 private string _containerName;
8
9 private string _providerName;
10
11 private int _type;
12
13 private uint _flags;
14
15 private bool _fPersistKeyInCsp;
16
17 internal string ContainerName
18 {
19 set
20 {
22 }
23 }
24
25 internal string ProviderName
26 {
27 set
28 {
30 }
31 }
32
33 internal int Types
34 {
35 set
36 {
37 _type = value;
38 }
39 }
40
41 internal uint Flags
42 {
43 set
44 {
45 _flags = value;
46 }
47 }
48
49 internal bool PersistKeyInCsp
50 {
51 get
52 {
53 return _fPersistKeyInCsp;
54 }
55 set
56 {
58 }
59 }
60
62
64 : base(ownsHandle: true)
65 {
67 _containerName = null;
68 _providerName = null;
69 _type = 0;
70 _flags = 0u;
71 _fPersistKeyInCsp = true;
72 }
73
74 protected override void Dispose(bool disposing)
75 {
76 if (!SafeHandleCache<SafeProvHandle>.IsCachedInvalidHandle(this))
77 {
78 base.Dispose(disposing);
79 }
80 }
81
82 protected override bool ReleaseHandle()
83 {
84 if (!_fPersistKeyInCsp && (_flags & 0xF0000000u) == 0)
85 {
86 uint dwFlags = (_flags & 0x20u) | 0x10u;
87 global::Interop.Advapi32.CryptAcquireContext(out var phProv, _containerName, _providerName, _type, dwFlags);
88 phProv.Dispose();
89 }
90 bool result = global::Interop.Advapi32.CryptReleaseContext(handle, 0);
92 return result;
93 }
94}
static T GetInvalidHandle(Func< T > invalidHandleFactory)
override void Dispose(bool disposing)
static readonly IntPtr Zero
Definition IntPtr.cs:18