blob: b2c56550e141189de6d415ced7948767cbfa1793 (
plain)
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
|
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
// ============================================================
//
// Variables.cpp
//
//
// Implements the Variables class
//
// ============================================================
#include "variables.hpp"
#include "ex.h"
namespace BINDER_SPACE
{
#ifdef FEATURE_VERSIONING_LOG
namespace
{
HRESULT CheckFileExistence(LPCWSTR pwzFile, LPDWORD pdwAttrib)
{
HRESULT hr = S_FALSE;
DWORD dwRet = 0;
_ASSERTE(pwzFile && pdwAttrib);
*pdwAttrib = 0;
dwRet = WszGetFileAttributes(pwzFile);
if (dwRet == INVALID_FILE_ATTRIBUTES)
{
hr = HRESULT_FROM_GetLastError();
if ((hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) ||
(hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)))
{
GO_WITH_HRESULT(S_FALSE);
}
}
else
{
*pdwAttrib = dwRet;
GO_WITH_HRESULT(S_OK);
}
Exit:
return hr;
}
};
#endif // FEATURE_VERSIONING_LOG
Variables *g_BinderVariables = NULL;
Variables::Variables()
{
// Nothing to do here
}
Variables::~Variables()
{
// Nothing to do here
}
HRESULT Variables::Init()
{
HRESULT hr = S_OK;
EX_TRY
{
// ApplicationContext string constants
// AssemblyBinder string constants
httpURLPrefix.SetLiteral(W("http://"));
// AssemblyName string constants
architectureMSIL.SetLiteral(W("MSIL"));
architectureX86.SetLiteral(W("x86"));
architectureAMD64.SetLiteral(W("AMD64"));
architectureARM.SetLiteral(W("ARM"));
architectureARM64.SetLiteral(W("ARM64"));
cultureNeutral.SetLiteral(W("neutral"));
mscorlib.SetLiteral(W("mscorlib"));
emptyString.Clear();
#ifdef FEATURE_VERSIONING_LOG
REGUTIL::CORConfigLevel kCorConfigLevel =
static_cast<REGUTIL::CORConfigLevel>(REGUTIL::COR_CONFIG_ENV |
REGUTIL::COR_CONFIG_FUSION);
DWORD dwLoggingNeeded = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::EXTERNAL_ForceLog,
0,
kCorConfigLevel,
TRUE);
fLoggingNeeded = (dwLoggingNeeded ? TRUE : FALSE);
NewArrayHolder<WCHAR> pwzLogDirectory = REGUTIL::GetConfigString_DontUse_(CLRConfig::INTERNAL_LogPath,
TRUE,
kCorConfigLevel,
FALSE /* fUsePerfCache */);
// When no directory is specified, we can't log.
if (pwzLogDirectory == NULL)
{
fLoggingNeeded = FALSE;
}
else
{
DWORD dwAttr = 0;
// If we do not get a regular directory, then we can't log either
hr = CheckFileExistence(pwzLogDirectory, &dwAttr);
if ((hr == S_OK) && ((dwAttr & FILE_ATTRIBUTE_DIRECTORY) != 0))
{
logPath.Set(pwzLogDirectory);
}
else
{
// Any failure here simply yields no logging.
hr = S_OK;
fLoggingNeeded = FALSE;
}
}
#endif // FEATURE_VERSIONING_LOG
}
EX_CATCH_HRESULT(hr);
return hr;
}
};
|