summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2019-05-17 06:28:51 -0700
committerGitHub <noreply@github.com>2019-05-17 06:28:51 -0700
commitcbeb928cb05982edc71ed8ab80ef13d7f142cffa (patch)
treee178e91d1a91cce78d604ad40a6380dee380cb7f
parentc55319243ed42f8bdcb940d69f03a9c6554cc1d4 (diff)
downloadcoreclr-cbeb928cb05982edc71ed8ab80ef13d7f142cffa.tar.gz
coreclr-cbeb928cb05982edc71ed8ab80ef13d7f142cffa.tar.bz2
coreclr-cbeb928cb05982edc71ed8ab80ef13d7f142cffa.zip
Delete unnecessary locale arguments (#24624)
Everything in the runtime should use Invariant culture. It is not necessary to pass the locale arguments around.
-rw-r--r--clr.featuredefines.props2
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/OAVariantLib.cs5
-rw-r--r--src/System.Private.CoreLib/src/System/RtType.cs4
-rw-r--r--src/binder/CMakeLists.txt1
-rw-r--r--src/binder/fusionhelpers.cpp113
-rw-r--r--src/binder/inc/fusionhelpers.hpp9
-rw-r--r--src/binder/inc/utils.hpp6
-rw-r--r--src/inc/corpriv.h6
-rw-r--r--src/inc/dacvars.h3
-rw-r--r--src/inc/sstring.h57
-rw-r--r--src/inc/sstring.inl49
-rw-r--r--src/inc/winwrap.h6
-rw-r--r--src/utilcode/sstring.cpp108
-rw-r--r--src/utilcode/winfix.cpp173
-rw-r--r--src/vm/appdomain.hpp18
-rw-r--r--src/vm/baseassemblyspec.inl4
-rw-r--r--src/vm/compile.cpp4
-rw-r--r--src/vm/coreclr/corebindresult.inl2
-rw-r--r--src/vm/corhost.cpp6
-rw-r--r--src/vm/peimage.cpp21
-rw-r--r--src/vm/peimage.h3
-rw-r--r--src/vm/peimage.inl7
22 files changed, 65 insertions, 542 deletions
diff --git a/clr.featuredefines.props b/clr.featuredefines.props
index d96297eb0c..929768fdbd 100644
--- a/clr.featuredefines.props
+++ b/clr.featuredefines.props
@@ -26,7 +26,6 @@
<FeatureArrayStubAsIL Condition="'$(Platform)' != 'x86'">true</FeatureArrayStubAsIL>
<FeatureMulticastStubAsIL Condition="'$(Platform)' != 'x86'">true</FeatureMulticastStubAsIL>
<FeatureStubsAsIL Condition="'$(Platform)' == 'arm64'">true</FeatureStubsAsIL>
- <FeatureUseLcid>true</FeatureUseLcid>
<FeatureCominterop>true</FeatureCominterop>
<FeatureClassicCominterop>true</FeatureClassicCominterop>
<FeatureCominteropUnmanagedActivation>true</FeatureCominteropUnmanagedActivation>
@@ -59,7 +58,6 @@
<DefineConstants Condition="'$(FeaturePal)' == 'true'">$(DefineConstants);FEATURE_PAL</DefineConstants>
<DefineConstants Condition="'$(FeaturePerfTracing)' == 'true'">$(DefineConstants);FEATURE_PERFTRACING</DefineConstants>
<DefineConstants Condition="'$(FeatureXplatEventSource)' == 'true'">$(DefineConstants);FEATURE_EVENTSOURCE_XPLAT</DefineConstants>
- <DefineConstants Condition="'$(FeatureUseLcid)' == 'true'">$(DefineConstants);FEATURE_USE_LCID</DefineConstants>
<DefineConstants Condition="'$(FeatureWin32Registry)' == 'true'">$(DefineConstants);FEATURE_WIN32_REGISTRY</DefineConstants>
<DefineConstants Condition="'$(FeatureDefaultInterfaces)' == 'true'">$(DefineConstants);FEATURE_DEFAULT_INTERFACES</DefineConstants>
<DefineConstants Condition="'$(FeatureTypeEquivalence)' == 'true'">$(DefineConstants);FEATURE_TYPEEQUIVALENCE</DefineConstants>
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/OAVariantLib.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/OAVariantLib.cs
index fc04674764..6b46de0ed1 100644
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/OAVariantLib.cs
+++ b/src/System.Private.CoreLib/src/Microsoft/Win32/OAVariantLib.cs
@@ -82,12 +82,7 @@ namespace Microsoft.Win32
throw new ArgumentNullException(nameof(culture));
Variant result = new Variant();
ChangeTypeEx(ref result, ref source,
-#if FEATURE_USE_LCID
culture.LCID,
-#else
- // @CORESYSTODO: what does CoreSystem expect for this argument?
- 0,
-#endif
targetClass.TypeHandle.Value, GetCVTypeFromClass(targetClass), options);
return result;
}
diff --git a/src/System.Private.CoreLib/src/System/RtType.cs b/src/System.Private.CoreLib/src/System/RtType.cs
index 617f4ee853..dfdaa7fffa 100644
--- a/src/System.Private.CoreLib/src/System/RtType.cs
+++ b/src/System.Private.CoreLib/src/System/RtType.cs
@@ -3866,7 +3866,7 @@ namespace System
}
}
-#if FEATURE_COMINTEROP && FEATURE_USE_LCID
+#if FEATURE_COMINTEROP
if (target != null && target.GetType().IsCOMObject)
{
if ((bindingFlags & ClassicBindingMask) == 0)
@@ -3898,7 +3898,7 @@ namespace System
return InvokeDispMethod(name, bindingFlags, target, providedArgs, isByRef, lcid, namedParams);
}
-#endif // FEATURE_COMINTEROP && FEATURE_USE_LCID
+#endif // FEATURE_COMINTEROP
if (namedParams != null && Array.IndexOf(namedParams, null!) != -1)
throw new ArgumentException(SR.Arg_NamedParamNull, nameof(namedParams));
diff --git a/src/binder/CMakeLists.txt b/src/binder/CMakeLists.txt
index 46008739e7..d92bec6c99 100644
--- a/src/binder/CMakeLists.txt
+++ b/src/binder/CMakeLists.txt
@@ -22,7 +22,6 @@ set(BINDER_COMMON_SOURCES
assemblyidentitycache.cpp
coreclrbindercommon.cpp
fusionassemblyname.cpp
- fusionhelpers.cpp
)
set(BINDER_COMMON_HEADERS
diff --git a/src/binder/fusionhelpers.cpp b/src/binder/fusionhelpers.cpp
deleted file mode 100644
index 4372bcf344..0000000000
--- a/src/binder/fusionhelpers.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// ============================================================
-//
-// FusionHelpers.cpp
-//
-// Implements various helper functions
-//
-// ============================================================
-
-#include "fusionhelpers.hpp"
-
-#include "shlwapi.h"
-
-#define IS_UPPER_A_TO_Z(x) (((x) >= L'A') && ((x) <= L'Z'))
-#define IS_LOWER_A_TO_Z(x) (((x) >= L'a') && ((x) <= L'z'))
-#define IS_0_TO_9(x) (((x) >= L'0') && ((x) <= L'9'))
-#define CAN_SIMPLE_UPCASE(x) (((x)&~0x7f) == 0)
-#define SIMPLE_UPCASE(x) (IS_LOWER_A_TO_Z(x) ? ((x) - L'a' + L'A') : (x))
-#define CAN_SIMPLE_LOWERCASE(x) (((x)&~0x7f) == 0)
-#define SIMPLE_LOWERCASE(x) (IS_UPPER_A_TO_Z(x) ? ((x) - L'A' + L'a') : (x))
-
-// ---------------------------------------------------------------------------
-// Private Helpers
-// ---------------------------------------------------------------------------
-namespace
-{
- WCHAR FusionMapChar(WCHAR wc)
- {
- WCHAR wTmp;
-
-#ifndef FEATURE_PAL
-
-#ifdef FEATURE_USE_LCID
- int iRet = WszLCMapString(g_lcid, LCMAP_UPPERCASE, &wc, 1, &wTmp, 1);
-#else
- int iRet = LCMapStringEx(g_lcid, LCMAP_UPPERCASE, &wc, 1, &wTmp, 1, NULL, NULL, 0);
-#endif
- if (!iRet) {
- _ASSERTE(!"LCMapString failed!");
- iRet = GetLastError();
- wTmp = wc;
- }
-#else // !FEATURE_PAL
- // For PAL, no locale specific processing is done
- wTmp = toupper(wc);
-#endif // !FEATURE_PAL
-
- return wTmp;
- }
-};
-
-// ---------------------------------------------------------------------------
-// FusionCompareStringN
-// ---------------------------------------------------------------------------
-// if nChar < 0, compare the whole string
-int FusionCompareStringN(LPCWSTR pwz1, LPCWSTR pwz2, int nChar, BOOL bCaseSensitive)
-{
- int iRet = 0;
- int nCount = 0;
- WCHAR ch1;
- WCHAR ch2;
- _ASSERTE(pwz1 && pwz2);
-
- // same point always return equal.
- if (pwz1 == pwz2) {
- return 0;
- }
-
- // Case sensitive comparison
- if (bCaseSensitive) {
- if (nChar >= 0)
- return wcsncmp(pwz1, pwz2, nChar);
- else
- return wcscmp(pwz1, pwz2);
- }
-
- for (;;) {
- ch1 = *pwz1++;
- ch2 = *pwz2++;
-
- if (ch1 == L'\0' || ch2 == L'\0') {
- break;
- }
-
- // We use OS mapping table
- ch1 = (CAN_SIMPLE_UPCASE(ch1)) ? (SIMPLE_UPCASE(ch1)) : (FusionMapChar(ch1));
- ch2 = (CAN_SIMPLE_UPCASE(ch2)) ? (SIMPLE_UPCASE(ch2)) : (FusionMapChar(ch2));
- nCount++;
-
- if (ch1 != ch2 || (nChar >= 0 && nCount >= nChar)) {
- break;
- }
- }
-
- if (ch1 > ch2) {
- iRet = 1;
- }
- else if (ch1 < ch2) {
- iRet = -1;
- }
-
- return iRet;
-}
-
-// ---------------------------------------------------------------------------
-// FusionCompareStringI
-// ---------------------------------------------------------------------------
-int FusionCompareStringI(LPCWSTR pwz1, LPCWSTR pwz2)
-{
- return FusionCompareStringN(pwz1, pwz2, -1, FALSE);
-}
diff --git a/src/binder/inc/fusionhelpers.hpp b/src/binder/inc/fusionhelpers.hpp
index 7b81e8589c..18beba7204 100644
--- a/src/binder/inc/fusionhelpers.hpp
+++ b/src/binder/inc/fusionhelpers.hpp
@@ -81,9 +81,10 @@ WSTRDupDynamic(LPCWSTR pwszSrc)
#define SET_BIT(id, mask) (mask[((id)-1)>>3] |= (0x1<< (((id)-1)&0x7)))
#define UNSET_BIT(id, mask) (mask[((id)-1)>>3] &= (0xFF - (0x1<<(((id)-1)&0x7))))
-int FusionCompareStringI(LPCWSTR pwz1, LPCWSTR pwz2);
-
-// CLR lobal culture ID
-extern LocaleID g_lcid;
+inline
+int FusionCompareStringI(LPCWSTR pwz1, LPCWSTR pwz2)
+{
+ return SString::_wcsicmp(pwz1, pwz2);
+}
#endif
diff --git a/src/binder/inc/utils.hpp b/src/binder/inc/utils.hpp
index 6b19f26b77..601e02f835 100644
--- a/src/binder/inc/utils.hpp
+++ b/src/binder/inc/utils.hpp
@@ -17,18 +17,16 @@
#include "bindertypes.hpp"
-extern LocaleID g_lcid;
-
namespace BINDER_SPACE
{
inline BOOL EqualsCaseInsensitive(SString &a, SString &b)
{
- return a.EqualsCaseInsensitive(b, g_lcid);
+ return a.EqualsCaseInsensitive(b);
}
inline ULONG HashCaseInsensitive(SString &string)
{
- return string.HashCaseInsensitive(g_lcid);
+ return string.HashCaseInsensitive();
}
HRESULT FileOrDirectoryExists(PathString &path);
diff --git a/src/inc/corpriv.h b/src/inc/corpriv.h
index 07be47c38c..cb504bdd02 100644
--- a/src/inc/corpriv.h
+++ b/src/inc/corpriv.h
@@ -36,12 +36,6 @@ STDAPI MetaDataGetDispenser( // Return HRESULT
REFIID riid, // Interface wanted on class factory.
LPVOID FAR *ppv); // Return interface pointer here.
-// Helper function to check whether policy allows accessing the file
-STDAPI RuntimeCheckLocationAccess(LPCWSTR wszLocation);
-STDAPI RuntimeIsNativeImageOptedOut(IAssemblyName* pAssemblyDef);
-
-LocaleID RuntimeGetFileSystemLocale();
-
BOOL RuntimeFileNotFound(HRESULT hr);
// Helper function to get an Internal interface with an in-memory metadata section
diff --git a/src/inc/dacvars.h b/src/inc/dacvars.h
index 17f84814c9..520b501dac 100644
--- a/src/inc/dacvars.h
+++ b/src/inc/dacvars.h
@@ -136,9 +136,6 @@ DEFINE_DACVAR(ULONG, PTR_SString, SString__s_Empty, SString::s_Empty)
DEFINE_DACVAR(ULONG, BOOL, dac__g_fAppX, ::g_fAppX)
#endif // FEATURE_APPX
-DEFINE_DACVAR(ULONG, BOOL, SString__s_IsANSIMultibyte, SString::s_IsANSIMultibyte)
-
-
DEFINE_DACVAR(ULONG, INT32, ArrayBase__s_arrayBoundsZero, ArrayBase::s_arrayBoundsZero)
DEFINE_DACVAR(ULONG, BOOL, StackwalkCache__s_Enabled, StackwalkCache::s_Enabled)
diff --git a/src/inc/sstring.h b/src/inc/sstring.h
index 267912a097..a37070d533 100644
--- a/src/inc/sstring.h
+++ b/src/inc/sstring.h
@@ -125,9 +125,6 @@ private:
enum tagUTF8 { Utf8 };
enum tagANSI { Ansi };
enum tagASCII {Ascii };
-#ifdef SSTRING_CONSOLECODEPAGE
- enum tagCONSOLE { Console };
-#endif
static void Startup();
static CHECK CheckStartup();
@@ -151,10 +148,6 @@ private:
SString(enum tagUTF8 dummytag, const UTF8 *string, COUNT_T count);
SString(enum tagANSI dummytag, const ANSI *string);
SString(enum tagANSI dummytag, const ANSI *string, COUNT_T count);
-#ifdef SSTRING_CONSOLECODEPAGE
- SString(enum tagCONSOLE dummytag, const CONSOLE *string);
- SString(enum tagCONSOLE dummytag, const CONSOLE *string, COUNT_T count);
-#endif
SString(WCHAR character);
// NOTE: Literals MUST be read-only never-freed strings.
@@ -180,9 +173,6 @@ private:
void SetASCII(const ASCII *string);
void SetUTF8(const UTF8 *string);
void SetANSI(const ANSI *string);
-#ifdef SSTRING_CONSOLECODEPAGE
- void SetConsole(const CONSOLE *string);
-#endif
// Set this string to a copy of the first count chars of the given string
void Set(const WCHAR *string, COUNT_T count);
@@ -195,9 +185,6 @@ private:
void SetUTF8(const UTF8 *string, COUNT_T count);
void SetANSI(const ANSI *string, COUNT_T count);
-#ifdef SSTRING_CONSOLECODEPAGE
- void SetConsole(const CONSOLE *string, COUNT_T count);
-#endif
// Set this string to the unicode character
void Set(WCHAR character);
@@ -241,31 +228,26 @@ private:
// Compute a content-based hash value
ULONG Hash() const;
ULONG HashCaseInsensitive() const;
- ULONG HashCaseInsensitive(LocaleID locale) const;
// Do a string comparison. Return 0 if the strings
// have the same value, -1 if this is "less than" s, or 1 if
// this is "greater than" s.
int Compare(const SString &s) const;
int CompareCaseInsensitive(const SString &s) const; // invariant locale
- int CompareCaseInsensitive(const SString &s, LocaleID locale) const;
// Do a case sensitive string comparison. Return TRUE if the strings
// have the same value FALSE if not.
BOOL Equals(const SString &s) const;
BOOL EqualsCaseInsensitive(const SString &s) const; // invariant locale
- BOOL EqualsCaseInsensitive(const SString &s, LocaleID locale) const;
// Match s to a portion of the string starting at the position.
// Return TRUE if the strings have the same value
// (regardless of representation), FALSE if not.
BOOL Match(const CIterator &i, const SString &s) const;
BOOL MatchCaseInsensitive(const CIterator &i, const SString &s) const; // invariant locale
- BOOL MatchCaseInsensitive(const CIterator &i, const SString &s, LocaleID locale) const;
BOOL Match(const CIterator &i, WCHAR c) const;
BOOL MatchCaseInsensitive(const CIterator &i, WCHAR c) const; // invariant locale
- BOOL MatchCaseInsensitive(const CIterator &i, WCHAR c, LocaleID locale) const;
// Like match, but advances the iterator past the match
// if successful
@@ -292,12 +274,10 @@ private:
// Returns TRUE if this string begins with the contents of s
BOOL BeginsWith(const SString &s) const;
BOOL BeginsWithCaseInsensitive(const SString &s) const; // invariant locale
- BOOL BeginsWithCaseInsensitive(const SString &s, LocaleID locale) const;
// Returns TRUE if this string ends with the contents of s
BOOL EndsWith(const SString &s) const;
BOOL EndsWithCaseInsensitive(const SString &s) const; // invariant locale
- BOOL EndsWithCaseInsensitive(const SString &s, LocaleID locale) const;
// Sets this string to an empty string "".
void Clear();
@@ -572,9 +552,6 @@ private:
const UTF8 *GetUTF8(AbstractScratchBuffer &scratch) const;
const UTF8 *GetUTF8(AbstractScratchBuffer &scratch, COUNT_T *pcbUtf8) const;
const ANSI *GetANSI(AbstractScratchBuffer &scratch) const;
-#ifdef SSTRING_CONSOLECODEPAGE
- const CONSOLE *GetConsole(AbstractScratchBuffer &scratch) const;
-#endif
// Used when the representation is known, throws if the representation doesn't match
const UTF8 *GetUTF8NoConvert() const;
@@ -583,9 +560,6 @@ private:
void ConvertToUnicode(SString &dest) const;
void ConvertToANSI(SString &dest) const;
COUNT_T ConvertToUTF8(SString &dest) const;
-#ifdef SSTRING_CONSOLECODEPAGE
- void ConvertToConsole(SString &dest) const;
-#endif
//-------------------------------------------------------------------
// Accessing the string contents directly
@@ -761,22 +735,14 @@ private:
SString(void *buffer, COUNT_T size);
private:
- static int CaseCompareHelperA(const CHAR *buffer1, const CHAR *buffer2, COUNT_T count, LocaleID lcid, BOOL stopOnNull, BOOL stopOnCount);
- static int CaseCompareHelper(const WCHAR *buffer1, const WCHAR *buffer2, COUNT_T count, LocaleID lcid, BOOL stopOnNull, BOOL stopOnCount);
+ static int CaseCompareHelperA(const CHAR *buffer1, const CHAR *buffer2, COUNT_T count, BOOL stopOnNull, BOOL stopOnCount);
+ static int CaseCompareHelper(const WCHAR *buffer1, const WCHAR *buffer2, COUNT_T count, BOOL stopOnNull, BOOL stopOnCount);
// Internal helpers:
static const BYTE s_EmptyBuffer[2];
static UINT s_ACP;
- SVAL_DECL(BOOL, s_IsANSIMultibyte);
-
-#ifdef SSTRING_CONSOLECODEPAGE
- static UINT s_ConsoleCP;
- static BOOL s_IsConsoleMultibyte;
-#endif
-
- const static LocaleID s_defaultLCID;
SPTR_DECL(SString,s_Empty);
@@ -787,9 +753,6 @@ private:
UTF8 *GetRawUTF8() const;
ANSI *GetRawANSI() const;
WCHAR *GetRawUnicode() const;
-#ifdef SSTRING_CONSOLECODEPAGE
- CONSOLE *GetRawConsole() const;
-#endif
void InitEmpty();
@@ -952,22 +915,6 @@ public:
SetANSI(string, count);
}
-#ifdef SSTRING_CONSOLECODEPAGE
- FORCEINLINE InlineSString(enum tagCONSOLE dummytag, const CONSOLE *string)
- : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE))
- {
- WRAPPER_NO_CONTRACT;
- SetCONSOLE(string);
- }
-
- FORCEINLINE InlineSString(enum tagCONSOLE dummytag, const CONSOLE *string, COUNT_T count)
- : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE))
- {
- WRAPPER_NO_CONTRACT;
- SetCONSOLE(string, count);
- }
-#endif
-
FORCEINLINE InlineSString(WCHAR character)
: SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE))
{
diff --git a/src/inc/sstring.inl b/src/inc/sstring.inl
index 9b0c422000..3bf84443bd 100644
--- a/src/inc/sstring.inl
+++ b/src/inc/sstring.inl
@@ -806,7 +806,7 @@ inline void SString::AppendUTF8(const CHAR c)
/* static */
inline int __cdecl SString::_stricmp(const CHAR *buffer1, const CHAR *buffer2) {
WRAPPER_NO_CONTRACT;
- int returnValue = CaseCompareHelperA(buffer1, buffer2, 0, s_defaultLCID, TRUE, FALSE);
+ int returnValue = CaseCompareHelperA(buffer1, buffer2, 0, TRUE, FALSE);
#ifdef VERIFY_CRT_EQUIVALNCE
_ASSERTE((returnValue == 0) == (::_stricmp(buffer1, buffer2) == 0));
#endif
@@ -817,7 +817,7 @@ inline int __cdecl SString::_stricmp(const CHAR *buffer1, const CHAR *buffer2) {
/* static */
inline int __cdecl SString::_strnicmp(const CHAR *buffer1, const CHAR *buffer2, COUNT_T count) {
WRAPPER_NO_CONTRACT;
- int returnValue = CaseCompareHelperA(buffer1, buffer2, count, s_defaultLCID, TRUE, TRUE);
+ int returnValue = CaseCompareHelperA(buffer1, buffer2, count, TRUE, TRUE);
#ifdef VERIFY_CRT_EQUIVALNCE
_ASSERTE((returnValue == 0) == (::_strnicmp(buffer1, buffer2, count) == 0));
#endif
@@ -827,7 +827,7 @@ inline int __cdecl SString::_strnicmp(const CHAR *buffer1, const CHAR *buffer2,
/* static */
inline int __cdecl SString::_wcsicmp(const WCHAR *buffer1, const WCHAR *buffer2) {
WRAPPER_NO_CONTRACT;
- int returnValue = CaseCompareHelper(buffer1, buffer2, 0, s_defaultLCID, TRUE, FALSE);
+ int returnValue = CaseCompareHelper(buffer1, buffer2, 0, TRUE, FALSE);
#ifdef VERIFY_CRT_EQUIVALNCE
_ASSERTE((returnValue == 0) == (::_wcsicmp(buffer1, buffer2) == 0));
#endif
@@ -838,7 +838,7 @@ inline int __cdecl SString::_wcsicmp(const WCHAR *buffer1, const WCHAR *buffer2)
/* static */
inline int __cdecl SString::_wcsnicmp(const WCHAR *buffer1, const WCHAR *buffer2, COUNT_T count) {
WRAPPER_NO_CONTRACT;
- int returnValue = CaseCompareHelper(buffer1, buffer2, count, s_defaultLCID, TRUE, TRUE);
+ int returnValue = CaseCompareHelper(buffer1, buffer2, count, TRUE, TRUE);
#ifdef VERIFY_CRT_EQUIVALNCE
_ASSERTE((returnValue == 0) == (::_wcsnicmp(buffer1, buffer2, count) == 0));
#endif
@@ -865,36 +865,6 @@ inline int SString::_tstrnicmp(const WCHAR *buffer1, const WCHAR *buffer2, COUNT
return _wcsnicmp(buffer1, buffer2, count);
}
-inline ULONG SString::HashCaseInsensitive() const
-{
- WRAPPER_NO_CONTRACT;
- return HashCaseInsensitive(s_defaultLCID);
-}
-
-inline int SString::CompareCaseInsensitive(const SString &s) const
-{
- WRAPPER_NO_CONTRACT;
- return CompareCaseInsensitive(s, s_defaultLCID);
-}
-
-inline BOOL SString::EqualsCaseInsensitive(const SString &s) const
-{
- WRAPPER_NO_CONTRACT;
- return EqualsCaseInsensitive(s, s_defaultLCID);
-}
-
-inline BOOL SString::MatchCaseInsensitive(const CIterator &i, const SString &s) const
-{
- WRAPPER_NO_CONTRACT;
- return MatchCaseInsensitive(i, s, s_defaultLCID);
-}
-
-inline BOOL SString::MatchCaseInsensitive(const CIterator &i, WCHAR c) const
-{
- WRAPPER_NO_CONTRACT;
- return MatchCaseInsensitive(i, c, s_defaultLCID);
-}
-
inline BOOL SString::Match(const CIterator &i, WCHAR c) const
{
SS_CONTRACT(BOOL)
@@ -1454,7 +1424,7 @@ inline BOOL SString::IsFixedSize() const
STATIC_CONTRACT_SUPPORTS_DAC;
if (GetRepresentation()&REPRESENTATION_VARIABLE_MASK)
- return ((GetRepresentation() == REPRESENTATION_ANSI) && !s_IsANSIMultibyte);
+ return FALSE;
else
return TRUE;
}
@@ -1586,20 +1556,11 @@ inline CHECK SString::CheckCount(COUNT_T count)
inline CHECK SString::CheckRepresentation(int representation)
{
CANNOT_HAVE_CONTRACT;
-#ifdef SSTRING_CONSOLECODEPAGE
- CHECK(representation == REPRESENTATION_EMPTY
- || representation == REPRESENTATION_UNICODE
- || representation == REPRESENTATION_ASCII
- || representation == REPRESENTATION_UTF8
- || representation == REPRESENTATION_ANSI
- || representation == REPRESENTATION_CONSOLE);
-#else
CHECK(representation == REPRESENTATION_EMPTY
|| representation == REPRESENTATION_UNICODE
|| representation == REPRESENTATION_ASCII
|| representation == REPRESENTATION_UTF8
|| representation == REPRESENTATION_ANSI);
-#endif
CHECK((representation & REPRESENTATION_MASK) == representation);
CHECK_OK;
diff --git a/src/inc/winwrap.h b/src/inc/winwrap.h
index acd70d52d4..e4386767f5 100644
--- a/src/inc/winwrap.h
+++ b/src/inc/winwrap.h
@@ -313,12 +313,6 @@ BOOL RunningInteractive();
#define RunningInteractive() FALSE
#endif // !FEATURE_PAL
-// Determines if the process is running as Local System or as a service. Note that this function uses the
-// process' identity and not the thread's (if the thread is impersonating).
-//
-// If the function succeeds, it returns ERROR_SUCCESS, else it returns the error code returned by GetLastError()
-DWORD RunningAsLocalSystemOrService(OUT BOOL& fIsLocalSystemOrService);
-
#ifndef Wsz_mbstowcs
#define Wsz_mbstowcs(szOut, szIn, iSize) WszMultiByteToWideChar(CP_ACP, 0, szIn, -1, szOut, iSize)
#endif
diff --git a/src/utilcode/sstring.cpp b/src/utilcode/sstring.cpp
index 6a6a332c2d..c2467b8485 100644
--- a/src/utilcode/sstring.cpp
+++ b/src/utilcode/sstring.cpp
@@ -24,22 +24,14 @@
// Have one internal, well-known, literal for the empty string.
const BYTE SString::s_EmptyBuffer[2] = { 0 };
-// @todo: these need to be initialized by calling GetACP() or GetConsoleOutputCP()
-// followed by a GetCPInfo to see if the max character size is 1.
+// @todo: these need to be initialized by calling GetACP()
UINT SString::s_ACP = 0;
-SVAL_IMPL_INIT(BOOL, SString, s_IsANSIMultibyte, TRUE);
#ifndef DACCESS_COMPILE
static BYTE s_EmptySpace[sizeof(SString)] = { 0 };
#endif // DACCESS_COMPILE
-#if FEATURE_USE_LCID
-const LocaleID SString::s_defaultLCID = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
-#else
-const LocaleID SString::s_defaultLCID = NULL;
-#endif
-
SPTR_IMPL(SString,SString,s_Empty);
void SString::Startup()
@@ -48,12 +40,8 @@ void SString::Startup()
STATIC_CONTRACT_GC_NOTRIGGER;
if (s_ACP == 0)
- {
- CPINFO info;
-
+ {
UINT ACP = GetACP();
- if (GetCPInfo(ACP, &info) && info.MaxCharSize == 1)
- s_IsANSIMultibyte = FALSE;
#ifndef DACCESS_COMPILE
s_Empty = PTR_SString(new (s_EmptySpace) SString());
@@ -77,7 +65,7 @@ CHECK SString::CheckStartup()
// Case insensitive helpers.
//-----------------------------------------------------------------------------
-static WCHAR MapChar(WCHAR wc, DWORD dwFlags, LocaleID lcid)
+static WCHAR MapChar(WCHAR wc, DWORD dwFlags)
{
WRAPPER_NO_CONTRACT;
@@ -86,11 +74,9 @@ static WCHAR MapChar(WCHAR wc, DWORD dwFlags, LocaleID lcid)
#ifndef FEATURE_PAL
#ifdef FEATURE_USE_LCID
- int iRet = WszLCMapString(lcid, dwFlags, &wc, 1, &wTmp, 1);
+ int iRet = WszLCMapString(MAKELCID(LOCALE_INVARIANT, SORT_DEFAULT), dwFlags, &wc, 1, &wTmp, 1);
#else
- // TODO: Uncertain if this is the best behavior. Caller should specify locale name
- if (lcid == NULL || lcid[0]==W('!')) lcid = W("");
- int iRet = ::LCMapStringEx(lcid, dwFlags, &wc, 1, &wTmp, 1, NULL, NULL, 0);
+ int iRet = ::LCMapStringEx(LOCALE_NAME_INVARIANT, dwFlags, &wc, 1, &wTmp, 1, NULL, NULL, 0);
#endif
if (!iRet) {
// This can fail in non-exceptional cases becauseof unknown unicode characters.
@@ -132,7 +118,7 @@ static WCHAR MapChar(WCHAR wc, DWORD dwFlags, LocaleID lcid)
#define SIMPLE_DOWNCASE(x) (IS_UPPER_A_TO_Z(x) ? ((x) - W('A') + W('a')) : (x))
/* static */
-int SString::CaseCompareHelper(const WCHAR *buffer1, const WCHAR *buffer2, COUNT_T count, LocaleID lcid, BOOL stopOnNull, BOOL stopOnCount)
+int SString::CaseCompareHelper(const WCHAR *buffer1, const WCHAR *buffer2, COUNT_T count, BOOL stopOnNull, BOOL stopOnCount)
{
LIMITED_METHOD_CONTRACT;
@@ -157,8 +143,8 @@ int SString::CaseCompareHelper(const WCHAR *buffer1, const WCHAR *buffer2, COUNT
{
if (diff != 0)
{
- diff = ((CAN_SIMPLE_UPCASE(ch1) ? SIMPLE_UPCASE(ch1) : MapChar(ch1, LCMAP_UPPERCASE, lcid))
- - (CAN_SIMPLE_UPCASE(ch2) ? SIMPLE_UPCASE(ch2) : MapChar(ch2, LCMAP_UPPERCASE, lcid)));
+ diff = ((CAN_SIMPLE_UPCASE(ch1) ? SIMPLE_UPCASE(ch1) : MapChar(ch1, LCMAP_UPPERCASE))
+ - (CAN_SIMPLE_UPCASE(ch2) ? SIMPLE_UPCASE(ch2) : MapChar(ch2, LCMAP_UPPERCASE)));
}
if (diff != 0)
{
@@ -174,8 +160,7 @@ int SString::CaseCompareHelper(const WCHAR *buffer1, const WCHAR *buffer2, COUNT
#define CAN_SIMPLE_UPCASE_ANSI(x) (((x) >= 0x20) && ((x) <= 0x7f))
#define SIMPLE_UPCASE_ANSI(x) (IS_LOWER_A_TO_Z(x) ? ((x) - 'a' + 'A') : (x))
-// TODO: Need to get rid of LocaleID and use a LPCWSTR locale name instead.
-int GetCaseInsensitiveValueA(LocaleID lcid, const CHAR *buffer, int length) {
+int GetCaseInsensitiveValueA(const CHAR *buffer, int length) {
LIMITED_METHOD_CONTRACT;
_ASSERTE(buffer != NULL);
_ASSERTE(length == 1 || ((length == 2) && IsDBCSLeadByte(*buffer)));
@@ -198,13 +183,13 @@ int GetCaseInsensitiveValueA(LocaleID lcid, const CHAR *buffer, int length) {
else
{
_ASSERTE(conversionReturn == 1);
- sortValue = MapChar(wideCh, LCMAP_UPPERCASE, lcid);
+ sortValue = MapChar(wideCh, LCMAP_UPPERCASE);
}
return sortValue;
}
/* static */
-int SString::CaseCompareHelperA(const CHAR *buffer1, const CHAR *buffer2, COUNT_T count, LocaleID lcid, BOOL stopOnNull, BOOL stopOnCount)
+int SString::CaseCompareHelperA(const CHAR *buffer1, const CHAR *buffer2, COUNT_T count, BOOL stopOnNull, BOOL stopOnCount)
{
LIMITED_METHOD_CONTRACT;
@@ -244,15 +229,14 @@ int SString::CaseCompareHelperA(const CHAR *buffer1, const CHAR *buffer2, COUNT_
else
{
int length = 1;
- if (s_IsANSIMultibyte
- && IsDBCSLeadByte(ch1)
+ if (IsDBCSLeadByte(ch1)
&& IsDBCSLeadByte(ch2)
&& (!stopOnCount || ((buffer1 + 1) < buffer1End)))
{
length = 2;
}
- int sortValue1 = GetCaseInsensitiveValueA(lcid, buffer1, length);
- int sortValue2 = GetCaseInsensitiveValueA(lcid, buffer2, length);
+ int sortValue1 = GetCaseInsensitiveValueA(buffer1, length);
+ int sortValue2 = GetCaseInsensitiveValueA(buffer2, length);
diff = sortValue1 - sortValue2;
if (diff != 0)
{
@@ -266,7 +250,7 @@ int SString::CaseCompareHelperA(const CHAR *buffer1, const CHAR *buffer2, COUNT_
}
-int CaseHashHelper(const WCHAR *buffer, COUNT_T count, LocaleID lcid)
+int CaseHashHelper(const WCHAR *buffer, COUNT_T count)
{
LIMITED_METHOD_CONTRACT;
@@ -276,7 +260,7 @@ int CaseHashHelper(const WCHAR *buffer, COUNT_T count, LocaleID lcid)
while (buffer < bufferEnd)
{
WCHAR ch = *buffer++;
- ch = CAN_SIMPLE_UPCASE(ch) ? SIMPLE_UPCASE(ch) : MapChar(ch, LCMAP_UPPERCASE, lcid);
+ ch = CAN_SIMPLE_UPCASE(ch) ? SIMPLE_UPCASE(ch) : MapChar(ch, LCMAP_UPPERCASE);
hash = (((hash << 5) + hash) ^ ch);
}
@@ -662,7 +646,7 @@ ULONG SString::Hash() const
//-----------------------------------------------------------------------------
// Hash the string contents
//-----------------------------------------------------------------------------
-ULONG SString::HashCaseInsensitive(LocaleID lcid) const
+ULONG SString::HashCaseInsensitive() const
{
SS_CONTRACT(ULONG)
{
@@ -680,7 +664,7 @@ ULONG SString::HashCaseInsensitive(LocaleID lcid) const
{
case REPRESENTATION_UNICODE:
case REPRESENTATION_EMPTY:
- result = CaseHashHelper(GetRawUnicode(), GetRawCount(), lcid);
+ result = CaseHashHelper(GetRawUnicode(), GetRawCount());
break;
case REPRESENTATION_ASCII:
@@ -1392,21 +1376,11 @@ BOOL SString::BeginsWith(const SString &s) const
//-----------------------------------------------------------------------------
// Returns TRUE if this string begins with the contents of s
//-----------------------------------------------------------------------------
-BOOL SString::BeginsWithCaseInsensitive(const SString &s, LocaleID locale) const
-{
- WRAPPER_NO_CONTRACT;
-
- return MatchCaseInsensitive(Begin(), s, locale);
-}
-
-//-----------------------------------------------------------------------------
-// Returns TRUE if this string begins with the contents of s. Invariant locale.
-//-----------------------------------------------------------------------------
BOOL SString::BeginsWithCaseInsensitive(const SString &s) const
{
WRAPPER_NO_CONTRACT;
- return BeginsWithCaseInsensitive(s, s_defaultLCID);
+ return MatchCaseInsensitive(Begin(), s);
}
//-----------------------------------------------------------------------------
@@ -1428,7 +1402,7 @@ BOOL SString::EndsWith(const SString &s) const
//-----------------------------------------------------------------------------
// Returns TRUE if this string ends with the contents of s
//-----------------------------------------------------------------------------
-BOOL SString::EndsWithCaseInsensitive(const SString &s, LocaleID locale) const
+BOOL SString::EndsWithCaseInsensitive(const SString &s) const
{
WRAPPER_NO_CONTRACT;
@@ -1438,17 +1412,7 @@ BOOL SString::EndsWithCaseInsensitive(const SString &s, LocaleID locale) const
return FALSE;
}
- return MatchCaseInsensitive(End() - s.GetCount(), s, locale);
-}
-
-//-----------------------------------------------------------------------------
-// Returns TRUE if this string ends with the contents of s. Invariant locale.
-//-----------------------------------------------------------------------------
-BOOL SString::EndsWithCaseInsensitive(const SString &s) const
-{
- WRAPPER_NO_CONTRACT;
-
- return EndsWithCaseInsensitive(s, s_defaultLCID);
+ return MatchCaseInsensitive(End() - s.GetCount(), s);
}
//-----------------------------------------------------------------------------
@@ -1521,7 +1485,7 @@ int SString::Compare(const SString &s) const
// Return 0 if equal, <0 if this < s, >0 is this > s. (same as strcmp).
//-----------------------------------------------------------------------------
-int SString::CompareCaseInsensitive(const SString &s, LocaleID lcid) const
+int SString::CompareCaseInsensitive(const SString &s) const
{
CONTRACT(int)
{
@@ -1558,12 +1522,12 @@ int SString::CompareCaseInsensitive(const SString &s, LocaleID lcid) const
switch (GetRepresentation())
{
case REPRESENTATION_UNICODE:
- result = CaseCompareHelper(GetRawUnicode(), source.GetRawUnicode(), smaller, lcid, FALSE, TRUE);
+ result = CaseCompareHelper(GetRawUnicode(), source.GetRawUnicode(), smaller, FALSE, TRUE);
break;
case REPRESENTATION_ASCII:
case REPRESENTATION_ANSI:
- result = CaseCompareHelperA(GetRawASCII(), source.GetRawASCII(), smaller, lcid, FALSE, TRUE);
+ result = CaseCompareHelperA(GetRawASCII(), source.GetRawASCII(), smaller, FALSE, TRUE);
break;
case REPRESENTATION_EMPTY:
@@ -1630,7 +1594,7 @@ BOOL SString::Equals(const SString &s) const
// Compare this string's contents case insensitively to s's contents.
// Return 1 if equal, 0 if not.
//-----------------------------------------------------------------------------
-BOOL SString::EqualsCaseInsensitive(const SString &s, LocaleID lcid) const
+BOOL SString::EqualsCaseInsensitive(const SString &s) const
{
CONTRACT(BOOL)
{
@@ -1653,11 +1617,11 @@ BOOL SString::EqualsCaseInsensitive(const SString &s, LocaleID lcid) const
switch (GetRepresentation())
{
case REPRESENTATION_UNICODE:
- RETURN (CaseCompareHelper(GetRawUnicode(), source.GetRawUnicode(), count, lcid, FALSE, TRUE) == 0);
+ RETURN (CaseCompareHelper(GetRawUnicode(), source.GetRawUnicode(), count, FALSE, TRUE) == 0);
case REPRESENTATION_ASCII:
case REPRESENTATION_ANSI:
- RETURN (CaseCompareHelperA(GetRawASCII(), source.GetRawASCII(), count, lcid, FALSE, TRUE) == 0);
+ RETURN (CaseCompareHelperA(GetRawASCII(), source.GetRawASCII(), count, FALSE, TRUE) == 0);
case REPRESENTATION_EMPTY:
RETURN TRUE;
@@ -1720,7 +1684,7 @@ BOOL SString::Match(const CIterator &i, const SString &s) const
// Compare s's contents case insensitively to the substring starting at position
// Return TRUE if equal, FALSE if not
//-----------------------------------------------------------------------------
-BOOL SString::MatchCaseInsensitive(const CIterator &i, const SString &s, LocaleID lcid) const
+BOOL SString::MatchCaseInsensitive(const CIterator &i, const SString &s) const
{
CONTRACT(BOOL)
{
@@ -1745,10 +1709,10 @@ BOOL SString::MatchCaseInsensitive(const CIterator &i, const SString &s, LocaleI
{
case REPRESENTATION_UNICODE:
case REPRESENTATION_ANSI:
- RETURN (CaseCompareHelper(i.GetUnicode(), source.GetRawUnicode(), count, lcid, FALSE, TRUE) == 0);
+ RETURN (CaseCompareHelper(i.GetUnicode(), source.GetRawUnicode(), count, FALSE, TRUE) == 0);
case REPRESENTATION_ASCII:
- RETURN (CaseCompareHelperA(i.GetASCII(), source.GetRawASCII(), count, lcid, FALSE, TRUE) == 0);
+ RETURN (CaseCompareHelperA(i.GetASCII(), source.GetRawASCII(), count, FALSE, TRUE) == 0);
case REPRESENTATION_EMPTY:
RETURN TRUE;
@@ -1765,7 +1729,7 @@ BOOL SString::MatchCaseInsensitive(const CIterator &i, const SString &s, LocaleI
// Compare c case insensitively to the character at position
// Return TRUE if equal, FALSE if not
//-----------------------------------------------------------------------------
-BOOL SString::MatchCaseInsensitive(const CIterator &i, WCHAR c, LocaleID lcid) const
+BOOL SString::MatchCaseInsensitive(const CIterator &i, WCHAR c) const
{
SS_CONTRACT(BOOL)
{
@@ -1784,8 +1748,8 @@ BOOL SString::MatchCaseInsensitive(const CIterator &i, WCHAR c, LocaleID lcid) c
WCHAR test = i[0];
SS_RETURN (test == c
- || ((CAN_SIMPLE_UPCASE(test) ? SIMPLE_UPCASE(test) : MapChar(test, LCMAP_UPPERCASE, lcid))
- == (CAN_SIMPLE_UPCASE(c) ? SIMPLE_UPCASE(c) : MapChar(c, LCMAP_UPPERCASE, lcid))));
+ || ((CAN_SIMPLE_UPCASE(test) ? SIMPLE_UPCASE(test) : MapChar(test, LCMAP_UPPERCASE))
+ == (CAN_SIMPLE_UPCASE(c) ? SIMPLE_UPCASE(c) : MapChar(c, LCMAP_UPPERCASE))));
}
//-----------------------------------------------------------------------------
@@ -1809,7 +1773,7 @@ void SString::LowerCase()
for (WCHAR *pwch = GetRawUnicode(); pwch < GetRawUnicode() + GetRawCount(); ++pwch)
{
- *pwch = (CAN_SIMPLE_DOWNCASE(*pwch) ? SIMPLE_DOWNCASE(*pwch) : MapChar(*pwch, LCMAP_LOWERCASE, s_defaultLCID));
+ *pwch = (CAN_SIMPLE_DOWNCASE(*pwch) ? SIMPLE_DOWNCASE(*pwch) : MapChar(*pwch, LCMAP_LOWERCASE));
}
}
@@ -1834,7 +1798,7 @@ void SString::LowerCase(__inout_z LPWSTR wszString)
for (WCHAR * pwch = wszString; *pwch != '\0'; ++pwch)
{
- *pwch = (CAN_SIMPLE_DOWNCASE(*pwch) ? SIMPLE_DOWNCASE(*pwch) : MapChar(*pwch, LCMAP_LOWERCASE, s_defaultLCID));
+ *pwch = (CAN_SIMPLE_DOWNCASE(*pwch) ? SIMPLE_DOWNCASE(*pwch) : MapChar(*pwch, LCMAP_LOWERCASE));
}
}
@@ -1860,7 +1824,7 @@ void SString::UpperCase()
for (WCHAR *pwch = GetRawUnicode(); pwch < GetRawUnicode() + GetRawCount(); ++pwch)
{
- *pwch = (CAN_SIMPLE_UPCASE(*pwch) ? SIMPLE_UPCASE(*pwch) : MapChar(*pwch, LCMAP_UPPERCASE, s_defaultLCID));
+ *pwch = (CAN_SIMPLE_UPCASE(*pwch) ? SIMPLE_UPCASE(*pwch) : MapChar(*pwch, LCMAP_UPPERCASE));
}
}
diff --git a/src/utilcode/winfix.cpp b/src/utilcode/winfix.cpp
index 2d72ae7f53..06e0dd07b0 100644
--- a/src/utilcode/winfix.cpp
+++ b/src/utilcode/winfix.cpp
@@ -252,179 +252,6 @@ BOOL RunningInteractive()
return fInteractive != 0;
}
-
-// Wrapper function around CheckTokenMembership to determine if the token enables the SID "S-1-5-<rid>".
-// If hToken is NULL, this function uses the thread's impersonation token. If the thread is not impersonating, the
-// process token is used.
-//
-// If the function succeeds, it returns ERROR_SUCCESS, else it returns the error code returned by GetLastError()
-static DWORD TokenEnablesSID(IN HANDLE hToken OPTIONAL, IN DWORD rid, OUT BOOL& fResult)
-{
- DWORD dwError;
- SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY;
- PSID pSid = NULL;
- HMODULE hAdvApi32 = NULL;
- typedef BOOL (WINAPI *CheckTokenMembership_t)(HANDLE TokenHandle, PSID SidToCheck, PBOOL IsMember);
- CheckTokenMembership_t pfnCheckTokenMembership = NULL;
-
- hAdvApi32 = WszGetModuleHandle(W("advapi32.dll"));
- if (hAdvApi32 == NULL)
- {
- dwError = ERROR_MOD_NOT_FOUND;
- goto lExit;
- }
- pfnCheckTokenMembership = (CheckTokenMembership_t) GetProcAddress(hAdvApi32, "CheckTokenMembership");
- if (pfnCheckTokenMembership == NULL)
- {
- dwError = GetLastError();
- goto lExit;
- }
-
- fResult = FALSE;
- if (!AllocateAndInitializeSid(&SIDAuthNT, 1, rid, 0, 0, 0, 0, 0, 0, 0, &pSid))
- {
- dwError = GetLastError();
- goto lExit;
- }
- if (!pfnCheckTokenMembership(hToken, pSid, &fResult))
- {
- dwError = GetLastError();
- goto lExit;
- }
- dwError = ERROR_SUCCESS;
-
-lExit:
- if (pSid) FreeSid(pSid);
- return dwError;
-
-}
-
-// Determines if the process is running as Local System or as a service. Note that
-// the function attempts to determine the process' identity and not the thread's
-// (if the thread is impersonating).
-//
-// Parameters:
-// fIsLocalSystemOrService - TRUE if the function succeeds and the process is
-// running as SYSTEM or as a service
-//
-// Return value:
-//
-// If the function succeeds, it returns ERROR_SUCCESS, else it returns the error
-// code returned by GetLastError()
-//
-// Notes:
-//
-// This function will generally fail if the calling thread is impersonating at the
-// ANONYMOUS level; see the comments in the function.
-//
-DWORD RunningAsLocalSystemOrService(OUT BOOL& fIsLocalSystemOrService)
-{
- STATIC_CONTRACT_NOTHROW;
- STATIC_CONTRACT_FORBID_FAULT;
-
- static int fLocalSystemOrService = -1;
- if (fLocalSystemOrService != -1)
- {
- fIsLocalSystemOrService = fLocalSystemOrService != 0;
- return ERROR_SUCCESS;
- }
-
- DWORD dwError;
- HANDLE hThreadToken = NULL;
- HANDLE hProcessToken = NULL;
- HANDLE hDuplicatedProcessToken = NULL;
- BOOL fLocalSystem = FALSE;
- BOOL fService = FALSE;
- BOOL bReverted = FALSE;
-
- if (OpenThreadToken(GetCurrentThread(), TOKEN_IMPERSONATE, TRUE, &hThreadToken))
- {
- if (RevertToSelf())
- {
- bReverted = TRUE;
- }
-#ifdef _DEBUG
- else
- {
- // For debugging only, continue as the impersonated user; see comment below
- dwError = GetLastError();
- }
-#endif // #ifdef _DEBUG
- }
-#ifdef _DEBUG
- else
- {
- dwError = GetLastError();
- if (dwError == ERROR_NO_IMPERSONATION_TOKEN || dwError == ERROR_NO_TOKEN)
- {
- // The thread is not impersonating; it's safe to continue
- }
- else
- {
- // The thread could be impersonating, but we won't be able to restore the impersonation
- // token if we RevertToSelf(). Continue as the impersonated user. OpenProcessToken will
- // fail (unless the impersonated user is SYSTEM or the same as the process' user).
- //
- // Note that this case will occur if the impersonation level is ANONYMOUS, the error
- // code will be ERROR_CANT_OPEN_ANONYMOUS.
- }
- }
-#endif // #ifdef _DEBUG
-
- if (!OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE, &hProcessToken))
- {
- dwError = GetLastError();
- goto lExit;
- }
-
- if (!DuplicateToken(hProcessToken, SecurityImpersonation, &hDuplicatedProcessToken))
- {
- dwError = GetLastError();
- goto lExit;
- }
-
- dwError = TokenEnablesSID(hDuplicatedProcessToken, SECURITY_LOCAL_SYSTEM_RID, fLocalSystem);
- if (dwError != ERROR_SUCCESS)
- {
- goto lExit;
- }
- if (fLocalSystem)
- {
- goto lExit;
- }
-
- dwError = TokenEnablesSID(hDuplicatedProcessToken, SECURITY_SERVICE_RID, fService);
-
-lExit:
- if (bReverted)
- {
- if (!SetThreadToken(NULL, hThreadToken))
- {
- DWORD dwLastError = GetLastError();
- _ASSERT("SetThreadToken failed");
-
- TerminateProcess(GetCurrentProcess(), dwLastError);
- }
- }
-
- if (hThreadToken) CloseHandle(hThreadToken);
- if (hProcessToken) CloseHandle(hProcessToken);
- if (hDuplicatedProcessToken) CloseHandle(hDuplicatedProcessToken);
-
- if (dwError != ERROR_SUCCESS)
- {
- fIsLocalSystemOrService = FALSE; // We don't really know
- }
- else
- {
- fLocalSystemOrService = (fLocalSystem || fService)? 1 : 0;
- fIsLocalSystemOrService = fLocalSystemOrService != 0;
- }
-
- return dwError;
-
-}
-
typedef HRESULT(WINAPI *pfnSetThreadDescription)(HANDLE hThread, PCWSTR lpThreadDescription);
extern pfnSetThreadDescription g_pfnSetThreadDescription;
diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp
index b2f2269771..8944c21ad4 100644
--- a/src/vm/appdomain.hpp
+++ b/src/vm/appdomain.hpp
@@ -3127,13 +3127,12 @@ public:
WRAPPER_NO_CONTRACT;
// See if it is the installation path to mscorlib
- if (path.EqualsCaseInsensitive(m_BaseLibrary, PEImage::GetFileSystemLocale()))
+ if (path.EqualsCaseInsensitive(m_BaseLibrary))
return TRUE;
// Or, it might be the GAC location of mscorlib
if (System()->SystemAssembly() != NULL
- && path.EqualsCaseInsensitive(System()->SystemAssembly()->GetManifestFile()->GetPath(),
- PEImage::GetFileSystemLocale()))
+ && path.EqualsCaseInsensitive(System()->SystemAssembly()->GetManifestFile()->GetPath()))
return TRUE;
return FALSE;
@@ -3145,20 +3144,9 @@ public:
// See if it is the installation path to mscorlib.resources
SString s(SString::Ascii,g_psBaseLibrarySatelliteAssemblyName);
- if (path.EqualsCaseInsensitive(s, PEImage::GetFileSystemLocale()))
+ if (path.EqualsCaseInsensitive(s))
return TRUE;
- // workaround! Must implement some code to do this string comparison for
- // mscorlib.resources in a culture-specific directory in the GAC.
-
- /*
- // Or, it might be the GAC location of mscorlib.resources
- if (System()->SystemAssembly() != NULL
- && path.EqualsCaseInsensitive(System()->SystemAssembly()->GetManifestFile()->GetPath(),
- PEImage::GetFileSystemLocale()))
- return TRUE;
- */
-
return FALSE;
}
#endif // DACCESS_COMPILE
diff --git a/src/vm/baseassemblyspec.inl b/src/vm/baseassemblyspec.inl
index 9f9bae32cb..468d604ff3 100644
--- a/src/vm/baseassemblyspec.inl
+++ b/src/vm/baseassemblyspec.inl
@@ -15,8 +15,6 @@
#ifndef __BASE_ASSEMBLY_SPEC_INL__
#define __BASE_ASSEMBLY_SPEC_INL__
-extern LocaleID g_lcid;
-
BOOL AreSameBinderInstance(ICLRPrivBinder *pBinderA, ICLRPrivBinder *pBinderB);
inline int BaseAssemblySpec::CompareStrings(LPCUTF8 string1, LPCUTF8 string2)
@@ -26,7 +24,7 @@ inline int BaseAssemblySpec::CompareStrings(LPCUTF8 string1, LPCUTF8 string2)
SString s2;
s1.SetUTF8(string1);
s2.SetUTF8(string2);
- return s1.CompareCaseInsensitive(s2,g_lcid);
+ return s1.CompareCaseInsensitive(s2);
}
diff --git a/src/vm/compile.cpp b/src/vm/compile.cpp
index 92a2e081ad..32087818ed 100644
--- a/src/vm/compile.cpp
+++ b/src/vm/compile.cpp
@@ -692,14 +692,14 @@ BOOL IsAssemblySpecifiedInCA(ASSEMBLY * pAssembly, SString dependencyNameFromCA)
// First, check for this:
// DependencyAttribute("Foo", LoadHint.Always)
StackSString simpleName(SString::Utf8, pAssembly->GetSimpleName());
- if (simpleName.EqualsCaseInsensitive(dependencyNameFromCA, PEImage::GetFileSystemLocale()))
+ if (simpleName.EqualsCaseInsensitive(dependencyNameFromCA))
return TRUE;
// Now, check for this:
// DependencyAttribute("Foo,", LoadHint.Always)
SString comma(W(","));
StackSString simpleNameWithComma(simpleName, comma);
- if (simpleNameWithComma.EqualsCaseInsensitive(dependencyNameFromCA, PEImage::GetFileSystemLocale()))
+ if (simpleNameWithComma.EqualsCaseInsensitive(dependencyNameFromCA))
return TRUE;
// Finally:
diff --git a/src/vm/coreclr/corebindresult.inl b/src/vm/coreclr/corebindresult.inl
index 51a47d17b4..5c85c02718 100644
--- a/src/vm/coreclr/corebindresult.inl
+++ b/src/vm/coreclr/corebindresult.inl
@@ -35,7 +35,7 @@ inline BOOL CoreBindResult::IsMscorlib()
#ifndef CROSSGEN_COMPILE
return pAssembly->GetAssemblyName()->IsMscorlib();
#else
- return (pAssembly->GetPath()).EndsWithCaseInsensitive(SString(CoreLibName_IL_W), PEImage::GetFileSystemLocale());
+ return (pAssembly->GetPath()).EndsWithCaseInsensitive(SString(CoreLibName_IL_W));
#endif
}
diff --git a/src/vm/corhost.cpp b/src/vm/corhost.cpp
index 025f708fe5..dfbf48c890 100644
--- a/src/vm/corhost.cpp
+++ b/src/vm/corhost.cpp
@@ -2348,12 +2348,6 @@ void CExecutionEngine::GetLastThrownObjectExceptionFromThread(void **ppvExceptio
} // HRESULT CExecutionEngine::GetLastThrownObjectExceptionFromThread()
-
-LocaleID RuntimeGetFileSystemLocale()
-{
- return PEImage::GetFileSystemLocale();
-};
-
HRESULT CorHost2::DllGetActivationFactory(DWORD appDomainID, LPCWSTR wszTypeName, IActivationFactory ** factory)
{
#ifdef FEATURE_COMINTEROP_WINRT_MANAGED_ACTIVATION
diff --git a/src/vm/peimage.cpp b/src/vm/peimage.cpp
index a79a33b620..e842224e13 100644
--- a/src/vm/peimage.cpp
+++ b/src/vm/peimage.cpp
@@ -31,8 +31,6 @@ PtrHashMap *PEImage::s_Images = NULL;
CrstStatic PEImage::s_ijwHashLock;
PtrHashMap *PEImage::s_ijwFixupDataHash;
-extern LocaleID g_lcid; // fusion path comparison lcid
-
/* static */
void PEImage::Startup()
{
@@ -60,11 +58,6 @@ void PEImage::Startup()
s_ijwFixupDataHash->Init(CompareIJWDataBase, FALSE, &ijwLock);
PEImageLayout::Startup();
-#ifdef FEATURE_USE_LCID
- g_lcid = MAKELCID(LOCALE_INVARIANT, SORT_DEFAULT);
-#else // FEATURE_USE_LCID
- g_lcid = NULL; // invariant
-#endif //FEATURE_USE_LCID
RETURN;
}
@@ -344,18 +337,6 @@ CHECK PEImage::CheckCanonicalFullPath(const SString &path)
CHECK_OK;
}
-#ifdef FEATURE_USE_LCID
-LCID g_lcid =0; // fusion path comparison lcid
-#else
-LPCWSTR g_lcid=NULL;
-#endif
-/* static */
-LocaleID PEImage::GetFileSystemLocale()
-{
- LIMITED_METHOD_CONTRACT;
- return g_lcid;
-}
-
BOOL PEImage::PathEquals(const SString &p1, const SString &p2)
{
CONTRACTL
@@ -369,7 +350,7 @@ BOOL PEImage::PathEquals(const SString &p1, const SString &p2)
#ifdef FEATURE_CASE_SENSITIVE_FILESYSTEM
return p1.Equals(p2);
#else
- return p1.EqualsCaseInsensitive(p2, g_lcid);
+ return p1.EqualsCaseInsensitive(p2);
#endif
}
diff --git a/src/vm/peimage.h b/src/vm/peimage.h
index 45452160bf..a543375477 100644
--- a/src/vm/peimage.h
+++ b/src/vm/peimage.h
@@ -184,8 +184,7 @@ public:
#ifndef FEATURE_PAL
static void GetPathFromDll(HINSTANCE hMod, SString &result);
-#endif // !FEATURE_PAL
- static LocaleID GetFileSystemLocale();
+#endif // !FEATURE_PAL
static BOOL PathEquals(const SString &p1, const SString &p2);
BOOL IsTrustedNativeImage(){LIMITED_METHOD_CONTRACT; return m_bIsTrustedNativeImage;};
void SetIsTrustedNativeImage(){LIMITED_METHOD_CONTRACT; m_bIsTrustedNativeImage=TRUE;};
diff --git a/src/vm/peimage.inl b/src/vm/peimage.inl
index 142012ea54..a9d967beaa 100644
--- a/src/vm/peimage.inl
+++ b/src/vm/peimage.inl
@@ -485,17 +485,18 @@ inline PTR_PEImage PEImage::FindByPath(LPCWSTR pPath)
THROWS;
GC_TRIGGERS;
MODE_ANY;
+ PRECONDITION(CheckPointer(pPath));
PRECONDITION(s_hashLock.OwnedByCurrentThread());
}
CONTRACTL_END;
- int CaseHashHelper(const WCHAR *buffer, COUNT_T count, LocaleID lcid);
+ int CaseHashHelper(const WCHAR *buffer, COUNT_T count);
PEImageLocator locator(pPath);
#ifdef FEATURE_CASE_SENSITIVE_FILESYSTEM
DWORD dwHash=path.Hash();
#else
- DWORD dwHash = CaseHashHelper(pPath, (COUNT_T) wcslen(pPath), PEImage::GetFileSystemLocale());
+ DWORD dwHash = CaseHashHelper(pPath, (COUNT_T) wcslen(pPath));
#endif
return (PEImage *) s_Images->LookupValue(dwHash, &locator);
@@ -607,7 +608,7 @@ inline ULONG PEImage::GetIDHash()
#ifdef FEATURE_CASE_SENSITIVE_FILESYSTEM
RETURN m_path.Hash();
#else
- RETURN m_path.HashCaseInsensitive(PEImage::GetFileSystemLocale());
+ RETURN m_path.HashCaseInsensitive();
#endif
}