1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// <OWNER>[....]</OWNER>
//
//
// Config.cs
//
namespace System.Security.Util {
using System;
using System.Security.Util;
using System.Security.Policy;
using System.Security.Permissions;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Globalization;
using System.Text;
#if FEATURE_SERIALIZATION
using System.Runtime.Serialization.Formatters.Binary;
#endif // FEATURE_SERIALIZATION
using System.Threading;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
// Duplicated in vm\COMSecurityConfig.h
[Serializable]
[Flags]
internal enum QuickCacheEntryType
{
FullTrustZoneMyComputer = 0x1000000,
FullTrustZoneIntranet = 0x2000000,
FullTrustZoneInternet = 0x4000000,
FullTrustZoneTrusted = 0x8000000,
FullTrustZoneUntrusted = 0x10000000,
FullTrustAll = 0x20000000,
}
internal static class Config {
private static volatile string m_machineConfig;
private static volatile string m_userConfig;
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
private static void GetFileLocales()
{
if (m_machineConfig == null)
{
string machineConfig = null;
GetMachineDirectory(JitHelpers.GetStringHandleOnStack(ref machineConfig));
m_machineConfig = machineConfig;
}
if (m_userConfig == null)
{
string userConfig = null;
GetUserDirectory(JitHelpers.GetStringHandleOnStack(ref userConfig));
m_userConfig = userConfig;
}
}
internal static string MachineDirectory
{
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
get
{
GetFileLocales();
return m_machineConfig;
}
}
internal static string UserDirectory
{
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
get
{
GetFileLocales();
return m_userConfig;
}
}
#if FEATURE_CAS_POLICY
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
internal static extern int SaveDataByte(string path, [In] byte[] data, int length);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
internal static extern bool RecoverData(ConfigId id);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
internal static extern void SetQuickCache(ConfigId id, QuickCacheEntryType quickCacheFlags);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private static extern bool GetCacheEntry(ConfigId id, int numKey, [In] byte[] key, int keyLength, ObjectHandleOnStack retData);
[System.Security.SecurityCritical] // auto-generated
internal static bool GetCacheEntry(ConfigId id, int numKey, byte[] key, out byte[] data)
{
byte[] retData = null;
bool ret = GetCacheEntry(id, numKey, key, key.Length, JitHelpers.GetObjectHandleOnStack(ref retData));
data = retData;
return ret;
}
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private static extern void AddCacheEntry(ConfigId id, int numKey, [In] byte[] key, int keyLength, byte[] data, int dataLength);
[System.Security.SecurityCritical] // auto-generated
internal static void AddCacheEntry(ConfigId id, int numKey, byte[] key, byte[] data)
{
AddCacheEntry(id, numKey, key, key.Length, data, data.Length);
}
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
internal static extern void ResetCacheData(ConfigId id);
#endif
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private static extern void GetMachineDirectory(StringHandleOnStack retDirectory);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private static extern void GetUserDirectory(StringHandleOnStack retDirectory);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
internal static extern bool WriteToEventLog(string message);
}
}
|