diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/Common.h b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/Common.h index cf918834cf7..a69f18c4042 100644 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/Common.h +++ b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/Common.h @@ -6,6 +6,7 @@ #define __COMMON_H #include "precomp.hxx" +#include using namespace System::Security; @@ -64,7 +65,7 @@ private ref class Util sealed __declspec(noinline) const cli::interior_ptr static GetPtrToStringChars(System::String^ s) { - return CriticalPtrToStringChars(s); + return PtrToStringChars(s); } diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/Factory.cpp b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/Factory.cpp index 57109bfa0bd..5e1ce0e28db 100644 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/Factory.cpp +++ b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/Factory.cpp @@ -261,7 +261,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface { System::String^ uriString = uri->AbsoluteUri; IDWriteFontCollection* dwriteFontCollection = NULL; - pin_ptr uriPathWChar = CriticalPtrToStringChars(uriString); + pin_ptr uriPathWChar = PtrToStringChars(uriString); IntPtr pIDWriteFontCollectionLoaderMirror = Marshal::GetComInterfaceForObject( _wpfFontCollectionLoader, @@ -299,7 +299,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface if (isLocal) { //Protect the pointer to the filepath from being moved around by the garbage collector. - pin_ptr uriPathWChar = CriticalPtrToStringChars(filePathUri->LocalPath); + pin_ptr uriPathWChar = PtrToStringChars(filePathUri->LocalPath); // DWrite currently has a slow lookup for the last write time, which // introduced a noticable perf regression when we switched over. @@ -385,7 +385,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface { System::String^ filePath = filePathUri->AbsoluteUri; //Protect the pointer to the filepath from being moved around by the garbage collector. - pin_ptr uriPathWChar = CriticalPtrToStringChars(filePath); + pin_ptr uriPathWChar = PtrToStringChars(filePath); IntPtr pIDWriteFontFileLoaderMirror = Marshal::GetComInterfaceForObject( fontFileLoader, diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontCollection.cpp b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontCollection.cpp index 28d2b08a5cd..fdf54fa472a 100644 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontCollection.cpp +++ b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontCollection.cpp @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. #include "FontCollection.h" -#include namespace MS { namespace Internal { namespace Text { namespace TextInterface { diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/LocalizedStrings.cpp b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/LocalizedStrings.cpp index 4d353f4d045..731c484e477 100644 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/LocalizedStrings.cpp +++ b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/LocalizedStrings.cpp @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. #include "LocalizedStrings.h" -#include "wpfvcclr.h" namespace MS { namespace Internal { namespace Text { namespace TextInterface { @@ -144,7 +143,7 @@ namespace MS { namespace Internal { namespace Text { namespace TextInterface } else { - pin_ptr localeNameWChar = CriticalPtrToStringChars(localeName); + pin_ptr localeNameWChar = PtrToStringChars(localeName); BOOL exists = FALSE; UINT32 localeNameIndex = 0; HRESULT hr = _localizedStrings->Value->FindLocaleName( diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/TrueTypeSubsetter/util2.cpp b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/TrueTypeSubsetter/util2.cpp index 51a28664b8f..56d253328ef 100644 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/TrueTypeSubsetter/util2.cpp +++ b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/TrueTypeSubsetter/util2.cpp @@ -4,8 +4,6 @@ #include "precomp.hxx" #include "util2.h" -#include - namespace MS { namespace Internal { namespace FontCache { @@ -15,7 +13,7 @@ bool Util2::GetRegistryKeyLastWriteTimeUtc(System::String ^ registryKey, [System { HKEY hkey = NULL; - pin_ptr registryKeyUnmanaged = CriticalPtrToStringChars(registryKey); + pin_ptr registryKeyUnmanaged = PtrToStringChars(registryKey); if (::RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryKeyUnmanaged, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) { diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/TrueTypeSubsetter/util2.h b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/TrueTypeSubsetter/util2.h index 71676319451..e66e1f40dda 100644 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/TrueTypeSubsetter/util2.h +++ b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/TrueTypeSubsetter/util2.h @@ -4,6 +4,7 @@ #pragma once +#include namespace MS { namespace Internal { namespace FontCache { diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/wpfvcclr.h b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/wpfvcclr.h deleted file mode 100644 index d4c83cc3fb6..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/wpfvcclr.h +++ /dev/null @@ -1,61 +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. - -//------------------------------------------------------------------------------ -// This file is a copy of , with modifications necessary for WPF. -//------------------------------------------------------------------------------ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#if !defined(_INC_WPFVCCLR) -#define _INC_WPFVCCLR -#ifndef RC_INVOKED - -#using -#include - -#pragma warning(push) -#pragma warning(disable:4400) - -#ifdef __cplusplus_cli -typedef cli::interior_ptr __const_Char_ptr; -typedef cli::interior_ptr __const_Byte_ptr; -typedef cli::interior_ptr _Byte_ptr; -typedef const System::String^ __const_String_handle; -#define _NULLPTR nullptr -#else -typedef const System::Char* __const_Char_ptr; -typedef const System::Byte* __const_Byte_ptr; -typedef System::Byte* _Byte_ptr; -typedef const System::String* __const_String_handle; -#define _NULLPTR 0 -#endif - -/// -/// The standard PtrToStringChars function in vcclr.h is not annotated as -/// SecurityCritical. A recent change to the compiler detects this and -/// prevents it from being inlined. For some reason, this now causes -/// JIT-ing the first time this method is called. This JIT happens in a -/// startup code path that is sensitive to perf. So we make a copy here -/// and annotate it. -/// -inline __const_Char_ptr CriticalPtrToStringChars(__const_String_handle s) -{ - _Byte_ptr bp = const_cast<_Byte_ptr>(reinterpret_cast<__const_Byte_ptr>(s)); - if( bp != _NULLPTR ) - { - unsigned offset = System::Runtime::CompilerServices::RuntimeHelpers::OffsetToStringData; - bp += offset; - } - return reinterpret_cast<__const_Char_ptr>(bp); -} - -#pragma warning(pop) - -#undef _NULLPTR - -#endif /* RC_INVOKED */ -#endif //_INC_WPFVCCLR