Delete dead code (#14703)
authorJan Kotas <jkotas@microsoft.com>
Fri, 27 Oct 2017 23:08:24 +0000 (16:08 -0700)
committerGitHub <noreply@github.com>
Fri, 27 Oct 2017 23:08:24 +0000 (16:08 -0700)
32 files changed:
src/dlls/mscoree/mscoree.cpp
src/ildasm/dasm.cpp
src/inc/CMakeLists.txt
src/inc/MSCOREE.IDL
src/inc/binderngen.idl [deleted file]
src/inc/corhost.h
src/inc/corpriv.h
src/inc/ex.h
src/inc/ivalidator.idl [deleted file]
src/inc/ivehandler.idl [deleted file]
src/inc/metahost_mktlb.rc [deleted file]
src/inc/metahostpriv.idl [deleted file]
src/inc/mscoree_tlb.idl [deleted file]
src/inc/sxshelpers.h [deleted file]
src/inc/sxshelpers.inl [deleted file]
src/inc/tlbimpexp.idl [deleted file]
src/md/compiler/mdvalidator.cpp [deleted file]
src/md/compiler/regmeta.cpp
src/md/compiler/regmeta.h
src/pal/prebuilt/idl/fusionpriv_i.cpp [deleted file]
src/pal/prebuilt/idl/ivalidator_i.cpp [deleted file]
src/pal/prebuilt/idl/ivehandler_i.cpp [deleted file]
src/pal/prebuilt/idl/tlbimpexp_i.cpp [deleted file]
src/pal/prebuilt/inc/ivalidator.h [deleted file]
src/pal/prebuilt/inc/ivehandler.h [deleted file]
src/pal/prebuilt/inc/mscoree.h
src/tools/metainfo/mdinfo.cpp
src/tools/metainfo/mdinfo.h
src/utilcode/sxshelpers.cpp [deleted file]
src/vm/appdomain.cpp
src/vm/vertable.h [deleted file]
src/zap/zapper.cpp

index f3e22da..36b22f2 100644 (file)
@@ -518,60 +518,6 @@ STDAPI LoadStringRCEx(
 #endif // CROSSGEN_COMPILE
 
 
-
-
-// Note that there are currently two callers of this function: code:CCompRC.LoadLibrary
-// and code:CorLaunchApplication.
-STDAPI GetRequestedRuntimeInfoInternal(LPCWSTR pExe, 
-                               LPCWSTR pwszVersion,
-                               LPCWSTR pConfigurationFile, 
-                               DWORD startupFlags,
-                               DWORD runtimeInfoFlags, 
-                                __out_ecount_opt(dwDirectory) LPWSTR pDirectory,
-                               DWORD dwDirectory, 
-                               __out_opt DWORD *pdwDirectoryLength, 
-                               __out_ecount_opt(cchBuffer) LPWSTR pVersion, 
-                               DWORD cchBuffer, 
-                               __out_opt DWORD* pdwLength)
-{
-    CONTRACTL
-    {
-        NOTHROW;
-        GC_NOTRIGGER;
-        ENTRY_POINT;
-        PRECONDITION( pVersion != NULL && cchBuffer > 0);
-    } CONTRACTL_END;
-
-    // for simplicity we will cheat and return the entire system directory in pDirectory
-    pVersion[0] = 0;
-    if (pdwLength != NULL)
-        *pdwLength = 0;
-    HRESULT hr;
-
-    BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(SetLastError(COR_E_STACKOVERFLOW); return COR_E_STACKOVERFLOW;)
-    EX_TRY
-    {
-
-        PathString pDirectoryPath;
-
-        hr = GetCORSystemDirectoryInternaL(pDirectoryPath);
-        *pdwLength = pDirectoryPath.GetCount() + 1;
-        if (dwDirectory >= *pdwLength)
-        {
-            wcscpy_s(pDirectory, pDirectoryPath.GetCount() + 1, pDirectoryPath);
-        }
-        else
-        {
-            hr = E_FAIL;
-        }
-        
-    }
-    EX_CATCH_HRESULT(hr);
-    END_SO_INTOLERANT_CODE
-
-    return hr;
-}
-
 // Replacement for legacy shim API GetCORRequiredVersion(...) used in linked libraries.
 // Used in code:TiggerStorage::GetDefaultVersion#CallTo_CLRRuntimeHostInternal_GetImageVersionString.
 HRESULT 
index 3d172f0..ca64522 100644 (file)
@@ -149,7 +149,7 @@ extern ULONG    g_LocalComTypeNum;
 
 // MetaInfo integration:
 #include "../tools/metainfo/mdinfo.h"
-#include "ivehandler.h"
+
 BOOL                    g_fDumpMetaInfo = FALSE;
 ULONG                   g_ulMetaInfoFilter = MDInfo::dumpDefault;
 // Validator module type.
@@ -6849,29 +6849,6 @@ void DumpMI(__in __nullterminated const char *str)
     }
 }
 
-HRESULT VEHandlerReporter( // Return status.
-    LPCWSTR     szMsg,                  // Error message.
-    VEContext   Context,                // Error context (offset,token)
-    HRESULT     hrRpt)                  // HRESULT for the message
-{
-    WCHAR* wzMsg;
-    if(szMsg)
-    {
-        size_t L = wcslen(szMsg)+256;
-        if((wzMsg = new (nothrow) WCHAR[L]) != NULL)
-        {
-            wcscpy_s(wzMsg,L,szMsg);
-            // include token and offset from Context
-            if(Context.Token) swprintf_s(&wzMsg[wcslen(wzMsg)], L-wcslen(wzMsg), W(" [token:0x%08X]"),Context.Token);
-            if(Context.uOffset) swprintf_s(&wzMsg[wcslen(wzMsg)], L-wcslen(wzMsg), W(" [at:0x%X]"),Context.uOffset);
-            swprintf_s(&wzMsg[wcslen(wzMsg)], L-wcslen(wzMsg), W(" [hr:0x%08X]\n"),hrRpt);
-            DumpMI(UnicodeToUtf(wzMsg));
-            delete[] wzMsg;
-        }
-    }
-    return S_OK;
-}
-
 void DumpMetaInfo(__in __nullterminated const WCHAR* pwzFileName, __in_opt __nullterminated const char* pszObjFileName, void* GUICookie)
 {
     const WCHAR* pch = wcsrchr(pwzFileName,L'.');
@@ -6913,7 +6890,6 @@ void DumpMetaInfo(__in __nullterminated const WCHAR* pwzFileName, __in_opt __nul
             printLine(GUICookie,RstrUTF(IDS_E_MISTART));
             //MDInfo metaDataInfo(g_pPubImport, g_pAssemblyImport, (LPCWSTR)pwzFileName, DumpMI, g_ulMetaInfoFilter);
             MDInfo metaDataInfo(g_pDisp,(LPCWSTR)pwzFileName, DumpMI, g_ulMetaInfoFilter);
-            metaDataInfo.SetVEHandlerReporter((__int64) (size_t) VEHandlerReporter);
             metaDataInfo.DisplayMD();
             printLine(GUICookie,RstrUTF(IDS_E_MIEND));
         }
index 4c82f15..c109c2f 100644 (file)
@@ -6,11 +6,8 @@ set( CORGUIDS_IDL_SOURCES
   xclrdata.idl
   corprof.idl
   corpub.idl
-  ivalidator.idl
-  ivehandler.idl
   gchost.idl
   mscorsvc.idl
-  tlbimpexp.idl
   clrprivappxhosting.idl
   clrprivbinding.idl
   clrprivhosting.idl
index a6b60b9..15be516 100644 (file)
@@ -22,7 +22,6 @@ import "unknwn.idl";
 #if defined(FEATURE_WINDOWSPHONE)
 import "gchost.idl";
 #endif
-import "ivalidator.idl";
 
 #include "product_version.h"
 
@@ -931,11 +930,6 @@ library mscoree
 {
     importlib("stdole32.tlb");
 
-#ifdef INCLUDE_SVC_IDL
-#define IN_MSCOREE
-#include "mscorsvc.idl"
-#endif
-
     //*****************************************************************************
     //
     //*****************************************************************************
diff --git a/src/inc/binderngen.idl b/src/inc/binderngen.idl
deleted file mode 100644 (file)
index f3d41cd..0000000
+++ /dev/null
@@ -1,254 +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.
-
-//+---------------------------------------------------------------------------
-//
-//  File:       binderngen.idl
-//
-//  Contents:   Binder to Native Binder Interfaces
-//
-//  Classes:
-//
-//  Functions:
-//
-//
-//----------------------------------------------------------------------------
-
-cpp_quote("")
-cpp_quote("#ifdef _MSC_VER")
-cpp_quote("#pragma comment(lib,\"uuid.lib\")")
-cpp_quote("#endif")
-cpp_quote("")
-cpp_quote("//---------------------------------------------------------------------------=")
-cpp_quote("// Binder Interfaces")
-cpp_quote("interface INativeImageInstallInfo;")
-cpp_quote("interface IILFingerprint;")
-cpp_quote("interface IILFingerprintFactory;")
-
-import "objidl.idl";
-import "fusion.idl";
-import "fusionpriv.idl";
-
-cpp_quote("#ifdef _MSC_VER")
-cpp_quote("#pragma once")
-cpp_quote("#endif")
-
-// interface IAssemblyName defined in fusion.idl
-// interface IAssemblyEnum defined in fusion.idl
-// interface ICorSvcLogger defined in mscorsvc.idl
-
-interface IAssemblyLocation;
-interface IBindResult;
-interface IBindContext;
-interface INativeImageInstallInfo;
-interface IILFingerprint;
-
-typedef enum
-{
-    PRE_BIND_NONE         = 0x00,
-    PRE_BIND_APPLY_POLICY = 0x80
-} PRE_BIND_FLAGS;
-
-
-typedef enum
-{
-    ASSEMBLY_LOCATION_PATH       = 0x01,
-    ASSEMBLY_LOCATION_GAC        = 0x02,
-    ASSEMBLY_LOCATION_HAS        = 0x04,
-    ASSEMBLY_LOCATION_BYTE_ARRAY = 0x08
-} ASSEMBLY_LOCATION_FLAGS;
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// IAssemblyLocation
-//
-///////////////////////////////////////////////////////////////////////////////
-
-cpp_quote("// {6970aad6-d5fb-469b-9098-a03ddc65a4bd}")
-cpp_quote("EXTERN_GUID(IID_IAssemblyLocation, 0x6970aad6, 0xd5fb, 0x469b, 0x90, 0x98, 0xa0, 0x3d, 0xdc, 0x65, 0xa4, 0xbd);")
-
-[
-        local,
-        object,
-        uuid(6970aad6-d5fb-469b-9098-a03ddc65a4bd),
-        pointer_default(unique)
-]
-interface IAssemblyLocation : IUnknown
-{
-    typedef [unique] IAssemblyLocation *LPASSEMBLYLOCATION;
-
-    HRESULT GetLocationType([in] DWORD *pdwLocationType);
-
-    HRESULT GetPath([in, annotation("__inout_ecount(*pdwccAssemblyPath)")]  LPWSTR  pwzAssemblyPath,
-                   [in, annotation("__inout")]  LPDWORD pdwccAssemblyPath);
-
-    HRESULT GetHostID(UINT64 *puiHostID);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// IBindResult
-//
-//   IBindResult was added mid-Dev10 when the native binder was split off
-//   from Fusion. It seeks to provide a unified view of filepath-based assemblies (IAssembly),
-//   host assemblies (IHostAssembly), NI images (the now-defunct CNativeImageAssembly) and
-//   other things such as byte array assemblies (currently not expressible in Fusion at all.)
-//
-//   At this time, it has not yet been widely adopted outside the native binder.
-//
-//   @todo: Is it necessary for IBindResult to be a separately allocated object?
-//          Why not create a base interface for the existing IAssembly/IHostAssembly?
-//
-//
-// Changes from Dev10:
-//   Removed a bunch of methods that were added as expediencies and would
-//   be long term liabilities if IBindResult is adopted as a universal assembly interface.
-//
-//   In particular, it is no longer permitted to create IBindResult's that wrap
-//   nothing more than an assembly name.
-//
-///////////////////////////////////////////////////////////////////////////////
-cpp_quote("// {82cff42f-55c2-45d2-aa6b-ff96e4de889c}")
-cpp_quote("EXTERN_GUID(IID_IBindResult, 0x82cff42f, 0x55c2, 0x45d2, 0xaa, 0x6b, 0xff, 0x96, 0xe4, 0xde, 0x88, 0x9c);")
-
-[
-        local,
-        object,
-        uuid(82cff42f-55c2-45d2-aa6b-ff96e4de889c),
-        pointer_default(unique)
-]
-interface IBindResult : IUnknown
-{
-     typedef [unique] IBindResult *LPBINDRESULT;
-
-     //--------------------------------------------------------------------------------
-     // These methods are good candidates for a "universal" Assembly interface.
-     //--------------------------------------------------------------------------------
-     HRESULT GetAssemblyNameDef([out] IAssemblyName **ppIAssemblyNameDef);
-
-     HRESULT GetNextAssemblyModuleName([in]      DWORD   dwNIndex,
-                                      [in, out, annotation("__inout_ecount(*pdwCCModuleName)")]  LPWSTR  pwzModuleName,
-                                      [in, out, annotation("__inout")]  LPDWORD pdwCCModuleName);
-
-     HRESULT GetAssemblyLocation([out] IAssemblyLocation **ppIAssemblyLocation);
-
-
-     //--------------------------------------------------------------------------------
-     // Native image binding.
-     //
-     // @todo: Do these need to be on IBindResult? I'd say it's cleaner for
-     // these to be exposed as methods on the load context as was done pre-split.
-     //--------------------------------------------------------------------------------
-     HRESULT GetNativeImage([out] IBindResult **ppINativeImage,
-                           [out] BOOL         *pfNativeImageProbed);
-
-     HRESULT SetNativeImage([in]  IBindResult  *pINativeImage,
-                           [out] IBindResult **ppINativeImageFinal);
-
-
-     //--------------------------------------------------------------------------------
-     // This is needed because IBindResults in Dev10 are not "interned" objects
-     // so we can't do pointer comparison on them as is done with IAssembly.
-     //--------------------------------------------------------------------------------
-     HRESULT IsEqual([in] IUnknown *pIUnk);
-
-
-     //--------------------------------------------------------------------------------
-     // These are used by the closure code only. We may want to rework these further
-     // post Dev10-MQ.
-     //--------------------------------------------------------------------------------
-     HRESULT GetNextAssemblyNameRef([in]  DWORD           dwNIndex,
-                                   [out] IAssemblyName **ppIAssemblyNameRef);
-
-     HRESULT GetNextDependentAssembly([in]  DWORD      dwNIndex,
-                                     [out] IUnknown **ppIUnknownAssembly);
-
-     // Ad-hoc method that gives the closure code the info it needs without native IBindResults
-     // actually having to maintain a reference to its partnered IL IBindResult.
-     HRESULT GetAssemblyLocationOfILImage([out] IAssemblyLocation **ppAssemblyLocation);
-
-
-     //--------------------------------------------------------------------------------
-     // For use on IL's only: Obtain information about IL timestamps/MVIDs/SNHashes, etc.
-     // Note that the MVID/SNHashes may be speculative (as we avoid opening the IL
-     // for workset reasons.) However, everyone in the process will see the same MVID/SNHashs
-     // for a given IL file.
-     //--------------------------------------------------------------------------------
-     HRESULT GetILFingerprint([out] IILFingerprint **ppFingerprint);
-     HRESULT GetSourceILTimestamp([out] FILETIME* pFileTime);
-     HRESULT GetSourceILSize([out] DWORD* pSize);
-
-     //--------------------------------------------------------------------------------
-     // For use on NI's only: Obtain information about NI version and dependencies.
-     //--------------------------------------------------------------------------------
-     HRESULT GetNIInfo([out] INativeImageInstallInfo** pInfo);
-
-     enum
-     {
-        IBindResultFlag_Default                    = 0x00,
-        IBindResultFlag_AssemblyNameDefIncomplete  = 0x01,
-     };
-
-     //--------------------------------------------------------------------------------
-     // Returns the set of flags, defined in IBindResultFlags, that apply to this
-     // IBindResult object.
-     //--------------------------------------------------------------------------------
-     HRESULT GetFlags(DWORD * pdwFlags);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// IBindContext
-//
-//   IBindContext represents a Fusion load context. It is an interface
-//   via which Fusion provides services to the native binder.
-//
-//   Note: This should *not* be adopted as a general interface for Fusion
-//    load contexts. The services exposed here are quite specific to the native
-//    binder's needs and it would be a liability to make them widely available.
-//
-///////////////////////////////////////////////////////////////////////////////
-cpp_quote("// {88db0d1a-460e-4341-96d7-a7c9b68f4679}")
-cpp_quote("EXTERN_GUID(IID_IBindContext, 0x88db0d1a, 0x460e, 0x4341, 0x96, 0xd7, 0xa7, 0xc9, 0xb6, 0x8f, 0x46, 0x79);")
-
-[
-        local,
-        object,
-        uuid(88db0d1a-460e-4341-96d7-a7c9b68f4679),
-        pointer_default(unique)
-]
-interface IBindContext : IUnknown
-{
-    typedef [unique] IBindContext *LPBINDCONTEXT;
-
-    HRESULT PreBind([in]  IAssemblyName  *pIAssemblyName,
-                   [in]  DWORD           dwPreBindFlags,
-                   [out] IBindResult  **ppIBindResult);
-
-    HRESULT IsDefaultContext();
-}
-
-
-
-#pragma midl_echo("STDAPI GetBindResultFromPath(LPCWSTR pwzFilePath, DWORD dwMetaDataImportFlags, DWORD dwAssemblyLocation, IBindContext *pBindContext, IBindResult **ppIBindResult, HANDLE hFile = INVALID_HANDLE_VALUE); ")
-//
-// Interface fraction implemented by ngen binder folks.
-//
-
-typedef struct
-{
-    WCHAR *pwzZapConfigString;
-    DWORD dwZapConfigMask;
-} NativeConfigData;
-
-#pragma midl_echo("interface ICorSvcLogger;")
-#pragma midl_echo("STDAPI InitializeNativeBinder(); ")
-#pragma midl_echo("STDAPI GetZapDir(__deref_out LPCWSTR *pszZapDir); ")
-#pragma midl_echo("STDAPI InstallNativeAssembly(LPCWSTR pwzAssemblyPath, HANDLE hFile, LPCWSTR pwzZapSet, IBindContext* pBindCtx, IAssemblyName **ppAssemblyName, IAssemblyLocation **ppAssemblyLocation);")
-#pragma midl_echo("STDAPI UninstallNativeAssembly(IAssemblyName *pIAssemblyName, ICorSvcLogger *pLogSink); ")
-#pragma midl_echo("STDAPI QueryNativeAssemblyInfo(IAssemblyName *pIAssemblyName, __out_ecount(*pdwSize) LPWSTR pwzFilePath, __inout LPDWORD pdwSize); ")
-#pragma midl_echo("STDAPI GetAssemblyNameFromNIPath(LPCWSTR wszNIPath, IAssemblyName ** ppAssemblyName); ")
-#pragma midl_echo("STDAPI CreateNativeAssemblyEnum(IAssemblyEnum **ppIAssemblyEnum, IAssemblyName  *pIAssemblyName);")
-#pragma midl_echo("STDAPI BindToNativeAssembly(IBindResult *pGivenILAsm, const NativeConfigData *pNativeConfigData, IBindContext *pBindContext, IFusionBindLog *pFusionBindLog); ")
-#pragma midl_echo("struct IMDInternalImport;")
index 6d1d577..2990576 100644 (file)
@@ -26,8 +26,6 @@
 
 #include "clrinternal.h"
 
-#include "ivehandler.h"
-#include "ivalidator.h"
 #include "holder.h"
 
 #include "clrprivhosting.h"
index c422351..edd55e9 100644 (file)
@@ -390,8 +390,6 @@ DECLARE_INTERFACE_(ICeeGenInternal, IUnknown)
 #ifdef FEATURE_PREJIT
 // ===========================================================================
 
-#define CLR_OPTIMIZATION_SERVICE_DLL_NAME W("mscorsvc.dll")
-#define CLR_OPT_SVC_ENTRY_POINT "CorGetSvc"
 
 // Use the default JIT compiler
 #define DEFAULT_NGEN_COMPILER_DLL_NAME W("clrjit.dll")
@@ -473,12 +471,6 @@ typedef GUID CORCOMPILE_NGEN_SIGNATURE;
 //**********************************************************************
 // Internal versions of shim functions for use by the CLR.
 
-STDAPI LoadLibraryShimInternal(
-    LPCWSTR szDllName,
-    LPCWSTR szVersion,
-    LPVOID pvReserved,
-    HMODULE *phModDll);
-
 STDAPI GetCORSystemDirectoryInternaL(
     SString& pBuffer
       );
@@ -495,18 +487,6 @@ STDAPI GetCORVersionInternal(
                                   DWORD  cchBuffer,
     __out                         DWORD *pdwLength);
 
-STDAPI GetRequestedRuntimeInfoInternal(LPCWSTR pExe, 
-                               LPCWSTR pwszVersion,
-                               LPCWSTR pConfigurationFile, 
-                               DWORD startupFlags,
-                               DWORD runtimeInfoFlags, 
-                               __out_ecount_opt(dwDirectory) LPWSTR pDirectory,
-                               DWORD dwDirectory, 
-                               __out_opt DWORD *pdwDirectoryLength, 
-                               __out_ecount_opt(cchBuffer) LPWSTR pVersion, 
-                               DWORD cchBuffer, 
-                               __out_opt DWORD* pdwLength);
-
 
 #ifdef FEATURE_PREJIT
 
index 80b9aa0..d345a74 100644 (file)
@@ -1202,31 +1202,6 @@ Exception *ExThrowWithInnerHelper(Exception *inner);
     }                                                                           \
     EX_END_CATCH(SwallowAllExceptions)
 
-
-//===================================================================================
-// Variant of the above Macro for used by ngen and mscorsvc to add
-// a RetailAssert when a reg key is set if we get an unexpected HRESULT
-// from one of the RPC calls.
-//===================================================================================
-
-#define EX_CATCH_HRESULT_AND_NGEN_CLEAN(_hr)                                    \
-    EX_CATCH                                                                    \
-    {                                                                           \
-        (_hr) = GET_EXCEPTION()->GetHR();                                       \
-        RetailAssertIfExpectedClean();                                          \
-        /* Enable this assert after we fix EH so that GetHR() never */          \
-        /* mistakenly returns S_OK */                                           \
-        /***/                                                                   \
-        /* _ASSERTE(FAILED(_hr)); */                                            \
-        IErrorInfo *pErr = GET_EXCEPTION()->GetErrorInfo();                     \
-        if (pErr != NULL)                                                       \
-        {                                                                       \
-            SetErrorInfo(0, pErr);                                              \
-            pErr->Release();                                                    \
-        }                                                                       \
-    }                                                                           \
-    EX_END_CATCH(SwallowAllExceptions)
-
 #else // FEATURE_COMINTEROP
 
 #define EX_CATCH_HRESULT(_hr) EX_CATCH_HRESULT_NO_ERRORINFO(_hr)
diff --git a/src/inc/ivalidator.idl b/src/inc/ivalidator.idl
deleted file mode 100644 (file)
index d028d98..0000000
+++ /dev/null
@@ -1,116 +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.
-/* ------------------------------------------------------------------------- *
- * Common Language Runtime Verifier / Validator Interace
- *
- * Purpose: IValidator is used to staticly validate COR images.
- *
- * Protocol:
- *
- * Client CoCreates CorHost.Validator, 
- *      Calls Validate()
- *          [in/optional] IVEHandler for error callbacks on error
- *          [in/optional] Appdomain to use for validating assemblies
- *
- *      On Error, Validator calls IVEHandler.VEHandler() method. 
- *          (IVEHandler supplied by the client).
- *          VEHandler() could return CONTINUE / STOP ...
- *
- *      VEHandler() can call Validator.FormatEventInfo()  to get a detailed 
- *          error message on any error passed to IVEHandler.
- *
- * ------------------------------------------------------------------------- */
-
-/* ------------------------------------------------------------------------- *
- * Imported types
- * ------------------------------------------------------------------------- */
-
-#ifndef DO_NO_IMPORTS
-import "ivehandler.idl";
-#endif
-
-#pragma warning(push)
-#pragma warning(disable:28718)    //Unable to annotate as this is not a local interface
-
-
-
-/* ------------------------------------------------------------------------- *
- * Forward declarations
- * ------------------------------------------------------------------------- */
-
-interface IValidator;
-interface ILoader;
-
-
-/* ------------------------------------------------------------------------- *
- * Flags
- * ------------------------------------------------------------------------- */
-enum ValidatorFlags
-{
-        VALIDATOR_EXTRA_VERBOSE =       0x00000001,
-        VALIDATOR_SHOW_SOURCE_LINES =   0x00000002, // RESERVED FOR FUTURE USE
-        VALIDATOR_CHECK_ILONLY =        0x00000004,
-        VALIDATOR_CHECK_PEFORMAT_ONLY = 0x00000008,
-        VALIDATOR_NOCHECK_PEFORMAT =    0x00000010,
-        VALIDATOR_TRANSPARENT_ONLY =    0x00000020,
-};
-
-/* ------------------------------------------------------------------------- *
- * IValidator interface
- * ------------------------------------------------------------------------- */
-[
- object,
- uuid(63DF8730-DC81-4062-84A2-1FF943F59FAC),
- pointer_default(unique)
-]
-interface IValidator : IUnknown
-{
-        HRESULT Validate(
-                        [in] IVEHandler        *veh,
-                        [in] IUnknown          *pAppDomain,
-                        [in] unsigned long      ulFlags,
-                        [in] unsigned long      ulMaxError,
-                        [in] unsigned long      token,
-                        [in] LPWSTR             fileName,
-                        [in, size_is(ulSize)] BYTE *pe,
-                        [in] unsigned long      ulSize);
-
-        HRESULT FormatEventInfo(
-                        [in] HRESULT            hVECode,
-                        [in] VEContext          Context,
-                        [in, out] LPWSTR        msg,
-                        [in] unsigned long      ulMaxLength,
-                        [in] SAFEARRAY(VARIANT) psa);
-};
-
-
-/* ------------------------------------------------------------------------- *
- * ICLRValidator interface
- * ------------------------------------------------------------------------- */
-[
- object,
- uuid(63DF8730-DC81-4062-84A2-1FF943F59FDD),
- pointer_default(unique)
-]
-interface ICLRValidator : IUnknown
-{
-        HRESULT Validate(
-                        [in] IVEHandler        *veh,
-                        [in] unsigned long      ulAppDomainId,
-                        [in] unsigned long      ulFlags,
-                        [in] unsigned long      ulMaxError,
-                        [in] unsigned long      token,
-                        [in] LPWSTR             fileName,
-                        [in, size_is(ulSize)] BYTE *pe,
-                        [in] unsigned long      ulSize);
-
-        HRESULT FormatEventInfo(
-                        [in] HRESULT            hVECode,
-                        [in] VEContext          Context,
-                        [in, out] LPWSTR        msg,
-                        [in] unsigned long      ulMaxLength,
-                        [in] SAFEARRAY(VARIANT) psa);
-};
-#pragma warning(pop)
-
diff --git a/src/inc/ivehandler.idl b/src/inc/ivehandler.idl
deleted file mode 100644 (file)
index 0c0ad2b..0000000
+++ /dev/null
@@ -1,72 +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.
-/* ------------------------------------------------------------------------- *
- * Common Language Runtime Verification Event Handler Interface
- * ------------------------------------------------------------------------- */
-
-/* ------------------------------------------------------------------------- *
- * Imported types
- * ------------------------------------------------------------------------- */
-
-#ifndef DO_NO_IMPORTS
-
-import "unknwn.idl";
-
-#define _VER_RAW_STRUCT_FOR_IDL_
-#include "VerError.h"
-#undef _VER_RAW_STRUCT_FOR_IDL_
-
-#endif
-
-typedef _VerError VEContext;
-
-/* ------------------------------------------------------------------------- *
- * Forward declarations
- * ------------------------------------------------------------------------- */
-
-interface IVEHandler;
-
-
-/* ------------------------------------------------------------------------- *
- * Library defintion
- * ------------------------------------------------------------------------- */
-
-[
-  uuid(856CA1B0-7DAB-11d3-ACEC-00C04F86C309),
-  version(1.0),
-  helpstring("Common Language Runtime Verification Event Handler 1.0 Type Library")
-]
-library VEHandlerLib
-{
-    importlib("STDOLE2.TLB");
-
-       [
-        uuid(856CA1B1-7DAB-11d3-ACEC-00C04F86C309)
-       ]
-       coclass VEHandlerClass
-       {
-               [default] interface IVEHandler;
-       };
-    
-};
-
-/* ------------------------------------------------------------------------- *
- * IVEHandler interface
- * ------------------------------------------------------------------------- */
-[
- object,
- uuid(856CA1B2-7DAB-11d3-ACEC-00C04F86C309),
- pointer_default(unique)
-]
-interface IVEHandler : IUnknown
-{
-    HRESULT VEHandler(
-                       [in] HRESULT VECode,
-                       [in] VEContext Context,
-                       [in] SAFEARRAY(VARIANT) psa);
-       HRESULT SetReporterFtn(
-                       [in] __int64 lFnPtr);
-
-};
-
diff --git a/src/inc/metahost_mktlb.rc b/src/inc/metahost_mktlb.rc
deleted file mode 100644 (file)
index a8a60ee..0000000
+++ /dev/null
@@ -1,11 +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.
-
-#define FX_VER_FILEDESCRIPTION_STR "Microsoft .NET Runtime Metahosting Interfaces\0"
-#define FX_VER_INTERNALNAME_STR METAHOST.IDL
-
-#include <fxver.h>
-#include <fxver.rc>
-
-1 typelib REAL_METAHOST_TLB_FILE
diff --git a/src/inc/metahostpriv.idl b/src/inc/metahostpriv.idl
deleted file mode 100644 (file)
index 6d833b3..0000000
+++ /dev/null
@@ -1,212 +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.
-
-/**************************************************************************************
- ** NOTE: This file should be removed before 4.0 RTM. Specifically, when we decide   **
- ** that enough time has elapsed that there should be no binaries left depending on  **
- ** this old interface version.
- **************************************************************************************/
-
-import "metahost.idl";
-
-// IID ICLRMetaHostCompat1 : uuid(D332DB9E-B9B3-4125-8207-A14884F53215)
-cpp_quote("EXTERN_GUID(IID_ICLRMetaHostCompat1, 0xD332DB9E, 0xB9B3, 0x4125, 0x82, 0x07, 0xA1, 0x48, 0x84, 0xF5, 0x32, 0x15);")
-
-// IID ICLRMetaHostPolicyCompat1 : uuid(E2190695-77B2-492e-8E14-C4B3A7FDD592)
-cpp_quote("EXTERN_GUID(IID_ICLRMetaHostPolicyCompat1, 0xE2190695, 0x77B2, 0x492e, 0x8E, 0x14, 0xC4, 0xB3, 0xA7, 0xFD, 0xD5, 0x92);")
-
-// IID ICLRRuntimeHost3 : uuid(F4A7AE38-3213-4057-85FC-3DA54AFD0CFC)
-cpp_quote("EXTERN_GUID(IID_ICLRRuntimeHost3, 0xF4A7AE38, 0x3213, 0x4057, 0x85, 0xFC, 0x3D, 0xA5, 0x4A, 0xFD, 0x0C, 0xFC);")
-
-[
-    uuid(D332DB9E-B9B3-4125-8207-A14884F53215),
-    version(1.0),
-    helpstring("CLR meta hosting interface"),
-    local
-]
-interface ICLRMetaHostCompat1 : IUnknown
-{
-    /**********************************************************************************
-     ** Returns installed runtime with the specific version. Fails if not found.     **
-     ** NULL or any other wildcard is not accepted as pwzVersion                     **
-     ** Supersedes: CorBindToRuntimeEx with STARTUP_LOADER_SAFEMODE                  **
-
-
-     **********************************************************************************/
-    HRESULT GetRuntime(
-        [in]  LPCWSTR pwzVersion,
-        [in]  REFIID  riid,   // IID_ICLRRuntimeInfo
-        [out, iid_is(riid), retval] LPVOID *ppRuntime);
-
-    /**********************************************************************************
-     ** Returns runtime version burned into a file's metadata.                       **
-     ** Supersedes: GetFileVersion                                                   **
-     **********************************************************************************/
-    HRESULT GetVersionFromFile(
-        [in]      LPCWSTR pwzFilePath,
-        [out, size_is(*pcchBuffer), annotation("__out_ecount_full(*pcchBuffer)")] 
-                  LPWSTR pwzBuffer, 
-        [in, out] DWORD *pcchBuffer);
-
-    /**********************************************************************************
-     ** Returns an enumerator of runtimes installed on the machine.                  **
-     ** Supersedes: (none)                                                           **
-     **********************************************************************************/
-    HRESULT EnumerateInstalledRuntimes(
-        [out, retval] IEnumUnknown **ppEnumerator);
-
-    /**********************************************************************************
-     ** Provides an enumerator of runtimes loaded into the given process.            **
-     ** Supersedes: GetVersionFromProcess                                            **
-
-     **********************************************************************************/
-    HRESULT EnumerateLoadedRuntimes(
-        [in]  HANDLE hndProcess,
-        [out, retval] IEnumUnknown **ppEnumerator);
-
-    /**********************************************************************************
-     ** Provides a callback when a new runtime version has just been loaded, but not **
-     ** started.                                                                     **
-     **                                                                              **
-     ** The callback works in the following way:                                     **
-     **   - the callback is invoked only when a runtime is loaded for the first time **
-     **   - the callback will not be invoked for reentrant loads of the same runtime **
-     **   - the callback will be for reentrant loads of other runtimes               **
-     **   - it is guaranteed that no other thread may load the runtime until the     **
-     **     callback returns; any thread that does so blocks until this time.        **
-     **   - for non-reentrant multi-threaded runtime loads, callbacks are serialized **
-     **   - if the host intends to load (or cause to be loaded) another runtime in a **
-     **     reentrant fashion, or intends to perform any operations on the runtime   **
-     **     corresponding to the callback instance, the pfnCallbackThreadSet and     **
-     **     pfnCallbackThreadUnset arguments provided in the callback must be used   **
-     **     in the following way:                                                    **
-     **     - pfnCallbackThreadSet must be called by the thread that might cause a   **
-     **       runtime load before such a load is attempted                           **
-     **     - pfnCallbackThreadUnset must be called when the thread will no longer   **
-     **       cause such a runtime load (and before returning from the initial       **
-     **       callback)                                                              **
-     **     - pfnCallbackThreadSet and pfnCallbackThreadUnset are non-reentrant.     **
-     **                                                                              **
-     **   pCallbackFunction: This function is invoked when a new runtime has just    **
-     **                      been loaded. A value of NULL results in a failure       **
-     **                      return value of E_POINTER.                              **
-     **                                                                              **
-     ** Supersedes: LockClrVersion                                                   **
-     **********************************************************************************/
-    HRESULT RequestRuntimeLoadedNotification(
-        [in] RuntimeLoadedCallbackFnPtr pCallbackFunction);
-
-    /**********************************************************************************
-     ** Provides a mechanism to set the process wide config file settings.           **
-     ** Supersedes: none                                                             **
-     **********************************************************************************/
-    HRESULT SetProcessConfig(
-        [in]  IStream * pstmConfig);
-} // interface ICLRMetaHost
-
-
-/**************************************************************************************
- ** ICLRMetaHostPolicyCompat1                                                        **
- ** Activated using mscoree!CreateInterface. Implements a policy for determining     **
- ** a runtime based on various inputs (metadata, config stream, ...).                **
- **************************************************************************************/
-[
-    uuid(E2190695-77B2-492e-8E14-C4B3A7FDD592),
-    version(1.0),
-    helpstring("CLR meta hosting policy"),
-    local
-]
-interface ICLRMetaHostPolicyCompat1 : IUnknown
-{
-    /**********************************************************************************
-     ** Returns requested runtime version and runtime (not necessarily of that       **
-     ** version) based on a managed binary, version, and config file.                **
-     ** The return value is S_OK if a compatible runtime was found and S_FALSE if    **
-     ** not. *ppRuntime will be NULL in the latter case.                             **
-     ** Supersedes: GetRequestedRuntimeInfo, GetRequestedRuntimeVersion,             **
-     **             CorBindToRuntimeHost, CorBindToRuntimeByCfg,                     **
-     **             GetCORRequiredVersion                                            **
-     **********************************************************************************/
-    HRESULT GetRequestedRuntime(
-        [in]  METAHOST_POLICY_FLAGS dwPolicyFlags,
-        [in]  LPCWSTR pwzBinary,                              // optional
-        [in]  IStream *pCfgStream,                            // optional
-        [in, out, size_is(*pcchVersion), annotation("__inout_ecount_full(*pcchVersion)")] 
-              LPWSTR pwzVersion,   // optional
-        [in, out]  DWORD *pcchVersion, 
-        [out, size_is(*pcchImageVersion), annotation("__out_ecount_full(*pcchImageVersion)")] 
-              LPWSTR pwzImageVersion, // image version to be used by compilers
-        [in, out]  DWORD *pcchImageVersion,
-        [in]  REFIID  riid,   // IID_ICLRRuntimeInfo
-        [out, iid_is(riid), retval] LPVOID *ppRuntime);
-} // interface ICLRMetaHostPolicy
-
-/**************************************************************************************
- ** ICLRRuntimeHost3                                                                 **
- ** This is the functionality that moved from being flat APIs (loading the latest    **
- ** runtime) to something that is runtime-specific and requires the runtime to be    **
- ** loaded.
- **************************************************************************************/
-[
-    uuid(F4A7AE38-3213-4057-85FC-3DA54AFD0CFC),
-    version(1.0),
-    helpstring("CLR hosting interface for V4.0"),
-    local
-]
-interface ICLRRuntimeHost3 : ICLRRuntimeHost
-{
-    /**********************************************************************************
-     ** Creates an instance of the type specified by a fully qualified name.         **
-     ** Returns a CCW wrapping the managed object. This method is intended to be     **
-     ** used primarily by the COM host. TODO: Specify the AppDomain?                 **
-     **
-     ** Supersedes: ClrCreateManagedInstance                                         **
-     **********************************************************************************/
-    HRESULT CreateManagedObject(
-        [in]  LPCWSTR  pwzTypeName, 
-        [in]  REFIID   riid, 
-        [out, iid_is(riid), retval] LPVOID *ppObject);
-
-    /**********************************************************************************
-     ** Releases all cached RCWs.                                                    **
-     ** Supersedes: CoEEShutDownCOM                                                  **
-     **********************************************************************************/
-    HRESULT ShutdownCOMInterop();
-
-    /**********************************************************************************
-     ** Shuts down the current process.                                              **
-     ** Supersedes: CorExitProcess                                                   **
-     **********************************************************************************/
-    HRESULT ExitProcess(
-        [in]  INT32 iExitCode);
-
-    /**********************************************************************************
-     ** Returns TRUE if the runtime has been started, i.e. Start() has been called.  **
-     ** If it has been started, its STARTUP_FLAGS are returned.                      **
-     ** Supersedes: (none)                                                           **
-     **********************************************************************************/
-    HRESULT IsStarted(
-        [out] BOOL *pbStarted,
-        [out] DWORD *pdwStartupFlags);
-
-    /**********************************************************************************
-     ** Starts the runtime with the given STARTUP_FLAGS and host config file.        **
-     ** Supersedes: ICLRRuntimeHost::Start                                           **
-     **********************************************************************************/
-    HRESULT StartWithFlags(
-        [in]  DWORD dwStartupFlags,
-        [in]  LPCWSTR pwzHostConfigFile);
-};  // interface ICLRRuntimeHost3
-
-[
-    uuid(5288DA6A-A8D3-43a1-8365-37DB0E7D5944),
-    version(1.0),
-]
-library CLRMetaHostCompat
-{
-    interface ICLRMetaHostCompat1;
-    interface ICLRMetaHostPolicyCompat1;
-    interface ICLRRuntimeHost3;
-};
-
diff --git a/src/inc/mscoree_tlb.idl b/src/inc/mscoree_tlb.idl
deleted file mode 100644 (file)
index 838e2cc..0000000
+++ /dev/null
@@ -1,15 +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.
-
-                                                      
-/**************************************************************************************
- **                                                                                  **
- ** Mscoree_tlb.idl - mscoree.idl + internal intefaces from mscorsvc.dll             **
- **                   Used for making mscoree.tlb                                    **
- **                                                                                  **
- **************************************************************************************/
-
-#define INCLUDE_SVC_IDL
-#include "mscoree.idl"
-
diff --git a/src/inc/sxshelpers.h b/src/inc/sxshelpers.h
deleted file mode 100644 (file)
index 199c1d4..0000000
+++ /dev/null
@@ -1,141 +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.
-//****************************************************************************
-//
-//   SxSHelpers.h
-//
-//   Some helping classes and methods for SxS in mscoree and mscorwks/mscorsvr
-//
-
-//****************************************************************************
-
-
-#ifndef SXSHELPERS_H_
-#define SXSHELPERS_H_
-
-#define V1_VERSION_NUM W("v1.0.3705")
-
-// This string is the magic string located in the registry which determines that a key is actually
-// a version.
-// 
-// For example:
-//
-// HCR/clsid/xxxx-xx-xx-xx/InprocServer32/1.0.3705.0
-//                                                                         /1.0.3705.125
-//
-// If this SBSVERSIONVALUE is set as a ValueName in these
-// version keys, then we're saying that there is an implementation of the object
-// for that version of the runtime.
-//
-// i.e., if 1.0.3705.0 has the value name of SBSVERSIONVALUE, then 1.0.3705.0 implements
-// this class id.
-#define SBSVERSIONVALUE        W("ImplementedInThisVersion")
-
-// Find the runtime version from registry for rclsid
-// If succeeded, *ppwzRuntimeVersion will have the runtime version 
-//      corresponding to the highest version
-// If failed, *ppwzRuntimeVersion will be NULL
-// 
-// Note: If succeeded, this function will allocate memory for 
-//      *ppwzRuntimeVersion. It if the caller's repsonsibility to
-//      release that memory
-HRESULT FindRuntimeVersionFromRegistry(
-    REFCLSID rclsid,
-    __deref_out_z LPWSTR *ppwzRuntimeVersion,
-    __deref_out_opt LPWSTR *ppwzSupportedVersions);
-
-// Find assembly info from registry for rclsid
-// If succeeded, *ppwzClassName, *ppwzAssemblyString, *ppwzCodeBase
-//      will have their value corresponding to the highest version
-// If failed, they will be set to NULL
-// Note: If succeeded, this function will allocate memory for 
-//      *ppwzClassName, *ppwzAssemblyString and *ppwzCodeBase. 
-//      Caller is responsible to release them.
-//
-HRESULT FindShimInfoFromRegistry(
-    REFCLSID rclsid,
-    BOOL bLoadRecord,
-    WORD wHighestRuntimeMajorVersion,
-    WORD wHighestRuntimeMinorVersion,
-    __deref_out_z LPWSTR *ppwzClassName,
-    __deref_out_z LPWSTR *ppwzAssemblyString,
-    __deref_out_z LPWSTR *ppwzCodeBase);
-
-// Find assembly info from Win32 activattion context for rclsid
-// If succeeded, *ppwzRuntimeVersion, *ppwzClassName, *ppwzAssemblyString, 
-//      will have their value corresponding to the highest version
-// If failed, they will be set to NULL
-// Note: If succeeded, this function will allocate memory for 
-//      *ppwzClassName, *ppwzAssemblyString and *ppwzCodeBase. 
-//      Caller is responsible to release them.
-//      Also notice codebase is not supported in Win32 case.
-//
-HRESULT FindShimInfoFromWin32(
-    REFCLSID rclsid,
-    BOOL bLoadRecord,
-    __deref_opt_out_opt LPWSTR *ppwzRuntimeVersion,
-    __deref_opt_out_opt LPWSTR *ppwszSupportedRuntimeVersions,
-    __deref_opt_out_opt LPWSTR *ppwzClassName,
-    __deref_opt_out_opt LPWSTR *ppwzAssemblyString,
-    BOOL *pfRegFreePIA);
-
-// Get information from the Win32 fusion about the config file and the application base.
-HRESULT GetConfigFileFromWin32Manifest(__out_ecount_part(dwBuffer, *pSize) WCHAR* buffer, SIZE_T dwBuffer, SIZE_T* pSize);
-HRESULT GetApplicationPathFromWin32Manifest(__out_ecount_part(dwBuffer, *pSize) WCHAR* buffer, SIZE_T dwBuffer, SIZE_T* pSize);
-
-
-//****************************************************************************
-//  AssemblyVersion
-//  
-//  class to handle assembly version
-//  Since only functions in this file will use it,
-//  we declare it in the cpp file so other people won't use it.
-//
-//****************************************************************************
-class AssemblyVersion
-{
-    public:
-        // constructors
-        inline AssemblyVersion();
-
-        inline AssemblyVersion(AssemblyVersion& version);
-        
-        // Init
-        HRESULT Init(__in_z LPCWSTR pwzVersion, BOOL bStartsWithV);
-        inline HRESULT Init(WORD major, WORD minor, WORD build, WORD revision);
-
-        // Mofifiers.
-        inline void SetBuild(WORD build);
-        inline void SetRevision(WORD revision);
-
-        // assign operator
-        inline AssemblyVersion& operator=(const AssemblyVersion& version);
-
-        // Comparison operator
-        friend BOOL operator==(const AssemblyVersion& version1,
-                               const AssemblyVersion& version2);
-        friend BOOL operator>=(const AssemblyVersion& version1,
-                               const AssemblyVersion& version2);
-
-    private:
-
-        // pwzVersion must have format of "a.b.c.d",
-        // where a,b,c,d are all numbers
-        HRESULT ValidateVersion(LPCWSTR pwzVersion);
-
-    private:
-        WORD        _major;
-        WORD        _minor;
-        WORD        _build;
-        WORD        _revision;
-};
-extern BOOL operator==(const AssemblyVersion& version1, 
-                       const AssemblyVersion& version2);
-
-extern BOOL operator>=(const AssemblyVersion& version1,
-                       const AssemblyVersion& version2);
-inline BOOL operator<(const AssemblyVersion& version1,
-                      const AssemblyVersion& version2);
-#include <sxshelpers.inl>
-#endif  // SXSHELPERS_H_
diff --git a/src/inc/sxshelpers.inl b/src/inc/sxshelpers.inl
deleted file mode 100644 (file)
index 3e42051..0000000
+++ /dev/null
@@ -1,76 +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.
-
-#ifndef _SXSHELPERS_INL_
-#define _SXSHELPERS_INL_
-
-AssemblyVersion::AssemblyVersion()
-:_major(0)
-,_minor(0)
-,_build(0)
-,_revision(0)
-{
-    LIMITED_METHOD_CONTRACT;
-
-}
-
-AssemblyVersion::AssemblyVersion(AssemblyVersion& version)
-{
-    LIMITED_METHOD_CONTRACT;
-
-    _major = version._major;
-    _minor = version._minor;
-    _build = version._build;
-    _revision = version._revision;
-}
-
-HRESULT AssemblyVersion::Init(WORD major, WORD minor, WORD build, WORD revision)
-{
-    LIMITED_METHOD_CONTRACT;
-
-    _major = major;
-    _minor = minor;
-    _build = build;
-    _revision = revision;
-
-    return S_OK;
-}
-
-
-void AssemblyVersion::SetBuild(WORD build)
-{
-    LIMITED_METHOD_CONTRACT;
-    
-    _build = build;
-}
-
-void AssemblyVersion::SetRevision(WORD revision)
-{
-    LIMITED_METHOD_CONTRACT;
-    
-    _revision = revision;
-}
-
-AssemblyVersion& AssemblyVersion::operator=(const AssemblyVersion& version)
-{
-    LIMITED_METHOD_CONTRACT;
-
-    _major = version._major;
-    _minor = version._minor;
-    _build = version._build;
-    _revision = version._revision;
-
-    return *this;
-}
-
-BOOL operator<(const AssemblyVersion& version1,
-               const AssemblyVersion& version2)
-{
-    WRAPPER_NO_CONTRACT;
-
-    return !operator>=(version1, version2);
-}
-
-
-#endif /* _SXSHELPERS_INL_ */
diff --git a/src/inc/tlbimpexp.idl b/src/inc/tlbimpexp.idl
deleted file mode 100644 (file)
index b7b1174..0000000
+++ /dev/null
@@ -1,72 +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.
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-// .Net Developer Platform TypeLib importer/exporter event notification 
-//   interface definitions.
-// 
-// NOTE:  This IDL must remain synchronized with the definitions in
-//        BCL/System/Runtime/InteropServices/ITypeLibConverter.cs.
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-[
-    uuid(20BC1825-06F0-11d2-8CF4-00A0C9B0A063),
-    version(1.0)
-]
-library TlbImpLib
-{
-    importlib("stdole32.tlb") ;
-
-    typedef [uuid(F82895D2-1338-36A8-9A89-F9B0AFBE7801)]
-    enum {
-        NOTIF_TYPECONVERTED         = 0,
-        NOTIF_CONVERTWARNING        = 1,
-        ERROR_REFTOINVALIDTYPELIB   = 2
-    } ImporterEventKind;
-
-    [
-        odl,
-        uuid(F1C3BF76-C3E4-11D3-88E7-00902754C43A),
-        oleautomation
-    ]
-    interface ITypeLibImporterNotifySink : IUnknown {
-        HRESULT _stdcall ReportEvent(
-                        [in] ImporterEventKind EventKind, 
-                        [in] long EventCode, 
-                        [in] BSTR EventMsg);
-        HRESULT _stdcall ResolveRef(
-                        [in] IUnknown* Typelib, 
-                        [out, retval] IUnknown** pRetVal);
-    };
-
-    [
-        odl,
-        uuid(F1C3BF77-C3E4-11D3-88E7-00902754C43A),
-        oleautomation
-    ]
-    interface ITypeLibExporterNotifySink : IUnknown {
-        HRESULT _stdcall ReportEvent(
-                        [in] ImporterEventKind EventKind, 
-                        [in] long EventCode, 
-                        [in] BSTR EventMsg);
-        HRESULT _stdcall ResolveRef(
-                        [in] IUnknown* Asm, 
-                        [out, retval] IUnknown** pRetVal);
-    };
-
-    [
-        odl,
-        uuid(FA1F3615-ACB9-486d-9EAC-1BEF87E36B09),
-        oleautomation
-    ]
-    interface ITypeLibExporterNameProvider : IUnknown {
-        HRESULT _stdcall GetNames (
-                        [out, retval] SAFEARRAY(BSTR) *Names); 
-    };
-
-       
-
-};
-
-
-
diff --git a/src/md/compiler/mdvalidator.cpp b/src/md/compiler/mdvalidator.cpp
deleted file mode 100644 (file)
index ce6c14e..0000000
+++ /dev/null
@@ -1,7589 +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.
-//*****************************************************************************
-// MDValidator.cpp
-// 
-
-//
-// Implementation for the MetaData validator.
-// Only supported for full mscorwks version.
-//
-//*****************************************************************************
-#include "stdafx.h"
-
-#ifdef FEATURE_METADATA_VALIDATOR
-
-#include "regmeta.h"
-#include "importhelper.h"
-#include "pedecoder.h"
-#include "stgio.h"
-#include "corhost.h"
-#include "sstring.h"
-#include "nsutilpriv.h"
-#include "holder.h"
-#include "vererror.h"
-
-#include "mdsighelper.h"
-
-#ifdef DACCESS_COMPILE
-#error Dac should be using standalone version of metadata, not Wks version.
-#endif
-
-//-----------------------------------------------------------------------------
-// Application specific debug macro.
-#define IfBreakGo(EXPR) \
-do {if ((EXPR) != S_OK) IfFailGo(VLDTR_E_INTERRUPTED); } while (0)
-
-//-----------------------------------------------------------------------------
-
-//#define CACHE_IMPLMAP_VALIDATION_RESULT
-#ifdef CACHE_IMPLMAP_VALIDATION_RESULT
-// To avoid multiple validation of the same thing:
-struct ValidationResult
-{
-    mdToken     tok;
-    HRESULT     hr;
-};
-ValidationResult*               g_rValidated=NULL; // allocated in ValidateMetaData
-unsigned                        g_nValidated=0;
-#endif
-
-//-----------------------------------------------------------------------------
-
-#define BASE_OBJECT_CLASSNAME   "Object"
-#define BASE_NAMESPACE          "System"
-#define BASE_VTYPE_CLASSNAME    "ValueType"
-#define BASE_ENUM_CLASSNAME     "Enum"
-#define BASE_VALUE_FIELDNAME    "value__"
-#define BASE_CTOR_NAME          ".ctor"
-#define BASE_CCTOR_NAME         ".cctor"
-#define BASE_MCDELEGATE_CLASSNAME "MulticastDelegate"
-
-#define SYSTEM_OBJECT_TOSTRING_METHODNAME    "ToString"
-#define SYSTEM_OBJECT_GETHASHCODE_METHODNAME "GetHashCode"
-#define SYSTEM_OBJECT_EQUALS_METHODNAME      "Equals"
-
-// string ToString()
-static const BYTE g_sigSystemObject_ToString[] = 
-{ 
-    IMAGE_CEE_CS_CALLCONV_HASTHIS,  // 0x20
-    0,                              // 0x00 ... Param Count
-    ELEMENT_TYPE_STRING             // 0x0e ... Return Type - string
-};
-
-// int GetHashCode()
-static const BYTE g_sigSystemObject_GetHashCode[] = 
-{ 
-    IMAGE_CEE_CS_CALLCONV_HASTHIS,  // 0x20
-    0,                              // 0x00 ... Param Count
-    ELEMENT_TYPE_I4                 // 0x08 ... Return Type - I4
-};
-
-// bool Equals(object)
-static const BYTE g_sigSystemObject_Equals[] = 
-{ 
-    IMAGE_CEE_CS_CALLCONV_HASTHIS,  // 0x20
-    1,                              // 0x01 ... Param Count
-    ELEMENT_TYPE_BOOLEAN,           // 0x02 ... Return Type - bool
-    ELEMENT_TYPE_OBJECT             // 0x1c ... Param #1 - object
-};
-
-// as defined in src\vm\vars.hpp
-#define MAX_CLASSNAME_LENGTH 1024
-//-----------------------------------------------------------------------------
-// Class names used in long form signatures (namespace is always "System")
-unsigned g_NumSigLongForms = 19;
-static const LPCSTR g_SigLongFormName[] = {
-    "String",
-    "______", // "Object", <REVISIT_TODO>// uncomment when EE handles ELEMENT_TYPE_OBJECT</REVISIT_TODO>
-    "Boolean",
-    "Char",
-    "Byte",
-    "SByte",
-    "UInt16",
-    "Int16",
-    "UInt32",
-    "Int32",
-    "UInt64",
-    "Int64",
-    "Single",
-    "Double",
-    "SysInt",  // Review this.
-    "SysUInt", // Review this.
-    "SingleResult",
-    "Void",
-    "IntPtr"
-};
-
-// <REVISIT_TODO>: Why are these global variables?</REVISIT_TODO>
-mdToken g_tkEntryPoint;
-bool    g_fValidatingMscorlib;
-bool    g_fIsDLL;
-
-//-----------------------------------------------------------------------------
-
-static HRESULT _FindClassLayout(
-    CMiniMdRW   *pMiniMd,               // [IN] the minimd to lookup
-    mdTypeDef   tkParent,               // [IN] the parent that ClassLayout is associated with
-    RID         *clRid,                 // [OUT] rid for the ClassLayout.
-    RID         rid);                   // [IN] rid to be ignored.
-
-static HRESULT _FindFieldLayout(
-    CMiniMdRW   *pMiniMd,               // [IN] the minimd to lookup
-    mdFieldDef  tkParent,               // [IN] the parent that FieldLayout is associated with
-    RID         *flRid,                 // [OUT] rid for the FieldLayout record.
-    RID         rid);                   // [IN] rid to be ignored.
-
-static BOOL _IsValidLocale(LPCUTF8 szLocale,
-                           BOOL    fIsV2Assembly);
-
-
-#define REPORT_ERROR0(_VECode)                                  \
-    IfFailGo(_ValidateErrorHelper(_VECode, veCtxt))
-#define REPORT_ERROR1(_VECode, _Arg0)                           \
-    IfFailGo(_ValidateErrorHelper(_VECode, veCtxt, _Arg0))
-#define REPORT_ERROR2(_VECode, _Arg0, _Arg1)                    \
-    IfFailGo(_ValidateErrorHelper(_VECode, veCtxt, _Arg0, _Arg1))
-#define REPORT_ERROR3(_VECode, _Arg0, _Arg1, _Arg2)             \
-    IfFailGo(_ValidateErrorHelper(_VECode, veCtxt, _Arg0, _Arg1, _Arg2))
-
-//*****************************************************************************
-// Returns true if ixPtrTbl and ixParTbl are a valid parent-child combination
-// in the pointer table scheme.
-//*****************************************************************************
-static inline bool IsTblPtr(ULONG ixPtrTbl, ULONG ixParTbl)
-{
-    if ((ixPtrTbl == TBL_Field && ixParTbl == TBL_TypeDef) ||
-        (ixPtrTbl == TBL_Method && ixParTbl == TBL_TypeDef) ||
-        (ixPtrTbl == TBL_Param && ixParTbl == TBL_Method) ||
-        (ixPtrTbl == TBL_Property && ixParTbl == TBL_PropertyMap) ||
-        (ixPtrTbl == TBL_Event && ixParTbl == TBL_EventMap))
-    {
-        return true;
-    }
-        return false;
-}   // IsTblPtr()
-
-//*****************************************************************************
-// This inline function is used to set the return hr value for the Validate
-// functions to one of VLDTR_S_WRN, VLDTR_S_ERR or VLDTR_S_WRNERR based on
-// the current hr value and the new success code.
-// The general algorithm for error codes from the validation functions is:
-//      if (no warnings or errors found)
-//          return S_OK or S_FALSE
-//      else if (warnings found)
-//          return VLDTR_S_WRN
-//      else if (errors found)
-//          return VLDTR_S_ERR
-//      else if (warnings and errors found)
-//          return VLDTR_S_WRNERR
-//*****************************************************************************
-static inline void SetVldtrCode(HRESULT *phr, HRESULT successcode)
-{
-    _ASSERTE(successcode == S_OK || successcode == S_FALSE ||successcode == VLDTR_S_WRN ||
-             successcode == VLDTR_S_ERR || successcode == VLDTR_S_WRNERR);
-    _ASSERTE(*phr == S_OK || *phr == VLDTR_S_WRN || *phr == VLDTR_S_ERR ||
-             *phr == VLDTR_S_WRNERR);
-    if (successcode == S_OK || successcode == S_FALSE ||*phr == VLDTR_S_WRNERR)
-        return;
-    else if (*phr == S_OK || *phr == S_FALSE)
-        *phr = successcode;
-    else if (*phr != successcode)
-        *phr = VLDTR_S_WRNERR;
-}   // SetVldtrCode()
-
-//*****************************************************************************
-// Initialize the Validator related structures in RegMeta.
-//*****************************************************************************
-HRESULT RegMeta::ValidatorInit(         // S_OK or error.
-    DWORD       dwModuleType,           // [IN] Specifies whether the module is a PE file or an obj.
-    IUnknown    *pUnk)                  // [IN] Validation error handler.
-{
-    HRESULT     hr = S_OK;              // Return value.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    int         i = 0;                  // Index into the function pointer table.
-
-    // Initialize the array of function pointers to the validation function on
-    // each table.
-#undef MiniMdTable
-#define MiniMdTable(x) m_ValidateRecordFunctionTable[i++] = &RegMeta::Validate##x;
-    MiniMdTables()
-
-    // Verify that the ModuleType passed in is a valid one.
-    if (dwModuleType < ValidatorModuleTypeMin ||
-        dwModuleType > ValidatorModuleTypeMax)
-    {
-        IfFailGo(E_INVALIDARG);
-    }
-
-    // Verify that the interface passed in supports IID_IVEHandler.
-    IfFailGo(pUnk->QueryInterface(IID_IVEHandler, (void **)&m_pVEHandler));
-
-    // Set the ModuleType class member.  Do this last, this is used in
-    // ValidateMetaData to see if the validator is correctly initialized.
-    m_ModuleType = (CorValidatorModuleType)dwModuleType;
-ErrExit:
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // HRESULT RegMeta::ValidatorInit()
-
-
-//*****************************************************************************
-// Public implementation for code:IMetaDataValidate::ValidateMetaData
-// 
-// Validate the entire MetaData.  Here is the basic algorithm.
-//      for each table
-//          for each record
-//          {
-//              Do generic validation - validate that the offsets into the blob
-//              pool are good, validate that all the rids are within range,
-//              validate that token encodings are consistent.
-//          }
-//      if (problems found in generic validation)
-//          return;
-//      for each table
-//          for each record
-//              Do semantic validation.
-//******************************************************************************
-HRESULT RegMeta::ValidateMetaData()
-{
-    HRESULT hr = S_OK;
-    
-    BEGIN_ENTRYPOINT_NOTHROW;
-    
-    CMiniMdRW * pMiniMd = &(m_pStgdb->m_MiniMd);
-    HRESULT     hrSave = S_OK;      // Saved hr from generic validation.
-    ULONG       ulCount;            // Count of records in the current table.
-    ULONG       i;                  // Index to iterate over the tables.
-    ULONG       j;                  // Index to iterate over the records in a given table.
-    IHostTaskManager * pHostTaskManager = NULL;
-
-#ifdef CACHE_IMPLMAP_VALIDATION_RESULT
-    ULONG       rValidatedSize=0;   // Size of g_rValidated array
-#endif
-
-    // Verify that the validator is initialized correctly
-    if (m_ModuleType == ValidatorModuleTypeInvalid)
-    {
-        _ASSERTE(!"Validator not initialized, initialize with ValidatorInit().");
-        IfFailGo(VLDTR_E_NOTINIT);
-    }
-
-    // First do a validation pass to do some basic structural checks based on
-    // the Meta-Meta data.  This'll validate all the offsets into the pools,
-    // rid value and coded token ranges.
-    for (i = 0; i < pMiniMd->GetCountTables(); i++)
-    {
-        ulCount = pMiniMd->GetCountRecs(i);
-
-#ifdef CACHE_IMPLMAP_VALIDATION_RESULT
-        switch(i)
-        {
-            case TBL_ImplMap:
-                rValidatedSize += ulCount;
-            default:
-                ;
-        }
-#endif
-        for (j = 1; j <= ulCount; j++)
-        {
-            IfFailGo(ValidateRecord(i, j));
-            SetVldtrCode(&hrSave, hr);
-        }
-    }
-    // Validate that the size of the Ptr tables matches with the corresponding
-    // real tables.
-
-    // Do not do semantic validation if structural validation failed.
-    if (hrSave != S_OK)
-    {
-        hr = hrSave;
-        goto ErrExit;
-    }
-
-    // Verify the entry point (if any)
-    ::g_tkEntryPoint = 0;
-    ::g_fIsDLL = false;
-    if(m_pStgdb && m_pStgdb->m_pImage)
-    {
-        NewHolder<PEDecoder> pe;
-
-        EX_TRY
-        {
-            // We need to use different PEDecoder constructors based on the type of data we give it.
-            // We use the one with a 'bool' as the second argument when dealing with a mapped file,
-            // and we use the one that takes a COUNT_T as the second argument when dealing with a
-            // flat file.
-
-            if (m_pStgdb->m_pStgIO->GetMemoryMappedType() == MTYPE_IMAGE)
-                pe = new (nothrow) PEDecoder(m_pStgdb->m_pImage, false);
-            else
-                pe = new (nothrow) PEDecoder(m_pStgdb->m_pImage, (COUNT_T)(m_pStgdb->m_dwImageSize));
-
-            hr = S_OK;
-        }
-        EX_CATCH
-        {
-            hr = COR_E_BADIMAGEFORMAT;
-        }
-        EX_END_CATCH(SwallowAllExceptions)
-
-        if (SUCCEEDED(hr) && pe == NULL)
-            IfFailGo(E_OUTOFMEMORY);
-
-        if(FAILED(hr) || !pe->CheckFormat())
-        {
-            VEContext   veCtxt;             // Context structure.
-            
-            memset(&veCtxt, 0, sizeof(VEContext));
-            veCtxt.Token = 0;
-            veCtxt.uOffset = 0;
-            REPORT_ERROR0(COR_E_BADIMAGEFORMAT);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if(!pe->IsILOnly())
-        {
-            VEContext   veCtxt;             // Context structure.
-            memset(&veCtxt, 0, sizeof(VEContext));
-            veCtxt.Token = 0;
-            veCtxt.uOffset = 0;
-            REPORT_ERROR0(VER_E_BAD_PE);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        if((pe->GetCorHeader()->Flags & COMIMAGE_FLAGS_NATIVE_ENTRYPOINT) == 0)
-                g_tkEntryPoint = pe->GetEntryPointToken();
-        g_fIsDLL = pe->IsDll() ? true : false;
-
-        if(g_tkEntryPoint)
-        {
-            RID rid = RidFromToken(g_tkEntryPoint);
-            RID maxrid = 0;
-            switch(TypeFromToken(g_tkEntryPoint))
-            {
-                case mdtMethodDef:  maxrid = pMiniMd->getCountMethods(); break;
-                case mdtFile:       maxrid = pMiniMd->getCountFiles(); break;
-                default:            break;
-            }
-            if((rid == 0)||(rid > maxrid))
-            {
-                VEContext   veCtxt;             // Context structure.
-                memset(&veCtxt, 0, sizeof(VEContext));
-                veCtxt.Token = g_tkEntryPoint;
-                veCtxt.uOffset = 0;
-                REPORT_ERROR0(VLDTR_E_EP_BADTOKEN);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-        else if(!g_fIsDLL) // exe must have an entry point
-        {
-            VEContext   veCtxt;             // Context structure.
-            memset(&veCtxt, 0, sizeof(VEContext));
-            veCtxt.Token = g_tkEntryPoint;
-            veCtxt.uOffset = 0;
-            REPORT_ERROR0(VLDTR_E_EP_BADTOKEN);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    g_fValidatingMscorlib = false;
-    if(pMiniMd->GetCountRecs(TBL_Assembly))
-    {
-        AssemblyRec *pRecord;
-        IfFailGo(pMiniMd->GetAssemblyRecord(1, &pRecord));
-        LPCSTR szName;
-        IfFailGo(pMiniMd->getNameOfAssembly(pRecord, &szName));
-        g_fValidatingMscorlib = (0 == SString::_stricmp(szName,"mscorlib"));
-    }
-    // Verify there are no circular class hierarchies.
-
-    // Do per record semantic validation on the MetaData.  The function
-    // pointers to the per record validation are stored in the table by the
-    // ValidatorInit() function.
-
-#ifdef CACHE_IMPLMAP_VALIDATION_RESULT
-    g_rValidated = NULL;
-    ::g_nValidated = 0;
-    if (rValidatedSize)
-    {
-        g_rValidated = new(nothrow) ValidationResult[rValidatedSize];
-        IfNullGo(g_rValidated);
-    }
-#endif
-    pHostTaskManager = CorHost2::GetHostTaskManager();
-
-#ifdef Sleep
-#undef Sleep
-#endif
-    //DWORD cBegin=0,cEnd=0;
-    for (i = 0; i < pMiniMd->GetCountTables(); i++)
-    {
-        ulCount = pMiniMd->GetCountRecs(i);
-        //cBegin = GetTickCount();
-        for (j = 1; j <= ulCount; j++)
-        {
-            IfFailGo((this->*m_ValidateRecordFunctionTable[i])(j));
-            SetVldtrCode(&hrSave, hr);
-            if(pHostTaskManager)
-            {
-                // SwitchToTask forces the current thread to give up quantum, while a host can decide what
-                // to do with Sleep if the current thread has not run out of quantum yet.
-                ClrSleepEx(0, FALSE);
-            }
-        }
-        //cEnd = GetTickCount();
-        //printf("Table %d, recs: %d, time: %d\n",i,ulCount,(cEnd-cBegin));
-    }
-    hr = hrSave;
-ErrExit:
-
-#ifdef CACHE_IMPLMAP_VALIDATION_RESULT
-    if(g_rValidated) delete [] g_rValidated;
-#endif
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateMetaData()
-
-//*****************************************************************************
-// Validate the Module record.
-//*****************************************************************************
-HRESULT RegMeta::ValidateModule(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    ModuleRec   *pRecord;           // Module record.
-    VEContext   veCtxt;             // Context structure.
-    HRESULT     hr = S_OK;          // Value returned.
-    HRESULT     hrSave = S_OK;      // Save state.
-    LPCSTR      szName;
-    GUID GuidOfModule;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    // Get the Module record.
-    veCtxt.Token = TokenFromRid(rid, mdtModule);
-    veCtxt.uOffset = 0;
-    IfFailGo(pMiniMd->GetModuleRecord(rid, &pRecord));
-
-    // There can only be one Module record.
-    if (rid > 1)
-    {
-        REPORT_ERROR0(VLDTR_E_MOD_MULTI);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Verify the name
-    IfFailGo(pMiniMd->getNameOfModule(pRecord, &szName));
-    if(szName && *szName)
-    {
-        ULONG L = (ULONG)strlen(szName);
-        if(L >= MAX_CLASSNAME_LENGTH)
-        {
-            // Name too long
-            REPORT_ERROR2(VLDTR_E_TD_NAMETOOLONG, L, (ULONG)(MAX_CLASSNAME_LENGTH-1));
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        if(strchr(szName,':') || strchr(szName,'\\'))
-        {
-            REPORT_ERROR0(VLDTR_E_MOD_NAMEFULLQLFD);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    else
-    {
-        REPORT_ERROR0(VLDTR_E_MOD_NONAME);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Verify that the MVID is valid.
-    IfFailGo(pMiniMd->getMvidOfModule(pRecord, &GuidOfModule));
-    if (GuidOfModule == GUID_NULL)
-    {
-        REPORT_ERROR0(VLDTR_E_MOD_NULLMVID);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateModule()
-
-//*****************************************************************************
-// Validate the given TypeRef.
-//*****************************************************************************
-HRESULT RegMeta::ValidateTypeRef(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    TypeRefRec  *pRecord;               // TypeRef record.
-    mdToken     tkRes;                  // Resolution scope.
-    LPCSTR      szNamespace;            // TypeRef Namespace.
-    LPCSTR      szName;                 // TypeRef Name.
-    mdTypeRef   tkTypeRef;              // Duplicate TypeRef.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    // Get the TypeRef record.
-    veCtxt.Token = TokenFromRid(rid, mdtTypeRef);
-    veCtxt.uOffset = 0;
-
-    IfFailGo(pMiniMd->GetTypeRefRecord(rid, &pRecord));
-
-    // Check name is not NULL.
-    IfFailGo(pMiniMd->getNamespaceOfTypeRef(pRecord, &szNamespace));
-    IfFailGo(pMiniMd->getNameOfTypeRef(pRecord, &szName));
-    if (!*szName)
-    {
-        REPORT_ERROR0(VLDTR_E_TR_NAMENULL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else
-    {
-        RID ridScope;
-        // Look for a Duplicate, this function reports only one duplicate.
-        tkRes = pMiniMd->getResolutionScopeOfTypeRef(pRecord);
-        hr = ImportHelper::FindTypeRefByName(pMiniMd, tkRes, szNamespace, szName, &tkTypeRef, rid);
-        if (hr == S_OK)
-        {
-            REPORT_ERROR1(VLDTR_E_TR_DUP, tkTypeRef);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-            hr = S_OK;
-        else
-            IfFailGo(hr);
-        ULONG L = (ULONG)(strlen(szName)+strlen(szNamespace));
-        if(L >= MAX_CLASSNAME_LENGTH)
-        {
-            REPORT_ERROR2(VLDTR_E_TD_NAMETOOLONG, L, (ULONG)(MAX_CLASSNAME_LENGTH-1));
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        ridScope = RidFromToken(tkRes);
-        if(ridScope)
-        {
-            bool badscope = true;
-            //check if valid scope
-            switch(TypeFromToken(tkRes))
-            {
-                case mdtAssemblyRef:
-                case mdtModuleRef:
-                case mdtModule:
-                case mdtTypeRef:
-                    badscope = !IsValidToken(tkRes);
-                    break;
-                default:
-                    break;
-            }
-            if(badscope)
-            {
-                REPORT_ERROR1(VLDTR_E_TR_BADSCOPE, tkTypeRef);
-                SetVldtrCode(&hrSave, VLDTR_S_WRN);
-            }
-        }
-        else
-        {
-            // check if there is a ExportedType
-            //hr = ImportHelper::FindExportedType(pMiniMd, szNamespace, szName, tkImpl, &tkExportedType, rid);
-        }
-        // Check if there is TypeDef with the same name
-        if(!ridScope)
-        {
-            if((TypeFromToken(tkRes) != mdtTypeRef) &&
-                (S_OK == ImportHelper::FindTypeDefByName(pMiniMd, szNamespace, szName, mdTokenNil,&tkTypeRef, 0)))
-            {
-                REPORT_ERROR1(VLDTR_E_TR_HASTYPEDEF, tkTypeRef);
-                SetVldtrCode(&hrSave, VLDTR_S_WRN);
-            }
-        }
-    }
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateTypeRef()
-
-//*****************************************************************************
-// Validate the given TypeDef.
-//*****************************************************************************
-#ifdef _PREFAST_
-#pragma warning(push)
-#pragma warning(disable:21000) // Suppress PREFast warning about overly large function
-#endif
-HRESULT RegMeta::ValidateTypeDef(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    TypeDefRec  *pRecord;               // TypeDef record.
-    TypeDefRec  *pExtendsRec = 0;       // TypeDef record for the parent class.
-    mdTypeDef   tkTypeDef;              // Duplicate TypeDef token.
-    DWORD       dwFlags;                // TypeDef flags.
-    DWORD       dwExtendsFlags;         // TypeDef flags of the parent class.
-    LPCSTR      szName;                 // TypeDef Name.
-    LPCSTR      szNameSpace;            // TypeDef NameSpace.
-    LPCSTR      szExtName = NULL;       // Parent Name.
-    LPCSTR      szExtNameSpace = NULL;  // Parent NameSpace.
-    CQuickBytes qb;                     // QuickBytes for flexible allocation.
-    mdToken     tkExtends;              // TypeDef of the parent class.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    mdToken     tkEncloser=mdTokenNil;  // Encloser, if any
-    BOOL        bIsEnum,bExtendsEnum,bExtendsVType,bIsVType,bExtendsObject,bIsObject,bExtendsMCDelegate;
-    BOOL        bHasMethods=FALSE, bHasFields=FALSE;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    // Skip validating m_tdModule class.
-    if (rid == RidFromToken(m_tdModule))
-        goto ErrExit;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    // Get the TypeDef record.
-    veCtxt.Token = TokenFromRid(rid, mdtTypeDef);
-    veCtxt.uOffset = 0;
-
-    IfFailGo(pMiniMd->GetTypeDefRecord(rid, &pRecord));
-
-    // Do checks for name validity..
-    IfFailGo(pMiniMd->getNameOfTypeDef(pRecord, &szName));
-    IfFailGo(pMiniMd->getNamespaceOfTypeDef(pRecord, &szNameSpace));
-    if (!*szName)
-    {
-        // TypeDef Name is null.
-        REPORT_ERROR0(VLDTR_E_TD_NAMENULL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else if (!IsDeletedName(szName))
-    {
-        RID iRecord;
-        IfFailGo(pMiniMd->FindNestedClassHelper(TokenFromRid(rid, mdtTypeDef), &iRecord));
-        
-        if (InvalidRid(iRecord))
-        {
-            tkEncloser = mdTokenNil;
-        }
-        else
-        {
-            NestedClassRec *pNestedClassRec;
-            IfFailGo(pMiniMd->GetNestedClassRecord(iRecord, &pNestedClassRec));
-            tkEncloser = pMiniMd->getEnclosingClassOfNestedClass(pNestedClassRec);
-        }
-        
-        // Check for duplicates based on Name/NameSpace.  Do not do Dup checks
-        // on deleted records.
-        hr = ImportHelper::FindTypeDefByName(pMiniMd, szNameSpace, szName, tkEncloser,
-                                             &tkTypeDef, rid);
-        if (hr == S_OK)
-        {
-            REPORT_ERROR1(VLDTR_E_TD_DUPNAME, tkTypeDef);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-            hr = S_OK;
-        else
-            IfFailGo(hr);
-        ULONG L = (ULONG)(strlen(szName)+strlen(szNameSpace));
-        if(L >= MAX_CLASSNAME_LENGTH)
-        {
-            REPORT_ERROR2(VLDTR_E_TD_NAMETOOLONG, L, (ULONG)(MAX_CLASSNAME_LENGTH-1));
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    // Get the flag value for the TypeDef.
-    dwFlags = pMiniMd->getFlagsOfTypeDef(pRecord);
-    // Do semantic checks on the flags.
-    // RTSpecialName bit must be set on Deleted records.
-    if (IsDeletedName(szName))
-    {
-        if(!IsTdRTSpecialName(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_TD_DLTNORTSPCL);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        hr = hrSave;
-        goto ErrExit;
-    }
-
-    // If RTSpecialName bit is set, the record must be a Deleted record.
-    if (IsTdRTSpecialName(dwFlags))
-    {
-        REPORT_ERROR0(VLDTR_E_TD_RTSPCLNOTDLT);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        if(!IsTdSpecialName(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_TD_RTSPCLNOTSPCL);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    // Check if flag value is valid
-    {
-        DWORD dwInvalidMask, dwExtraBits;
-        dwInvalidMask = (DWORD)~(tdVisibilityMask | tdLayoutMask | tdClassSemanticsMask | 
-                tdAbstract | tdSealed | tdSpecialName | tdImport | tdSerializable | tdWindowsRuntime | 
-                tdStringFormatMask | tdBeforeFieldInit | tdReservedMask);
-        // check for extra bits
-        dwExtraBits = dwFlags & dwInvalidMask;
-        if (dwExtraBits == 0)
-        {
-            // if no extra bits, check layout
-            dwExtraBits = dwFlags & tdLayoutMask;
-            if (dwExtraBits != tdLayoutMask)
-            {
-                // layout OK, check string format
-                dwExtraBits = dwFlags & tdStringFormatMask;
-                if (dwExtraBits != tdStringFormatMask)
-                    dwExtraBits = 0;
-            }
-        }
-        if (dwExtraBits != 0)
-        {
-            REPORT_ERROR1(VLDTR_E_TD_EXTRAFLAGS, dwExtraBits);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-
-
-        // Generic types may be specified to have only AutoLayout or SequentialLayout (never ExplicitLayout).
-        if (IsTdExplicitLayout(dwFlags))
-        {
-            HENUMInternal hEnumTyPars;
-            ULONG ulTypeDefArity;
-            hr = pMiniMd->FindGenericParamHelper(TokenFromRid(rid, mdtTypeDef), &hEnumTyPars);
-            if (SUCCEEDED(hr))
-            {
-                IfFailGo(HENUMInternal::GetCount(&hEnumTyPars,&ulTypeDefArity));
-                HENUMInternal::ClearEnum(&hEnumTyPars);
-                if (ulTypeDefArity != 0)
-                {
-                    REPORT_ERROR0(VLDTR_E_TD_GENERICHASEXPLAYOUT);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-        }
-        
-    }
-
-    // Get the parent of the TypeDef.
-    tkExtends = pMiniMd->getExtendsOfTypeDef(pRecord);
-
-    // Check if TypeDef extends itself
-    if (tkExtends == veCtxt.Token)
-    {
-        REPORT_ERROR0(VLDTR_E_TD_EXTENDSITSELF);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Check if TypeDef extends one of its children
-    if (RidFromToken(tkExtends)&&(TypeFromToken(tkExtends)==mdtTypeDef))
-    {
-        TypeDefRec *pRec;
-        IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkExtends), &pRec));
-        mdToken tkExtends2 = pMiniMd->getExtendsOfTypeDef(pRec);
-        if( tkExtends2 == veCtxt.Token)
-        {
-            REPORT_ERROR0(VLDTR_E_TD_EXTENDSCHILD);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    
-    
-    
-    if (IsNilToken(tkEncloser) == IsTdNested(dwFlags))
-    {
-        REPORT_ERROR0(IsNilToken(tkEncloser) ? VLDTR_E_TD_NESTEDNOENCL : VLDTR_E_TD_ENCLNOTNESTED);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    
-    bIsObject = bIsEnum = bIsVType = FALSE;
-    if(0 == strcmp(szNameSpace,BASE_NAMESPACE))
-    {
-        bIsObject = (0 == strcmp(szName,BASE_OBJECT_CLASSNAME));
-        if(!bIsObject)
-        {
-            bIsEnum   = (0 == strcmp(szName,BASE_ENUM_CLASSNAME));
-            if(!bIsEnum)
-            {
-                bIsVType  = (0 == strcmp(szName,BASE_VTYPE_CLASSNAME));
-            }
-        }
-    }
-
-    if (IsNilToken(tkExtends))
-    {
-        // If the parent token is nil, the class must be marked Interface,
-        // unless it's the System.Object class.
-        if ( !(bIsObject || IsTdInterface(dwFlags)))
-        {
-            REPORT_ERROR0(VLDTR_E_TD_NOTIFACEOBJEXTNULL);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        szExtName = "";
-        szExtNameSpace = "";
-    }
-    else
-    {
-
-        // If tkExtends is a TypeSpec, extract the generic type and continue
-        if (TypeFromToken(tkExtends) == mdtTypeSpec)
-        {
-            //@GENERICSVER: TODO first validate the spec
-
-            TypeSpecRec *pRec;
-            IfFailGo(pMiniMd->GetTypeSpecRecord(RidFromToken(tkExtends), &pRec));
-            PCCOR_SIGNATURE pSig;
-            ULONG       cSig;
-
-            IfFailGo(pMiniMd->getSignatureOfTypeSpec(pRec, &pSig, &cSig));
-           
-            switch(CorSigUncompressElementType(pSig))
-            { 
-                default: 
-                {
-                    REPORT_ERROR1(VLDTR_E_TD_EXTBADTYPESPEC, tkExtends);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    szExtName = "";
-                    szExtNameSpace = "";
-                    break;
-                }
-                case ELEMENT_TYPE_GENERICINST:
-                { 
-                    switch(CorSigUncompressElementType(pSig)) 
-                    { 
-                        default:
-                        {
-                            REPORT_ERROR1(VLDTR_E_TD_EXTBADTYPESPEC, tkExtends);
-                            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                            szExtName = "";
-                            szExtNameSpace = "";
-                            break;
-                        }
-                        case ELEMENT_TYPE_VALUETYPE:
-                        case ELEMENT_TYPE_CLASS: 
-                        { 
-                            tkExtends = CorSigUncompressToken(pSig);
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-
-        // If tkExtends is a TypeRef try to resolve it to a corresponding
-        // TypeDef.  If it resolves successfully, issue a warning.  It means
-        // that the Ref to Def optimization didn't happen successfully.
-        if (TypeFromToken(tkExtends) == mdtTypeRef)
-        {
-            TypeRefRec *pTypeRefRec;
-            IfFailGo(pMiniMd->GetTypeRefRecord(RidFromToken(tkExtends), &pTypeRefRec));
-
-            IfFailGo(pMiniMd->getNameOfTypeRef(pTypeRefRec, &szExtName));
-            IfFailGo(pMiniMd->getNamespaceOfTypeRef(pTypeRefRec, &szExtNameSpace));
-
-            BOOL fLookForDef = TRUE;
-            mdToken tkResScope = pMiniMd->getResolutionScopeOfTypeRef(pTypeRefRec);
-            if (TypeFromToken(tkResScope) == mdtAssemblyRef)
-            {   // We will look for the TypeDef of the same name, only if the AssemblyRef has the same name as AssemblyDef
-                fLookForDef = FALSE;
-                RID ridResScope = RidFromToken(tkResScope);
-                if ((ridResScope > 0) && (ridResScope <= pMiniMd->GetCountRecs(TBL_AssemblyRef)))
-                {
-                    if (pMiniMd->GetCountRecs(TBL_Assembly) > 0)
-                    {
-                        AssemblyRefRec * pAsmRefRec;
-                        IfFailGo(pMiniMd->GetAssemblyRefRecord(ridResScope, &pAsmRefRec));
-                        AssemblyRec *pAsmRec;
-                        IfFailGo(pMiniMd->GetAssemblyRecord(1, &pAsmRec));
-                        if ((pAsmRec != NULL) && (pAsmRefRec != NULL))
-                        {
-                            LPCUTF8 szAsmName;
-                            IfFailGo(pMiniMd->getNameOfAssembly(pAsmRec, &szAsmName));
-                            LPCUTF8 szAsmRefName;
-                            IfFailGo(pMiniMd->getNameOfAssemblyRef(pAsmRefRec, &szAsmRefName));
-                            if ((szAsmName != NULL) && (szAsmRefName != NULL))
-                                fLookForDef = (strcmp(szAsmName,szAsmRefName) == 0);
-                        }
-                    }
-                }
-            }
-            
-            if (fLookForDef)
-            {
-                mdTypeDef tkResTd;
-    
-                if (ImportHelper::FindTypeDefByName(pMiniMd,
-                        szExtNameSpace, 
-                        szExtName, 
-                        tkResScope, 
-                        &tkResTd) == S_OK)
-                {
-                    // Ref to Def optimization is not expected to happen for Obj files.
-                    /*
-                    if (m_ModuleType != ValidatorModuleTypeObj)
-                    {
-                        REPORT_ERROR2(VLDTR_E_TD_EXTTRRES, tkExtends, tkResTd);
-                        SetVldtrCode(&hrSave, VLDTR_S_WRN);
-                    }
-                    */
-    
-                    // Set tkExtends to the new TypeDef, so we can continue
-                    // with the validation.
-                    tkExtends = tkResTd;
-                }
-            }
-        }
-
-        // Continue validation, even for the case where TypeRef got resolved
-        // to a corresponding TypeDef in the same Module.
-        if (TypeFromToken(tkExtends) == mdtTypeDef)
-        {
-            // Extends must not be sealed.
-            IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkExtends), &pExtendsRec));
-            dwExtendsFlags = pMiniMd->getFlagsOfTypeDef(pExtendsRec);
-            IfFailGo(pMiniMd->getNameOfTypeDef(pExtendsRec, &szExtName));
-            IfFailGo(pMiniMd->getNamespaceOfTypeDef(pExtendsRec, &szExtNameSpace));
-            if (IsTdSealed(dwExtendsFlags))
-            {
-                REPORT_ERROR1(VLDTR_E_TD_EXTENDSSEALED, tkExtends);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            if (IsTdInterface(dwExtendsFlags))
-            {
-                REPORT_ERROR1(VLDTR_E_TD_EXTENDSIFACE, tkExtends);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-        else if(TypeFromToken(tkExtends) == mdtTypeSpec)
-        {
-            //If we got here, the instantiated generic type is itself a type spec, which is illegal
-            REPORT_ERROR1(VLDTR_E_TD_EXTBADTYPESPEC, tkExtends);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            szExtName = "";
-            szExtNameSpace = "";
-
-        }
-        // If the parent token is non-null, the class must not be System.Object.
-        if (bIsObject)
-        {
-            REPORT_ERROR1(VLDTR_E_TD_OBJEXTENDSNONNULL, tkExtends);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    bExtendsObject = bExtendsEnum = bExtendsVType = bExtendsMCDelegate = FALSE;
-    if(0 == strcmp(szExtNameSpace,BASE_NAMESPACE))
-    {
-        bExtendsObject = (0 == strcmp(szExtName,BASE_OBJECT_CLASSNAME));
-        if(!bExtendsObject)
-        {
-            bExtendsEnum   = (0 == strcmp(szExtName,BASE_ENUM_CLASSNAME));
-            if(!bExtendsEnum)
-            {
-                bExtendsVType  = (0 == strcmp(szExtName,BASE_VTYPE_CLASSNAME));
-                if(!bExtendsVType)
-                {
-                    bExtendsMCDelegate  = (0 == strcmp(szExtName,BASE_MCDELEGATE_CLASSNAME));
-                }
-            }
-        }
-    }
-
-    // System.ValueType must extend System.Object
-    if(bIsVType && !bExtendsObject)
-    {
-        REPORT_ERROR0(VLDTR_E_TD_SYSVTNOTEXTOBJ);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Validate rules for interface.  Some of the VOS rules are verified as
-    // part of the validation for the corresponding Methods, fields etc.
-    if (IsTdInterface(dwFlags))
-    {
-        // Interface type must be marked abstract.
-        if (!IsTdAbstract(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_TD_IFACENOTABS);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-
-        // Interface must not be sealed
-        if(IsTdSealed(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_TD_IFACESEALED);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-
-        // Interface must have parent Nil token.
-        if (!IsNilToken(tkExtends))
-        {
-            REPORT_ERROR1(VLDTR_E_TD_IFACEPARNOTNIL, tkExtends);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-
-        //Interface must have only static fields -- checked in ValidateField
-        //Interface must have only public fields -- checked in ValidateField
-        //Interface must have only abstract or static methods -- checked in ValidateMethod
-        //Interface must have only public methods -- checked in ValidateMethod
-
-        // Interface must have GUID
-        /*
-        if (*pGuid == GUID_NULL)
-        {
-            REPORT_ERROR0(VLDTR_E_TD_IFACEGUIDNULL);
-            SetVldtrCode(&hrSave, VLDTR_S_WRN);
-        }
-        */
-    }
-
-
-    // Class must have valid method and field lists
-    {
-        ULONG           ridStart,ridEnd;
-        ridStart = pMiniMd->getMethodListOfTypeDef(pRecord);
-        ridEnd  = pMiniMd->getCountMethods() + 1;
-        if(ridStart > ridEnd)
-        {
-            REPORT_ERROR0(VLDTR_E_TD_BADMETHODLST);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else 
-        {
-            IfFailGo(pMiniMd->getEndMethodListOfTypeDef(rid, &ridEnd));
-            bHasMethods = (ridStart && (ridStart < ridEnd));
-        }
-
-        ridStart = pMiniMd->getFieldListOfTypeDef(pRecord);
-        ridEnd  = pMiniMd->getCountFields() + 1;
-        if(ridStart > ridEnd)
-        {
-            REPORT_ERROR0(VLDTR_E_TD_BADFIELDLST);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else 
-        {
-            IfFailGo(pMiniMd->getEndFieldListOfTypeDef(rid, &ridEnd));
-            bHasFields = (ridStart && (ridStart < ridEnd));
-        }
-    }
-
-    // Validate rules for System.Enum
-    if(bIsEnum)
-    {
-        if(!IsTdClass(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_TD_SYSENUMNOTCLASS);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        if(!bExtendsVType)
-        {
-            REPORT_ERROR0(VLDTR_E_TD_SYSENUMNOTEXTVTYPE);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    else
-    {
-        if(bExtendsVType || bExtendsEnum)
-        {
-            // ValueTypes and Enums must be sealed
-            if(!IsTdSealed(dwFlags))
-            {
-                REPORT_ERROR0(VLDTR_E_TD_VTNOTSEAL);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            // Value class must have fields or size
-            if(!bHasFields)
-            {
-                ULONG ulClassSize = 0;
-                ClassLayoutRec  *pRec;
-                RID ridClassLayout;
-                IfFailGo(pMiniMd->FindClassLayoutHelper(TokenFromRid(rid, mdtTypeDef), &ridClassLayout));
-
-                if (!InvalidRid(ridClassLayout))
-                {
-                    IfFailGo(pMiniMd->GetClassLayoutRecord(RidFromToken(ridClassLayout), &pRec));
-                    ulClassSize = pMiniMd->getClassSizeOfClassLayout(pRec);
-                }
-                if(ulClassSize == 0)
-                {
-                    REPORT_ERROR0(VLDTR_E_TD_VTNOSIZE);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-        }
-        else if(bExtendsMCDelegate)
-        {
-            // Delegates must be sealed
-            if(!IsTdSealed(dwFlags))
-            {
-                REPORT_ERROR0(VLDTR_E_TD_VTNOTSEAL);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-    }
-
-    // Enum-related checks
-    if (bExtendsEnum)
-    {
-        {
-            PCCOR_SIGNATURE pValueSig = NULL;
-            ULONG           cbValueSig = 0;
-            mdFieldDef      tkValueField=0, tkField, tkValue__Field = 0;
-            ULONG           ridStart,ridEnd,index;
-            FieldRec        *pFieldRecord;               // Field record.
-            DWORD           dwRecordFlags, dwTally, dwValueFlags, dwValue__Flags = 0;
-            RID             ridField,ridValue=0,ridValue__ = 0;
-
-            ridStart = pMiniMd->getFieldListOfTypeDef(pRecord);
-            IfFailGo(pMiniMd->getEndFieldListOfTypeDef(rid, &ridEnd));
-            // check the instance (value__) field(s)
-            dwTally = 0;
-            for (index = ridStart; index < ridEnd; index++ )
-            {
-                IfFailGo(pMiniMd->GetFieldRid(index, &ridField));
-                IfFailGo(pMiniMd->GetFieldRecord(ridField, &pFieldRecord));
-                dwRecordFlags = pFieldRecord->GetFlags();
-                if(!IsFdStatic(dwRecordFlags))
-                {
-                    dwTally++;
-                    if(ridValue == 0)
-                    {
-                        ridValue = ridField;
-                        tkValueField = TokenFromRid(ridField, mdtFieldDef);
-                        IfFailGo(pMiniMd->getSignatureOfField(pFieldRecord, &pValueSig, &cbValueSig));
-                        dwValueFlags = dwRecordFlags;
-                    }
-                }
-                LPCSTR szFieldName;
-                IfFailGo(pMiniMd->getNameOfField(pFieldRecord, &szFieldName));
-                if(!strcmp(szFieldName, BASE_VALUE_FIELDNAME))
-                {
-                    ridValue__ = ridField;
-                    dwValue__Flags = dwRecordFlags;
-                    tkValue__Field = TokenFromRid(ridField, mdtFieldDef);
-                }
-            }
-            // Enum must have one (and only one) inst.field
-            if(dwTally == 0)
-            {
-                REPORT_ERROR0(VLDTR_E_TD_ENUMNOINSTFLD);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            else if(dwTally > 1)
-            {
-                REPORT_ERROR0(VLDTR_E_TD_ENUMMULINSTFLD);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            
-            // inst.field name must be "value__" (CLS)
-            if(ridValue__ == 0)
-            {
-                REPORT_ERROR0(VLDTR_E_TD_ENUMNOVALUE);
-                SetVldtrCode(&hrSave, VLDTR_S_WRN);
-            }
-            else
-            {
-                // if "value__" field is present ...
-                // ... it must be 1st instance field
-                if(ridValue__ != ridValue)
-                {
-                    REPORT_ERROR1(VLDTR_E_TD_ENUMVALNOT1ST, tkValue__Field);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                // ... it must not be static
-                if(IsFdStatic(dwValue__Flags))
-                {
-                    REPORT_ERROR1(VLDTR_E_TD_ENUMVALSTATIC, tkValue__Field);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                // ... it must be fdRTSpecialName
-                if(!IsFdRTSpecialName(dwValue__Flags))
-                {
-                    REPORT_ERROR1(VLDTR_E_TD_ENUMVALNOTSN, tkValueField);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                // ... its type must be integral
-                if(cbValueSig && pValueSig)
-                {
-                    //ULONG ulCurByte = CorSigUncompressedDataSize(pValueSig);
-                    //CorSigUncompressData(pValueSig);
-                    //ULONG ulElemSize,ulElementType;
-                    //ulCurByte += (ulElemSize = CorSigUncompressedDataSize(pValueSig));
-                    //ulElementType = CorSigUncompressData(pValueSig);
-                    //switch (ulElementType)
-                    BYTE* pB = (BYTE*)pValueSig;
-                    pB++; // skip the calling convention
-                    while((*pB == ELEMENT_TYPE_CMOD_OPT)||
-                          (*pB == ELEMENT_TYPE_CMOD_REQD))
-                    {
-                        mdToken tok;
-                        pB++; // move from E_T_... to compressed token
-                        pB += CorSigUncompressToken((PCOR_SIGNATURE)pB,&tok);
-                    }
-                    switch(*pB)
-                    {
-                        case ELEMENT_TYPE_BOOLEAN:
-                        case ELEMENT_TYPE_CHAR:
-                        case ELEMENT_TYPE_I1:
-                        case ELEMENT_TYPE_U1:
-                        case ELEMENT_TYPE_I2:
-                        case ELEMENT_TYPE_U2:
-                        case ELEMENT_TYPE_I4:
-                        case ELEMENT_TYPE_U4:
-                        case ELEMENT_TYPE_I8:
-                        case ELEMENT_TYPE_U8:
-                        case ELEMENT_TYPE_U:
-                        case ELEMENT_TYPE_I:
-                        case ELEMENT_TYPE_R4:
-                        case ELEMENT_TYPE_R8:
-                            break;
-                        default:
-                            REPORT_ERROR1(VLDTR_E_TD_ENUMFLDBADTYPE, tkValue__Field);
-                            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-                }
-            }
-            // check all the fields
-            dwTally = 0;
-            for (index = ridStart; index < ridEnd; index++ )
-            {
-                IfFailGo(pMiniMd->GetFieldRid(index, &ridField));
-                if(ridField == ridValue) continue; 
-                IfFailGo(pMiniMd->GetFieldRecord(ridField, &pFieldRecord));
-                LPCSTR szFieldName;
-                IfFailGo(pMiniMd->getNameOfField(pFieldRecord, &szFieldName));
-                if(IsFdRTSpecialName(pFieldRecord->GetFlags()) 
-                    && IsDeletedName(szFieldName)) continue;
-                dwTally++;
-                tkField = TokenFromRid(ridField, mdtFieldDef);
-                if(!IsFdStatic(pFieldRecord->GetFlags()))
-                {
-                    REPORT_ERROR1(VLDTR_E_TD_ENUMFLDNOTST, tkField);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                if(!IsFdLiteral(pFieldRecord->GetFlags()))
-                {
-                    REPORT_ERROR1(VLDTR_E_TD_ENUMFLDNOTLIT, tkField);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                /*
-                IfFailGo(pMiniMd->getSignatureOfField(pFieldRecord, &pvSigTmp, &cbSig));
-                if(!(pvSigTmp && (cbSig==cbValueSig) &&(memcmp(pvSigTmp,pValueSig,cbSig)==0)))
-                {
-                    REPORT_ERROR1(VLDTR_E_TD_ENUMFLDSIGMISMATCH, tkField);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                */
-            }
-            if(dwTally == 0)
-            {
-                REPORT_ERROR0(VLDTR_E_TD_ENUMNOLITFLDS);
-                SetVldtrCode(&hrSave, VLDTR_S_WRN);
-            }
-        }
-        // Enum must have no methods
-        if (bHasMethods)
-        {
-            REPORT_ERROR0(VLDTR_E_TD_ENUMHASMETHODS);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // Enum must implement no interfaces
-        {
-            ULONG ridStart = 1;
-            ULONG ridEnd = pMiniMd->getCountInterfaceImpls() + 1;
-            ULONG index;
-            for (index = ridStart; index < ridEnd; index ++ )
-            {
-                InterfaceImplRec *pInterfaceImplRecord;
-                IfFailGo(pMiniMd->GetInterfaceImplRecord(index, &pInterfaceImplRecord));
-                if (veCtxt.Token == pMiniMd->getClassOfInterfaceImpl(pInterfaceImplRecord))
-                {
-                    REPORT_ERROR0(VLDTR_E_TD_ENUMIMPLIFACE);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    break;
-                }
-            }
-        }
-        // Enum must have no properties
-        {
-            ULONG ridStart = 1;
-            ULONG ridEnd = pMiniMd->getCountPropertys() + 1;
-            ULONG index;
-            mdToken tkClass;
-            for (index = ridStart; index < ridEnd; index ++ )
-            {
-                IfFailGo(pMiniMd->FindParentOfPropertyHelper(index | mdtProperty, &tkClass));
-                if (veCtxt.Token == tkClass)
-                {
-                    REPORT_ERROR0(VLDTR_E_TD_ENUMHASPROP);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    break;
-                }
-            }
-        }
-        // Enum must have no events
-        {
-            ULONG ridStart = 1;
-            ULONG ridEnd = pMiniMd->getCountEvents() + 1;
-            ULONG index;
-            mdToken tkClass;
-            for (index = ridStart; index < ridEnd; index ++ )
-            {
-                IfFailGo(pMiniMd->FindParentOfEventHelper(index | mdtEvent, &tkClass));
-                if (veCtxt.Token == tkClass)
-                {
-                    REPORT_ERROR0(VLDTR_E_TD_ENUMHASEVENT);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    break;
-                }
-            }
-        }
-    } // end if(bExtendsEnum)
-    // Class having security must be marked tdHasSecurity and vice versa
-    {
-        ULONG ridStart = 1;
-        ULONG ridEnd = pMiniMd->getCountDeclSecuritys() + 1;
-        ULONG index;
-        BOOL  bHasSecurity = FALSE;
-        for (index = ridStart; index < ridEnd; index ++ )
-        {
-            DeclSecurityRec *pDeclSecurityRecord;
-            IfFailGo(pMiniMd->GetDeclSecurityRecord(index, &pDeclSecurityRecord));
-            if (veCtxt.Token == pMiniMd->getParentOfDeclSecurity(pDeclSecurityRecord))
-            {
-                bHasSecurity = TRUE;
-                break;
-            }
-        }
-        if (!bHasSecurity) // No records, check for CA "SuppressUnmanagedCodeSecurityAttribute"
-        {
-            bHasSecurity = (S_OK == ImportHelper::GetCustomAttributeByName(pMiniMd, veCtxt.Token, 
-                "System.Security.SuppressUnmanagedCodeSecurityAttribute", NULL, NULL));
-        }
-        if(bHasSecurity != (IsTdHasSecurity(pRecord->GetFlags())!=0))
-        {
-            REPORT_ERROR0(bHasSecurity ? VLDTR_E_TD_SECURNOTMARKED : VLDTR_E_TD_MARKEDNOSECUR);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateTypeDef()
-#ifdef _PREFAST_
-#pragma warning(pop)
-#endif
-
-//*****************************************************************************
-// Validate the given FieldPtr.
-//*****************************************************************************
-HRESULT RegMeta::ValidateFieldPtr(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateFieldPtr()
-
-
-//*****************************************************************************
-// Validate the given Field.
-//*****************************************************************************
-HRESULT RegMeta::ValidateField(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    FieldRec    *pRecord;               // Field record.
-    mdTypeDef   tkTypeDef;              // Parent TypeDef token.
-    mdFieldDef  tkFieldDef;             // Duplicate FieldDef token.
-    LPCSTR      szName;                 // FieldDef name.
-    PCCOR_SIGNATURE pbSig;              // FieldDef signature.
-    ULONG       cbSig;                  // Signature size in bytes.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    BOOL        bIsValueField;
-    BOOL        bIsGlobalField = FALSE;
-    BOOL        bHasValidRVA = FALSE;
-    DWORD       dwInvalidFlags;
-    DWORD       dwFlags;
-    RID         tempRid;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-    
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    // Get the FieldDef record.
-    veCtxt.Token = TokenFromRid(rid, mdtFieldDef);
-    veCtxt.uOffset = 0;
-
-    IfFailGo(pMiniMd->GetFieldRecord(rid, &pRecord));
-
-    // Do checks for name validity.
-    IfFailGo(pMiniMd->getNameOfField(pRecord, &szName));
-    if (!*szName)
-    {
-        // Field name is NULL.
-        REPORT_ERROR0(VLDTR_E_FD_NAMENULL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else
-    {
-        if(!strcmp(szName,COR_DELETED_NAME_A)) goto ErrExit; 
-        ULONG L = (ULONG)strlen(szName);
-        if(L >= MAX_CLASSNAME_LENGTH)
-        {
-            REPORT_ERROR2(VLDTR_E_TD_NAMETOOLONG, L, (ULONG)(MAX_CLASSNAME_LENGTH-1));
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    bIsValueField = (strcmp(szName,BASE_VALUE_FIELDNAME)==0);
-    // If field is RTSpecialName, its name must be 'value__' and vice versa
-    if((IsFdRTSpecialName(pRecord->GetFlags())!=0) != bIsValueField)
-    {
-        REPORT_ERROR1(bIsValueField ? VLDTR_E_TD_ENUMVALNOTSN : VLDTR_E_FD_NOTVALUERTSN, veCtxt.Token);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Validate flags
-    dwFlags = pRecord->GetFlags();
-    dwInvalidFlags = ~(fdFieldAccessMask | fdStatic | fdInitOnly | fdLiteral | fdNotSerialized | fdSpecialName
-        | fdPinvokeImpl | fdReservedMask);
-    if(dwFlags & dwInvalidFlags)
-    {
-        REPORT_ERROR1(VLDTR_E_TD_EXTRAFLAGS, dwFlags & dwInvalidFlags);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Validate access
-    if((dwFlags & fdFieldAccessMask) == fdFieldAccessMask)
-    {
-        REPORT_ERROR0(VLDTR_E_FMD_BADACCESSFLAG);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Literal : Static, !InitOnly
-    if(IsFdLiteral(dwFlags))
-    {
-        if(IsFdInitOnly(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_FD_INITONLYANDLITERAL);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        if(!IsFdStatic(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_FD_LITERALNOTSTATIC);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        if(!IsFdHasDefault(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_FD_LITERALNODEFAULT);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    // RTSpecialName => SpecialName
-    if(IsFdRTSpecialName(dwFlags) && !IsFdSpecialName(dwFlags))
-    {
-        REPORT_ERROR0(VLDTR_E_FMD_RTSNNOTSN);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Validate Field signature.
-    IfFailGo(pMiniMd->getSignatureOfField(pRecord, &pbSig, &cbSig));
-    IfFailGo(ValidateFieldSig(TokenFromRid(rid, mdtFieldDef), pbSig, cbSig));
-    if (hr != S_OK)
-        SetVldtrCode(&hrSave, hr);
-
-    // Validate Field RVA
-    if(IsFdHasFieldRVA(dwFlags))
-    {
-        ULONG iFieldRVARid;
-        IfFailGo(pMiniMd->FindFieldRVAHelper(TokenFromRid(rid, mdtFieldDef), &iFieldRVARid));
-        if((iFieldRVARid==0) || (iFieldRVARid > pMiniMd->getCountFieldRVAs()))
-        {
-            REPORT_ERROR0(VLDTR_E_FD_RVAHASNORVA);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else
-        {
-            /*
-            FieldRVARec *pRVARec;
-            IfFailGo(pMiniMd->GetFieldRVARecord(iFieldRVARid, &pRVARec));
-            if(pRVARec->GetRVA() == 0)
-            {
-                REPORT_ERROR0(VLDTR_E_FD_RVAHASZERORVA);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            else
-            */ 
-                bHasValidRVA = TRUE;
-        }
-    }
-
-    // Get the parent of the Field.
-    IfFailGo(pMiniMd->FindParentOfFieldHelper(TokenFromRid(rid, mdtFieldDef), &tkTypeDef));
-    // Validate that the parent is not nil.
-    if (IsNilToken(tkTypeDef))
-    {
-        REPORT_ERROR0(VLDTR_E_FD_PARNIL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else if (RidFromToken(tkTypeDef) != RidFromToken(m_tdModule))
-    {
-        if(IsValidToken(tkTypeDef) && (TypeFromToken(tkTypeDef) == mdtTypeDef))
-        {
-            TypeDefRec *pParentRec;
-            IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkTypeDef), &pParentRec));
-            // If the name is "value__" ...
-            if(bIsValueField)
-            {
-                // parent must be Enum
-                mdToken tkExtends = pMiniMd->getExtendsOfTypeDef(pParentRec);
-                RID     ridExtends = RidFromToken(tkExtends);
-                LPCSTR  szExtName="",szExtNameSpace="";
-                if(ridExtends)
-                {
-                    if(TypeFromToken(tkExtends) == mdtTypeRef)
-                    {
-                        TypeRefRec *pExtRec;
-                        IfFailGo(pMiniMd->GetTypeRefRecord(ridExtends, &pExtRec));
-                        IfFailGo(pMiniMd->getNameOfTypeRef(pExtRec, &szExtName));
-                        IfFailGo(pMiniMd->getNamespaceOfTypeRef(pExtRec, &szExtNameSpace));
-                    }
-                    else if(TypeFromToken(tkExtends) == mdtTypeDef)
-                    {
-                        TypeDefRec *pExtRec;
-                        IfFailGo(pMiniMd->GetTypeDefRecord(ridExtends, &pExtRec));
-                        IfFailGo(pMiniMd->getNameOfTypeDef(pExtRec, &szExtName));
-                        IfFailGo(pMiniMd->getNamespaceOfTypeDef(pExtRec, &szExtNameSpace));
-                    }
-                }
-                if(strcmp(szExtName,BASE_ENUM_CLASSNAME) || strcmp(szExtNameSpace,BASE_NAMESPACE))
-                {
-                    REPORT_ERROR0(VLDTR_E_FD_VALUEPARNOTENUM);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-
-                // field must be instance - checked in ValidateTypeDef
-                // must be no other instance fields - checked in ValidateTypeDef
-                // must be first field - checked in ValidateTypeDef
-                // must be RTSpecialName -- checked in ValidateTypeDef
-            }
-            if(IsTdInterface(pMiniMd->getFlagsOfTypeDef(pParentRec)))
-            {
-                // Fields in interface are not CLS compliant
-                REPORT_ERROR0(VLDTR_E_FD_FLDINIFACE);
-                SetVldtrCode(&hrSave, VLDTR_S_WRN);
-
-                // If field is not static, verify parent is not interface.
-                if(!IsFdStatic(dwFlags))
-                {
-                    REPORT_ERROR0(VLDTR_E_FD_INSTINIFACE);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    // If field is not public, verify parent is not interface.
-                    if(!IsFdPublic(dwFlags))
-                    {
-                        REPORT_ERROR0(VLDTR_E_FD_NOTPUBINIFACE);
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-                }
-            }
-        } // end if Valid and TypeDef
-        else
-        {
-            REPORT_ERROR1(VLDTR_E_FD_BADPARENT, tkTypeDef);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    else // i.e. if (RidFromToken(tkTypeDef) == RidFromToken(m_tdModule))
-    {
-        bIsGlobalField = TRUE;
-        // Globals are not CLS-compliant
-        REPORT_ERROR0(VLDTR_E_FMD_GLOBALITEM);
-        SetVldtrCode(&hrSave, VLDTR_S_WRN);
-        // Validate global field:
-        // Must be static
-        if(!IsFdStatic(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_FMD_GLOBALNOTSTATIC);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // Must have a non-zero RVA
-        /*
-        if(!bHasValidRVA)
-        {
-            REPORT_ERROR0(VLDTR_E_FD_GLOBALNORVA);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        */
-    }
-
-    // Check for duplicates, except global fields with PrivateScope.
-    if (*szName && cbSig && !IsFdPrivateScope(dwFlags))
-    {
-        hr = ImportHelper::FindField(pMiniMd, tkTypeDef, szName, pbSig, cbSig, &tkFieldDef, rid);
-        if (hr == S_OK)
-        {
-            if(!IsFdPrivateScope(dwFlags))
-            {
-                REPORT_ERROR1(VLDTR_E_FD_DUP, tkFieldDef);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            else hr = S_OK;
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-        {
-            hr = S_OK;
-        }
-        else
-        {
-            IfFailGo(hr);
-        }
-    }
-    // Field having security must be marked fdHasSecurity and vice versa
-    {
-        ULONG ridStart = 1;
-        ULONG ridEnd = pMiniMd->getCountDeclSecuritys() + 1;
-        ULONG index;
-        BOOL  bHasSecurity = FALSE;
-        for (index = ridStart; index < ridEnd; index ++ )
-        {
-            DeclSecurityRec *pDeclSecurityRecord;
-            IfFailGo(pMiniMd->GetDeclSecurityRecord(index, &pDeclSecurityRecord));
-            if ( veCtxt.Token == pMiniMd->getParentOfDeclSecurity(pDeclSecurityRecord))
-            {
-                bHasSecurity = TRUE;
-                break;
-            }
-        }
-        if(!bHasSecurity) // No records, check for CA "SuppressUnmanagedCodeSecurityAttribute"
-        {
-            bHasSecurity = (S_OK == ImportHelper::GetCustomAttributeByName(pMiniMd, veCtxt.Token, 
-                "System.Security.SuppressUnmanagedCodeSecurityAttribute", NULL, NULL));
-        }
-        if(bHasSecurity)
-        {
-            REPORT_ERROR0(VLDTR_E_FMD_SECURNOTMARKED);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    // Field having marshaling must be marked fdHasFieldMarshal and vice versa
-    IfFailGo(pMiniMd->FindFieldMarshalHelper(veCtxt.Token, &tempRid));
-    if (InvalidRid(tempRid) == (IsFdHasFieldMarshal(dwFlags) != 0))
-    {
-        REPORT_ERROR0(IsFdHasFieldMarshal(dwFlags)? VLDTR_E_FD_MARKEDNOMARSHAL : VLDTR_E_FD_MARSHALNOTMARKED);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Field having const value must be marked fdHasDefault and vice versa
-    IfFailGo(pMiniMd->FindConstantHelper(veCtxt.Token, &tempRid));
-    if(InvalidRid(tempRid) == (IsFdHasDefault(dwFlags) != 0))
-    {
-        REPORT_ERROR0(IsFdHasDefault(dwFlags)? VLDTR_E_FD_MARKEDNODEFLT : VLDTR_E_FD_DEFLTNOTMARKED);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Check the field's impl.map
-    {
-        ULONG iRecord;
-        IfFailGo(pMiniMd->FindImplMapHelper(veCtxt.Token, &iRecord));
-        if(IsFdPinvokeImpl(dwFlags))
-        {
-            // must be static
-            if(!IsFdStatic(dwFlags))
-            {
-                REPORT_ERROR0(VLDTR_E_FMD_PINVOKENOTSTATIC);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            // must have ImplMap
-            if (InvalidRid(iRecord))
-            {
-                REPORT_ERROR0(VLDTR_E_FMD_MARKEDNOPINVOKE);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-        else
-        {
-            // must have no ImplMap
-            if (!InvalidRid(iRecord))
-            {
-                REPORT_ERROR0(VLDTR_E_FMD_PINVOKENOTMARKED);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-        if (!InvalidRid(iRecord))
-        {
-            hr = ValidateImplMap(iRecord);
-            if(hr != S_OK)
-            {
-                REPORT_ERROR0(VLDTR_E_FMD_BADIMPLMAP);
-                SetVldtrCode(&hrSave, VLDTR_S_WRN);
-            }
-        }
-
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateField()
-
-//*****************************************************************************
-// Validate the given MethodPtr.
-//*****************************************************************************
-HRESULT RegMeta::ValidateMethodPtr(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateMethodPtr()
-
-
-//*****************************************************************************
-// Validate the given Method.
-//*****************************************************************************
-#ifdef _PREFAST_
-#pragma warning(push)
-#pragma warning(disable:21000) // Suppress PREFast warning about overly large function
-#endif
-HRESULT RegMeta::ValidateMethod(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    MethodRec   *pRecord = NULL;               // Method record.
-    mdTypeDef   tkTypeDef;              // Parent TypeDef token.
-    mdMethodDef tkMethodDef;            // Duplicate MethodDef token.
-    LPCSTR      szName;                 // MethodDef name.
-    DWORD       dwFlags = 0;                // Method flags.
-    DWORD       dwImplFlags = 0;            // Method impl.flags.
-    PCCOR_SIGNATURE pbSig;              // MethodDef signature.
-    ULONG       cbSig;                  // Signature size in bytes.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    BOOL        bIsCtor=FALSE;
-    BOOL        bIsCctor=FALSE;
-    BOOL        bIsGlobal=FALSE;
-    BOOL        bIsParentImport = FALSE;
-    BOOL        bIsGeneric = FALSE;
-    unsigned    retType;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    // Get the MethodDef record.
-    veCtxt.Token = TokenFromRid(rid, mdtMethodDef);
-    veCtxt.uOffset = 0;
-
-    IfFailGo(pMiniMd->GetMethodRecord(rid, &pRecord));
-
-    // Do checks for name validity.
-    IfFailGo(pMiniMd->getNameOfMethod(pRecord, &szName));
-    if (!*szName)
-    {
-        // Method name is NULL.
-        REPORT_ERROR0(VLDTR_E_MD_NAMENULL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else
-    {
-        if(!strcmp(szName,COR_DELETED_NAME_A)) goto ErrExit; 
-        bIsCtor = (0 == strcmp(szName,BASE_CTOR_NAME));
-        bIsCctor = (0 == strcmp(szName,BASE_CCTOR_NAME));
-        ULONG L = (ULONG)strlen(szName);
-        if(L >= MAX_CLASSNAME_LENGTH)
-        {
-            REPORT_ERROR2(VLDTR_E_TD_NAMETOOLONG, L, (ULONG)(MAX_CLASSNAME_LENGTH-1));
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    // Get the parent, flags and signature of the Method.
-    IfFailGo(pMiniMd->FindParentOfMethodHelper(TokenFromRid(rid, mdtMethodDef), &tkTypeDef));
-    dwFlags = pMiniMd->getFlagsOfMethod(pRecord);
-    dwImplFlags = pMiniMd->getImplFlagsOfMethod(pRecord);
-    IfFailGo(pMiniMd->getSignatureOfMethod(pRecord, &pbSig, &cbSig));
-
-    // Check for duplicates.
-    if (*szName && cbSig && !IsNilToken(tkTypeDef) && !IsMdPrivateScope(dwFlags))
-    {
-        hr = ImportHelper::FindMethod(pMiniMd, tkTypeDef, szName, pbSig, cbSig, &tkMethodDef, rid);
-        if (hr == S_OK)
-        {
-            REPORT_ERROR1(VLDTR_E_MD_DUP, tkMethodDef);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-            hr = S_OK;
-        else
-            IfFailGo(hr);
-    }
-
-    // No further error checking for VtblGap methods.
-    if (IsVtblGapName(szName))
-    {
-        hr = hrSave;
-        goto ErrExit;
-    }
-
-    // Validate Method signature.
-    IfFailGo(ValidateMethodSig(TokenFromRid(rid, mdtMethodDef), pbSig, cbSig,
-                               dwFlags));
-    if (hr != S_OK)
-        SetVldtrCode(&hrSave, hr);
-
-    // Validate that the parent is not nil.
-    if (IsNilToken(tkTypeDef))
-    {
-        REPORT_ERROR0(VLDTR_E_MD_PARNIL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else if (RidFromToken(tkTypeDef) != RidFromToken(m_tdModule))
-    {
-        if(TypeFromToken(tkTypeDef) == mdtTypeDef)
-        {
-            TypeDefRec *pTDRec;
-            IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkTypeDef), &pTDRec));
-            DWORD       dwTDFlags = pTDRec->GetFlags();
-            LPCSTR szTDName;
-            IfFailGo(pMiniMd->getNameOfTypeDef(pTDRec, &szTDName));
-            LPCSTR      szTDNameSpace;
-            IfFailGo(pMiniMd->getNamespaceOfTypeDef(pTDRec, &szTDNameSpace));
-            BOOL        fIsTdValue=FALSE, fIsTdEnum=FALSE;
-            mdToken     tkExtends = pMiniMd->getExtendsOfTypeDef(pTDRec);
-
-            if(0 == strcmp(szTDNameSpace,BASE_NAMESPACE))
-            {
-                fIsTdEnum   = (0 == strcmp(szTDName,BASE_ENUM_CLASSNAME));
-                if(!fIsTdEnum)
-                {
-                    fIsTdValue  = (0 == strcmp(szTDName,BASE_VTYPE_CLASSNAME));
-                }
-            }
-            if(fIsTdEnum || fIsTdValue)
-            {
-                fIsTdEnum = fIsTdValue = FALSE; // System.Enum and System.ValueType themselves are classes
-            }
-            else if(RidFromToken(tkExtends))
-            { 
-                if(TypeFromToken(tkExtends) == mdtTypeDef)
-                {
-                    IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkExtends), &pTDRec));
-                    IfFailGo(pMiniMd->getNameOfTypeDef(pTDRec, &szTDName));
-                    IfFailGo(pMiniMd->getNamespaceOfTypeDef(pTDRec, &szTDNameSpace));
-                }
-                else if(TypeFromToken(tkExtends) == mdtTypeSpec)
-                {
-                    fIsTdEnum = fIsTdValue = FALSE; // a type extending a spec cannot be an enum or value type 
-                    // the assignments are redundant, but clear.
-                }
-                else 
-                {
-                    TypeRefRec *pTRRec;
-                    IfFailGo(pMiniMd->GetTypeRefRecord(RidFromToken(tkExtends), &pTRRec));
-                    IfFailGo(pMiniMd->getNameOfTypeRef(pTRRec, &szTDName));
-                    IfFailGo(pMiniMd->getNamespaceOfTypeRef(pTRRec, &szTDNameSpace));
-                }
-
-                if(0 == strcmp(szTDNameSpace,BASE_NAMESPACE))
-                {
-                    fIsTdEnum   = (0 == strcmp(szTDName,BASE_ENUM_CLASSNAME));
-                    if(!fIsTdEnum)
-                    {
-                        fIsTdValue  = (0 == strcmp(szTDName,BASE_VTYPE_CLASSNAME));
-                    }
-                    else fIsTdValue = FALSE;
-                }
-            }
-
-            // If Method is abstract, verify parent is abstract.
-            if(IsMdAbstract(dwFlags) && !IsTdAbstract(dwTDFlags))
-            {
-                REPORT_ERROR1(VLDTR_E_MD_ABSTPARNOTABST, tkTypeDef);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            // If parent is import, method must have zero RVA, otherwise it depends...
-            if(IsTdImport(dwTDFlags)) bIsParentImport = TRUE;
-            if(IsTdInterface(dwTDFlags))
-            {
-                if(!IsMdStatic(dwFlags))
-                { 
-                    // No non-abstract instance methods in interface.
-                    if(!IsMdAbstract(dwFlags))
-                    {
-                        REPORT_ERROR1(VLDTR_E_MD_NOTSTATABSTININTF, tkTypeDef);
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-                    // No non-public instance methods in interface.
-                    if(!IsMdPublic(dwFlags))
-                    {
-                        REPORT_ERROR1(VLDTR_E_MD_NOTPUBININTF, tkTypeDef);
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-                }
-                // If Method is constructor, verify parent is not interface.
-                if(bIsCtor)
-                {
-                    REPORT_ERROR1(VLDTR_E_MD_CTORININTF, tkTypeDef);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }//end if(interface)
-            if((fIsTdValue || fIsTdEnum) && IsMiSynchronized(dwImplFlags))
-            {
-                REPORT_ERROR1(VLDTR_E_MD_SYNCMETHODINVTYPE, tkTypeDef);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            if(bIsCtor)
-            {
-                // .ctor must be instance
-                if(IsMdStatic(dwFlags))
-                {
-                    REPORT_ERROR1(VLDTR_E_MD_CTORSTATIC, tkTypeDef);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }//end if .ctor
-            else if(bIsCctor)
-            {
-                // .cctor must be static
-                if(!IsMdStatic(dwFlags))
-                {
-                    REPORT_ERROR1(VLDTR_E_MD_CCTORNOTSTATIC, tkTypeDef);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                // ..cctor must have default callconv
-                IfFailGo(pMiniMd->getSignatureOfMethod(pRecord, &pbSig, &cbSig));
-                if(IMAGE_CEE_CS_CALLCONV_DEFAULT != CorSigUncompressData(pbSig))
-                {
-                    REPORT_ERROR0(VLDTR_E_MD_CCTORCALLCONV);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                // .cctor must have no arguments
-                if(0 != CorSigUncompressData(pbSig))
-                {
-                    REPORT_ERROR0(VLDTR_E_MD_CCTORHASARGS);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-
-
-            }//end if .cctor
-            if(bIsCtor || bIsCctor)
-            {
-                // .ctor, .cctor must be SpecialName and RTSpecialName
-                if(!(IsMdSpecialName(dwFlags) && IsMdRTSpecialName(dwFlags)))
-                {
-                    REPORT_ERROR1(VLDTR_E_MD_CTORNOTSNRTSN, tkTypeDef);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-#ifdef NO_SUCH_CHECKS_NEEDED_SPEC_TO_BE_UODATED
-                // .ctor, .cctor must not be virtual
-                if(IsMdVirtual(dwFlags))
-                {
-                    REPORT_ERROR1(VLDTR_E_MD_CTORVIRT, tkTypeDef);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                // .ctor, .cctor must not be abstract
-                if(IsMdAbstract(dwFlags))
-                {
-                    REPORT_ERROR1(VLDTR_E_MD_CTORABST, tkTypeDef);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                // .ctor, .cctor must not be PInvoke
-                if(IsMdPinvokeImpl(dwFlags))
-                {
-                    REPORT_ERROR1(VLDTR_E_MD_CTORPINVOKE, tkTypeDef);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                // .ctor,.cctor must have RVA!=0
-                if(pRecord->GetRVA()==0)
-                { 
-                    REPORT_ERROR0(VLDTR_E_MD_CTORZERORVA);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-#endif
-            }//end if .ctor or .cctor
-        }// end if(parent == TypeDef)
-    }// end if not Module
-    else // i.e. if (RidFromToken(tkTypeDef) == RidFromToken(m_tdModule))
-    {
-        bIsGlobal = TRUE;
-        // Globals are not CLS-compliant
-        REPORT_ERROR0(VLDTR_E_FMD_GLOBALITEM);
-        SetVldtrCode(&hrSave, VLDTR_S_WRN);
-        // Validate global method:
-        // Must be static
-        if(!IsMdStatic(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_FMD_GLOBALNOTSTATIC);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // Must not be abstract or virtual
-        if(IsMdAbstract(dwFlags) || IsMdVirtual(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_MD_GLOBALABSTORVIRT);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // Must be not .ctor or .cctor
-        if(bIsCtor)
-        {
-            REPORT_ERROR0(VLDTR_E_MD_GLOBALCTORCCTOR);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    } //end if Module
-
-    // Signature specifics: .ctor, .cctor, entrypoint
-    if(bIsCtor || bIsCctor)
-    {
-        // .ctor, .cctor must return void
-        IfFailGo(pMiniMd->getSignatureOfMethod(pRecord, &pbSig, &cbSig));
-        CorSigUncompressData(pbSig); // get call conv out of the way
-        CorSigUncompressData(pbSig); // get num args out of the way
-        while (((retType=CorSigUncompressData(pbSig)) == ELEMENT_TYPE_CMOD_OPT) 
-            || (retType == ELEMENT_TYPE_CMOD_REQD)) CorSigUncompressToken(pbSig);
-        if(retType != ELEMENT_TYPE_VOID)
-        {
-            REPORT_ERROR0(VLDTR_E_MD_CTORNOTVOID);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    if(g_tkEntryPoint == veCtxt.Token)
-    {
-        ULONG ulCallConv;
-        // EP must be static
-        if(!IsMdStatic(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_EP_INSTANCE);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        
-        // EP can't belong to generic class or nested in generic class
-        mdToken tkTypeDefCur;
-        for(tkTypeDefCur = tkTypeDef; tkTypeDefCur != mdTokenNil;)
-        {
-            HENUMInternal hEnumTyPars;
-            ULONG ulTypeDefArity = 0;
-            hr = pMiniMd->FindGenericParamHelper(tkTypeDefCur, &hEnumTyPars);
-            if (SUCCEEDED(hr))
-            {
-                IfFailGo(HENUMInternal::GetCount(&hEnumTyPars,&ulTypeDefArity));
-                HENUMInternal::ClearEnum(&hEnumTyPars);
-                if (ulTypeDefArity != 0)
-                {
-                    REPORT_ERROR0(VLDTR_E_EP_GENERIC_TYPE);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-            if(ulTypeDefArity == 0)
-            {
-                // This class is not generic, how about the encloser?
-                RID iRecord;
-                IfFailGo(pMiniMd->FindNestedClassHelper(tkTypeDefCur, &iRecord));
-                
-                if (InvalidRid(iRecord))
-                {
-                    tkTypeDefCur = mdTokenNil;
-                }
-                else
-                {
-                    NestedClassRec *pNestedClassRec;
-                    IfFailGo(pMiniMd->GetNestedClassRecord(iRecord, &pNestedClassRec));
-                    tkTypeDefCur = pMiniMd->getEnclosingClassOfNestedClass(pNestedClassRec);
-                }
-            }
-            else
-                tkTypeDefCur = mdTokenNil;
-        }
-
-        // EP must have a predetermined signature (different for DLL and EXE
-        IfFailGo(pMiniMd->getSignatureOfMethod(pRecord, &pbSig, &cbSig));
-        ulCallConv = CorSigUncompressData(pbSig); // get call conv out of the way
-        // EP can't be generic
-        if (ulCallConv & IMAGE_CEE_CS_CALLCONV_GENERIC)
-        {
-            // Skip the arity
-            CorSigUncompressData(pbSig);
-            REPORT_ERROR0(VLDTR_E_EP_GENERIC_METHOD);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-
-        // EP must have 0 or 1 argument
-        unsigned nArgs = CorSigUncompressData(pbSig);
-        if(g_fIsDLL)
-        {
-            if(nArgs != 3)
-            {
-                REPORT_ERROR1(VLDTR_E_EP_TOOMANYARGS, 3);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            //EP must return I4
-            while (((retType=CorSigUncompressData(pbSig)) == ELEMENT_TYPE_CMOD_OPT) 
-                || (retType == ELEMENT_TYPE_CMOD_REQD)) CorSigUncompressToken(pbSig);
-    
-            if(retType != ELEMENT_TYPE_I4)
-            {
-                REPORT_ERROR0(VLDTR_E_EP_BADRET);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            // Arguments must be VOID*, U4, VOID*
-            if(nArgs)
-            {
-                unsigned jj;
-                bool    badarg;
-                for(jj=0; jj<nArgs;jj++)
-                {
-                    while (((retType=CorSigUncompressData(pbSig)) == ELEMENT_TYPE_CMOD_OPT) 
-                        || (retType == ELEMENT_TYPE_CMOD_REQD)) CorSigUncompressToken(pbSig);
-        
-                    switch(jj)
-                    {
-                        case 0:
-                        case 2:
-                            badarg = (retType != ELEMENT_TYPE_PTR)
-                                    ||(CorSigUncompressData(pbSig) != ELEMENT_TYPE_VOID);
-                            break;
-    
-                        case 1:
-                            badarg = (retType != ELEMENT_TYPE_U4);
-                            break;
-    
-                        default:
-                            badarg = true;
-                    }
-                    if(badarg)
-                    {
-                        REPORT_ERROR1(VLDTR_E_EP_BADARG, jj+1);
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-                }
-            }
-        }
-        else
-        {
-            if(nArgs > 1)
-            {
-                REPORT_ERROR1(VLDTR_E_EP_TOOMANYARGS, 1);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            //EP must return VOID, I4 or U4
-            while (((retType=CorSigUncompressData(pbSig)) == ELEMENT_TYPE_CMOD_OPT) 
-                || (retType == ELEMENT_TYPE_CMOD_REQD)) CorSigUncompressToken(pbSig);
-    
-            if((retType != ELEMENT_TYPE_VOID)&&(retType != ELEMENT_TYPE_I4)&&(retType != ELEMENT_TYPE_U4))
-            {
-                REPORT_ERROR0(VLDTR_E_EP_BADRET);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            // Argument (if any) must be vector of strings
-            if(nArgs)
-            {
-                while (((retType=CorSigUncompressData(pbSig)) == ELEMENT_TYPE_CMOD_OPT) 
-                    || (retType == ELEMENT_TYPE_CMOD_REQD)) CorSigUncompressToken(pbSig);
-    
-                if((retType != ELEMENT_TYPE_SZARRAY)||(CorSigUncompressData(pbSig) != ELEMENT_TYPE_STRING))
-                {
-                    REPORT_ERROR1(VLDTR_E_EP_BADARG, 1);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-        } // end if(IsDll)--else
-    }  // end if (IsEntryPoint)
-
-
-    // Check method RVA
-    if(pRecord->GetRVA()==0)
-    { 
-        if(!(IsMdPinvokeImpl(dwFlags) || IsMdAbstract(dwFlags) 
-            || IsMiRuntime(dwImplFlags) || IsMiInternalCall(dwImplFlags)
-            || bIsParentImport))
-        {
-            REPORT_ERROR0(VLDTR_E_MD_ZERORVA);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    else
-    {
-        if(m_pStgdb && m_pStgdb->m_pImage)
-        {
-            NewHolder<PEDecoder> pe;
-
-            EX_TRY
-            {
-                // We need to use different PEDecoder constructors based on the type of data we give it.
-                // We use the one with a 'bool' as the second argument when dealing with a mapped file,
-                // and we use the one that takes a COUNT_T as the second argument when dealing with a
-                // flat file.
-            
-                if (m_pStgdb->m_pStgIO->GetMemoryMappedType() == MTYPE_IMAGE)
-                    pe = new (nothrow) PEDecoder(m_pStgdb->m_pImage, false);
-                else
-                    pe = new (nothrow) PEDecoder(m_pStgdb->m_pImage, (COUNT_T)(m_pStgdb->m_dwImageSize));
-
-            }
-            EX_CATCH
-            {
-                hr = COR_E_BADIMAGEFORMAT;
-            }
-            EX_END_CATCH(SwallowAllExceptions)
-
-            IfFailGo(hr);
-            IfNullGo(pe);
-
-            if (!pe->CheckRva(pRecord->GetRVA()))
-            {
-                REPORT_ERROR1(VLDTR_E_MD_BADRVA, pRecord->GetRVA());
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            else
-            {
-                if(IsMiManaged(dwImplFlags) && (IsMiIL(dwImplFlags) || IsMiOPTIL(dwImplFlags)))
-                {
-                    HRESULT hrTemp = S_OK;
-                    // validate locals signature token
-                    EX_TRY
-                    {
-                        COR_ILMETHOD_DECODER method((COR_ILMETHOD*) pe->GetRvaData(pRecord->GetRVA()));
-                        if (method.LocalVarSigTok)
-                        {
-                            if((TypeFromToken(method.GetLocalVarSigTok()) != mdtSignature) ||
-                                (!IsValidToken(method.GetLocalVarSigTok())) || (RidFromToken(method.GetLocalVarSigTok())==0))
-                            {
-                                hrTemp = _ValidateErrorHelper(VLDTR_E_MD_BADLOCALSIGTOK, veCtxt, method.GetLocalVarSigTok());
-                                if (SUCCEEDED(hrTemp))
-                                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                            }
-                        }
-                    } 
-                    EX_CATCH
-                    {
-                        hrTemp = _ValidateErrorHelper(VLDTR_E_MD_BADHEADER, veCtxt);
-                        if (SUCCEEDED(hrTemp))
-                            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-                    EX_END_CATCH(SwallowAllExceptions)
-
-                    IfFailGo(hrTemp);
-                }
-            }
-        }
-
-        if(IsMdAbstract(dwFlags) || bIsParentImport
-            || IsMiRuntime(dwImplFlags) || IsMiInternalCall(dwImplFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_MD_ZERORVA);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    // Check the method flags
-    // Validate access
-    if((dwFlags & mdMemberAccessMask) == mdMemberAccessMask)
-    {
-        REPORT_ERROR0(VLDTR_E_FMD_BADACCESSFLAG);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Final/NewSlot must be virtual
-    if((IsMdFinal(dwFlags)||IsMdNewSlot(dwFlags)||IsMdCheckAccessOnOverride(dwFlags)) 
-        && !IsMdVirtual(dwFlags))
-    {
-        REPORT_ERROR0(VLDTR_E_MD_FINNOTVIRT);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Static can't be final or virtual
-    if(IsMdStatic(dwFlags))
-    {
-        if(IsMdFinal(dwFlags) || IsMdVirtual(dwFlags) || IsMdNewSlot(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_MD_STATANDFINORVIRT);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    else // non-static can't be an entry point
-    {
-        if(g_tkEntryPoint == veCtxt.Token)
-        {
-            REPORT_ERROR0(VLDTR_E_EP_INSTANCE);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    if(IsMdAbstract(dwFlags))
-    {
-        // Can't be both abstract and final
-        if(IsMdFinal(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_MD_ABSTANDFINAL);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // If abstract, must be not miForwardRef, not Pinvoke, and must be virtual
-        if(IsMiForwardRef(dwImplFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_MD_ABSTANDIMPL);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        if(IsMdPinvokeImpl(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_MD_ABSTANDPINVOKE);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        if(!IsMdVirtual(dwFlags))
-        {
-            REPORT_ERROR0(VLDTR_E_MD_ABSTNOTVIRT);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    // If PrivateScope, must have RVA!=0
-    if(IsMdPrivateScope(dwFlags) && (pRecord->GetRVA() ==0))
-    {
-        REPORT_ERROR0(VLDTR_E_MD_PRIVSCOPENORVA);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // RTSpecialName => SpecialName
-    if(IsMdRTSpecialName(dwFlags) && !IsMdSpecialName(dwFlags))
-    {
-        REPORT_ERROR0(VLDTR_E_FMD_RTSNNOTSN);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Method having security must be marked mdHasSecurity and vice versa
-    {
-        ULONG ridStart = 1;
-        ULONG ridEnd = pMiniMd->getCountDeclSecuritys() + 1;
-        ULONG index;
-        BOOL  bHasSecurity = FALSE;
-        for (index = ridStart; index < ridEnd; index ++ )
-        {
-            DeclSecurityRec *pDeclSecurityRecord;
-            IfFailGo(pMiniMd->GetDeclSecurityRecord(index, &pDeclSecurityRecord));
-            if ( veCtxt.Token == pMiniMd->getParentOfDeclSecurity(pDeclSecurityRecord))
-            {
-                bHasSecurity = TRUE;
-                break;
-            }
-        }
-        if(!bHasSecurity) // No records, check for CA "SuppressUnmanagedCodeSecurityAttribute"
-        {
-            bHasSecurity = (S_OK == ImportHelper::GetCustomAttributeByName(pMiniMd, veCtxt.Token, 
-                "System.Security.SuppressUnmanagedCodeSecurityAttribute", NULL, NULL));
-        }
-        if(bHasSecurity != (IsMdHasSecurity(dwFlags)!=0))
-        {
-            REPORT_ERROR0(bHasSecurity ? VLDTR_E_FMD_SECURNOTMARKED : VLDTR_E_FMD_MARKEDNOSECUR);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    // Validate method semantics
-    {
-        MethodSemanticsRec  *pRec;
-        ULONG               ridEnd;
-        ULONG               index;
-        unsigned            uTally = 0;
-        mdToken             tkEventProp;
-        ULONG               iCount;
-        DWORD               dwSemantic;
-        // get the range of method rids given a typedef
-        ridEnd = pMiniMd->getCountMethodSemantics();
-
-        for (index = 1; index <= ridEnd; index++ )
-        {
-            IfFailGo(pMiniMd->GetMethodSemanticsRecord(index, &pRec));
-            if ( pMiniMd->getMethodOfMethodSemantics(pRec) ==  veCtxt.Token )
-            {
-                uTally++;
-                if(uTally > 1)
-                {
-                    REPORT_ERROR0(VLDTR_E_MD_MULTIPLESEMANTICS);
-                    SetVldtrCode(&hrSave, VLDTR_S_WRN);
-                }
-                tkEventProp = pMiniMd->getAssociationOfMethodSemantics(pRec);
-                if((TypeFromToken(tkEventProp) == mdtEvent)||(TypeFromToken(tkEventProp) == mdtProperty))
-                {
-                    iCount = (TypeFromToken(tkEventProp) == mdtEvent) ? pMiniMd->getCountEvents() :
-                                                                        pMiniMd->getCountPropertys();
-                    if(RidFromToken(tkEventProp) > iCount)
-                    {
-                        REPORT_ERROR1(VLDTR_E_MD_SEMANTICSNOTEXIST, tkEventProp);
-                        SetVldtrCode(&hrSave, VLDTR_S_WRN);
-                    }
-                }
-                else
-                {
-                    REPORT_ERROR1(VLDTR_E_MD_INVALIDSEMANTICS, tkEventProp);
-                    SetVldtrCode(&hrSave, VLDTR_S_WRN);
-                }
-                // One and only one semantics flag must be set
-                iCount = 0;
-                dwSemantic = pRec->GetSemantic();
-                if(IsMsSetter(dwSemantic)) iCount++;
-                if(IsMsGetter(dwSemantic)) iCount++;
-                if(IsMsOther(dwSemantic))  iCount++;
-                if(IsMsAddOn(dwSemantic))  iCount++;
-                if(IsMsRemoveOn(dwSemantic)) iCount++;
-                if(IsMsFire(dwSemantic)) iCount++;
-                if(iCount != 1)
-                {
-                    REPORT_ERROR1(iCount ? VLDTR_E_MD_MULTSEMANTICFLAGS : VLDTR_E_MD_NOSEMANTICFLAGS, tkEventProp);
-                    SetVldtrCode(&hrSave, VLDTR_S_WRN);
-                }
-            }
-        }// end for(index)
-    }
-    // Check the method's impl.map
-    {
-        RID iRecord;
-        IfFailGo(pMiniMd->FindImplMapHelper(veCtxt.Token, &iRecord));
-        if(IsMdPinvokeImpl(dwFlags))
-        {
-            // must be static
-            if(!IsMdStatic(dwFlags))
-            {
-                REPORT_ERROR0(VLDTR_E_FMD_PINVOKENOTSTATIC);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            // must have either ImplMap or RVA == 0
-            if (InvalidRid(iRecord))
-            {
-                if(pRecord->GetRVA()==0)
-                {
-                    REPORT_ERROR0(VLDTR_E_FMD_MARKEDNOPINVOKE);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-            else
-            {
-                if(pRecord->GetRVA()!=0)
-                {
-                    // C++ emits ImplMaps for IJW methods,
-                    // with resolution=ModuleRef with name ""
-                    ImplMapRec  *pIMRecord;
-                    mdToken     tkModuleRef;
-                    IfFailGo(pMiniMd->GetImplMapRecord(iRecord, &pIMRecord));
-                    tkModuleRef = pMiniMd->getImportScopeOfImplMap(pIMRecord);
-                    if((TypeFromToken(tkModuleRef) == mdtModuleRef) && (!IsNilToken(tkModuleRef)))
-                    {
-                        ModuleRefRec *pMRRecord;              // ModuleRef record.
-                        LPCUTF8     szMRName;                 // ModuleRef name.
-                        // Get the ModuleRef record.
-                        IfFailGo(pMiniMd->GetModuleRefRecord(RidFromToken(tkModuleRef), &pMRRecord));
-                        // Check ModuleRef name is "".
-                        IfFailGo(pMiniMd->getNameOfModuleRef(pMRRecord, &szMRName));
-                        if (*szMRName)
-                        {
-                            REPORT_ERROR0(VLDTR_E_MD_RVAANDIMPLMAP);
-                            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                        }
-                    }
-                }
-                else
-                {
-                    hr = ValidateImplMap(iRecord);
-                    if(hr != S_OK)
-                    {
-                        REPORT_ERROR0(VLDTR_E_FMD_BADIMPLMAP);
-                        SetVldtrCode(&hrSave, VLDTR_S_WRN);
-                    }
-                }
-            }
-
-        }
-        else
-        {
-            // must have no ImplMap
-            if (!InvalidRid(iRecord))
-            {
-                REPORT_ERROR0(VLDTR_E_FMD_PINVOKENOTMARKED);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-    }
-    // Validate params
-    {
-        ULONG ridStart = pMiniMd->getParamListOfMethod(pRecord);
-        ULONG ridEnd;
-        IfFailGo(pMiniMd->getEndParamListOfMethod(rid, &ridEnd));
-        ParamRec* pRec;
-        ULONG cbSigT;
-        PCCOR_SIGNATURE typePtr;
-        IfFailGo(pMiniMd->getSignatureOfMethod(pRecord, &typePtr, &cbSigT));
-        unsigned  callConv = CorSigUncompressData(typePtr);  // get the calling convention out of the way
-        unsigned  numTyArgs = 0;
-        if (callConv & IMAGE_CEE_CS_CALLCONV_GENERIC)
-        { 
-            bIsGeneric = TRUE;
-            numTyArgs = CorSigUncompressData(typePtr);
-        }
-
-        unsigned  numArgs = CorSigUncompressData(typePtr);
-        USHORT    usPrevSeq = 0;
-
-        for(ULONG ridP = ridStart; ridP < ridEnd; ridP++)
-        {
-            RID tempRid;
-            IfFailGo(pMiniMd->GetParamRecord(ridP, &pRec));
-            // Sequence order must be ascending
-            if(ridP > ridStart)
-            {
-                if(pRec->GetSequence() <= usPrevSeq)
-                {
-                    REPORT_ERROR2(VLDTR_E_MD_PARAMOUTOFSEQ, ridP-ridStart,pRec->GetSequence());
-                    SetVldtrCode(&hrSave, VLDTR_S_WRN);
-                }
-            }
-            usPrevSeq = pRec->GetSequence();
-            // Sequence value must not exceed num of arguments
-            if(usPrevSeq > numArgs)
-            {
-                REPORT_ERROR2(VLDTR_E_MD_PARASEQTOOBIG, ridP-ridStart,usPrevSeq);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-
-            // Param having marshaling must be marked pdHasFieldMarshal and vice versa
-            IfFailGo(pMiniMd->FindFieldMarshalHelper(TokenFromRid(ridP,mdtParamDef), &tempRid));
-            if (InvalidRid(tempRid) == (IsPdHasFieldMarshal(pRec->GetFlags()) != 0))
-            {
-                REPORT_ERROR1(IsPdHasFieldMarshal(pRec->GetFlags()) ? VLDTR_E_MD_PARMMARKEDNOMARSHAL
-                    : VLDTR_E_MD_PARMMARSHALNOTMARKED, ridP-ridStart);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            // Param having const value must be marked pdHasDefault and vice versa
-            IfFailGo(pMiniMd->FindConstantHelper(TokenFromRid(ridP,mdtParamDef), &tempRid));
-            if (InvalidRid(tempRid) == (IsPdHasDefault(pRec->GetFlags()) != 0))
-            {
-                REPORT_ERROR1(IsPdHasDefault(pRec->GetFlags()) ? VLDTR_E_MD_PARMMARKEDNODEFLT 
-                    : VLDTR_E_MD_PARMDEFLTNOTMARKED, ridP-ridStart);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-    }
-
-    // Generic Method related checks
-    if (bIsGeneric)
-    {
-        if (bIsCctor)
-        {
-            REPORT_ERROR0(VLDTR_E_MD_GENERIC_CCTOR);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-
-        if (bIsCtor)
-        {
-            REPORT_ERROR0(VLDTR_E_MD_GENERIC_CTOR);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-
-        if (bIsParentImport)
-        {
-            REPORT_ERROR0(VLDTR_E_MD_GENERIC_IMPORT);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateMethod()
-#ifdef _PREFAST_
-#pragma warning(pop)
-#endif
-
-//*****************************************************************************
-// Validate the given ParamPtr.
-//*****************************************************************************
-HRESULT RegMeta::ValidateParamPtr(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateParamPtr()
-
-//*****************************************************************************
-// Validate the given Param.
-//*****************************************************************************
-HRESULT RegMeta::ValidateParam(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    ParamRec    *pRecord;               // Param record
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    LPCSTR      szName;                 // Param name.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    // Get the InterfaceImpl record.
-    veCtxt.Token = TokenFromRid(rid, mdtParamDef);
-    veCtxt.uOffset = 0;
-
-    DWORD   dwBadFlags = 0;
-    DWORD   dwFlags = 0;
-    IfFailGo(pMiniMd->GetParamRecord(rid, &pRecord));
-    // Name, if any, must not exceed MAX_CLASSNAME_LENGTH
-    IfFailGo(pMiniMd->getNameOfParam(pRecord, &szName));
-    ULONG L = (ULONG)strlen(szName);
-    if(L >= MAX_CLASSNAME_LENGTH)
-    {
-        REPORT_ERROR2(VLDTR_E_TD_NAMETOOLONG, L, (ULONG)(MAX_CLASSNAME_LENGTH-1));
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    
-    // Flags must be as defined in CorHdr.h
-    dwBadFlags = ~(pdIn | pdOut | pdOptional | pdHasDefault | pdHasFieldMarshal);
-    dwFlags = pRecord->GetFlags();
-    if(dwFlags & dwBadFlags)
-    {
-        REPORT_ERROR1(VLDTR_E_PD_BADFLAGS, dwFlags);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateParam()
-
-//*****************************************************************************
-// Helper function for ValidateInterfaceImpl
-//*****************************************************************************
-int IsMethodImplementedByClass(CMiniMdRW *pMiniMd, 
-                                mdToken tkMethod, 
-                                LPCUTF8 szName,
-                                PCCOR_SIGNATURE pSig,
-                                ULONG cbSig,
-                                mdToken tkClass)
-{
-    HRESULT hr;
-    int numImpl = 0;
-    if(TypeFromToken(tkMethod) == mdtMethodDef)
-    {
-        if(TypeFromToken(tkClass) == mdtTypeSpec)
-        {
-            // We are trying to find out if an interface method is implemented in the generic class tkClass.
-            // Simple signature comparison doesn't work here, because "int Method()" in the interface might 
-            // be implemented by "T Type.Method()" in the generic type.
-            // Therefore we assume it is implemented. Atlernatively we could implement better signature 
-            // comparison which would match T with any other type, etc.
-            numImpl = 1;
-        }
-        else if(TypeFromToken(tkClass) == mdtTypeDef)
-        {
-            TypeDefRec *pClass;
-            IfFailRet(pMiniMd->GetTypeDefRecord(RidFromToken(tkClass), &pClass));
-            RID ridClsStart = pMiniMd->getMethodListOfTypeDef(pClass);
-            RID ridClsEnd;
-            IfFailRet(pMiniMd->getEndMethodListOfTypeDef(RidFromToken(tkClass), &ridClsEnd));
-            mdMethodDef tkFoundMethod = 0;
-            DWORD dwFoundMethodFlags = 0;
-            // Check among methods
-            hr = ImportHelper::FindMethod(pMiniMd, tkClass, szName, pSig, cbSig, &tkFoundMethod, 0);
-            if(SUCCEEDED(hr))
-            {
-                MethodRec * pMethod;
-                IfFailRet(pMiniMd->GetMethodRecord(RidFromToken(tkFoundMethod), &pMethod));
-                if(pMethod)
-                {
-                    dwFoundMethodFlags = pMiniMd->getFlagsOfMethod(pMethod);
-                    if(IsMdVirtual(dwFoundMethodFlags)) //&&!IsMdNewSlot(dwFoundMethodFlags))
-                        numImpl = 1;
-                }
-            }
-            if (numImpl==0) //if(hr == CLDB_E_RECORD_NOTFOUND)
-            { // Check among MethodImpls
-                RID ridImpl;
-                for(RID idxCls = ridClsStart; idxCls < ridClsEnd; idxCls++)
-                {
-                    RID ridCls;
-                    IfFailRet(pMiniMd->GetMethodRid(idxCls, &ridCls));
-    
-                    hr = ImportHelper::FindMethodImpl(pMiniMd,tkClass,TokenFromRid(ridCls,mdtMethodDef),
-                        tkMethod,&ridImpl);
-                    if(hr != CLDB_E_RECORD_NOTFOUND)
-                    { 
-                        if(SUCCEEDED(hr)) numImpl++;
-                        break; 
-                    }
-                }
-                if(numImpl == 0)
-                {
-                    // Check if parent class implements this method
-                    mdToken tkParent = pMiniMd->getExtendsOfTypeDef(pClass);
-                    if(RidFromToken(tkParent))
-                           numImpl = IsMethodImplementedByClass(pMiniMd,tkMethod,szName,pSig,cbSig,tkParent);
-                }
-            }
-        }
-        else if (TypeFromToken(tkClass) == mdtTypeRef)
-        {
-            TypeRefRec  *pRecord;               // TypeRef record.
-            LPCSTR      szTRNamespace;          // TypeRef Namespace.
-            LPCSTR      szTRName;               // TypeRef Name.
-
-            // Get the TypeRef record.
-            IfFailRet(pMiniMd->GetTypeRefRecord(RidFromToken(tkClass), &pRecord));
-        
-            // Check name is not NULL.
-            IfFailRet(pMiniMd->getNamespaceOfTypeRef(pRecord, &szTRNamespace));
-            IfFailRet(pMiniMd->getNameOfTypeRef(pRecord, &szTRName));
-            
-            mdToken tkRefScope = pMiniMd->getResolutionScopeOfTypeRef(pRecord);
-            if (tkRefScope == TokenFromRid(1, mdtModule))
-            {
-                // if the typeref is referring to a type in this module then
-                // we should check the type definition it is referring to
-                mdTypeDef tkTypeDef;
-                hr = ImportHelper::FindTypeDefByName(pMiniMd, szTRNamespace, szTRName, tkRefScope, &tkTypeDef);
-                if (SUCCEEDED(hr))
-                    numImpl = IsMethodImplementedByClass(pMiniMd, tkMethod, szName, pSig, cbSig, tkTypeDef);
-            }
-            else if ((strcmp(szTRNamespace, BASE_NAMESPACE) == 0) && 
-                      ((strcmp(szTRName, BASE_OBJECT_CLASSNAME) == 0) || 
-                       (strcmp(szTRName, BASE_VTYPE_CLASSNAME) == 0) || 
-                       (strcmp(szTRName, BASE_ENUM_CLASSNAME) == 0)))
-            {
-                if (((strcmp(szName, SYSTEM_OBJECT_TOSTRING_METHODNAME) == 0) && 
-                     (cbSig == _countof(g_sigSystemObject_ToString)) && 
-                     (memcmp(pSig, g_sigSystemObject_ToString, cbSig) == 0)) || 
-                    ((strcmp(szName, SYSTEM_OBJECT_GETHASHCODE_METHODNAME) == 0) && 
-                     (cbSig == _countof(g_sigSystemObject_GetHashCode)) && 
-                     (memcmp(pSig, g_sigSystemObject_GetHashCode, cbSig) == 0)) || 
-                    ((strcmp(szName, SYSTEM_OBJECT_EQUALS_METHODNAME) == 0) && 
-                     (cbSig == _countof(g_sigSystemObject_Equals)) && 
-                     (memcmp(pSig, g_sigSystemObject_Equals, cbSig) == 0)))
-                {
-                    numImpl = 1; // Method signature matches one of System.Object's virtual methods
-                }
-                else
-                {
-                    numImpl = 0; // These classes (System.Object, System.ValueType and System.Enum) don't implement any other virtual methods
-                }
-            }
-            else
-            {
-                numImpl = -1; // The method is defined in another module, we cannot verify it (no external modules are loaded)
-            }
-        }
-    }
-    return numImpl;
-}
-
-//*****************************************************************************
-// Validate the given InterfaceImpl.
-//*****************************************************************************
-//@todo GENERICS: complete logic for type specs 
-// - for now, we just allow them, but we should be checking more properties
-HRESULT RegMeta::ValidateInterfaceImpl(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    InterfaceImplRec *pRecord;          // InterfaceImpl record.
-    mdTypeDef   tkClass;                // Class implementing the interface.
-    mdToken     tkInterface;            // TypeDef for the interface.
-    mdInterfaceImpl tkInterfaceImpl;    // Duplicate InterfaceImpl.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    BOOL        fCheckTheMethods=TRUE;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    // Get the InterfaceImpl record.
-    veCtxt.Token = TokenFromRid(rid, mdtInterfaceImpl);
-    veCtxt.uOffset = 0;
-
-    IfFailGo(pMiniMd->GetInterfaceImplRecord(rid, &pRecord));
-
-    // Get implementing Class and the TypeDef for the interface.
-    tkClass = pMiniMd->getClassOfInterfaceImpl(pRecord);
-
-    // No validation needs to be done on deleted records.
-    if (IsNilToken(tkClass))
-        goto ErrExit;
-
-    tkInterface = pMiniMd->getInterfaceOfInterfaceImpl(pRecord);
-
-    // Validate that the Class is TypeDef.
-    if((!IsValidToken(tkClass))||(TypeFromToken(tkClass) != mdtTypeDef)/*&&(TypeFromToken(tkClass) != mdtTypeRef)*/)
-    {
-        REPORT_ERROR1(VLDTR_E_IFACE_BADIMPL, tkClass);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        fCheckTheMethods = FALSE;
-    }
-    // Validate that the Interface is TypeDef or TypeRef or TypeSpec
-    if((!IsValidToken(tkInterface))||(TypeFromToken(tkInterface) != mdtTypeDef)&&(TypeFromToken(tkInterface) != mdtTypeRef)
-        &&(TypeFromToken(tkInterface) != mdtTypeSpec))
-    {
-        REPORT_ERROR1(VLDTR_E_IFACE_BADIFACE, tkInterface);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        fCheckTheMethods = FALSE;
-    }
-    // Validate that Interface is marked tdInterface.
-    else if(TypeFromToken(tkInterface) == mdtTypeDef)
-    {
-        TypeDefRec *pTDRec;
-        IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkInterface), &pTDRec));
-        if(!IsTdInterface(pTDRec->GetFlags()))
-        {
-            REPORT_ERROR1(VLDTR_E_IFACE_NOTIFACE, tkInterface);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        
-    }
-
-    // Look for duplicates.
-    hr = ImportHelper::FindInterfaceImpl(pMiniMd, tkClass, tkInterface,
-                                         &tkInterfaceImpl, rid);
-    if (hr == S_OK)
-    {
-        REPORT_ERROR1(VLDTR_E_IFACE_DUP, tkInterfaceImpl);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else if (hr == CLDB_E_RECORD_NOTFOUND)
-        hr = S_OK;
-    else
-        IfFailGo(hr);
-
-    // Validate that the Class (if not interface or abstract) implements all the methods of Interface
-    if((TypeFromToken(tkInterface) == mdtTypeDef) && fCheckTheMethods && (tkInterface != tkClass))
-    {
-        TypeDefRec *pClass;
-        IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkClass), &pClass));
-        if(!(IsTdAbstract(pClass->GetFlags())
-             ||IsTdImport(pClass->GetFlags())
-             ||IsTdInterface(pClass->GetFlags())))
-        {
-            TypeDefRec *pInterface;
-            IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkInterface), &pInterface));
-            RID ridIntStart = pMiniMd->getMethodListOfTypeDef(pInterface);
-            RID ridIntEnd;
-            IfFailGo(pMiniMd->getEndMethodListOfTypeDef(RidFromToken(tkInterface), &ridIntEnd));
-            MethodRec*  pIntMethod;
-            for(RID idxInt = ridIntStart; idxInt < ridIntEnd; idxInt++)
-            {
-                RID ridInt;
-                IfFailGo(pMiniMd->GetMethodRid(idxInt, &ridInt));
-                IfFailGo(pMiniMd->GetMethodRecord(ridInt, &pIntMethod));
-                const char* szName;
-                IfFailGo(pMiniMd->getNameOfMethod(pIntMethod, &szName));
-                if(!IsMdStatic(pIntMethod->GetFlags()) 
-                    && !IsDeletedName(szName) 
-                    && !IsVtblGapName(szName))
-                {
-                ULONG       cbSig;
-                PCCOR_SIGNATURE pSig;
-                IfFailGo(pMiniMd->getSignatureOfMethod(pIntMethod, &pSig, &cbSig));
-                if(cbSig)
-                {
-                        int num = IsMethodImplementedByClass(pMiniMd,TokenFromRid(ridInt,mdtMethodDef),szName,pSig,cbSig,tkClass);
-                        if(num == 0) 
-                        { // Error: method not implemented
-                            REPORT_ERROR3(VLDTR_E_IFACE_METHNOTIMPL, tkClass, tkInterface, TokenFromRid(ridInt,mdtMethodDef));
-                            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                        }
-                        if(num == -1)
-                        {
-                            // Traced to a TypeRef, which might implement the method, give warning
-                            REPORT_ERROR3(VLDTR_E_IFACE_METHNOTIMPLTHISMOD, tkClass, tkInterface, TokenFromRid(ridInt,mdtMethodDef));
-                            SetVldtrCode(&hrSave, VLDTR_S_WRN);
-                        }
-                        if(num > 1) 
-                        { // Error: multiple method implementation
-                            REPORT_ERROR3(VLDTR_E_IFACE_METHMULTIMPL, tkClass, tkInterface, TokenFromRid(ridInt,mdtMethodDef));
-                            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                        }
-                }
-            }
-        }
-    }
-    }
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateInterfaceImpl()
-
-//*****************************************************************************
-// Validate the given GenericParam.
-//*****************************************************************************
-HRESULT RegMeta::ValidateGenericParam(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    GenericParamRec *pRecord;           // GenericParam record.
-    LPCSTR      szName;                 // GenericParam name field.
-    mdToken     tkOwner;                // GenericParam owner field.
-    ULONG       ulNumber;                 // GenericParam number field.
-    DWORD       dwFlags;                  // GenericParam flags field
-
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    // Get the GenericParam record.
-    veCtxt.Token = TokenFromRid(rid, mdtGenericParam);
-    veCtxt.uOffset = 0;
-    IfFailGo(pMiniMd->GetGenericParamRecord(rid, &pRecord));
-
-    // 1. GenericParam may contain zero or more rows.
-    // (Nothing to check.)
-
-    tkOwner = pMiniMd->getOwnerOfGenericParam(pRecord);
-    // 2. Owner must be a valid token and a type def or method def 
-    // (Already checked by ValidateRecord)
-
-    // CLR tolerates Nil owners, ECMA does not
-    if(IsNilToken(tkOwner)) 
-    {
-        REPORT_ERROR0(VLDTR_E_GP_OWNERNIL); 
-        SetVldtrCode(&hrSave, VLDTR_S_WRN);
-    }
-   
-    //3. Every generic type shall own one row in the Generic Param table for each of its type parameters. [ERROR]
-    // (Nothing to check, as the arity of a generic type is, by definition, the number of generic param entries).
-
-    //4. Every generic method shall own one row in the Generic Param table for each of its type parameters. [ERROR]
-    // (This is checked in ValidateMethodSig, error VLDTR_E_MD_GPMISMATCH).
-
-    ulNumber = pMiniMd->getNumberOfGenericParam(pRecord);
-
-    // 5. Flags must be valid
-    {
-        DWORD dwInvalidMask, dwExtraBits;
-
-        dwFlags = pMiniMd->getFlagsOfGenericParam(pRecord);
-
-
-        // check for extra bits
-        dwInvalidMask = (DWORD)~(gpVarianceMask|gpSpecialConstraintMask); 
-        dwExtraBits = dwFlags & dwInvalidMask;
-        if(dwExtraBits)
-        {
-            //@GENERICS: we could use a custom error,
-            // but this is one is already used in more than one context.
-            REPORT_ERROR1(VLDTR_E_TD_EXTRAFLAGS, dwExtraBits); 
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-
-        //Check Variance
-        { 
-            DWORD dwVariance = dwFlags & gpVarianceMask;
-            switch (dwVariance)
-            {
-                case gpNonVariant: 
-                    // always ok
-                    break;
-                case gpCovariant:
-                case gpContravariant:
-                    if (TypeFromToken(tkOwner)==mdtTypeDef)
-                    {
-                        if (IsNilToken(tkOwner))
-                            break;
-                        TypeDefRec *pTypeDefRec;
-                        IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkOwner), &pTypeDefRec));
-                        // co-contra variance only legal on interfaces and delegates
-                        // If owner is not an interface and does not extend MultiCastDelegate, report an error
-                        if(!IsTdInterface(pTypeDefRec->GetFlags()))
-                        {
-                            // Get the parent of the TypeDef.
-                            mdToken tkExtends = pMiniMd->getExtendsOfTypeDef(pTypeDefRec);
-                            LPCSTR      szExtName = NULL;       // Parent Name.
-                            LPCSTR      szExtNameSpace = NULL;  // Parent NameSpace.
-                            BOOL bExtendsMCDelegate = FALSE;
-                            
-                            // Determine if the parent is MCDelegate
-                            if (TypeFromToken(tkExtends) != mdtTypeSpec) 
-                            {
-                                if (TypeFromToken(tkExtends) == mdtTypeRef)
-                                {
-                                    TypeRefRec *pExtTypeRefRec;
-                                    IfFailGo(pMiniMd->GetTypeRefRecord(RidFromToken(tkExtends), &pExtTypeRefRec));
-                                    mdToken tkResScope = pMiniMd->getResolutionScopeOfTypeRef(pExtTypeRefRec);
-                                    if (RidFromToken(tkResScope) && (TypeFromToken(tkResScope) == mdtAssemblyRef))
-                                    {
-                                        AssemblyRefRec * pARRec;
-                                        IfFailGo(pMiniMd->GetAssemblyRefRecord(RidFromToken(tkResScope), &pARRec));
-                                        LPCSTR szAssemblyRefName;
-                                        IfFailGo(pMiniMd->getNameOfAssemblyRef(pARRec, &szAssemblyRefName));
-                                        if ((0 == SString::_stricmp("mscorlib", szAssemblyRefName)) || (0 == SString::_stricmp("System.Runtime", szAssemblyRefName)))
-                                        // otherwise don't even bother extracting the name
-                                        {
-                                            IfFailGo(pMiniMd->getNameOfTypeRef(pExtTypeRefRec, &szExtName));
-                                            IfFailGo(pMiniMd->getNamespaceOfTypeRef(pExtTypeRefRec, &szExtNameSpace));
-                                        }
-                                    }
-                                }
-                                else if (TypeFromToken(tkExtends) == mdtTypeDef)
-                                {
-                                    if (g_fValidatingMscorlib) // otherwise don't even bother extracting the name
-                                    {
-                                        TypeDefRec * pExtTypeRefRec;
-                                        IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkExtends), &pExtTypeRefRec));
-                                        IfFailGo(pMiniMd->getNameOfTypeDef(pExtTypeRefRec, &szExtName));
-                                        IfFailGo(pMiniMd->getNamespaceOfTypeDef(pExtTypeRefRec, &szExtNameSpace));
-                                    }
-                                }
-                                
-                                bExtendsMCDelegate  = 
-                                    szExtNameSpace && szExtName && 
-                                    (0 == strcmp(szExtNameSpace,BASE_NAMESPACE)) && 
-                                    (0 == strcmp(szExtName,BASE_MCDELEGATE_CLASSNAME));
-                            }
-                      
-                            // Report any error
-                            if (!bExtendsMCDelegate)
-                            {
-                                REPORT_ERROR1(VLDTR_E_GP_UNEXPECTED_OWNER_FOR_VARIANT_VAR,tkOwner);
-                                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                            }
-                        }
-                    }
-                    else
-                    {
-                        // co-contra variance never legal on MVARs
-                        REPORT_ERROR0(VLDTR_E_GP_ILLEGAL_VARIANT_MVAR);
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-                    break;
-                default:
-                    REPORT_ERROR1(VLDTR_E_GP_ILLEGAL_VARIANCE_FLAGS,dwFlags); 
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    break;
-            }
-        }
-        
-        // Check special constraints
-        { 
-            DWORD dwSpecialConstraints = dwFlags & gpSpecialConstraintMask;
-            // It is illegal go declare both gpNotNullableValueTypeConstraint
-            // and gpReferenceTypeConstraint, but gpDefaultConstructorConstraint
-            // is legal with either (or neither).
-            if ((dwSpecialConstraints & (gpReferenceTypeConstraint | gpNotNullableValueTypeConstraint)) == 
-                (gpReferenceTypeConstraint | gpNotNullableValueTypeConstraint))
-            {
-                    REPORT_ERROR1(VLDTR_E_GP_REFANDVALUETYPE,dwFlags); 
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-    }
-
-    // 6. Number shall have a value >=0 and < number of type parameters in owner type or method.
-    // 7. Successive rows of the GenericParam table that are owned by the same method (sic) (owner?) shall
-    //    be ordered by increasing Number value; there can be no gaps in the Number sequence.
-    {
-        if(ulNumber>0)
-        {  if(rid==1)
-           {
-               REPORT_ERROR0(VLDTR_E_GP_NONSEQ_BY_NUMBER);
-               SetVldtrCode(&hrSave, VLDTR_S_ERR);
-           }
-           else 
-           {
-               GenericParamRec *pPredRecord;
-               IfFailGo(pMiniMd->GetGenericParamRecord(rid-1, &pPredRecord));
-               mdToken tkPredOwner = pMiniMd->getOwnerOfGenericParam(pPredRecord);
-               ULONG ulPredNumber = pMiniMd->getNumberOfGenericParam(pPredRecord);
-               if (tkPredOwner != tkOwner) 
-               {
-                   REPORT_ERROR0(VLDTR_E_GP_NONSEQ_BY_OWNER);
-                   SetVldtrCode(&hrSave, VLDTR_S_ERR);
-               }
-               if (ulPredNumber != ulNumber-1) 
-               {
-                   REPORT_ERROR0(VLDTR_E_GP_NONSEQ_BY_NUMBER);
-                   SetVldtrCode(&hrSave, VLDTR_S_ERR);
-               }
-           }
-        }
-    }
-
-    // 8. Name must be non-null and not too long 
-    IfFailGo(pMiniMd->getNameOfGenericParam(pRecord, &szName));
-    if (!*szName)
-    {
-        // name is NULL.
-        REPORT_ERROR0(VLDTR_E_GP_NAMENULL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else
-    {
-        if(!strcmp(szName,COR_DELETED_NAME_A)) goto ErrExit; //@GENERICS: do we allow parameters to be deleted?
-        ULONG L = (ULONG)strlen(szName);
-        if(L >= MAX_CLASSNAME_LENGTH)
-        {
-            REPORT_ERROR2(VLDTR_E_TD_NAMETOOLONG, L, (ULONG)(MAX_CLASSNAME_LENGTH-1));
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-#ifdef THIS_RULE_IS_DISABLED_BECAUSE_CSHARP_EMITS_DUP_NAMES_AND_DOESNT_WANT_TO_STOP
-    // 9. There shall be no duplicates based upon Owner and Name
-    if (szName)
-    {
-        mdGenericParam tkDupGenericParam;
-        hr = ImportHelper::FindGenericParamByOwner(pMiniMd, tkOwner, szName, NULL, &tkDupGenericParam, rid);
-        if (hr == S_OK)
-        {
-            REPORT_ERROR1(VLDTR_E_GP_DUPNAME, tkDupGenericParam);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-            hr = S_OK;
-        else
-            IfFailGo(hr);
-    }
-#endif
-
-    // 10. There shall be no duplicates based upon Owner and Number
-    {
-        mdGenericParam tkDupGenericParam;
-        hr = ImportHelper::FindGenericParamByOwner(pMiniMd, tkOwner, NULL, &ulNumber, &tkDupGenericParam, rid);
-        if (hr == S_OK)
-        {
-            REPORT_ERROR1(VLDTR_E_GP_DUPNUMBER, tkDupGenericParam);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-            hr = S_OK;
-        else
-            IfFailGo(hr);
-    }
-
-    hr = hrSave;
-
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateGenericParam()
-
-//*****************************************************************************
-// Validate the given MemberRef.
-//*****************************************************************************
-HRESULT RegMeta::ValidateMemberRef(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    MemberRefRec *pRecord;              // MemberRef record.
-    mdMemberRef tkMemberRef;            // Duplicate MemberRef.
-    mdToken     tkClass;                // MemberRef parent.
-    LPCSTR      szName;                 // MemberRef name.
-    PCCOR_SIGNATURE pbSig;              // MemberRef signature.
-    PCCOR_SIGNATURE pbSigTmp;           // Temp copy of pbSig, so that can be changed.
-    ULONG       cbSig;                  // Size of sig in bytes.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    // Get the MemberRef record.
-    veCtxt.Token = TokenFromRid(rid, mdtMemberRef);
-    veCtxt.uOffset = 0;
-
-    IfFailGo(pMiniMd->GetMemberRefRecord(rid, &pRecord));
-
-    // Do checks for name validity.
-    IfFailGo(pMiniMd->getNameOfMemberRef(pRecord, &szName));
-    if (!*szName)
-    {
-        REPORT_ERROR0(VLDTR_E_MR_NAMENULL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else 
-    {
-        if (IsVtblGapName(szName))
-        {
-            REPORT_ERROR0(VLDTR_E_MR_VTBLNAME);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (IsDeletedName(szName))
-        {
-            REPORT_ERROR0(VLDTR_E_MR_DELNAME);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        ULONG L = (ULONG)strlen(szName);
-        if(L >= MAX_CLASSNAME_LENGTH)
-        {
-            // Name too long
-            REPORT_ERROR2(VLDTR_E_TD_NAMETOOLONG, L, (ULONG)(MAX_CLASSNAME_LENGTH-1));
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    // MemberRef parent should never be nil in a PE file.
-    tkClass = pMiniMd->getClassOfMemberRef(pRecord);
-    if (m_ModuleType == ValidatorModuleTypePE && IsNilToken(tkClass))
-    {
-        REPORT_ERROR0(VLDTR_E_MR_PARNIL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Verify that the signature is a valid signature as per signature spec.
-    IfFailGo(pMiniMd->getSignatureOfMemberRef(pRecord, &pbSig, &cbSig));
-
-    // Do some semantic checks based on the signature.
-    if (hr == S_OK)
-    {
-        ULONG   ulCallingConv;
-        ULONG   ulArgCount;
-        ULONG   ulTyArgCount = 0;
-        ULONG   ulCurByte = 0;
-
-        // Extract calling convention.
-        pbSigTmp = pbSig;
-        ulCurByte += CorSigUncompressedDataSize(pbSigTmp);
-        ulCallingConv = CorSigUncompressData(pbSigTmp);
-
-        // Get the type argument count
-        if (ulCallingConv & IMAGE_CEE_CS_CALLCONV_GENERIC)
-        {
-            ulCurByte += CorSigUncompressedDataSize(pbSigTmp);
-            ulTyArgCount = CorSigUncompressData(pbSigTmp);
-        }
-
-        // Get the argument count.
-        ulCurByte += CorSigUncompressedDataSize(pbSigTmp);
-        ulArgCount = CorSigUncompressData(pbSigTmp);
-
-        // Calling convention must be one of IMAGE_CEE_CS_CALLCONV_DEFAULT,
-        // IMAGE_CEE_CS_CALLCONV_VARARG or IMAGE_CEE_CS_CALLCONV_FIELD.
-        if (!isCallConv(ulCallingConv, IMAGE_CEE_CS_CALLCONV_DEFAULT) &&
-            !isCallConv(ulCallingConv, IMAGE_CEE_CS_CALLCONV_VARARG) &&
-            !isCallConv(ulCallingConv, IMAGE_CEE_CS_CALLCONV_FIELD))
-        {
-            REPORT_ERROR1(VLDTR_E_MR_BADCALLINGCONV, ulCallingConv);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // [CLS] Calling convention must not be VARARG
-        if(isCallConv(ulCallingConv, IMAGE_CEE_CS_CALLCONV_VARARG))
-        {
-            REPORT_ERROR0(VLDTR_E_MR_VARARGCALLINGCONV);
-            SetVldtrCode(&hrSave, VLDTR_S_WRN);
-        }
-        
-        // If the parent is a MethodDef...
-        if (TypeFromToken(tkClass) == mdtMethodDef)
-        {
-            if (RidFromToken(tkClass) != 0)
-            {
-                // The MethodDef must be the same name and the fixed part of the
-                // vararg signature must be the same.
-                MethodRec   *pMethodRecord;     // Method Record.
-                LPCSTR      szMethodName;       // Method name.
-                PCCOR_SIGNATURE pbMethodSig;    // Method signature.
-                ULONG       cbMethodSig;        // Size in bytes of signature.
-                
-                // Get Method record, name and signature.
-                IfFailGo(pMiniMd->GetMethodRecord(RidFromToken(tkClass), &pMethodRecord));
-                IfFailGo(pMiniMd->getNameOfMethod(pMethodRecord, &szMethodName));
-                IfFailGo(pMiniMd->getSignatureOfMethod(pMethodRecord, &pbMethodSig, &cbMethodSig));
-                
-                // Verify that the name of the Method is the same as the MemberRef.
-                if (strcmp(szName, szMethodName))
-                {
-                    REPORT_ERROR1(VLDTR_E_MR_NAMEDIFF, tkClass);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                
-                if (isCallConv(ulCallingConv, IMAGE_CEE_CS_CALLCONV_VARARG))
-                {   // It's VARARG calling convention
-                    CQuickBytes qbFixedSig;         // Quick bytes to hold the fixed part of the variable signature.
-                    ULONG       cbFixedSig;         // Size in bytes of the fixed part.
-                    
-                    // Get the fixed part of the vararg signature of the MemberRef.
-                    hr = _GetFixedSigOfVarArg(pbSig, cbSig, &qbFixedSig, &cbFixedSig);
-                    if (FAILED(hr) || cbFixedSig != cbMethodSig ||
-                        memcmp(pbMethodSig, qbFixedSig.Ptr(), cbFixedSig))
-                    {
-                        UnifiedAssemblySigComparer uasc(*this);
-                        MDSigComparer sc(MDSigParser(pbMethodSig, cbMethodSig),
-                                         MDSigParser((PCCOR_SIGNATURE)qbFixedSig.Ptr(), cbFixedSig),
-                                         uasc);
-                        
-                        hr = sc.CompareMethodSignature();
-                        if (FAILED(hr))
-                        {
-                            hr = S_OK;
-                            REPORT_ERROR1(VLDTR_E_MR_SIGDIFF, tkClass);
-                            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                        }
-                    }
-                }
-                else
-                {   // It's not VARARG calling convention - a MemberRef is referencing MethodDef (part of 
-                    // NoPIA)
-                    UnifiedAssemblySigComparer uasc(*this);
-                    MDSigComparer sc(MDSigParser(pbMethodSig, cbMethodSig), 
-                                     MDSigParser(pbSig, cbSig), 
-                                     uasc);
-                    
-                    // Compare signatures
-                    hr = sc.CompareMethodSignature();
-                    if (FAILED(hr))
-                    {
-                        hr = S_OK;
-                        REPORT_ERROR1(VLDTR_E_MR_SIGDIFF, tkClass);
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-                }
-            }
-        }
-        
-        // There should be no duplicate MemberRefs.
-        if (*szName && pbSig && cbSig)
-        {
-            hr = ImportHelper::FindMemberRef(pMiniMd, tkClass, szName, pbSig,
-                                             cbSig, &tkMemberRef, rid, 
-                                             ImportHelper::CreateHash); // Optimize for multiple calls
-            if (hr == S_OK)
-            {
-                REPORT_ERROR1(VLDTR_E_MR_DUP, tkMemberRef);
-                SetVldtrCode(&hrSave, VLDTR_S_WRN);
-            }
-            else if (hr == CLDB_E_RECORD_NOTFOUND)
-            {
-                hr = S_OK;
-            }
-            else
-            {
-                IfFailGo(hr);
-            }
-        }
-
-        if (!isCallConv(ulCallingConv, IMAGE_CEE_CS_CALLCONV_FIELD))
-        {
-            hr = ValidateMethodSig(veCtxt.Token,pbSig, cbSig,0);
-            SetVldtrCode(&hrSave,hr);
-        }
-    }
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateMemberRef()
-
-//*****************************************************************************
-// Validate the given Constant.
-//*****************************************************************************
-HRESULT RegMeta::ValidateConstant(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    ConstantRec *pRecord;              // Constant record.
-    mdToken     tkParent;              // Constant parent.
-    const VOID* pbBlob;                 // Constant value blob ptr
-    DWORD       cbBlob;                 // Constant value blob size
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    // Get the MemberRef record.
-    veCtxt.Token = rid;
-    veCtxt.uOffset = 0;
-
-    ULONG maxrid = 0;
-    ULONG typ = 0;
-    IfFailGo(pMiniMd->GetConstantRecord(rid, &pRecord));
-    IfFailGo(pMiniMd->getValueOfConstant(pRecord, (const BYTE **)&pbBlob, &cbBlob));
-    switch(pRecord->GetType())
-    {
-        case ELEMENT_TYPE_BOOLEAN:
-        case ELEMENT_TYPE_CHAR:
-        case ELEMENT_TYPE_I1:
-        case ELEMENT_TYPE_U1:
-        case ELEMENT_TYPE_I2:
-        case ELEMENT_TYPE_U2:
-        case ELEMENT_TYPE_I4:
-        case ELEMENT_TYPE_U4:
-        case ELEMENT_TYPE_R4:
-        case ELEMENT_TYPE_I8:
-        case ELEMENT_TYPE_U8:
-        case ELEMENT_TYPE_R8:
-            if(pbBlob == NULL)
-            {
-                REPORT_ERROR1(VLDTR_E_CN_BLOBNULL, pRecord->GetType());
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        case ELEMENT_TYPE_STRING:
-            break;
-
-        case ELEMENT_TYPE_CLASS:
-            if(GET_UNALIGNED_32(pbBlob) != 0)
-            {
-                REPORT_ERROR1(VLDTR_E_CN_BLOBNOTNULL, pRecord->GetType());
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            break;
-
-        default:
-            REPORT_ERROR1(VLDTR_E_CN_BADTYPE, pRecord->GetType());
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            break;
-    }
-    tkParent = pMiniMd->getParentOfConstant(pRecord);
-    typ = TypeFromToken(tkParent);
-    switch(typ)
-    {
-        case mdtFieldDef:
-            maxrid = pMiniMd->getCountFields();
-            break;
-        case mdtParamDef:
-            maxrid = pMiniMd->getCountParams();
-            break;
-        case mdtProperty:
-            maxrid = pMiniMd->getCountPropertys();
-            break;
-    }
-    switch(typ)
-    {
-        case mdtFieldDef:
-        case mdtParamDef:
-        case mdtProperty:
-            {
-                ULONG rid_p = RidFromToken(tkParent);
-                if((0==rid_p)||(rid_p > maxrid))
-                {
-                    REPORT_ERROR1(VLDTR_E_CN_PARENTRANGE, tkParent);
-                    SetVldtrCode(&hrSave, VLDTR_S_WRN);
-                }
-                break;
-            }
-
-        default:
-            REPORT_ERROR1(VLDTR_E_CN_PARENTTYPE, tkParent);
-            SetVldtrCode(&hrSave, VLDTR_S_WRN);
-            break;
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateConstant()
-
-//*****************************************************************************
-// Validate the given CustomAttribute.
-//*****************************************************************************
-HRESULT RegMeta::ValidateCustomAttribute(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-    
-    CustomAttributeRec *pRecord;
-    IfFailGo(pMiniMd->GetCustomAttributeRecord(rid, &pRecord));
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    veCtxt.Token = TokenFromRid(rid,mdtCustomAttribute);
-    veCtxt.uOffset = 0;
-
-    if (pRecord != NULL)
-    {
-        mdToken     tkOwner = pMiniMd->getParentOfCustomAttribute(pRecord);
-        if(RidFromToken(tkOwner))
-        { // if 0, it's deleted CA, don't pay attention
-            mdToken     tkCAType = pMiniMd->getTypeOfCustomAttribute(pRecord);
-            DWORD       cbValue=0;
-            const BYTE *pbValue;
-            IfFailGo(pMiniMd->getValueOfCustomAttribute(pRecord, &pbValue, &cbValue));
-            if((TypeFromToken(tkOwner)==mdtCustomAttribute)||(!IsValidToken(tkOwner)))
-            {
-                REPORT_ERROR1(VLDTR_E_CA_BADPARENT, tkOwner);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            if(((TypeFromToken(tkCAType)!=mdtMethodDef)&&(TypeFromToken(tkCAType)!=mdtMemberRef))
-                ||(!IsValidToken(tkCAType))||(RidFromToken(tkCAType)==0))
-            {
-                REPORT_ERROR1(VLDTR_E_CA_BADTYPE, tkCAType);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            else
-            { //i.e. Type is valid MethodDef or MemberRef
-                LPCUTF8 szName;
-                PCCOR_SIGNATURE pSig=NULL;
-                DWORD           cbSig=0;
-                DWORD           dwFlags=0;
-                if (TypeFromToken(tkCAType) == mdtMethodDef)
-                {
-                    MethodRec *pTypeRec;
-                    IfFailGo(pMiniMd->GetMethodRecord(RidFromToken(tkCAType), &pTypeRec));
-                    IfFailGo(pMiniMd->getNameOfMethod(pTypeRec, &szName));
-                    IfFailGo(pMiniMd->getSignatureOfMethod(pTypeRec, &pSig, &cbSig));
-                    dwFlags = pTypeRec->GetFlags();
-                }
-                else // it can be only MemberRef, otherwise we wouldn't be here
-                {
-                    MemberRefRec *pTypeRec;
-                    IfFailGo(pMiniMd->GetMemberRefRecord(RidFromToken(tkCAType), &pTypeRec));
-                    IfFailGo(pMiniMd->getNameOfMemberRef(pTypeRec, &szName));
-                    IfFailGo(pMiniMd->getSignatureOfMemberRef(pTypeRec, &pSig, &cbSig));
-                }
-                if (strcmp(szName, ".ctor") != 0)
-                {
-                    REPORT_ERROR1(VLDTR_E_CA_NOTCTOR, tkCAType);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                if ((cbSig > 0) && (pSig != NULL))
-                {
-                    if(FAILED(ValidateMethodSig(tkCAType, pSig,cbSig,dwFlags))
-                        || (!((*pSig) & IMAGE_CEE_CS_CALLCONV_HASTHIS)))
-                    {
-                        REPORT_ERROR1(VLDTR_E_CA_BADSIG, tkCAType);
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-                    else
-                    { // sig seems to be OK
-                        if ((pbValue != NULL) && (cbValue > 0))
-                        {
-                            // Check if prolog is OK
-                            WORD pW = *((UNALIGNED WORD*)pbValue);
-                            if(pW != 0x0001)
-                            {
-                                REPORT_ERROR1(VLDTR_E_CA_BADPROLOG, pW);
-                                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                            }
-                            // Check if blob corresponds to the signature
-                        }
-                    }
-
-                }
-                else
-                {
-                    REPORT_ERROR1(VLDTR_E_CA_NOSIG, tkCAType);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            } // end if bad Type - else
-        } // end if RidFromToken(tkOwner)
-    } // end if pRecord
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateCustomAttribute()
-
-//*****************************************************************************
-// Validate the given FieldMarshal.
-//*****************************************************************************
-HRESULT RegMeta::ValidateFieldMarshal(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateFieldMarshal()
-
-//*****************************************************************************
-// Validate the given DeclSecurity.
-//*****************************************************************************
-HRESULT RegMeta::ValidateDeclSecurity(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    DeclSecurityRec *pRecord;
-    mdToken     tkOwner;                // Owner of the decl security
-    DWORD       dwAction;               // action flags
-    BOOL        bIsValidOwner = FALSE;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    IfFailGo(pMiniMd->GetDeclSecurityRecord(rid, &pRecord));
-    
-    memset(&veCtxt, 0, sizeof(VEContext));
-    
-    veCtxt.Token = TokenFromRid(rid,mdtPermission);
-    veCtxt.uOffset = 0;
-
-    // Must have a valid owner
-    tkOwner = pMiniMd->getParentOfDeclSecurity(pRecord);
-    if(RidFromToken(tkOwner)==0) goto ErrExit; // deleted record, no need to validate
-    switch(TypeFromToken(tkOwner))
-    {
-        case mdtModule:
-        case mdtAssembly:
-        case mdtTypeDef:
-        case mdtMethodDef:
-        case mdtFieldDef:
-        case mdtInterfaceImpl:
-            bIsValidOwner = IsValidToken(tkOwner);
-            break;
-        default:
-            break;
-    }
-    if(!bIsValidOwner)
-    {
-        REPORT_ERROR1(VLDTR_E_DS_BADOWNER, tkOwner);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Must have one and only one flag set
-    dwAction = pRecord->GetAction() & dclActionMask;
-    if(dwAction > dclMaximumValue) // the flags are 0,1,2,3,...,dclMaximumValue
-    {
-        REPORT_ERROR1(VLDTR_E_DS_BADFLAGS, dwAction);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // If field has DeclSecurity, verify its parent is not an interface.-- checked in ValidateField
-    // If method has DeclSecurity, verify its parent is not an interface.-- checked in ValidateMethod
-    
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateDeclSecurity()
-
-//*****************************************************************************
-// Validate the given ClassLayout.
-//*****************************************************************************
-HRESULT RegMeta::ValidateClassLayout(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    ClassLayoutRec *pRecord;            // ClassLayout record.
-    TypeDefRec  *pTypeDefRec;           // Parent TypeDef record.
-    DWORD       dwPackingSize;          // Packing size.
-    mdTypeDef   tkParent;               // Parent TypeDef token.
-    DWORD       dwTypeDefFlags;         // Parent TypeDef flags.
-    RID         clRid;                  // Duplicate ClassLayout rid.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    // Extract the record.
-    veCtxt.Token = rid;
-    veCtxt.uOffset = 0;
-    IfFailGo(pMiniMd->GetClassLayoutRecord(rid, &pRecord));
-
-    // Get the parent, if parent is nil its a deleted record.  Skip validation.
-    tkParent = pMiniMd->getParentOfClassLayout(pRecord);
-    if (IsNilToken(tkParent))
-        goto ErrExit;
-
-    // Parent should not have AutoLayout set on it.
-    IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkParent), &pTypeDefRec));
-    dwTypeDefFlags = pMiniMd->getFlagsOfTypeDef(pTypeDefRec);
-    if (IsTdAutoLayout(dwTypeDefFlags))
-    {
-        REPORT_ERROR1(VLDTR_E_CL_TDAUTO, tkParent);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Parent must not be an Interface
-    if(IsTdInterface(dwTypeDefFlags))
-    {
-        REPORT_ERROR1(VLDTR_E_CL_TDINTF, tkParent);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Validate the PackingSize.
-    dwPackingSize = pMiniMd->getPackingSizeOfClassLayout(pRecord);
-    if((dwPackingSize > 128)||((dwPackingSize & (dwPackingSize-1)) !=0 ))
-    {
-        REPORT_ERROR2(VLDTR_E_CL_BADPCKSZ, tkParent, dwPackingSize);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Validate that there are no duplicates.
-    hr = _FindClassLayout(pMiniMd, tkParent, &clRid, rid);
-    if (hr == S_OK)
-    {
-        REPORT_ERROR2(VLDTR_E_CL_DUP, tkParent, clRid);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else if (hr == CLDB_E_RECORD_NOTFOUND)
-        hr = S_OK;
-    else
-        IfFailGo(hr);
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateClassLayout()
-
-//*****************************************************************************
-// Validate the given FieldLayout.
-//*****************************************************************************
-HRESULT RegMeta::ValidateFieldLayout(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    FieldLayoutRec *pRecord;            // FieldLayout record.
-    mdFieldDef  tkField;                // Field token.
-    ULONG       ulOffset;               // Field offset.
-    FieldRec    *pFieldRec;             // Field record.
-    TypeDefRec  *pTypeDefRec;           // Parent TypeDef record.
-    mdTypeDef   tkTypeDef;              // Parent TypeDef token.
-    RID         clRid;                  // Corresponding ClassLayout token.
-    RID         flRid = 0;              // Duplicate FieldLayout rid.
-    DWORD       dwTypeDefFlags;         // Parent TypeDef flags.
-    DWORD       dwFieldFlags;           // Field flags.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    // Extract the record.
-    veCtxt.Token = rid;
-    veCtxt.uOffset = 0;
-    IfFailGo(pMiniMd->GetFieldLayoutRecord(rid, &pRecord));
-
-    // Get the field, if it's nil it's a deleted record, so just skip it.
-    tkField = pMiniMd->getFieldOfFieldLayout(pRecord);
-    if (IsNilToken(tkField))
-        goto ErrExit;
-
-    // Validate the Offset value.
-    ulOffset = pMiniMd->getOffSetOfFieldLayout(pRecord);
-    if (ulOffset == ULONG_MAX)
-    {
-        REPORT_ERROR2(VLDTR_E_FL_BADOFFSET, tkField, ulOffset);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Get the parent of the Field.
-    IfFailGo(pMiniMd->FindParentOfFieldHelper(tkField, &tkTypeDef));
-    // Validate that the parent is not nil.
-    if (IsNilToken(tkTypeDef))
-    {
-        REPORT_ERROR1(VLDTR_E_FL_TDNIL, tkField);
-        SetVldtrCode(&hr, hrSave);
-        goto ErrExit;
-    }
-
-    // Validate that there exists a ClassLayout record associated with
-    // this TypeDef.
-    IfFailGo(pMiniMd->FindClassLayoutHelper(tkTypeDef, &clRid));
-    if (InvalidRid(rid))
-    {
-        REPORT_ERROR2(VLDTR_E_FL_NOCL, tkField, tkTypeDef);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Validate that ExplicitLayout is set on the TypeDef flags.
-    IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkTypeDef), &pTypeDefRec));
-    dwTypeDefFlags = pMiniMd->getFlagsOfTypeDef(pTypeDefRec);
-    if (IsTdAutoLayout(dwTypeDefFlags))
-    {
-        REPORT_ERROR2(VLDTR_E_FL_TDNOTEXPLCT, tkField, tkTypeDef);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Extract Field record.
-    IfFailGo(pMiniMd->GetFieldRecord(RidFromToken(tkField), &pFieldRec));
-    // Validate that the field is non-static.
-    dwFieldFlags = pMiniMd->getFlagsOfField(pFieldRec);
-    if (IsFdStatic(dwFieldFlags))
-    {
-        REPORT_ERROR1(VLDTR_E_FL_FLDSTATIC, tkField);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    
-    // Look for duplicates.
-    hr = _FindFieldLayout(pMiniMd, tkField, &flRid, rid);
-    if (hr == S_OK)
-    {
-        REPORT_ERROR1(VLDTR_E_FL_DUP, flRid);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else if (hr == CLDB_E_RECORD_NOTFOUND)
-        hr = S_OK;
-    else
-        IfFailGo(hr);
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateFieldLayout()
-
-//*****************************************************************************
-// Validate the given StandAloneSig.
-//*****************************************************************************
-HRESULT RegMeta::ValidateStandAloneSig(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    StandAloneSigRec *pRecord;          // FieldLayout record.
-    PCCOR_SIGNATURE pbSig;              // Signature.
-    ULONG       cbSig;                  // Size in bytes of the signature.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    ULONG       ulCurByte = 0;          // Current index into the signature.
-    ULONG       ulCallConv;             // Calling convention.
-    ULONG       ulArgCount;             // Count of arguments.
-    ULONG       ulTyArgCount = 0;       // Count of type arguments.
-    ULONG       i;                      // Looping index.
-    ULONG       ulNSentinels = 0;       // Number of sentinels in the signature
-    BOOL        bNoVoidAllowed=TRUE;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-
-    // Extract the record.
-    veCtxt.Token = TokenFromRid(rid,mdtSignature);
-    veCtxt.uOffset = 0;
-    IfFailGo(pMiniMd->GetStandAloneSigRecord(rid, &pRecord));
-    IfFailGo(pMiniMd->getSignatureOfStandAloneSig(pRecord, &pbSig, &cbSig));
-
-    // Validate the signature is well-formed with respect to the compression
-    // scheme.  If this fails, no further validation needs to be done.
-    if ( (hr = ValidateSigCompression(veCtxt.Token, pbSig, cbSig)) != S_OK)
-        goto ErrExit;
-
-    //_ASSERTE((rid != 0x2c2)&&(rid!=0x2c8)&&(rid!=0x2c9)&&(rid!=0x2d6)&&(rid!=0x38b));
-    // Validate the calling convention.
-    ulCurByte += CorSigUncompressedDataSize(pbSig);
-    ulCallConv = CorSigUncompressData(pbSig);
-    i = ulCallConv & IMAGE_CEE_CS_CALLCONV_MASK;
-    if(i == IMAGE_CEE_CS_CALLCONV_FIELD) // <REVISIT_TODO>it's a temporary bypass (VB bug)</REVISIT_TODO>
-        ulArgCount = 1;
-    else 
-    {
-        if(i != IMAGE_CEE_CS_CALLCONV_LOCAL_SIG) // then it is function sig for calli
-        {
-            if((i >= IMAGE_CEE_CS_CALLCONV_FIELD) 
-                ||((ulCallConv & IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS)
-                &&(!(ulCallConv & IMAGE_CEE_CS_CALLCONV_HASTHIS))))
-            {
-                REPORT_ERROR1(VLDTR_E_MD_BADCALLINGCONV, ulCallConv);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            bNoVoidAllowed = FALSE;
-        }
-        // Is there any sig left for arguments?
-        _ASSERTE(ulCurByte <= cbSig);
-        if (cbSig == ulCurByte)
-        {
-            REPORT_ERROR1(VLDTR_E_MD_NOARGCNT, ulCurByte+1);
-            SetVldtrCode(&hr, hrSave);
-            goto ErrExit;
-        }
-
-        // Get the type argument count.
-        if (ulCallConv & IMAGE_CEE_CS_CALLCONV_GENERIC)
-    {
-          ulCurByte += CorSigUncompressedDataSize(pbSig);
-          ulTyArgCount = CorSigUncompressData(pbSig);
-    }
-
-        // Get the argument count.
-        ulCurByte += CorSigUncompressedDataSize(pbSig);
-        ulArgCount = CorSigUncompressData(pbSig);
-    }
-    // Validate the the arguments.
-    if(ulArgCount)
-    {
-        for(i=1; ulCurByte < cbSig; i++)
-        {
-            hr = ValidateOneArg(veCtxt.Token, pbSig, cbSig, &ulCurByte,&ulNSentinels,bNoVoidAllowed);
-            if (hr != S_OK)
-            {
-                if(hr == VLDTR_E_SIG_MISSARG)
-                {
-                    REPORT_ERROR1(VLDTR_E_SIG_MISSARG, i);
-                }
-                SetVldtrCode(&hr, hrSave);
-                hrSave = hr;
-                break;
-            }
-            bNoVoidAllowed = TRUE; // whatever it was for the 1st arg, it must be TRUE for the rest
-        }
-        if((ulNSentinels != 0) && (!isCallConv(ulCallConv, IMAGE_CEE_CS_CALLCONV_VARARG )))
-        {
-            REPORT_ERROR0(VLDTR_E_SIG_SENTMUSTVARARG);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        if(ulNSentinels > 1)
-        {
-            REPORT_ERROR0(VLDTR_E_SIG_MULTSENTINELS);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateStandAloneSig()
-
-//*****************************************************************************
-// Validate the given EventMap.
-//*****************************************************************************
-HRESULT RegMeta::ValidateEventMap(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateEventMap()
-
-//*****************************************************************************
-// Validate the given EventPtr.
-//*****************************************************************************
-HRESULT RegMeta::ValidateEventPtr(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateEventPtr()
-
-//*****************************************************************************
-// Validate the given Event.
-//*****************************************************************************
-HRESULT RegMeta::ValidateEvent(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    mdToken     tkClass;                // Declaring TypeDef
-    mdToken     tkEventType;            // Event Type (TypeDef/TypeRef)
-    EventRec *pRecord;
-    HENUMInternal hEnum;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    IfFailGo(pMiniMd->GetEventRecord(rid, &pRecord));
-    
-    memset(&veCtxt, 0, sizeof(VEContext));
-    memset(&hEnum, 0, sizeof(HENUMInternal));
-    veCtxt.Token = TokenFromRid(rid,mdtEvent);
-    veCtxt.uOffset = 0;
-
-    // The scope must be a valid TypeDef
-    if (FAILED(pMiniMd->FindParentOfEventHelper(veCtxt.Token, &tkClass)) || 
-        (TypeFromToken(tkClass) != mdtTypeDef) || 
-        !IsValidToken(tkClass))
-    {
-        REPORT_ERROR1(VLDTR_E_EV_BADSCOPE, tkClass);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        tkClass = 0;
-    }
-    // Must have name
-    {
-        LPCUTF8 szName;
-        IfFailGo(pMiniMd->getNameOfEvent(pRecord, &szName));
-        
-        if (*szName == 0)
-        {
-            REPORT_ERROR0(VLDTR_E_EV_NONAME);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else
-        {
-            if (strcmp(szName, COR_DELETED_NAME_A) == 0)
-                goto ErrExit; 
-            if (tkClass != 0)    // Must be no duplicates
-            {
-                RID          ridEventMap;
-                EventMapRec *pEventMapRec;
-                EventRec    *pRec;
-                ULONG        ridStart;
-                ULONG        ridEnd;
-                ULONG        i;
-                
-                IfFailGo(pMiniMd->FindEventMapFor(RidFromToken(tkClass), &ridEventMap));
-                if (!InvalidRid(ridEventMap))
-                {
-                    IfFailGo(pMiniMd->GetEventMapRecord(ridEventMap, &pEventMapRec));
-                    ridStart = pMiniMd->getEventListOfEventMap(pEventMapRec);
-                    IfFailGo(pMiniMd->getEndEventListOfEventMap(ridEventMap, &ridEnd));
-                    
-                    for (i = ridStart; i < ridEnd; i++)
-                    {
-                        if (i == rid)
-                            continue;
-                        IfFailGo(pMiniMd->GetEventRecord(i, &pRec));
-                        
-                        LPCSTR szEventName;
-                        IfFailGo(pMiniMd->getNameOfEvent(pRec, &szEventName));
-                        if (strcmp(szName, szEventName) != 0)
-                            continue;
-                        
-                        REPORT_ERROR1(VLDTR_E_EV_DUP, TokenFromRid(i, mdtEvent));
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-                }
-            }
-        }
-    }// end of name block
-    // EventType must be Nil or valid TypeDef, TypeRef or TypeSpec representing an instantiated generic type
-    tkEventType = pMiniMd->getEventTypeOfEvent(pRecord);
-    if (!IsNilToken(tkEventType))
-    {
-        if(IsValidToken(tkEventType) && 
-            ((TypeFromToken(tkEventType)==mdtTypeDef)||
-             (TypeFromToken(tkEventType)==mdtTypeRef)||
-             (TypeFromToken(tkEventType)==mdtTypeSpec)))
-        {
-            // TypeSpecs can be many things, we only handle instantiated generic types currently.
-            if (TypeFromToken(tkEventType)==mdtTypeSpec)
-            {
-                TypeSpecRec *pRec;
-                IfFailGo(pMiniMd->GetTypeSpecRecord(RidFromToken(tkEventType), &pRec));
-                PCCOR_SIGNATURE pSig;
-                ULONG           cSig;
-
-                IfFailGo(pMiniMd->getSignatureOfTypeSpec(pRec, &pSig, &cSig));
-           
-                if (CorSigUncompressElementType(pSig) == ELEMENT_TYPE_GENERICINST &&
-                    CorSigUncompressElementType(pSig) == ELEMENT_TYPE_CLASS)
-                {
-                    // Just update the event type token variable and fall through to the validation code below (it doesn't care
-                    // whether the type is generic or not).
-                    tkEventType = CorSigUncompressToken(pSig);
-                }
-                else
-                {
-                    REPORT_ERROR1(VLDTR_E_EV_BADEVTYPE, tkEventType);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-
-            // EventType must not be Interface or ValueType
-            if(TypeFromToken(tkEventType)==mdtTypeDef) // can't say anything about TypeRef: no flags available!
-            {
-                TypeDefRec *pTypeDefRecord;
-                IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkEventType), &pTypeDefRecord));
-                DWORD dwFlags = pTypeDefRecord->GetFlags();
-                if(!IsTdClass(dwFlags))
-                {
-                    REPORT_ERROR2(VLDTR_E_EV_EVTYPENOTCLASS, tkEventType, dwFlags);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-        }
-        else
-        {
-            REPORT_ERROR1(VLDTR_E_EV_BADEVTYPE, tkEventType);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    // Validate related methods
-    {
-        MethodSemanticsRec *pSemantics;
-        RID         ridCur;
-        ULONG       ulSemantics;
-        mdMethodDef tkMethod;
-        bool        bHasAddOn = false;
-        bool        bHasRemoveOn = false;
-
-        IfFailGo( pMiniMd->FindMethodSemanticsHelper(veCtxt.Token, &hEnum) );
-        while (HENUMInternal::EnumNext(&hEnum, (mdToken *)&ridCur))
-        {
-            IfFailGo(pMiniMd->GetMethodSemanticsRecord(ridCur, &pSemantics));
-            ulSemantics = pMiniMd->getSemanticOfMethodSemantics(pSemantics);
-            tkMethod = TokenFromRid( pMiniMd->getMethodOfMethodSemantics(pSemantics), mdtMethodDef );
-            // Semantics must be Setter, Getter or Other
-            switch (ulSemantics)
-            {
-                case msAddOn:
-                    bHasAddOn = true;
-                    break;
-                case msRemoveOn:
-                    bHasRemoveOn = true;
-                    break;
-                case msFire:
-                case msOther:
-                    break;
-                default:
-                    REPORT_ERROR2(VLDTR_E_EV_BADSEMANTICS, tkMethod,ulSemantics);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            // Method must be valid
-            if(!IsValidToken(tkMethod))
-            {
-                REPORT_ERROR1(VLDTR_E_EV_BADMETHOD, tkMethod);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            else
-            {
-                // Method's parent must be the same
-                mdToken tkTypeDef;
-                IfFailGo(pMiniMd->FindParentOfMethodHelper(tkMethod, &tkTypeDef));
-                if(tkTypeDef != tkClass)
-                {
-                    REPORT_ERROR2(VLDTR_E_EV_ALIENMETHOD, tkMethod,tkTypeDef);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-        } // end loop over methods
-        // AddOn and RemoveOn are a must
-        if(!bHasAddOn)
-        {
-            REPORT_ERROR0(VLDTR_E_EV_NOADDON);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        if(!bHasRemoveOn)
-        {
-            REPORT_ERROR0(VLDTR_E_EV_NOREMOVEON);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }// end of related method validation block
-    
-    hr = hrSave;
-ErrExit:
-    HENUMInternal::ClearEnum(&hEnum);
-
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateEvent()
-
-
-//*****************************************************************************
-// Validate the given PropertyMap.
-//*****************************************************************************
-HRESULT RegMeta::ValidatePropertyMap(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidatePropertyMap(0
-
-//*****************************************************************************
-// Validate the given PropertyPtr.
-//*****************************************************************************
-HRESULT RegMeta::ValidatePropertyPtr(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidatePropertyPtr()
-
-//*****************************************************************************
-// Validate the given Property.
-//*****************************************************************************
-HRESULT RegMeta::ValidateProperty(RID rid)
-{
-    CMiniMdRW    *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    VEContext     veCtxt;                 // Context record.
-    HRESULT       hr = S_OK;              // Value returned.
-    HRESULT       hrSave = S_OK;          // Save state.
-    mdToken       tkClass = mdTokenNil;   // Declaring TypeDef
-    PropertyRec  *pRecord;
-    HENUMInternal hEnum;
-    RID           tempRid;
-    
-    BEGIN_ENTRYPOINT_NOTHROW;
-    
-    IfFailGo(pMiniMd->GetPropertyRecord(rid, &pRecord));
-    
-    memset(&veCtxt, 0, sizeof(VEContext));
-    memset(&hEnum, 0, sizeof(HENUMInternal));
-    veCtxt.Token = TokenFromRid(rid,mdtProperty);
-    veCtxt.uOffset = 0;
-    // The scope must be a valid TypeDef
-    IfFailGo(pMiniMd->FindParentOfPropertyHelper( veCtxt.Token, &tkClass));
-    if ((TypeFromToken(tkClass) != mdtTypeDef) || 
-        !IsValidToken(tkClass) || 
-        IsNilToken(tkClass))
-    {
-        REPORT_ERROR1(VLDTR_E_PR_BADSCOPE, tkClass);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Must have name and signature
-    {
-        ULONG           cbSig;
-        PCCOR_SIGNATURE pvSig;
-        IfFailGo(pMiniMd->getTypeOfProperty(pRecord, &pvSig, &cbSig));
-        
-        LPCUTF8 szName;
-        IfFailGo(pMiniMd->getNameOfProperty(pRecord, &szName));
-        ULONG ulNameLen = (szName != NULL) ? (ULONG)strlen(szName) : 0;
-        
-        if (ulNameLen == 0)
-        {
-            REPORT_ERROR0(VLDTR_E_PR_NONAME);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else
-        {
-            if(strcmp(szName, COR_DELETED_NAME_A) == 0)
-                goto ErrExit; 
-        }
-        if (cbSig == 0)
-        {
-            REPORT_ERROR0(VLDTR_E_PR_NOSIG);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // Must be no duplicates
-        if ((ulNameLen != 0) && (cbSig != 0))
-        {
-            RID             ridPropertyMap;
-            PropertyMapRec *pPropertyMapRec;
-            PropertyRec    *pRec;
-            ULONG           ridStart;
-            ULONG           ridEnd;
-            ULONG           i;
-            ULONG           cbSig1;
-            PCCOR_SIGNATURE pvSig1;
-            
-            IfFailGo(pMiniMd->FindPropertyMapFor(RidFromToken(tkClass), &ridPropertyMap));
-            if (!InvalidRid(ridPropertyMap) )
-            {
-                IfFailGo(pMiniMd->GetPropertyMapRecord(ridPropertyMap, &pPropertyMapRec));
-                ridStart = pMiniMd->getPropertyListOfPropertyMap(pPropertyMapRec);
-                IfFailGo(pMiniMd->getEndPropertyListOfPropertyMap(ridPropertyMap, &ridEnd));
-                
-                for (i = ridStart; i < ridEnd; i++)
-                {
-                    if (i == rid)
-                        continue;
-                    IfFailGo(pMiniMd->GetPropertyRecord(i, &pRec));
-                    IfFailGo(pMiniMd->getTypeOfProperty(pRec, &pvSig1, &cbSig1));
-                    
-                    if (cbSig != cbSig1)
-                        continue;
-                    if (memcmp(pvSig,pvSig1,cbSig) != 0)
-                        continue;
-                    
-                    LPCSTR szPropertyName;
-                    IfFailGo(pMiniMd->getNameOfProperty(pRec, &szPropertyName));
-                    if (strcmp(szName, szPropertyName) != 0)
-                        continue;
-                    
-                    REPORT_ERROR1(VLDTR_E_PR_DUP, TokenFromRid(i,mdtProperty));
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-        }
-        // Validate the signature
-        if ((pvSig != NULL) && (cbSig != 0))
-        {
-            ULONG ulCurByte = 0;          // Current index into the signature.
-            ULONG ulCallConv;             // Calling convention.
-            ULONG ulArgCount;
-            ULONG i;
-            ULONG ulNSentinels = 0;
-            
-            // Validate the calling convention.
-            ulCurByte += CorSigUncompressedDataSize(pvSig);
-            ulCallConv = CorSigUncompressData(pvSig);
-            if (!isCallConv(ulCallConv, IMAGE_CEE_CS_CALLCONV_PROPERTY ))
-            {
-                REPORT_ERROR1(VLDTR_E_PR_BADCALLINGCONV, ulCallConv);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            // Get the argument count.
-            ulCurByte += CorSigUncompressedDataSize(pvSig);
-            ulArgCount = CorSigUncompressData(pvSig);
-            
-            // Validate the arguments.
-            for (i = 0; i < ulArgCount; i++)
-            {
-                hr = ValidateOneArg(veCtxt.Token, pvSig, cbSig, &ulCurByte,&ulNSentinels,(i>0));
-                if (hr != S_OK)
-                {
-                    if (hr == VLDTR_E_SIG_MISSARG)
-                    {
-                        REPORT_ERROR1(VLDTR_E_SIG_MISSARG, i+1);
-                    }
-                    SetVldtrCode(&hr, hrSave);
-                    break;
-                }
-            }
-        }//end if(pvSig && cbSig)
-    }// end of name/signature block
-    
-    // Marked HasDefault <=> has default value
-    IfFailGo(pMiniMd->FindConstantHelper(veCtxt.Token, &tempRid));
-    if (InvalidRid(tempRid) == IsPrHasDefault(pRecord->GetPropFlags()))
-    {
-        REPORT_ERROR0(IsPrHasDefault(pRecord->GetPropFlags())? VLDTR_E_PR_MARKEDNODEFLT : VLDTR_E_PR_DEFLTNOTMARKED);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Validate related methods
-    {
-        MethodSemanticsRec *pSemantics;
-        RID         ridCur;
-        ULONG       ulSemantics;
-        mdMethodDef tkMethod;
-
-        IfFailGo( pMiniMd->FindMethodSemanticsHelper(veCtxt.Token, &hEnum) );
-        while (HENUMInternal::EnumNext(&hEnum, (mdToken *) &ridCur))
-        {
-            IfFailGo(pMiniMd->GetMethodSemanticsRecord(ridCur, &pSemantics));
-            ulSemantics = pMiniMd->getSemanticOfMethodSemantics(pSemantics);
-            tkMethod = TokenFromRid( pMiniMd->getMethodOfMethodSemantics(pSemantics), mdtMethodDef );
-            // Semantics must be Setter, Getter or Other
-            switch (ulSemantics)
-            {
-                case msSetter:
-                case msGetter:
-                case msOther:
-                    break;
-                default:
-                    REPORT_ERROR2(VLDTR_E_PR_BADSEMANTICS, tkMethod, ulSemantics);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            // Method must be valid
-            if(!IsValidToken(tkMethod))
-            {
-                REPORT_ERROR1(VLDTR_E_PR_BADMETHOD, tkMethod);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            else
-            {
-                // Method's parent must be the same
-                mdToken tkTypeDef;
-                IfFailGo(pMiniMd->FindParentOfMethodHelper(tkMethod, &tkTypeDef));
-                if(tkTypeDef != tkClass)
-                {
-                    REPORT_ERROR2(VLDTR_E_PR_ALIENMETHOD, tkMethod, tkTypeDef);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-        } // end loop over methods
-    }// end of related method validation block
-    
-    hr = hrSave;
-ErrExit:
-    HENUMInternal::ClearEnum(&hEnum);
-
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateProperty()
-
-//*****************************************************************************
-// Validate the given MethodSemantics.
-//*****************************************************************************
-HRESULT RegMeta::ValidateMethodSemantics(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateMethodSemantics()
-
-//*****************************************************************************
-// Validate the given MethodImpl.
-//*****************************************************************************
-HRESULT RegMeta::ValidateMethodImpl(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    MethodImplRec* pRecord;
-    MethodImplRec* pRec;
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    mdToken     tkClass;                // Declaring TypeDef
-    mdToken     tkBody;                 // Implementing method (MethodDef or MemberRef)
-    mdToken     tkDecl;                 // Implemented method (MethodDef or MemberRef)
-    unsigned    iCount;
-    unsigned    index;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    veCtxt.Token = TokenFromRid(rid, mdtMethodImpl);
-    veCtxt.uOffset = 0;
-
-    PCCOR_SIGNATURE     pbBodySig = NULL;
-    PCCOR_SIGNATURE     pbDeclSig = NULL;
-
-    IfFailGo(pMiniMd->GetMethodImplRecord(rid, &pRecord));
-    tkClass = pMiniMd->getClassOfMethodImpl(pRecord);
-    // Class must be valid
-    if(!IsValidToken(tkClass) || (TypeFromToken(tkClass) != mdtTypeDef))
-    {
-        REPORT_ERROR1(VLDTR_E_MI_BADCLASS, tkClass);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else
-    { // ... and not an Interface
-        TypeDefRec *pTypeDefRecord;
-        IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkClass), &pTypeDefRecord));
-        if(IsTdInterface(pTypeDefRecord->GetFlags()))
-        {
-            REPORT_ERROR1(VLDTR_E_MI_CLASSISINTF, tkClass);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    // Decl must be valid MethodDef or MemberRef
-    tkDecl = pMiniMd->getMethodDeclarationOfMethodImpl(pRecord);
-    if(!(IsValidToken(tkDecl) &&
-        ((TypeFromToken(tkDecl) == mdtMethodDef) || (TypeFromToken(tkDecl) == mdtMemberRef))))
-    {
-        REPORT_ERROR1(VLDTR_E_MI_BADDECL, tkDecl);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Body must be valid MethodDef or MemberRef
-    tkBody = pMiniMd->getMethodBodyOfMethodImpl(pRecord);
-    if(!(IsValidToken(tkBody) &&
-        ((TypeFromToken(tkBody) == mdtMethodDef) || (TypeFromToken(tkBody) == mdtMemberRef))))
-    {
-        REPORT_ERROR1(VLDTR_E_MI_BADBODY, tkBody);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // No duplicates based on (tkClass,tkDecl)
-    iCount = pMiniMd->getCountMethodImpls();
-    for(index = rid+1; index <= iCount; index++)
-    {
-        IfFailGo(pMiniMd->GetMethodImplRecord(index, &pRec));
-        if((tkClass == pMiniMd->getClassOfMethodImpl(pRec)) &&
-            (tkDecl == pMiniMd->getMethodDeclarationOfMethodImpl(pRec)))
-        {
-            REPORT_ERROR1(VLDTR_E_MI_DUP, index);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    mdToken tkBodyParent;
-    ULONG               cbBodySig;
-
-    if(TypeFromToken(tkBody) == mdtMethodDef)
-    {
-        MethodRec *pBodyRec;
-        IfFailGo(pMiniMd->GetMethodRecord(RidFromToken(tkBody), &pBodyRec));
-        IfFailGo(pMiniMd->getSignatureOfMethod(pBodyRec, &pbBodySig, &cbBodySig));
-        IfFailGo(pMiniMd->FindParentOfMethodHelper(tkBody, &tkBodyParent));
-        // Body must not be static
-        if(IsMdStatic(pBodyRec->GetFlags()))
-        {
-            REPORT_ERROR1(VLDTR_E_MI_BODYSTATIC, tkBody);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    else if(TypeFromToken(tkBody) == mdtMemberRef)
-    {
-        MemberRefRec *pBodyRec;
-        IfFailGo(pMiniMd->GetMemberRefRecord(RidFromToken(tkBody), &pBodyRec));
-        tkBodyParent = pMiniMd->getClassOfMemberRef(pBodyRec);
-        IfFailGo(pMiniMd->getSignatureOfMemberRef(pBodyRec, &pbBodySig, &cbBodySig));
-    }
-    // Body must belong to the same class
-    if(tkBodyParent != tkClass)
-    {
-        REPORT_ERROR1(VLDTR_E_MI_ALIENBODY, tkBodyParent);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    mdToken tkDeclParent;
-    ULONG               cbDeclSig;
-
-    if(TypeFromToken(tkDecl) == mdtMethodDef)
-    {
-        MethodRec *pDeclRec;
-        IfFailGo(pMiniMd->GetMethodRecord(RidFromToken(tkDecl), &pDeclRec));
-        IfFailGo(pMiniMd->getSignatureOfMethod(pDeclRec, &pbDeclSig, &cbDeclSig));
-        IfFailGo(pMiniMd->FindParentOfMethodHelper(tkDecl, &tkDeclParent));
-        // Decl must be virtual
-        if(!IsMdVirtual(pDeclRec->GetFlags()))
-        {
-            REPORT_ERROR1(VLDTR_E_MI_DECLNOTVIRT, tkDecl);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // Decl must not be final
-        if(IsMdFinal(pDeclRec->GetFlags()))
-        {
-            REPORT_ERROR1(VLDTR_E_MI_DECLFINAL, tkDecl);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // Decl must not be private
-        if(IsMdPrivate(pDeclRec->GetFlags()) && IsMdCheckAccessOnOverride(pDeclRec->GetFlags()))
-        {
-            REPORT_ERROR1(VLDTR_E_MI_DECLPRIV, tkDecl);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    else if(TypeFromToken(tkDecl) == mdtMemberRef)
-    {
-        MemberRefRec *pDeclRec;
-        IfFailGo(pMiniMd->GetMemberRefRecord(RidFromToken(tkDecl), &pDeclRec));
-        tkDeclParent = pMiniMd->getClassOfMemberRef(pDeclRec);
-        IfFailGo(pMiniMd->getSignatureOfMemberRef(pDeclRec, &pbDeclSig, &cbDeclSig));
-    }
-
-    // Compare the signatures as best we can, delegating some comparisons to the loader.
-    if (*pbBodySig & IMAGE_CEE_CS_CALLCONV_GENERIC)
-    {
-        // decl's callconv must be generic
-        if (*pbDeclSig & IMAGE_CEE_CS_CALLCONV_GENERIC)
-        {
-            // and the arities must match
-            ULONG ulBodyArity = CorSigUncompressData(++pbBodySig);
-            ULONG ulDeclArity = CorSigUncompressData(++pbDeclSig);
-            if(ulBodyArity != ulDeclArity)
-            {
-                REPORT_ERROR3(VLDTR_E_MI_ARITYMISMATCH,tkDecl,ulDeclArity,ulBodyArity);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-        else
-        {
-            REPORT_ERROR1(VLDTR_E_MI_DECLNOTGENERIC,tkDecl); 
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // delegate precise signature checking to the loader, 
-        // as this requires signature comparison modulo substitution
-    }
-    else if (*pbDeclSig & IMAGE_CEE_CS_CALLCONV_GENERIC)
-    {
-        REPORT_ERROR1(VLDTR_E_MI_IMPLNOTGENERIC,tkDecl); 
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else if (TypeFromToken(tkDeclParent) == mdtTypeSpec)
-    {
-        // do nothing for now...
-        // delegate precise signature checking to the loader, 
-        // as this requires signature comparison modulo substitution
-    }
-    // Signatures must match (except call conv)
-    else if((cbDeclSig != cbBodySig)||(memcmp(pbDeclSig+1,pbBodySig+1,cbDeclSig-1)))
-    {
-        //@GENERICSVER: todo: 
-        /*
-          //@TODO: Fix to have peverify resolve assemblies 
-          // through the runtime. At that point, use this method instead
-          // of the current compare
-
-          // @TODO: check for other bad memcmp sig comparisons in peverify
-
-        // Can't use memcmp because there may be two AssemblyRefs
-        // in this scope, pointing to the same assembly, etc.).
-        if (!MetaSig::CompareMethodSigs(pbDeclSig,
-                                        cbDeclSig,
-                                        Module*     pModule1,
-                                        pbBodySig,
-                                        cbDeclSig,
-                                        Module*     pModule2))
-        */
-        UnifiedAssemblySigComparer uasc(*this);
-        MDSigComparer sc(MDSigParser(pbDeclSig, cbDeclSig),
-                         MDSigParser(pbBodySig, cbBodySig),
-                         uasc);
-
-        hr = sc.CompareMethodSignature();
-
-        if (FAILED(hr))
-        {
-            REPORT_ERROR2(VLDTR_E_MI_SIGMISMATCH,tkDecl,tkBody);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateMethodImpl()
-
-//*****************************************************************************
-// Validate the given ModuleRef.
-//*****************************************************************************
-HRESULT RegMeta::ValidateModuleRef(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    ModuleRefRec *pRecord;              // ModuleRef record.
-    LPCUTF8     szName;                 // ModuleRef name.
-    mdModuleRef tkModuleRef;            // Duplicate ModuleRef.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    // Get the ModuleRef record.
-    veCtxt.Token = TokenFromRid(rid, mdtModuleRef);
-    veCtxt.uOffset = 0;
-
-    IfFailGo(pMiniMd->GetModuleRefRecord(rid, &pRecord));
-
-    // C++ emits IJW methods with ImplMaps
-    // which have resolution=ModuleRef with empty name
-    IfFailGo(pMiniMd->getNameOfModuleRef(pRecord, &szName));
-    if (*szName)
-    {
-        // Look for a Duplicate, this function reports only one duplicate.
-        hr = ImportHelper::FindModuleRef(pMiniMd, szName, &tkModuleRef, rid);
-        if (hr == S_OK)
-        {
-            REPORT_ERROR1(VLDTR_E_MODREF_DUP, tkModuleRef);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-            hr = S_OK;
-        else
-            IfFailGo(hr);
-    }
-    else
-        hrSave = S_FALSE;
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateModuleRef()
-
-//*****************************************************************************
-// Validate the given TypeSpec.
-//*****************************************************************************
-//@todo GENERICS: reject duplicate specs?
-HRESULT RegMeta::ValidateTypeSpec(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    TypeSpecRec *pRecord;               // TypeSpec record.
-    PCCOR_SIGNATURE pbSig;              // Signature.
-    ULONG       cbSig;                  // Size in bytes of the signature.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    ULONG       ulCurByte = 0;          // Current index into the signature.
-    ULONG       ulNSentinels = 0;       // Number of sentinels in the signature
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    // Extract the record.
-    veCtxt.Token = TokenFromRid(rid,mdtTypeSpec);
-    veCtxt.uOffset = 0;
-    IfFailGo(pMiniMd->GetTypeSpecRecord(rid, &pRecord));
-    IfFailGo(pMiniMd->getSignatureOfTypeSpec(pRecord, &pbSig, &cbSig));
-
-    // Validate the signature is well-formed with respect to the compression
-    // scheme.  If this fails, no further validation needs to be done.
-    if ( (hr = ValidateSigCompression(veCtxt.Token, pbSig, cbSig)) != S_OK)
-        goto ErrExit;
-
-    hr = ValidateOneArg(veCtxt.Token, pbSig, cbSig, &ulCurByte,&ulNSentinels,FALSE);
-    if (hr != S_OK)
-    {
-        if(hr == VLDTR_E_SIG_MISSARG)
-        {
-            REPORT_ERROR0(VLDTR_E_TS_EMPTY);
-        }
-        SetVldtrCode(&hr, hrSave);
-        hrSave = hr;
-    }
-    if(ulNSentinels != 0)
-    {
-        REPORT_ERROR0(VLDTR_E_TS_HASSENTINALS);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateTypeSpec()
-
-//*****************************************************************************
-// This function validates the given Field signature.  This function works
-// with Field signature for both the MemberRef and FieldDef.
-//*****************************************************************************
-HRESULT RegMeta::ValidateMethodSpecSig(
-    mdMethodSpec tk,                     // [IN] Token whose signature needs to be validated.
-    PCCOR_SIGNATURE pbSig,              //  [IN] Signature.
-    ULONG       cbSig,                  //  [IN] Size in bytes of the signature.
-    ULONG       *pArity)                // [Out] Arity of the instantiation
-{
-    ULONG       ulCurByte = 0;          // Current index into the signature.
-    ULONG       ulCallConv;             // Calling convention.
-    ULONG       ulArity;                // Arity of instantiation.
-    ULONG       ulArgCnt;
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-    
-    memset(&veCtxt, 0, sizeof(VEContext));
-    _ASSERTE(TypeFromToken(tk) == mdtMethodSpec);
-
-    veCtxt.Token = tk;
-    veCtxt.uOffset = 0;
-
-    // Validate the calling convention.
-    ulCurByte += CorSigUncompressedDataSize(pbSig);
-    ulCallConv = CorSigUncompressData(pbSig);
-    if (!isCallConv(ulCallConv, IMAGE_CEE_CS_CALLCONV_GENERICINST))
-    {
-        REPORT_ERROR1(VLDTR_E_MS_BADCALLINGCONV, ulCallConv);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    if (cbSig == ulCurByte)
-    {
-        REPORT_ERROR1(VLDTR_E_MS_MISSARITY, ulCurByte + 1);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    ulCurByte += CorSigUncompressedDataSize(pbSig);
-    ulArity = CorSigUncompressData(pbSig);
-
-    if (ulArity == 0)
-    {
-        REPORT_ERROR1(VLDTR_E_MS_ARITYZERO, ulCurByte);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    ulArgCnt = ulArity;
-
-    if(pArity != NULL)
-    {
-        *pArity = ulArity; 
-    }
-
-    // Validate and consume the arguments.
-    while(ulArgCnt--)
-    {
-
-        PCCOR_SIGNATURE pbTypeArg = pbSig;
-        ULONG ulTypeArgByte = ulCurByte;
-
-        IfFailGo(ValidateOneArg(tk, pbSig, cbSig, &ulCurByte, NULL, TRUE)); 
-        if (hr != S_OK)
-        {
-            if(hr == VLDTR_E_SIG_MISSARG)
-            {
-                REPORT_ERROR1(VLDTR_E_MS_MISSARG, ulArity-ulArgCnt);
-            }
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            break;
-        }
-        // reject byref-like args
-        switch (CorSigUncompressData(pbTypeArg))
-        {
-            case ELEMENT_TYPE_TYPEDBYREF:
-            case ELEMENT_TYPE_BYREF:
-            {
-               REPORT_ERROR1(VLDTR_E_MS_BYREFINST, ulTypeArgByte);
-               SetVldtrCode(&hrSave, VLDTR_S_ERR);
-               break;
-            }
-            default: 
-              break;
-        }
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateMethodSpecSig()
-
-
-//*****************************************************************************
-// Validate the given MethodSpec.
-//*****************************************************************************
-HRESULT RegMeta::ValidateMethodSpec(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    MethodSpecRec *pRecord;                         // MethodSpec record.
-    mdToken     tkMethod;                           // Method field (a MethodDefOrRef)
-    PCCOR_SIGNATURE pInstantiation;                 // MethodSpec instantiation (a signature)
-    ULONG       cbInstantiation;                    // Size of instantiation.
-    ULONG       ulInstantiationArity;               // Arity of the Instantiation
-
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    // Get the GenericParamConstraint record.
-    veCtxt.Token = TokenFromRid(rid, mdtMethodSpec);
-    veCtxt.uOffset = 0;
-    IfFailGo(pMiniMd->GetMethodSpecRecord(rid, &pRecord));
-
-    // 1. The MethodSpec table may contain zero or more rows.
-    // (Nothing to check.)
-
-    // Implicit (missing from  spec): Method is not nil [ERROR]
-    tkMethod = pMiniMd->getMethodOfMethodSpec(pRecord);
-    if(IsNilToken(tkMethod)) 
-    {
-        REPORT_ERROR0(VLDTR_E_MS_METHODNIL); 
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Implicit in ValidateRecord: Method is a valid mdMethodDefOrRef.
-    
-    // 2. One or more rows may refer to the same row in the MethodDef or MethodRef table. 
-    //    (There may be more multiple instantions of the same generic method)
-    // (nothing to check!)
-
-    // 3. "The signature stored at Instantiation shall be a valid instantiation of the signature of the generic method stored at Method. [ERROR]
-    { 
-        IfFailGo(pMiniMd->getInstantiationOfMethodSpec(pRecord, &pInstantiation, &cbInstantiation));
-        IfFailGo(ValidateMethodSpecSig(TokenFromRid(rid, mdtMethodSpec), pInstantiation, cbInstantiation,&ulInstantiationArity));
-        if (hr != S_OK)
-            SetVldtrCode(&hrSave, hr);
-    }
-
-    IfFailGo(pMiniMd->getInstantiationOfMethodSpec(pRecord, &pInstantiation, &cbInstantiation));
-    // 4. There shall be no duplicate rows based upon Method and Instantiation [ERROR]
-    {
-        mdMethodSpec tkDupMethodSpec;
-        hr = ImportHelper::FindMethodSpecByMethodAndInstantiation(pMiniMd, tkMethod, pInstantiation, cbInstantiation, &tkDupMethodSpec, rid);
-        if (hr == S_OK)
-        {
-            REPORT_ERROR1(VLDTR_E_MS_DUP, tkDupMethodSpec); 
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-            hr = S_OK;
-        else
-            IfFailGo(hr);
-    }
-
-    // check the method is generic and that the arity of the instantiation is correct
-    {
-        PCCOR_SIGNATURE pbGenericMethodSig;
-        ULONG       cbGenericMethodSig;
-        
-        if(TypeFromToken(tkMethod) == mdtMethodDef)
-        {
-           MethodRec *pMethodRec;
-           IfFailGo(m_pStgdb->m_MiniMd.GetMethodRecord(RidFromToken(tkMethod), &pMethodRec)); 
-           IfFailGo(pMiniMd->getSignatureOfMethod(pMethodRec, &pbGenericMethodSig, &cbGenericMethodSig));
-        }
-        else
-        {
-            _ASSERTE(TypeFromToken(tkMethod) == mdtMemberRef);
-            MemberRefRec *pMethodRefRec;
-            IfFailGo(pMiniMd->GetMemberRefRecord(RidFromToken(tkMethod), &pMethodRefRec));
-            IfFailGo(pMiniMd->getSignatureOfMemberRef(pMethodRefRec, &pbGenericMethodSig, &cbGenericMethodSig));
-        }
-        
-        if (*pbGenericMethodSig & IMAGE_CEE_CS_CALLCONV_GENERIC)
-        {
-            ULONG ulGenericArity = CorSigUncompressData(++pbGenericMethodSig);
-            if(ulGenericArity != ulInstantiationArity)
-            {
-                REPORT_ERROR2(VLDTR_E_MS_ARITYMISMATCH,ulGenericArity,ulInstantiationArity); 
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-        else
-        {
-            REPORT_ERROR1(VLDTR_E_MS_METHODNOTGENERIC, tkMethod); 
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    hr = hrSave;
-
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}  // RegMeta::ValidateMethodSpec()
-
-
-//*****************************************************************************
-// Validate the given GenericParamConstraint.
-//*****************************************************************************
-HRESULT RegMeta::ValidateGenericParamConstraint(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd of the scope.
-    GenericParamConstraintRec *pRecord;             // GenericParamConstraint record.
-    mdGenericParam     tkOwner;                     // GenericParamConstraint owner field.
-    mdToken     tkConstraint;                       // GenericParamConstraint constraint field.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    // Get the GenericParamConstraint record.
-    veCtxt.Token = TokenFromRid(rid, mdtGenericParamConstraint);
-    veCtxt.uOffset = 0;
-    IfFailGo(pMiniMd->GetGenericParamConstraintRecord(rid, &pRecord));
-
-    // 1. GenericParamConstraint may contain zero or more rows.
-    // (Nothing to check.)
-
-    // 2. Each row shall have one, and only one, owner row in the GenericParamTable [ERROR]
-    // (Nothing to check except owner not nil)
-    tkOwner = pMiniMd->getOwnerOfGenericParamConstraint(pRecord);
-    if(IsNilToken(tkOwner)) 
-    {
-        REPORT_ERROR0(VLDTR_E_GPC_OWNERNIL); 
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    
-    // 3. Each row in the GenericParam table shall own a separate row in the GenericParamConstraint table for each constraint that type parameter has [ERROR]
-    // (Nothing to check)
-
-    // 4.All of the rows in the GenericParamConstraint table that are owned by a given row in the GenericParamTable
-    // shall form a contiguous range of rows [ERROR]
-    //@NOTE: this check is (iterated over all rows) is quadratic in the (typically small) number of constraints
-    {
-        RID curRid = rid;
-        GenericParamConstraintRec *pCurRecord;
-        mdGenericParam tkCurOwner = tkOwner;
-        // find the first preceding row with a distinct owner
-        while (curRid > 1 && tkCurOwner == tkOwner) 
-        { 
-            curRid--;
-            IfFailGo(pMiniMd->GetGenericParamConstraintRecord(curRid, &pCurRecord));
-            tkCurOwner = pMiniMd->getOwnerOfGenericParamConstraint(pCurRecord);
-        };
-        // reject this row if there is some row preceding the current row with this owner
-        while (curRid > 1) 
-        { 
-            curRid--;
-            IfFailGo(pMiniMd->GetGenericParamConstraintRecord(curRid, &pCurRecord));
-            tkCurOwner = pMiniMd->getOwnerOfGenericParamConstraint(pCurRecord);
-            if (tkCurOwner == tkOwner) 
-            {
-                REPORT_ERROR1(VLDTR_E_GPC_NONCONTIGUOUS,tkOwner); 
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                break;
-            }
-        };
-    }
-
-    // 5. "At most one class constraint per GenericParam" --- no longer required.
-    // 6. "Zero or more interface constraints per GenericParam" --- no longer required.
-    
-    tkConstraint = pMiniMd->getConstraintOfGenericParamConstraint(pRecord);
-    // 7. There shall be no duplicates based upon Owner and Constraint
-    {
-        mdGenericParamConstraint tkDupGenericParamConstraint;
-        hr = ImportHelper::FindGenericParamConstraintByOwnerAndConstraint(pMiniMd, tkOwner, tkConstraint, &tkDupGenericParamConstraint, rid);
-        if (hr == S_OK)
-        {
-            REPORT_ERROR1(VLDTR_E_GPC_DUP, tkDupGenericParamConstraint); 
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-            hr = S_OK;
-        else
-            IfFailGo(hr);
-    }
-
-    hr = hrSave;
-
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateGenericParamConstraint()
-
-//*****************************************************************************
-// Validate the given ImplMap.
-//*****************************************************************************
-HRESULT RegMeta::ValidateImplMap(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    ImplMapRec  *pRecord;
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    HRESULT     hrModuleRef=S_OK;
-    mdToken     tkModuleRef;
-    mdToken     tkMember;
-    USHORT      usFlags;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-#ifdef CACHE_IMPLMAP_VALIDATION_RESULT
-    for(unsigned jjj=0; jjj<g_nValidated; jjj++) 
-    { 
-        if(g_rValidated[jjj].tok == (rid | 0x51000000)) return g_rValidated[jjj].hr; 
-    }
-#endif
-    veCtxt.Token = rid;
-    veCtxt.uOffset = 0;
-    IfFailGo(pMiniMd->GetImplMapRecord(rid, &pRecord));
-    if(pRecord == NULL) IfFailGo(E_FAIL);
-    // ImplMap must have ModuleRef
-    tkModuleRef = pMiniMd->getImportScopeOfImplMap(pRecord);
-    if((TypeFromToken(tkModuleRef) != mdtModuleRef) || IsNilToken(tkModuleRef)
-        || FAILED(hrModuleRef= ValidateModuleRef(RidFromToken(tkModuleRef))))
-    {
-        REPORT_ERROR1(VLDTR_E_IMAP_BADMODREF, tkModuleRef);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // ImplMap must belong to FieldDef or MethodDef
-    tkMember = pMiniMd->getMemberForwardedOfImplMap(pRecord);
-    if((TypeFromToken(tkMember) != mdtFieldDef) && (TypeFromToken(tkMember) != mdtMethodDef))
-    {
-        REPORT_ERROR1(VLDTR_E_IMAP_BADMEMBER, tkMember);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // ImplMap must have import name, unless ModuleRef has no name
-    // (special case for C++ IJW methods)
-    if(hrModuleRef != S_FALSE)
-    {
-        LPCSTR szName;                 // Import name.
-        IfFailGo(pMiniMd->getImportNameOfImplMap(pRecord, &szName));
-        if((szName==NULL)||(*szName == 0))
-        {
-            REPORT_ERROR0(VLDTR_E_IMAP_BADIMPORTNAME);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-    // ImplMap must have valid flags:
-        // one value of pmCharSetMask - always so, no check needed (values: 0,2,4,6, mask=6)
-        // one value of pmCallConvMask...
-        // ...and it's not pmCallConvThiscall
-    usFlags = pRecord->GetMappingFlags() & pmCallConvMask;
-    if((usFlags < pmCallConvWinapi)||(usFlags > pmCallConvFastcall))
-    {
-        REPORT_ERROR1(VLDTR_E_IMAP_BADCALLCONV, usFlags);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-ErrExit:
-
-#ifdef CACHE_IMPLMAP_VALIDATION_RESULT
-    g_rValidated[g_nValidated].tok = rid | 0x51000000;
-    g_rValidated[g_nValidated].hr = hrSave;
-    g_nValidated++;
-#endif
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateImplMap()
-
-//*****************************************************************************
-// Validate the given FieldRVA.
-//*****************************************************************************
-HRESULT RegMeta::ValidateFieldRVA(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    FieldRVARec  *pRecord;
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    mdToken     tkField;
-    ULONG       ulRVA;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    veCtxt.Token = rid;
-    veCtxt.uOffset = 0;
-    IfFailGo(pMiniMd->GetFieldRVARecord(rid, &pRecord));
-    ulRVA = pRecord->GetRVA();
-    tkField = pMiniMd->getFieldOfFieldRVA(pRecord);
-    /*
-    if(ulRVA == 0)
-    {
-        REPORT_ERROR1(VLDTR_E_FRVA_ZERORVA, tkField);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    */
-    if((0==RidFromToken(tkField))||(TypeFromToken(tkField) != mdtFieldDef)||(!IsValidToken(tkField)))
-    {
-        REPORT_ERROR2(VLDTR_E_FRVA_BADFIELD, tkField, ulRVA);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    {
-        RID N = pMiniMd->getCountFieldRVAs();
-        RID tmp;
-        FieldRVARec* pRecTmp;
-        for(tmp = rid+1; tmp <= N; tmp++)
-        { 
-            IfFailGo(pMiniMd->GetFieldRVARecord(tmp, &pRecTmp));
-            if(tkField == pMiniMd->getFieldOfFieldRVA(pRecTmp))
-            {
-                REPORT_ERROR2(VLDTR_E_FRVA_DUPFIELD, tkField, tmp);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-    }
-    
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateFieldRVA()
-
-//*****************************************************************************
-// Validate the given ENCLog.
-//*****************************************************************************
-HRESULT RegMeta::ValidateENCLog(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateENCLog()
-
-//*****************************************************************************
-// Validate the given ENCMap.
-//*****************************************************************************
-HRESULT RegMeta::ValidateENCMap(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateENCMap()
-
-//*****************************************************************************
-// Validate the given Assembly.
-//*****************************************************************************
-HRESULT RegMeta::ValidateAssembly(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    AssemblyRec *pRecord;           // Assembly record.
-    CorAssemblyFlags   dwFlags;     // Assembly flags.
-    LPCSTR      szName;             // Assembly Name.
-    VEContext   veCtxt;             // Context structure.
-    HRESULT     hr = S_OK;          // Value returned.
-    HRESULT     hrSave = S_OK;      // Save state.
-    BOOL        invalidAssemblyFlags;  // Whether the CorAssemblyFlags are valid.
-    BOOL        fIsV2Assembly = FALSE;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    // Get the Assembly record.
-    veCtxt.Token = TokenFromRid(rid, mdtAssembly);
-    veCtxt.uOffset = 0;
-
-    IfFailGo(pMiniMd->GetAssemblyRecord(rid, &pRecord));
-
-    // There can only be one Assembly record.
-    if (rid > 1)
-    {
-        REPORT_ERROR0(VLDTR_E_AS_MULTI);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Do checks for name validity..
-    IfFailGo(pMiniMd->getNameOfAssembly(pRecord, &szName));
-    if (!*szName)
-    {
-        // Assembly Name is null.
-        REPORT_ERROR0(VLDTR_E_AS_NAMENULL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else
-    {
-        unsigned L = (unsigned)strlen(szName);
-        if((*szName==' ')||strchr(szName,':') || strchr(szName,'\\') || strchr(szName, '/') 
-            || strchr(szName, ',') || strchr(szName, '\n') || strchr(szName, '\r')
-            || ((L > 4)&&((!SString::_stricmp(&szName[L-4],".exe"))||(!SString::_stricmp(&szName[L-4],".dll")))))
-        {
-            //Assembly name has path and/or extension
-            REPORT_ERROR0(VLDTR_E_AS_BADNAME);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    // Get the flags value for the Assembly.
-    dwFlags = (CorAssemblyFlags) pMiniMd->getFlagsOfAssembly(pRecord);
-
-    // Validate the flags 
-    invalidAssemblyFlags = dwFlags & (~(afPublicKey | afRetargetable | afPA_FullMask | afDebuggableAttributeMask | afContentType_Mask));
-
-    // Validate we only set a legal processor architecture flags
-    // The processor architecture flags were introduced in CLR v2.0.
-    // Note that METAMODEL_MINOR_VER_V2_0 is 0.  GCC points out the comparison 
-    // is useless, so that part is commented out.
-    fIsV2Assembly = (m_pStgdb->m_MiniMd.m_Schema.m_major >= METAMODEL_MAJOR_VER_V2_0
-                     /* && m_pStgdb->m_MiniMd.m_Schema.m_minor >= METAMODEL_MINOR_VER_V2_0*/);
-    if (fIsV2Assembly)
-    {
-        if ((dwFlags & afPA_Mask) > afPA_AMD64 && !IsAfPA_NoPlatform(dwFlags))
-            invalidAssemblyFlags = true;
-    }
-    else {
-        if ((dwFlags & afPA_Mask) != 0)
-            invalidAssemblyFlags = true;
-    }
-
-    if (!IsAfContentType_Default(dwFlags) && !IsAfContentType_WindowsRuntime(dwFlags))
-    {   // Unknown ContentType value
-        invalidAssemblyFlags = true;
-    }
-
-    if (invalidAssemblyFlags)
-    {
-        REPORT_ERROR1(VLDTR_E_AS_BADFLAGS, dwFlags);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Validate hash algorithm ID
-    switch(pRecord->GetHashAlgId())
-    {
-        case CALG_MD2:
-        case CALG_MD4:
-        case CALG_MD5:
-        case CALG_SHA:
-        //case CALG_SHA1: // same as CALG_SHA
-        case CALG_MAC:
-        case CALG_SSL3_SHAMD5:
-        case CALG_HMAC:
-        case 0:
-            break;
-        default:
-            REPORT_ERROR1(VLDTR_E_AS_HASHALGID, pRecord->GetHashAlgId());
-            SetVldtrCode(&hrSave, VLDTR_S_WRN);
-    }
-    // Validate locale
-    {
-        LPCSTR szLocale;
-        IfFailGo(pMiniMd->getLocaleOfAssembly(pRecord, &szLocale));
-        if(!_IsValidLocale(szLocale, fIsV2Assembly))
-        {
-            REPORT_ERROR0(VLDTR_E_AS_BADLOCALE);
-            SetVldtrCode(&hrSave, VLDTR_S_WRN);
-        }
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateAssembly()
-
-//*****************************************************************************
-// Validate the given AssemblyProcessor.
-//*****************************************************************************
-HRESULT RegMeta::ValidateAssemblyProcessor(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateAssemblyProcessor()
-
-//*****************************************************************************
-// Validate the given AssemblyOS.
-//*****************************************************************************
-HRESULT RegMeta::ValidateAssemblyOS(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateAssemblyOS()
-
-//*****************************************************************************
-// Validate the given AssemblyRef.
-//*****************************************************************************
-HRESULT RegMeta::ValidateAssemblyRef(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    AssemblyRefRec *pRecord;        // Assembly record.
-    LPCSTR      szName;             // AssemblyRef Name.
-    VEContext   veCtxt;             // Context structure.
-    HRESULT     hr = S_OK;          // Value returned.
-    HRESULT     hrSave = S_OK;      // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    veCtxt.Token = TokenFromRid(rid, mdtAssemblyRef);
-    veCtxt.uOffset = 0;
-
-    // Get the AssemblyRef record.
-    IfFailGo(pMiniMd->GetAssemblyRefRecord(rid, &pRecord));
-
-    // Do checks for name and alias validity.
-    IfFailGo(pMiniMd->getNameOfAssemblyRef(pRecord, &szName));
-    if (!*szName)
-    {
-        // AssemblyRef Name is null.
-        REPORT_ERROR0(VLDTR_E_AR_NAMENULL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else
-    {
-        unsigned L = (unsigned)strlen(szName);
-        if((*szName==' ')||strchr(szName,':') || strchr(szName,'\\') || strchr(szName, '/') 
-            || strchr(szName, ',') || strchr(szName, '\n') || strchr(szName, '\r')
-            || ((L > 4)&&((!SString::_stricmp(&szName[L-4],".exe"))||(!SString::_stricmp(&szName[L-4],".dll")))))
-        {
-            //Assembly name has path and/or extension
-            REPORT_ERROR0(VLDTR_E_AS_BADNAME);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    // Validate locale
-    {
-        LPCSTR szLocale;
-        IfFailGo(pMiniMd->getLocaleOfAssemblyRef(pRecord, &szLocale));
-        BOOL fIsV2Assembly = (m_pStgdb->m_MiniMd.m_Schema.m_major >= METAMODEL_MAJOR_VER_V2_0
-                              /* && m_pStgdb->m_MiniMd.m_Schema.m_minor >= METAMODEL_MINOR_VER_V2_0*/);
-        if(!_IsValidLocale(szLocale, fIsV2Assembly))
-        {
-            REPORT_ERROR0(VLDTR_E_AS_BADLOCALE);
-            SetVldtrCode(&hrSave, VLDTR_S_WRN);
-        }
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateAssemblyRef()
-
-//*****************************************************************************
-// Validate the given AssemblyRefProcessor.
-//*****************************************************************************
-HRESULT RegMeta::ValidateAssemblyRefProcessor(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateAssemblyRefProcessor()
-
-//*****************************************************************************
-// Validate the given AssemblyRefOS.
-//*****************************************************************************
-HRESULT RegMeta::ValidateAssemblyRefOS(RID rid)
-{
-    return S_OK;
-}   // RegMeta::ValidateAssemblyRefOS()
-
-//*****************************************************************************
-// Validate the given File.
-//*****************************************************************************
-HRESULT RegMeta::ValidateFile(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    FileRec     *pRecord;           // File record.
-    mdFile      tkFile;             // Duplicate File token.
-    LPCSTR      szName;             // File Name.
-    VEContext   veCtxt;             // Context structure.
-    HRESULT     hr = S_OK;          // Value returned.
-    HRESULT     hrSave = S_OK;      // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    veCtxt.Token = TokenFromRid(rid, mdtFile);
-    veCtxt.uOffset = 0;
-
-    // Get the File record.
-    IfFailGo(pMiniMd->GetFileRecord(rid, &pRecord));
-
-    // Do checks for name validity.
-    IfFailGo(pMiniMd->getNameOfFile(pRecord, &szName));
-    if (!*szName)
-    {
-        // File Name is null.
-        REPORT_ERROR0(VLDTR_E_FILE_NAMENULL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else
-    {
-        ULONG L = (ULONG)strlen(szName);
-        if(L >= MAX_PATH_FNAME)
-        {
-            // Name too long
-            REPORT_ERROR2(VLDTR_E_TD_NAMETOOLONG, L, (ULONG)(MAX_PATH_FNAME-1));
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // Check for duplicates based on Name.
-        hr = ImportHelper::FindFile(pMiniMd, szName, &tkFile, rid);
-        if (hr == S_OK)
-        {
-            REPORT_ERROR1(VLDTR_E_FILE_DUP, tkFile);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-            hr = S_OK;
-        else
-            IfFailGo(hr);
-
-        // File name must not be fully qualified.
-        if(strchr(szName,':') || strchr(szName,'\\') || strchr(szName,'/'))
-        {
-            REPORT_ERROR0(VLDTR_E_FILE_NAMEFULLQLFD);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-
-        // File name must not be one of system names.
-        char *sysname[6]={"con","aux","lpt","prn","null","com"};
-        char *syssymbol = "0123456789$:";
-        for(unsigned i=0; i<6; i++)
-        {
-            L = (ULONG)strlen(sysname[i]);
-            if(!SString::_strnicmp(szName,sysname[i],L))
-            {
-                if((szName[L]==0)|| strchr(syssymbol,szName[L]))
-                {
-                    REPORT_ERROR0(VLDTR_E_FILE_SYSNAME);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    break;
-                }
-            }
-        }
-    }
-
-    if (pRecord->GetFlags() & (~0x00000003))
-    {
-        REPORT_ERROR1(VLDTR_E_FILE_BADFLAGS, pRecord->GetFlags());
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Validate hash value
-    {
-        const BYTE *pbHashValue = NULL;
-        ULONG       cbHashValue;
-        IfFailGo(m_pStgdb->m_MiniMd.getHashValueOfFile(pRecord, &pbHashValue, &cbHashValue));
-        if ((pbHashValue == NULL) || (cbHashValue == 0))
-        {
-            REPORT_ERROR0(VLDTR_E_FILE_NULLHASH);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    // Validate that the name is not the same as the file containing
-    // the manifest.
-
-    // File name must be a valid file name.
-
-    // Each ModuleRef in the assembly must have a corresponding File table entry.
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateFile()
-
-//*****************************************************************************
-// Validate the given ExportedType.
-//*****************************************************************************
-HRESULT RegMeta::ValidateExportedType(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    ExportedTypeRec  *pRecord;           // ExportedType record.
-    mdExportedType   tkExportedType;          // Duplicate ExportedType.
-    mdToken     tkImpl;             // Implementation token
-    mdToken     tkTypeDef;          // TypeDef token
-
-    LPCSTR      szName;             // ExportedType Name.
-    LPCSTR      szNamespace;        // ExportedType Namespace.
-    VEContext   veCtxt;             // Context structure.
-    HRESULT     hr = S_OK;          // Value returned.
-    HRESULT     hrSave = S_OK;      // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    veCtxt.Token = TokenFromRid(rid, mdtExportedType);
-    veCtxt.uOffset = 0;
-
-    // Get the ExportedType record.
-    IfFailGo(pMiniMd->GetExportedTypeRecord(rid, &pRecord));
-
-    tkImpl = pMiniMd->getImplementationOfExportedType(pRecord);
-    
-    tkTypeDef = pRecord->GetTypeDefId();
-    if ((TypeFromToken(tkImpl) == mdtFile) && IsNilToken(tkTypeDef))
-    {   // Report 'No TypeDefId' warning only for types exported from other modules (do not report it for 
-        // type forwarders)
-        REPORT_ERROR0(VLDTR_E_CT_NOTYPEDEFID);
-        SetVldtrCode(&hrSave, VLDTR_S_WRN);
-    }
-    
-    // Do checks for name validity.
-    IfFailGo(pMiniMd->getTypeNameOfExportedType(pRecord, &szName));
-    IfFailGo(pMiniMd->getTypeNamespaceOfExportedType(pRecord, &szNamespace));
-    if (!*szName)
-    {
-        // ExportedType Name is null.
-        REPORT_ERROR0(VLDTR_E_CT_NAMENULL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else
-    {
-        if(!strcmp(szName,COR_DELETED_NAME_A)) goto ErrExit; 
-        ULONG L = (ULONG)(strlen(szName)+strlen(szNamespace));
-        if(L >= MAX_CLASSNAME_LENGTH)
-        {
-            // Name too long
-            REPORT_ERROR2(VLDTR_E_TD_NAMETOOLONG, L, (ULONG)(MAX_CLASSNAME_LENGTH-1));
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        // Check for duplicates based on Name and Enclosing ExportedType.
-        hr = ImportHelper::FindExportedType(pMiniMd, szNamespace, szName, tkImpl, &tkExportedType, rid);
-        if (hr == S_OK)
-        {
-            REPORT_ERROR1(VLDTR_E_CT_DUP, tkExportedType);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-            hr = S_OK;
-        else
-            IfFailGo(hr);
-        // Check for duplicate TypeDef based on Name/NameSpace - only for top-level ExportedTypes.
-        if(TypeFromToken(tkImpl)==mdtFile)
-        {
-            mdToken tkTypeDef2;
-            hr = ImportHelper::FindTypeDefByName(pMiniMd, szNamespace, szName, mdTypeDefNil,
-                                             &tkTypeDef2, 0);
-            if (hr == S_OK)
-            {
-                REPORT_ERROR1(VLDTR_E_CT_DUPTDNAME, tkTypeDef2);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            else if (hr == CLDB_E_RECORD_NOTFOUND)
-                hr = S_OK;
-            else
-                IfFailGo(hr);
-        }
-    }
-    // Check if flag value is valid
-    {
-        DWORD dwFlags = pRecord->GetFlags();
-        DWORD dwInvalidMask, dwExtraBits;
-        dwInvalidMask = (DWORD)~(tdVisibilityMask | tdLayoutMask | tdClassSemanticsMask | 
-                tdAbstract | tdSealed | tdSpecialName | tdImport | tdSerializable | tdForwarder |
-                tdStringFormatMask | tdBeforeFieldInit | tdReservedMask);
-        // check for extra bits
-        dwExtraBits = dwFlags & dwInvalidMask;
-        if(!dwExtraBits)
-        {
-            // if no extra bits, check layout
-            dwExtraBits = dwFlags & tdLayoutMask;
-            if(dwExtraBits != tdLayoutMask)
-            {
-                // layout OK, check string format
-                dwExtraBits = dwFlags & tdStringFormatMask;
-                if(dwExtraBits != tdStringFormatMask) dwExtraBits = 0;
-            }
-        }
-        if(dwExtraBits)
-        {
-            REPORT_ERROR1(VLDTR_E_TD_EXTRAFLAGS, dwExtraBits);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    if(IsNilToken(tkImpl)
-        || ((TypeFromToken(tkImpl) != mdtFile)&&(TypeFromToken(tkImpl) != mdtExportedType)&&(TypeFromToken(tkImpl) != mdtAssemblyRef))
-        || (!IsValidToken(tkImpl)))
-    {
-        REPORT_ERROR1(VLDTR_E_CT_BADIMPL, tkImpl);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateExportedType()
-
-//*****************************************************************************
-// Validate the given ManifestResource.
-//*****************************************************************************
-HRESULT RegMeta::ValidateManifestResource(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    ManifestResourceRec  *pRecord;  // ManifestResource record.
-    LPCSTR      szName;             // ManifestResource Name.
-    DWORD       dwFlags;            // ManifestResource flags.
-    mdManifestResource tkmar;       // Duplicate ManifestResource.
-    VEContext   veCtxt;             // Context structure.
-    HRESULT     hr = S_OK;          // Value returned.
-    HRESULT     hrSave = S_OK;      // Save state.
-    mdToken     tkImplementation;
-    BOOL        bIsValidImplementation = TRUE;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    veCtxt.Token = TokenFromRid(rid, mdtManifestResource);
-    veCtxt.uOffset = 0;
-
-    // Get the ManifestResource record.
-    IfFailGo(pMiniMd->GetManifestResourceRecord(rid, &pRecord));
-
-    // Do checks for name validity.
-    IfFailGo(pMiniMd->getNameOfManifestResource(pRecord, &szName));
-    if (!*szName)
-    {
-        // ManifestResource Name is null.
-        REPORT_ERROR0(VLDTR_E_MAR_NAMENULL);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    else
-    {
-        // Check for duplicates based on Name.
-        hr = ImportHelper::FindManifestResource(pMiniMd, szName, &tkmar, rid);
-        if (hr == S_OK)
-        {
-            REPORT_ERROR1(VLDTR_E_MAR_DUP, tkmar);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        else if (hr == CLDB_E_RECORD_NOTFOUND)
-            hr = S_OK;
-        else
-            IfFailGo(hr);
-    }
-
-    // Get the flags of the ManifestResource.
-    dwFlags = pMiniMd->getFlagsOfManifestResource(pRecord);
-    if(dwFlags &(~0x00000003))
-    {
-            REPORT_ERROR1(VLDTR_E_MAR_BADFLAGS, dwFlags);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Visibility of ManifestResource flags must either be public or private.
-    if (!IsMrPublic(dwFlags) && !IsMrPrivate(dwFlags))
-    {
-        REPORT_ERROR0(VLDTR_E_MAR_NOTPUBPRIV);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Implementation must be Nil or valid AssemblyRef or File
-    tkImplementation = pMiniMd->getImplementationOfManifestResource(pRecord);
-    if(!IsNilToken(tkImplementation))
-    {
-        switch(TypeFromToken(tkImplementation))
-        {
-            case mdtAssemblyRef:
-                bIsValidImplementation = IsValidToken(tkImplementation);
-                break;
-            case mdtFile:
-                if((bIsValidImplementation = IsValidToken(tkImplementation)))
-                {   // if file not PE, offset must be 0
-                    FileRec *pFR;
-                    IfFailGo(pMiniMd->GetFileRecord(RidFromToken(tkImplementation), &pFR));
-                    if(IsFfContainsNoMetaData(pFR->GetFlags()) 
-                        && pRecord->GetOffset())
-                    {
-                        REPORT_ERROR1(VLDTR_E_MAR_BADOFFSET, tkImplementation);
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-                }
-                break;
-            default:
-                bIsValidImplementation = FALSE;
-        }
-    }
-    if(!bIsValidImplementation)
-    {
-        REPORT_ERROR1(VLDTR_E_MAR_BADIMPL, tkImplementation);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Validate the Offset into the PE file.
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateManifestResource()
-
-//*****************************************************************************
-// Validate the given NestedClass.
-//*****************************************************************************
-HRESULT RegMeta::ValidateNestedClass(RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);   // MiniMd for the scope.
-    NestedClassRec  *pRecord;  // NestedClass record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save the current state.
-    VEContext   veCtxt;             // Context structure.
-    mdToken     tkNested;
-    mdToken     tkEncloser;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    veCtxt.Token = rid;
-    veCtxt.uOffset = 0;
-
-    // Get the NestedClass record.
-    IfFailGo(pMiniMd->GetNestedClassRecord(rid, &pRecord));
-    tkNested = pMiniMd->getNestedClassOfNestedClass(pRecord);
-    tkEncloser = pMiniMd->getEnclosingClassOfNestedClass(pRecord);
-
-    // Nested must be valid TypeDef
-    if((TypeFromToken(tkNested) != mdtTypeDef) || !IsValidToken(tkNested))
-    {
-        REPORT_ERROR1(VLDTR_E_NC_BADNESTED, tkNested);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Encloser must be valid TypeDef
-    if((TypeFromToken(tkEncloser) != mdtTypeDef) || !IsValidToken(tkEncloser))
-    {
-        REPORT_ERROR1(VLDTR_E_NC_BADENCLOSER, tkEncloser);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    // Check for duplicates 
-    {
-        RID N = pMiniMd->getCountNestedClasss();
-        RID tmp;
-        NestedClassRec* pRecTmp;
-        mdToken tkEncloserTmp;
-        for(tmp = rid+1; tmp <= N; tmp++)
-        { 
-            IfFailGo(pMiniMd->GetNestedClassRecord(tmp, &pRecTmp));
-            if(tkNested == pMiniMd->getNestedClassOfNestedClass(pRecTmp))
-            {
-                if(tkEncloser == (tkEncloserTmp = pMiniMd->getEnclosingClassOfNestedClass(pRecTmp)))
-                {
-                    REPORT_ERROR1(VLDTR_E_NC_DUP, tmp);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                else
-                {
-                    REPORT_ERROR3(VLDTR_E_NC_DUPENCLOSER, tkNested, tkEncloser, tkEncloserTmp);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-        }
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateLocalVariable()
-
-//*****************************************************************************
-// Given a Table ID and a Row ID, validate all the columns contain meaningful
-// values given the column definitions.  Validate that the offsets into the
-// different pools are valid, the rids are within range and the coded tokens
-// are valid.  Every failure here is considered an error.
-//*****************************************************************************
-HRESULT RegMeta::ValidateRecord(ULONG ixTbl, RID rid)
-{
-    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save the current state.
-    ULONG       ulCount;                // Count of records in the table.
-    ULONG       ulRawColVal;            // Raw value of the column.
-    void        *pRow;                  // Row with the data.
-    CMiniTableDef *pTbl;                // Table definition.
-    CMiniColDef *pCol;                  // Column definition.
-    const CCodedTokenDef *pCdTkn;       // Coded token definition.
-    ULONG       ix;                     // Index into the array of coded tokens.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    // Get the table definition.
-    pTbl = &pMiniMd->m_TableDefs[ixTbl];
-
-    // Get the row.  We may assume that the Row pointer we get back from
-    // this call is correct since we do the verification on the Record
-    // pools for each table during the open sequence.  The only place
-    // this is not valid is for Dynamic IL and we don't do this
-    // verification in that case since we go through IMetaData* APIs
-    // in that case and it should all be consistent.
-    IfFailGo(m_pStgdb->m_MiniMd.getRow(ixTbl, rid, &pRow));
-
-    for (ULONG ixCol = 0; ixCol < pTbl->m_cCols; ixCol++)
-    {
-        // Get the column definition.
-        pCol = &pTbl->m_pColDefs[ixCol];
-
-        // Get the raw value stored in the column.  getIX currently doesn't
-        // handle byte sized fields, but there are some BYTE fields in the
-        // MetaData.  So using the conditional to access BYTE fields.
-        if (pCol->m_cbColumn == 1)
-            ulRawColVal = pMiniMd->getI1(pRow, *pCol);
-        else
-            ulRawColVal = pMiniMd->getIX(pRow, *pCol);
-
-        // Do some basic checks on the non-absurdity of the value stored in the
-        // column.
-        if (IsRidType(pCol->m_Type))
-        {
-            // Verify that the RID is within range.
-            _ASSERTE(pCol->m_Type < pMiniMd->GetCountTables());
-            ulCount = pMiniMd->GetCountRecs(pCol->m_Type);
-            // For records storing rids to pointer tables, the stored value may
-            // be one beyond the last record.
-            if (IsTblPtr(pCol->m_Type, ixTbl))
-                ulCount++;
-            if (ulRawColVal > ulCount)
-            {
-                VEContext   veCtxt;
-                memset(&veCtxt, 0, sizeof(VEContext));
-                veCtxt.Token    = 0;
-                veCtxt.uOffset  = 0;
-                REPORT_ERROR3(VLDTR_E_RID_OUTOFRANGE, ixTbl, ixCol, rid);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-        else if (IsCodedTokenType(pCol->m_Type))
-        {
-            // Verify that the Coded token and rid are valid.
-            pCdTkn = &g_CodedTokens[pCol->m_Type - iCodedToken];
-            ix = ulRawColVal & ~(-1 << CMiniMdRW::m_cb[pCdTkn->m_cTokens]);
-            if (ix >= pCdTkn->m_cTokens)
-            {
-                VEContext   veCtxt;
-                memset(&veCtxt, 0, sizeof(VEContext));
-                veCtxt.Token    = 0;
-                veCtxt.uOffset  = 0;
-                REPORT_ERROR3(VLDTR_E_CDTKN_OUTOFRANGE, ixTbl, ixCol, rid);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            ulCount = pMiniMd->GetCountRecs(TypeFromToken(pCdTkn->m_pTokens[ix]) >> 24);
-            if ( (ulRawColVal >> CMiniMdRW::m_cb[pCdTkn->m_cTokens]) > ulCount)
-            {
-                VEContext   veCtxt;
-                memset(&veCtxt, 0, sizeof(VEContext));
-                veCtxt.Token    = 0;
-                veCtxt.uOffset  = 0;
-                REPORT_ERROR3(VLDTR_E_CDRID_OUTOFRANGE, ixTbl, ixCol, rid);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        }
-        else if (IsHeapType(pCol->m_Type))
-        {
-            // Verify that the offsets for the Heap type fields are valid offsets
-            // into the heaps.
-            switch (pCol->m_Type)
-            {
-            case iSTRING:
-                if (!pMiniMd->m_StringHeap.IsValidIndex(ulRawColVal))
-                {
-                    VEContext   veCtxt;
-                    memset(&veCtxt, 0, sizeof(VEContext));
-                    veCtxt.Token    = 0;
-                    veCtxt.uOffset  = 0;
-                    REPORT_ERROR3(VLDTR_E_STRING_INVALID, ixTbl, ixCol, rid);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                break;
-            case iGUID:
-                if (ulRawColVal == 0)
-                {   // GUID value 0 is valid value, though it's invalid GUID heap index
-                    break;
-                }
-                if (!pMiniMd->m_GuidHeap.IsValidIndex(ulRawColVal))
-                {
-                    VEContext   veCtxt;
-                    memset(&veCtxt, 0, sizeof(VEContext));
-                    veCtxt.Token    = 0;
-                    veCtxt.uOffset  = 0;
-                    REPORT_ERROR3(VLDTR_E_GUID_INVALID, ixTbl, ixCol, rid);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                break;
-            case iBLOB:
-                if (! pMiniMd->m_BlobHeap.IsValidIndex(ulRawColVal))
-                {
-                    VEContext   veCtxt;
-                    memset(&veCtxt, 0, sizeof(VEContext));
-                    veCtxt.Token    = 0;
-                    veCtxt.uOffset  = 0;
-                    REPORT_ERROR3(VLDTR_E_BLOB_INVALID, ixTbl, ixCol, rid);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                break;
-            default:
-                _ASSERTE(!"Invalid heap type encountered!");
-            }
-        }
-        else
-        {
-            // Not much checking that can be done on the fixed type in a generic sense.
-            _ASSERTE (IsFixedType(pCol->m_Type));
-        }
-        hr = hrSave;
-    }
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateRecord()
-
-//*****************************************************************************
-// This function validates that the given Method signature is consistent as per
-// the compression scheme.
-//*****************************************************************************
-HRESULT RegMeta::ValidateSigCompression(
-    mdToken     tk,                     // [IN] Token whose signature needs to be validated.
-    PCCOR_SIGNATURE pbSig,              // [IN] Signature.
-    ULONG       cbSig)                  // [IN] Size in bytes of the signature.
-{
-    VEContext   veCtxt;                 // Context record.
-    ULONG       ulCurByte = 0;          // Current index into the signature.
-    ULONG       ulSize;                 // Size of uncompressed data at each point.
-    HRESULT     hr = S_OK;              // Value returned.
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    veCtxt.Token = tk;
-    veCtxt.uOffset = 0;
-
-    // Check for NULL signature.
-    if (!cbSig)
-    {
-        REPORT_ERROR0(VLDTR_E_SIGNULL);
-        SetVldtrCode(&hr, VLDTR_S_ERR);
-        goto ErrExit;
-    }
-
-    // Walk through the signature.  At each point make sure there is enough
-    // room left in the signature based on the encoding in the current byte.
-    while (cbSig - ulCurByte)
-    {
-        _ASSERTE(ulCurByte <= cbSig);
-        // Get next chunk of uncompressed data size.
-        if ((ulSize = CorSigUncompressedDataSize(pbSig)) > (cbSig - ulCurByte))
-        {
-            REPORT_ERROR1(VLDTR_E_SIGNODATA, ulCurByte+1);
-            SetVldtrCode(&hr, VLDTR_S_ERR);
-            goto ErrExit;
-        }
-        // Go past this chunk.
-        ulCurByte += ulSize;
-        CorSigUncompressData(pbSig);
-    }
-ErrExit:
-
-    return hr;
-}   // RegMeta::ValidateSigCompression()
-
-//*****************************************************************************
-// This function validates one argument given an offset into the signature
-// where the argument begins.  This function assumes that the signature is well
-// formed as far as the compression scheme is concerned.
-//*****************************************************************************
-//@GENERICS: todo: reject uninstantiated generic types used as types.
-#ifdef _PREFAST_
-#pragma warning(push)
-#pragma warning(disable:21000) // Suppress PREFast warning about overly large function
-#endif
-HRESULT RegMeta::ValidateOneArg(
-    mdToken     tk,                     // [IN] Token whose signature is being processed.
-    PCCOR_SIGNATURE &pbSig,             // [IN] Pointer to the beginning of argument.
-    ULONG       cbSig,                  // [IN] Size in bytes of the full signature.
-    ULONG       *pulCurByte,            // [IN/OUT] Current offset into the signature..
-    ULONG       *pulNSentinels,         // [IN/OUT] Number of sentinels
-    BOOL        bNoVoidAllowed)         // [IN] Flag indicating whether "void" is disallowed for this arg 
-{
-    ULONG       ulElementType;          // Current element type being processed.
-    ULONG       ulElemSize;             // Size of the element type.
-    mdToken     token;                  // Embedded token.
-    ULONG       ulArgCnt;               // Argument count for function pointer.
-    ULONG       ulRank;                 // Rank of the array.
-    ULONG       ulSizes;                // Count of sized dimensions of the array.
-    ULONG       ulLbnds;                // Count of lower bounds of the array.
-    ULONG       ulTkSize;               // Token size.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    BOOL        bRepeat = TRUE;         // MODOPT and MODREQ belong to the arg after them
-    BOOL        bByRefForbidden = FALSE;// ByRef is not allowed for fields
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    switch(TypeFromToken(tk))
-    {
-    case mdtFieldDef:
-        bByRefForbidden = TRUE;
-        break;
-    case mdtName:
-        tk = TokenFromRid(RidFromToken(tk),mdtFieldDef);
-        // Field type can be a FNPTR with a sig containing ByRefs.
-        // So we change the token type not to be mdtFieldDef and thus allow ByRefs,
-        // but the token needs to be restored to its original type for reporting
-        break;
-    }
-
-    _ASSERTE (pulCurByte);
-    memset(&veCtxt, 0, sizeof(VEContext));
-    veCtxt.Token = tk;
-    veCtxt.uOffset = 0;
-
-    while(bRepeat)
-    {
-        bRepeat = FALSE;
-    // Validate that the argument is not missing.
-    _ASSERTE(*pulCurByte <= cbSig);
-    if (cbSig == *pulCurByte)
-    {
-        hr = VLDTR_E_SIG_MISSARG;
-        goto ErrExit;
-    }
-
-    // Get the element type.
-    *pulCurByte += (ulElemSize = CorSigUncompressedDataSize(pbSig));
-    ulElementType = CorSigUncompressData(pbSig);
-
-    // Walk past all the modifier types.
-    while (ulElementType & ELEMENT_TYPE_MODIFIER)
-    {
-        _ASSERTE(*pulCurByte <= cbSig);
-        if(ulElementType == ELEMENT_TYPE_SENTINEL)
-        {
-            if(pulNSentinels) *pulNSentinels+=1;
-            if(TypeFromToken(tk) == mdtMethodDef)
-            {
-                REPORT_ERROR0(VLDTR_E_SIG_SENTINMETHODDEF);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            if (cbSig == *pulCurByte)
-            {
-                REPORT_ERROR0(VLDTR_E_SIG_LASTSENTINEL);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                goto ErrExit;
-            }
-        }
-        if (cbSig == *pulCurByte)
-        {
-            REPORT_ERROR2(VLDTR_E_SIG_MISSELTYPE, ulElementType, *pulCurByte + 1);
-            SetVldtrCode(&hr, hrSave);
-            goto ErrExit;
-        }
-        *pulCurByte += (ulElemSize = CorSigUncompressedDataSize(pbSig));
-        ulElementType = CorSigUncompressData(pbSig);
-    }
-
-    switch (ulElementType)
-    {
-        case ELEMENT_TYPE_VOID:
-            if(bNoVoidAllowed)
-            {
-                IfBreakGo(m_pVEHandler->VEHandler(VLDTR_E_SIG_BADVOID, veCtxt, 0));
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-        case ELEMENT_TYPE_BOOLEAN:
-        case ELEMENT_TYPE_CHAR:
-        case ELEMENT_TYPE_I1:
-        case ELEMENT_TYPE_U1:
-        case ELEMENT_TYPE_I2:
-        case ELEMENT_TYPE_U2:
-        case ELEMENT_TYPE_I4:
-        case ELEMENT_TYPE_U4:
-        case ELEMENT_TYPE_I8:
-        case ELEMENT_TYPE_U8:
-        case ELEMENT_TYPE_R4:
-        case ELEMENT_TYPE_R8:
-        case ELEMENT_TYPE_STRING:
-        case ELEMENT_TYPE_OBJECT:
-        case ELEMENT_TYPE_TYPEDBYREF:
-        case ELEMENT_TYPE_U:
-        case ELEMENT_TYPE_I:
-            break;
-        case ELEMENT_TYPE_BYREF:  //fallthru
-            if(bByRefForbidden)
-            {
-                IfBreakGo(m_pVEHandler->VEHandler(VLDTR_E_SIG_BYREFINFIELD, veCtxt, 0));
-                SetVldtrCode(&hr, hrSave);
-            }
-        case ELEMENT_TYPE_PTR:
-            // Validate the referenced type.
-            IfFailGo(ValidateOneArg(tk, pbSig, cbSig, pulCurByte,pulNSentinels,FALSE));
-            if (hr != S_OK)
-                SetVldtrCode(&hrSave, hr);
-            break;
-        case ELEMENT_TYPE_PINNED:
-        case ELEMENT_TYPE_SZARRAY:
-            // Validate the referenced type.
-            IfFailGo(ValidateOneArg(tk, pbSig, cbSig, pulCurByte,pulNSentinels,TRUE));
-            if (hr != S_OK)
-                SetVldtrCode(&hrSave, hr);
-            break;
-        case ELEMENT_TYPE_VALUETYPE: //fallthru
-        case ELEMENT_TYPE_CLASS:
-        case ELEMENT_TYPE_CMOD_OPT:
-        case ELEMENT_TYPE_CMOD_REQD:
-            // See if the token is missing.
-            _ASSERTE(*pulCurByte <= cbSig);
-            if (cbSig == *pulCurByte)
-            {
-                REPORT_ERROR1(VLDTR_E_SIG_MISSTKN, ulElementType);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                break;
-            }
-            // See if the token is a valid token.
-            ulTkSize = CorSigUncompressedDataSize(pbSig);
-            token = CorSigUncompressToken(pbSig);
-            if (!IsValidToken(token))
-            {
-                REPORT_ERROR2(VLDTR_E_SIG_TKNBAD, token, *pulCurByte);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                *pulCurByte += ulTkSize;
-                break;
-            }
-            *pulCurByte += ulTkSize;
-            if ((ulElementType == ELEMENT_TYPE_CLASS) || (ulElementType == ELEMENT_TYPE_VALUETYPE))
-            {
-                // Check for long-form encoding
-                CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);
-                LPCSTR      szName = "";                 // token's Name.
-                LPCSTR      szNameSpace = "";            // token's NameSpace.
-
-
-                // Check for TypeDef or TypeRef
-                // To prevent cycles in metadata, token must not be a TypeSpec.
-                if ((TypeFromToken(token) != mdtTypeRef) && (TypeFromToken(token) != mdtTypeDef))
-                {
-                    REPORT_ERROR2(VLDTR_E_SIG_BADTOKTYPE, token, *pulCurByte);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-
-                if (TypeFromToken(token) == mdtTypeRef)
-                {
-                    TypeRefRec *pTokenRec;
-                    IfFailGo(pMiniMd->GetTypeRefRecord(RidFromToken(token), &pTokenRec));
-                    mdToken tkResScope = pMiniMd->getResolutionScopeOfTypeRef(pTokenRec);
-                    if (RidFromToken(tkResScope) && (TypeFromToken(tkResScope) == mdtAssemblyRef))
-                    {
-                        AssemblyRefRec * pARRec;
-                        IfFailGo(pMiniMd->GetAssemblyRefRecord(RidFromToken(tkResScope), &pARRec));
-                        LPCSTR szAssemblyRefName;
-                        IfFailGo(pMiniMd->getNameOfAssemblyRef(pARRec, &szAssemblyRefName));
-                        if((0 == SString::_stricmp("mscorlib", szAssemblyRefName)) || (0 == SString::_stricmp("System.Runtime", szAssemblyRefName)))
-                        {
-                            IfFailGo(pMiniMd->getNamespaceOfTypeRef(pTokenRec, &szNameSpace));
-                            IfFailGo(pMiniMd->getNameOfTypeRef(pTokenRec, &szName));
-                        }
-                    }
-                }
-                else if (TypeFromToken(token) == mdtTypeDef)
-                {
-                    TypeDefRec *pTokenRec;
-                    IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(token), &pTokenRec));
-                    if(g_fValidatingMscorlib) // otherwise don't even bother checking the name
-                    {
-                        IfFailGo(pMiniMd->getNameOfTypeDef(pTokenRec, &szName));
-                        IfFailGo(pMiniMd->getNamespaceOfTypeDef(pTokenRec, &szNameSpace));
-                    }
-                    // while at it, check if token is indeed a class (valuetype)
-                    BOOL bValueType = FALSE;
-                    if(!IsTdInterface(pTokenRec->GetFlags()))
-                    {
-                        mdToken tkExtends = pMiniMd->getExtendsOfTypeDef(pTokenRec);
-                        if(RidFromToken(tkExtends))
-                        {
-                            LPCSTR      szExtName = "";                 // parent's Name.
-                            LPCSTR      szExtNameSpace = "";            // parent's NameSpace.
-                            if(TypeFromToken(tkExtends)==mdtTypeRef)
-                            {
-                                TypeRefRec *pExtRec;
-                                IfFailGo(pMiniMd->GetTypeRefRecord(RidFromToken(tkExtends), &pExtRec));
-                                mdToken tkResScope = pMiniMd->getResolutionScopeOfTypeRef(pExtRec);
-                                if(RidFromToken(tkResScope) && (TypeFromToken(tkResScope)==mdtAssemblyRef))
-                                {
-                                    AssemblyRefRec *pARRec;
-                                    IfFailGo(pMiniMd->GetAssemblyRefRecord(RidFromToken(tkResScope), &pARRec));
-                                    LPCSTR szAssemblyRefName;
-                                    IfFailGo(pMiniMd->getNameOfAssemblyRef(pARRec, &szAssemblyRefName));
-                                    if((0 == SString::_stricmp("mscorlib", szAssemblyRefName)) || (0 == SString::_stricmp("System.Runtime", szAssemblyRefName)))
-                                    {
-                                        IfFailGo(pMiniMd->getNamespaceOfTypeRef(pExtRec, &szExtNameSpace));
-                                        IfFailGo(pMiniMd->getNameOfTypeRef(pExtRec, &szExtName));
-                                    }
-                                }
-                            }
-                            else if(TypeFromToken(tkExtends)==mdtTypeDef)
-                            {
-                                if(g_fValidatingMscorlib) // otherwise don't even bother checking the name
-                                {
-                                    TypeDefRec *pExtRec;
-                                    IfFailGo(pMiniMd->GetTypeDefRecord(RidFromToken(tkExtends), &pExtRec));
-                                    IfFailGo(pMiniMd->getNameOfTypeDef(pExtRec, &szExtName));
-                                    IfFailGo(pMiniMd->getNamespaceOfTypeDef(pExtRec, &szExtNameSpace));
-                                }
-                            }
-                            if(0 == strcmp(szExtNameSpace,BASE_NAMESPACE))
-                            {
-                                if(0==strcmp(szExtName,BASE_ENUM_CLASSNAME)) bValueType = TRUE;
-                                else if(0==strcmp(szExtName,BASE_VTYPE_CLASSNAME))
-                                {
-                                    bValueType = (strcmp(szNameSpace,BASE_NAMESPACE) ||
-                                                strcmp(szName,BASE_ENUM_CLASSNAME));
-                                }
-                            }
-                        }
-                    }
-                    if(bValueType != (ulElementType == ELEMENT_TYPE_VALUETYPE))
-                    {
-                        REPORT_ERROR2(VLDTR_E_SIG_TOKTYPEMISMATCH, token, *pulCurByte);
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    }
-
-                }
-                if(0 == strcmp(szNameSpace,BASE_NAMESPACE))
-                {
-                    for(unsigned jjj = 0; jjj < g_NumSigLongForms; jjj++)
-                    {
-                        if(0 == strcmp(szName,g_SigLongFormName[jjj]))
-                        {
-                            REPORT_ERROR2(VLDTR_E_SIG_LONGFORM, token, *pulCurByte);
-                            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                            break;
-                        }
-                    }
-                }
-            }
-            else // i.e. if(ELEMENT_TYPE_CMOD_OPT || ELEMENT_TYPE_CMOD_REQD)
-                bRepeat = TRUE; // go on validating, we're not done with this arg
-            break;
-
-        case ELEMENT_TYPE_FNPTR: 
-            // Validate that calling convention is present.
-            _ASSERTE(*pulCurByte <= cbSig);
-            if (cbSig == *pulCurByte)
-            {
-                REPORT_ERROR1(VLDTR_E_SIG_MISSFPTR, *pulCurByte + 1);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                break;
-            }
-            // Consume calling convention.
-            *pulCurByte += CorSigUncompressedDataSize(pbSig);
-            CorSigUncompressData(pbSig);
-
-            // Validate that argument count is present.
-            _ASSERTE(*pulCurByte <= cbSig);
-            if (cbSig == *pulCurByte)
-            {
-                REPORT_ERROR1(VLDTR_E_SIG_MISSFPTRARGCNT, *pulCurByte + 1);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                break;
-            }
-            // Consume argument count.
-            *pulCurByte += CorSigUncompressedDataSize(pbSig);
-            ulArgCnt = CorSigUncompressData(pbSig);
-
-            // Checking the signature, ByRefs OK
-            if(bByRefForbidden)
-                tk = TokenFromRid(RidFromToken(tk),mdtName);
-
-            // Validate and consume return type.
-            IfFailGo(ValidateOneArg(tk, pbSig, cbSig, pulCurByte,NULL,FALSE));
-            if (hr != S_OK)
-            {
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                break;
-            }
-
-            // Validate and consume the arguments.
-            while(ulArgCnt--)
-            {
-                IfFailGo(ValidateOneArg(tk, pbSig, cbSig, pulCurByte,NULL,TRUE));
-                if (hr != S_OK)
-                {
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    break;
-                }
-            }
-            break;
-
-        case ELEMENT_TYPE_ARRAY:
-            // Validate and consume the base type.
-            IfFailGo(ValidateOneArg(tk, pbSig, cbSig, pulCurByte,pulNSentinels,TRUE));
-
-            // Validate that the rank is present.
-            _ASSERTE(*pulCurByte <= cbSig);
-            if (cbSig == *pulCurByte)
-            {
-                REPORT_ERROR1(VLDTR_E_SIG_MISSRANK, *pulCurByte + 1);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                break;
-            }
-            // Consume the rank.
-            *pulCurByte += CorSigUncompressedDataSize(pbSig);
-            ulRank = CorSigUncompressData(pbSig);
-
-            // Process the sizes.
-            if (ulRank)
-            {
-                // Validate that the count of sized-dimensions is specified.
-                _ASSERTE(*pulCurByte <= cbSig);
-                if (cbSig == *pulCurByte)
-                {
-                    REPORT_ERROR1(VLDTR_E_SIG_MISSNSIZE, *pulCurByte + 1);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    break;
-                }
-                // Consume the count of sized dimensions.
-                *pulCurByte += CorSigUncompressedDataSize(pbSig);
-                ulSizes = CorSigUncompressData(pbSig);
-
-                // Loop over the sizes.
-                while (ulSizes--)
-                {
-                    // Validate the current size.
-                    _ASSERTE(*pulCurByte <= cbSig);
-                    if (cbSig == *pulCurByte)
-                    {
-                        REPORT_ERROR1(VLDTR_E_SIG_MISSSIZE, *pulCurByte + 1);
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                        break;
-                    }
-                    // Consume the current size.
-                    *pulCurByte += CorSigUncompressedDataSize(pbSig);
-                    CorSigUncompressData(pbSig);
-                }
-
-                // Validate that the count of lower bounds is specified.
-                _ASSERTE(*pulCurByte <= cbSig);
-                if (cbSig == *pulCurByte)
-                {
-                    REPORT_ERROR1(VLDTR_E_SIG_MISSNLBND, *pulCurByte + 1);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    break;
-                }
-                // Consume the count of lower bound.
-                *pulCurByte += CorSigUncompressedDataSize(pbSig);
-                ulLbnds = CorSigUncompressData(pbSig);
-
-                // Loop over the lower bounds.
-                while (ulLbnds--)
-                {
-                    // Validate the current lower bound.
-                    _ASSERTE(*pulCurByte <= cbSig);
-                    if (cbSig == *pulCurByte)
-                    {
-                        REPORT_ERROR1(VLDTR_E_SIG_MISSLBND, *pulCurByte + 1);
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                        break;
-                    }
-                    // Consume the current size.
-                    *pulCurByte += CorSigUncompressedDataSize(pbSig);
-                    CorSigUncompressData(pbSig);
-                }
-            }
-            break;
-
-        case ELEMENT_TYPE_VAR: 
-        case ELEMENT_TYPE_MVAR: 
-            // Consume index.
-            *pulCurByte += CorSigUncompressedDataSize(pbSig);
-            CorSigUncompressData(pbSig);
-            break;
-
-        case ELEMENT_TYPE_GENERICINST: 
-            { 
-                PCCOR_SIGNATURE pbGenericTypeSig = pbSig;
-                BOOL fCheckArity = FALSE;
-                ULONG ulGenericArity = 0;
-            
-                // Validate and consume the type constructor
-                IfFailGo(ValidateOneArg(tk, pbSig, cbSig, pulCurByte, NULL, TRUE));
-
-                // Extract its arity
-                {
-                    CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);
-                    switch(CorSigUncompressElementType(pbGenericTypeSig))
-                    {
-                        case ELEMENT_TYPE_VALUETYPE:
-                        case ELEMENT_TYPE_CLASS: 
-                            { 
-                                mdToken tkGenericType = CorSigUncompressToken(pbGenericTypeSig);
-                                if (TypeFromToken(tkGenericType) == mdtTypeDef)
-                                {
-                                    HENUMInternal hEnumTyPars;
-                                    hr = pMiniMd->FindGenericParamHelper(tkGenericType, &hEnumTyPars);
-                                    if (SUCCEEDED(hr))
-                                    {
-                                        IfFailGo(HENUMInternal::GetCount(&hEnumTyPars,&ulGenericArity));
-                                        HENUMInternal::ClearEnum(&hEnumTyPars);
-                                        fCheckArity = TRUE;
-                                    }
-                                    ; 
-                                }
-                                // for a mdtTypeRef, don't check anything until load time
-                                break;
-                            }
-                    default:
-                        break;
-                    }
-                    
-                }
-                
-                // Consume argument count.
-                if (cbSig == *pulCurByte)
-                {
-                    REPORT_ERROR1(VLDTR_E_SIG_MISSARITY, *pulCurByte + 1);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                    break;
-                }
-                
-                *pulCurByte += CorSigUncompressedDataSize(pbSig);
-                ulArgCnt = CorSigUncompressData(pbSig);
-
-                if (ulArgCnt == 0)
-                {
-                    REPORT_ERROR1(VLDTR_E_SIG_ARITYZERO,*pulCurByte);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                
-                if (fCheckArity && ulArgCnt != ulGenericArity)
-                {
-                    REPORT_ERROR3(VLDTR_E_SIG_ARITYMISMATCH,ulGenericArity,ulArgCnt,*pulCurByte);
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-                
-                // Validate and consume the arguments.
-                while(ulArgCnt--)
-                {
-                    PCCOR_SIGNATURE pbTypeArg = pbSig;
-                    ULONG ulTypeArgByte = *pulCurByte;
-                    IfFailGo(ValidateOneArg(tk, pbSig, cbSig, pulCurByte, NULL, TRUE));
-                    if (hr != S_OK)
-                    {
-                        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                        break;
-                    }
-
-                    // reject byref-like args
-                    switch (CorSigUncompressData(pbTypeArg))
-                    {
-                       case ELEMENT_TYPE_TYPEDBYREF:
-                       case ELEMENT_TYPE_BYREF:
-                         {
-                            REPORT_ERROR1(VLDTR_E_SIG_BYREFINST, ulTypeArgByte);
-                            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                            break;
-                         }
-                       default: 
-                         break;
-                    }
-                }
-
-                break;
-            }
-            
-
-        case ELEMENT_TYPE_SENTINEL: // this case never works because all modifiers are skipped before switch
-            if(TypeFromToken(tk) == mdtMethodDef)
-            {
-                REPORT_ERROR0(VLDTR_E_SIG_SENTINMETHODDEF);
-                SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            }
-            break;
-        default:
-            REPORT_ERROR2(VLDTR_E_SIG_BADELTYPE, ulElementType, *pulCurByte - ulElemSize);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-            break;
-    }   // switch (ulElementType)
-    } // end while(bRepeat)
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateOneArg()
-#ifdef _PREFAST_
-#pragma warning(pop)
-#endif
-
-//*****************************************************************************
-// This function validates the given Method signature.  This function works
-// with Method signature for both the MemberRef and MethodDef.
-//*****************************************************************************
-HRESULT RegMeta::ValidateMethodSig(
-    mdToken     tk,                     // [IN] Token whose signature needs to be validated.
-    PCCOR_SIGNATURE pbSig,              // [IN] Signature.
-    ULONG       cbSig,                  // [IN] Size in bytes of the signature.
-    DWORD       dwFlags)                // [IN] Method flags.
-{
-    ULONG       ulCurByte = 0;          // Current index into the signature.
-    ULONG       ulCallConv;             // Calling convention.
-    ULONG       ulArgCount;             // Count of arguments.
-    ULONG       ulTyArgCount;           // Count of type arguments.
-    ULONG       i;                      // Looping index.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-    ULONG       ulNSentinels = 0;
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    _ASSERTE(TypeFromToken(tk) == mdtMethodDef ||
-             TypeFromToken(tk) == mdtMemberRef);
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    veCtxt.Token = tk;
-    veCtxt.uOffset = 0;
-
-    // Validate the signature is well-formed with respect to the compression
-    // scheme.  If this fails, no further validation needs to be done.
-    if ((hr = ValidateSigCompression(tk, pbSig, cbSig)) != S_OK)
-        goto ErrExit;
-
-    // Validate the calling convention.
-    ulCurByte += CorSigUncompressedDataSize(pbSig);
-    ulCallConv = CorSigUncompressData(pbSig);
-
-    i = ulCallConv & IMAGE_CEE_CS_CALLCONV_MASK;
-    if ((i != IMAGE_CEE_CS_CALLCONV_DEFAULT)&&( i != IMAGE_CEE_CS_CALLCONV_VARARG)
-        || (ulCallConv & IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS))
-    {
-        REPORT_ERROR1(VLDTR_E_MD_BADCALLINGCONV, ulCallConv);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    if (TypeFromToken(tk) == mdtMethodDef) // MemberRefs have no flags available
-    {
-        // If HASTHIS is set on the calling convention, the method should not be static.
-        if ((ulCallConv & IMAGE_CEE_CS_CALLCONV_HASTHIS) &&
-            IsMdStatic(dwFlags))
-        {
-            REPORT_ERROR1(VLDTR_E_MD_THISSTATIC, ulCallConv);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-
-        // If HASTHIS is not set on the calling convention, the method should be static.
-        if (!(ulCallConv & IMAGE_CEE_CS_CALLCONV_HASTHIS) &&
-            !IsMdStatic(dwFlags))
-        {
-            REPORT_ERROR1(VLDTR_E_MD_NOTTHISNOTSTATIC, ulCallConv);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-    }
-
-    // Get the type argument count.
-    if (ulCallConv & IMAGE_CEE_CS_CALLCONV_GENERIC)
-    {
-        if (i != IMAGE_CEE_CS_CALLCONV_DEFAULT)
-        {
-            REPORT_ERROR1(VLDTR_E_MD_GENERIC_BADCALLCONV, ulCallConv);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        
-        if (cbSig == ulCurByte)
-        {
-            REPORT_ERROR1(VLDTR_E_MD_MISSARITY, ulCurByte+1);
-            SetVldtrCode(&hr, hrSave);
-            goto ErrExit;
-        }
-        
-        ulCurByte += CorSigUncompressedDataSize(pbSig);
-        ulTyArgCount = CorSigUncompressData(pbSig);
-        
-        if (ulTyArgCount == 0)
-        {
-            REPORT_ERROR1(VLDTR_E_MD_ARITYZERO, ulCurByte);
-            SetVldtrCode(&hrSave, VLDTR_S_ERR);
-        }
-        
-        // If this is a def, check the arity against the number of generic params
-        if (TypeFromToken(tk) == mdtMethodDef)
-        {
-            CMiniMdRW   *pMiniMd = &(m_pStgdb->m_MiniMd);
-            ULONG ulGenericParamCount;
-            HENUMInternal hEnumTyPars;
-            hr = pMiniMd->FindGenericParamHelper(tk, &hEnumTyPars);
-            if (SUCCEEDED(hr))
-            {
-                IfFailGo(HENUMInternal::GetCount(&hEnumTyPars,&ulGenericParamCount));
-                HENUMInternal::ClearEnum(&hEnumTyPars);
-                if (ulTyArgCount != ulGenericParamCount)
-                {
-                    REPORT_ERROR2(VLDTR_E_MD_GPMISMATCH,ulTyArgCount,ulGenericParamCount); 
-                    SetVldtrCode(&hrSave, VLDTR_S_ERR);
-                }
-            }
-        }
-    }
-
-
-    // Is there any sig left for arguments?
-    _ASSERTE(ulCurByte <= cbSig);
-    if (cbSig == ulCurByte)
-    {
-        REPORT_ERROR1(VLDTR_E_MD_NOARGCNT, ulCurByte+1);
-        SetVldtrCode(&hr, hrSave);
-        goto ErrExit;
-    }
-
-    // Get the argument count.
-    ulCurByte += CorSigUncompressedDataSize(pbSig);
-    ulArgCount = CorSigUncompressData(pbSig);
-
-    // Validate the return type and the arguments.
-//    for (i = 0; i < (ulArgCount + 1); i++)
-    for(i=1; ulCurByte < cbSig; i++)
-    {
-        hr = ValidateOneArg(tk, pbSig, cbSig, &ulCurByte,&ulNSentinels,(i > 1));
-        if (hr != S_OK)
-        {
-            if(hr == VLDTR_E_SIG_MISSARG)
-            {
-                REPORT_ERROR1(VLDTR_E_SIG_MISSARG, i);
-            }
-            SetVldtrCode(&hr, hrSave);
-            hrSave = hr;
-            break;
-        }
-    }
-    if((ulNSentinels != 0) && (!isCallConv(ulCallConv, IMAGE_CEE_CS_CALLCONV_VARARG )))
-    {
-        REPORT_ERROR0(VLDTR_E_SIG_SENTMUSTVARARG);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-    if(ulNSentinels > 1)
-    {
-        REPORT_ERROR0(VLDTR_E_SIG_MULTSENTINELS);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateMethodSig()
-
-//*****************************************************************************
-// This function validates the given Field signature.  This function works
-// with Field signature for both the MemberRef and FieldDef.
-//*****************************************************************************
-HRESULT RegMeta::ValidateFieldSig(
-    mdToken     tk,                     // [IN] Token whose signature needs to be validated.
-    PCCOR_SIGNATURE pbSig,              // [IN] Signature.
-    ULONG       cbSig)                  // [IN] Size in bytes of the signature.
-{
-    ULONG       ulCurByte = 0;          // Current index into the signature.
-    ULONG       ulCallConv;             // Calling convention.
-    VEContext   veCtxt;                 // Context record.
-    HRESULT     hr = S_OK;              // Value returned.
-    HRESULT     hrSave = S_OK;          // Save state.
-
-    BEGIN_ENTRYPOINT_NOTHROW;
-
-    _ASSERTE(TypeFromToken(tk) == mdtFieldDef ||
-             TypeFromToken(tk) == mdtMemberRef);
-
-    memset(&veCtxt, 0, sizeof(VEContext));
-    veCtxt.Token = tk;
-    veCtxt.uOffset = 0;
-
-    // Validate the calling convention.
-    ulCurByte += CorSigUncompressedDataSize(pbSig);
-    ulCallConv = CorSigUncompressData(pbSig);
-    if (!isCallConv(ulCallConv, IMAGE_CEE_CS_CALLCONV_FIELD ))
-    {
-        REPORT_ERROR1(VLDTR_E_FD_BADCALLINGCONV, ulCallConv);
-        SetVldtrCode(&hrSave, VLDTR_S_ERR);
-    }
-
-    // Validate the field.
-    IfFailGo(ValidateOneArg(tk, pbSig, cbSig, &ulCurByte,NULL,TRUE));
-    SetVldtrCode(&hrSave, hr);
-
-    hr = hrSave;
-ErrExit:
-    ;
-    END_ENTRYPOINT_NOTHROW;
-    
-    return hr;
-}   // RegMeta::ValidateFieldSig()
-
-//*****************************************************************************
-// This is a utility function to allocate a one-dimensional zero-based safe
-// array of variants.
-//*****************************************************************************
-static HRESULT _AllocSafeVariantArrayVector( // Return status.
-    VARIANT     *rVar,                  // [IN] Variant array.
-    int         cElem,                  // [IN] Size of the array.
-    SAFEARRAY   **ppArray)              // [OUT] Double pointer to SAFEARRAY.
-{
-    HRESULT     hr = S_OK;
-    LONG        i;
-
-    _ASSERTE(rVar && cElem && ppArray);
-
-    IfNullGo(*ppArray = SafeArrayCreateVector(VT_VARIANT, 0, cElem));
-    for (i = 0; i < cElem; i++)
-        IfFailGo(SafeArrayPutElement(*ppArray, &i, &rVar[i]));
-ErrExit:
-    return hr;
-}   // _AllocSafeVariantArrayVector()
-
-//*****************************************************************************
-// Helper function for reporting error with no arguments
-//*****************************************************************************
-HRESULT RegMeta::_ValidateErrorHelper(
-        HRESULT     VECode,
-        VEContext   Context)
-{
-    HRESULT     hr = S_OK;
-    
-    //
-    // MDValidator does not zero out the Context. Fix it here. This fix relies 
-    // on the fact that MDValidator just uses the token  and offset field of the
-    // context.
-    //
-
-    if (Context.Token != 0) {
-        Context.flags = VER_ERR_TOKEN;
-    }
-
-    IfBreakGo(m_pVEHandler->VEHandler(VECode, Context, NULL));
-ErrExit:
-
-    return hr;
-}   // _ValidateErrorHelper()
-
-//*****************************************************************************
-// Helper function for reporting error with 1 argument
-//*****************************************************************************
-HRESULT RegMeta::_ValidateErrorHelper(
-        HRESULT     VECode,
-        VEContext   Context,
-        ULONG       ulVal1)
-{
-    HRESULT     hr = S_OK;
-    SAFEARRAY   *psa = 0;               // The SAFEARRAY.
-    VARIANT     rVar[1];                // The VARIANT array
-
-    if (Context.Token != 0) {
-        Context.flags = VER_ERR_TOKEN;
-    }
-
-    V_VT(&rVar[0]) = VT_UI4;
-    V_UI4(&rVar[0]) = ulVal1;
-    IfFailGo(_AllocSafeVariantArrayVector(rVar, 1, &psa));
-    IfBreakGo(m_pVEHandler->VEHandler(VECode, Context, psa));
-
-ErrExit:
-    if (psa)
-    {
-        HRESULT hrSave = SafeArrayDestroy(psa);
-        if (FAILED(hrSave))
-            hr = hrSave;
-    }
-    return hr;
-}   // _ValidateErrorHelper()
-
-//*****************************************************************************
-// Helper function for reporting error with 2 arguments
-//*****************************************************************************
-HRESULT RegMeta::_ValidateErrorHelper(
-        HRESULT     VECode,
-        VEContext   Context,
-        ULONG       ulVal1,
-        ULONG       ulVal2)
-{
-    HRESULT     hr = S_OK;
-    SAFEARRAY   *psa = 0;               // The SAFEARRAY.
-    VARIANT     rVar[2];                // The VARIANT array
-
-    if (Context.Token != 0) {
-        Context.flags = VER_ERR_TOKEN;
-    }
-    
-    V_VT(&rVar[0]) = VT_UI4;
-    V_UI4(&rVar[0]) = ulVal1;
-    V_VT(&rVar[1]) = VT_UI4;
-    V_UI4(&rVar[1]) = ulVal2;
-
-    IfFailGo(_AllocSafeVariantArrayVector(rVar, 2, &psa));
-    IfBreakGo(m_pVEHandler->VEHandler(VECode, Context, psa));
-
-ErrExit:
-    if (psa)
-    {
-        HRESULT hrSave = SafeArrayDestroy(psa);
-        if (FAILED(hrSave))
-            hr = hrSave;
-    }
-    return hr;
-}   // _ValidateErrorHelper()
-
-//*****************************************************************************
-// Helper function for reporting error with 3 arguments
-//*****************************************************************************
-HRESULT RegMeta::_ValidateErrorHelper(
-        HRESULT     VECode,
-        VEContext   Context,
-        ULONG       ulVal1,
-        ULONG       ulVal2,
-        ULONG       ulVal3)
-{
-    HRESULT     hr = S_OK;
-    SAFEARRAY   *psa = 0;               // The SAFEARRAY.
-    VARIANT     rVar[3];                // The VARIANT array
-
-    if (Context.Token != 0) {
-        Context.flags = VER_ERR_TOKEN;
-    }
-    
-    V_VT(&rVar[0]) = VT_UI4;
-    V_UI4(&rVar[0]) = ulVal1;
-    V_VT(&rVar[1]) = VT_UI4;
-    V_UI4(&rVar[1]) = ulVal2;
-    V_VT(&rVar[2]) = VT_UI4;
-    V_UI4(&rVar[2]) = ulVal3;
-
-    IfFailGo(_AllocSafeVariantArrayVector(rVar, 3, &psa));
-    IfBreakGo(m_pVEHandler->VEHandler(VECode, Context, psa));
-
-ErrExit:
-    if (psa)
-    {
-        HRESULT hrSave = SafeArrayDestroy(psa);
-        if (FAILED(hrSave))
-            hr = hrSave;
-    }
-    return hr;
-}
-
-//*****************************************************************************
-// Helper function to see if there is a duplicate record for ClassLayout.
-//*****************************************************************************
-static HRESULT _FindClassLayout(
-    CMiniMdRW   *pMiniMd,               // [IN] the minimd to lookup
-    mdTypeDef   tkParent,               // [IN] the parent that ClassLayout is associated with
-    RID         *pclRid,                // [OUT] rid for the ClassLayout.
-    RID         rid)                    // [IN] rid to be ignored.
-{
-    HRESULT hr;
-    ULONG       cClassLayoutRecs;
-    ClassLayoutRec *pRecord;
-    mdTypeDef   tkParTmp;
-    ULONG       i;
-
-    _ASSERTE(pMiniMd && pclRid && rid);
-    _ASSERTE(TypeFromToken(tkParent) == mdtTypeDef && RidFromToken(tkParent));
-
-    cClassLayoutRecs = pMiniMd->getCountClassLayouts();
-
-    for (i = 1; i <= cClassLayoutRecs; i++)
-    {
-        // Ignore the rid to be ignored!
-        if (rid == i)
-            continue;
-
-        IfFailRet(pMiniMd->GetClassLayoutRecord(i, &pRecord));
-        tkParTmp = pMiniMd->getParentOfClassLayout(pRecord);
-        if (tkParTmp == tkParent)
-        {
-            *pclRid = i;
-            return S_OK;
-        }
-    }
-    return CLDB_E_RECORD_NOTFOUND;
-}   // _FindClassLayout()
-
-//*****************************************************************************
-// Helper function to see if there is a duplicate for FieldLayout.
-//*****************************************************************************
-static HRESULT _FindFieldLayout(
-    CMiniMdRW   *pMiniMd,               // [IN] the minimd to lookup
-    mdFieldDef  tkParent,               // [IN] the parent that FieldLayout is associated with
-    RID         *pflRid,                // [OUT] rid for the FieldLayout record.
-    RID         rid)                    // [IN] rid to be ignored.
-{
-    HRESULT hr;
-    ULONG       cFieldLayoutRecs;
-    FieldLayoutRec *pRecord;
-    mdFieldDef  tkField;
-    ULONG       i;
-
-    _ASSERTE(pMiniMd && pflRid && rid);
-    _ASSERTE(TypeFromToken(tkParent) == mdtFieldDef && RidFromToken(tkParent));
-
-    cFieldLayoutRecs = pMiniMd->getCountFieldLayouts();
-
-    for (i = 1; i <= cFieldLayoutRecs; i++)
-    {
-        // Ignore the rid to be ignored!
-        if (rid == i)
-            continue;
-
-        IfFailRet(pMiniMd->GetFieldLayoutRecord(i, &pRecord));
-        tkField = pMiniMd->getFieldOfFieldLayout(pRecord);
-        if (tkField == tkParent)
-        {
-            *pflRid = i;
-            return S_OK;
-        }
-    }
-    return CLDB_E_RECORD_NOTFOUND;
-}   // _FindFieldLayout()
-
-//*****************************************************************************
-//*****************************************************************************
-HRESULT
-MDSigComparer::CompareMethodSignature()
-{
-    HRESULT hr = S_OK;
-
-    EX_TRY
-    {
-        hr = _CompareMethodSignature();
-    }
-    EX_CATCH
-    {
-        hr = E_FAIL;
-    }
-    EX_END_CATCH(SwallowAllExceptions)
-
-    return hr;
-}
-
-//*****************************************************************************
-//*****************************************************************************
-HRESULT
-MDSigComparer::_CompareMethodSignature()
-{
-    HRESULT hr;
-
-    // Test equivalency of method signature header
-    ULONG cArgs;
-    IfFailRet(_CompareMethodSignatureHeader(cArgs));
-
-    // Iterate for cArgs + 1 to include the return type
-    for (ULONG i = 0; i < cArgs + 1; i++)
-    {
-        IfFailRet(_CompareExactlyOne());
-    }
-
-    return S_OK;
-}
-
-//*****************************************************************************
-//*****************************************************************************
-HRESULT
-MDSigComparer::_CompareExactlyOne()
-{
-    HRESULT hr;
-
-    CorElementType typ1, typ2;
-    IfFailRet(m_sig1.GetElemType(&typ1));
-    IfFailRet(m_sig2.GetElemType(&typ2));
-
-    if (typ1 != typ2)
-    {
-        return E_FAIL;
-    }
-
-    CorElementType typ = typ1;
-    if (!CorIsPrimitiveType((CorElementType)typ))
-    {
-        switch (typ)
-        {
-            default:
-            {
-                // _ASSERT(!"Illegal or unimplement type in COM+ sig.");
-                return META_E_BAD_SIGNATURE;
-                break;
-            }
-            case ELEMENT_TYPE_VAR:
-            case ELEMENT_TYPE_MVAR:
-            {
-                IfFailRet(_CompareData(NULL));                  // Skip variable number
-                break;
-            }
-            case ELEMENT_TYPE_OBJECT:
-            case ELEMENT_TYPE_STRING:
-            case ELEMENT_TYPE_TYPEDBYREF:
-            {
-                break;
-            }
-
-            case ELEMENT_TYPE_BYREF:                            // fallthru
-            case ELEMENT_TYPE_PTR:
-            case ELEMENT_TYPE_PINNED:
-            case ELEMENT_TYPE_SZARRAY:
-            {
-                IfFailRet(_CompareExactlyOne());                // Compare referenced type
-                break;
-            }
-
-            case ELEMENT_TYPE_VALUETYPE:                        // fallthru
-            case ELEMENT_TYPE_CLASS:
-            {
-                mdToken tok1, tok2;
-                IfFailRet(m_sig1.GetToken(&tok1));
-                IfFailRet(m_sig2.GetToken(&tok2));
-                IfFailRet(m_comparer.CompareToken(tok1, tok2));
-                break;
-            }
-
-            case ELEMENT_TYPE_FNPTR:
-            {
-                IfFailRet(_CompareMethodSignature());
-                break;
-            }
-
-            case ELEMENT_TYPE_ARRAY:
-            {
-                IfFailRet(_CompareExactlyOne());                // Compare element type
-
-                ULONG rank;
-                IfFailRet(_CompareData(&rank));                 // Compare & get rank
-
-                if (rank)
-                {
-                    ULONG nsizes;
-                    IfFailRet(_CompareData(&nsizes));           // Compare & get # of sizes
-                    while (nsizes--)
-                    {
-                        IfFailRet(_CompareData(NULL));          // Compare size
-                    }
-
-                    ULONG nlbounds;
-                    IfFailRet(_CompareData(&nlbounds));         // Compare & get # of lower bounds
-                    while (nlbounds--)
-                    {
-                        IfFailRet(_CompareData(NULL));          // Compare lower bounds
-                    }
-                }
-
-                break;
-            }
-
-            case ELEMENT_TYPE_SENTINEL:
-            {
-                // Should be unreachable since GetElem strips it
-                break;
-            }
-
-            case ELEMENT_TYPE_INTERNAL:
-            {
-                // Shouldn't ever get this since it is internal to the runtime,
-                // but just in case we know how to compare and skip these.
-                PVOID val1 = *((PVOID *)m_sig1.m_ptr);
-                PVOID val2 = *((PVOID *)m_sig2.m_ptr);
-
-                if (val1 != val2)
-                {
-                    return E_FAIL;
-                }
-
-                m_sig1.SkipBytes(sizeof(void*));
-                m_sig2.SkipBytes(sizeof(void*));
-                break;
-            }
-
-            case ELEMENT_TYPE_GENERICINST:
-            {
-                IfFailRet(_CompareExactlyOne());                  // Compare generic type
-                ULONG argCnt;
-                IfFailRet(_CompareData(&argCnt));               // Compare & get number of parameters
-                _ASSERTE(argCnt > 0);
-                while (argCnt--)
-                {
-                    IfFailRet(_CompareExactlyOne());              // Compare the parameters
-                }
-                break;
-            }
-        }
-    }
-
-    return S_OK;
-}
-
-//*****************************************************************************
-//*****************************************************************************
-HRESULT
-MDSigComparer::_CompareData(
-    ULONG     *pulData)
-{
-    ULONG cbCompressedData1, cbCompressedData2;
-    ULONG ulData1, ulData2;
-
-    cbCompressedData1 = CorSigUncompressData(m_sig1.m_ptr, &ulData1);
-    cbCompressedData2 = CorSigUncompressData(m_sig2.m_ptr, &ulData2);
-
-    if ((cbCompressedData1 == ((ULONG)(-1))) ||
-        (cbCompressedData2 == ((ULONG)(-1))) ||
-        (cbCompressedData1 != cbCompressedData2) ||
-        (ulData1 != ulData2))
-    {
-        return E_FAIL;
-    }
-
-    m_sig1.SkipBytes(cbCompressedData1);
-    m_sig2.SkipBytes(cbCompressedData2);
-
-    // Out data
-    if (pulData)
-        *pulData = ulData1;
-
-    return S_OK;
-}
-
-//*****************************************************************************
-//*****************************************************************************
-HRESULT
-MDSigComparer::_CompareMethodSignatureHeader(
-    ULONG     &cArgs)
-{
-    HRESULT hr;
-
-    // Get calling convention information, but only use it to get type param information.
-    ULONG uCallConv1, uCallConv2;
-    IfFailRet(m_sig1.GetData(&uCallConv1));
-    IfFailRet(m_sig2.GetData(&uCallConv2));
-
-    // Check type parameter information
-    ULONG uTypeParamCount1 = 0;
-    ULONG uTypeParamCount2 = 0;
-
-    if (uCallConv1 & IMAGE_CEE_CS_CALLCONV_GENERIC)
-        IfFailRet(m_sig1.GetData(&uTypeParamCount1));
-
-    if (uCallConv2 & IMAGE_CEE_CS_CALLCONV_GENERIC)
-        IfFailRet(m_sig2.GetData(&uTypeParamCount2));
-
-    if (uTypeParamCount1 != uTypeParamCount2)
-    {
-        return E_FAIL;
-    }
-
-    // Get arg count
-    ULONG cArgs1, cArgs2;
-    IfFailRet(m_sig1.GetData(&cArgs1));
-    IfFailRet(m_sig2.GetData(&cArgs2));
-
-    if (cArgs1 != cArgs2)
-    {
-        return E_FAIL;
-    }
-
-    // Out parameter
-    cArgs = cArgs1;
-
-    return S_OK;
-}
-
-//*****************************************************************************
-//*****************************************************************************
-
-
-HRESULT UnifiedAssemblySigComparer::_CompareAssemblies(mdToken tkAsmRef1,mdToken tkAsmRef2, BOOL* pfEquivalent)
-{
-
-    HRESULT hr;
-    void const *        pvPublicKey1;
-    ULONG               cbPublicKey1;
-    ULONG               cchName1;
-    ASSEMBLYMETADATA    amd1;
-    void const *        pvHashValue;
-    ULONG               cbHashValue;
-    DWORD               dwFlags1;
-
-    void const *        pvPublicKey2;
-    ULONG               cbPublicKey2;
-    ULONG               cchName2;
-    ASSEMBLYMETADATA    amd2;
-    DWORD               dwFlags2;
-
-
-    ZeroMemory(&amd1, sizeof(amd1));
-    ZeroMemory(&amd2, sizeof(amd2));
-    
-    IfFailRet(m_pRegMeta->GetAssemblyRefProps(tkAsmRef1,
-                                  NULL,
-                                  NULL,
-                                  NULL,
-                                  0,
-                                  &cchName1,
-                                  &amd1,
-                                  NULL,
-                                  NULL,
-                                  NULL));
-
-    StackSString ssName1;
-    StackSString ssLocale1;
-    amd1.szLocale = ssLocale1.OpenUnicodeBuffer(amd1.cbLocale);
-
-    IfFailRet(m_pRegMeta->GetAssemblyRefProps(tkAsmRef1,
-                                  &pvPublicKey1,
-                                  &cbPublicKey1,
-                                  ssName1.OpenUnicodeBuffer(cchName1),
-                                  cchName1,
-                                  &cchName1,
-                                  &amd1,
-                                  &pvHashValue,
-                                  &cbHashValue,
-                                  &dwFlags1));
-
-    ssName1.CloseBuffer();
-    ssLocale1.CloseBuffer();
-
-    IfFailRet(m_pRegMeta->GetAssemblyRefProps(tkAsmRef2,
-                                  NULL,
-                                  NULL,
-                                  NULL,
-                                  0,
-                                  &cchName2,
-                                  &amd2,
-                                  NULL,
-                                  NULL,
-                                  NULL));
-
-    StackSString ssName2;
-    StackSString ssLocale2;
-    amd2.szLocale = ssLocale2.OpenUnicodeBuffer(amd2.cbLocale);
-
-    IfFailRet(m_pRegMeta->GetAssemblyRefProps(tkAsmRef2,
-                                  &pvPublicKey2,
-                                  &cbPublicKey2,
-                                  ssName2.OpenUnicodeBuffer(cchName2),
-                                  cchName2,
-                                  &cchName2,
-                                  &amd2,
-                                  &pvHashValue,
-                                  &cbHashValue,
-                                  &dwFlags2));
-
-    ssName2.CloseBuffer();
-    ssLocale2.CloseBuffer();
-
-    StackSString sMscorlib(W("mscorlib"));
-
-
-    if(ssName1.CompareCaseInsensitive(sMscorlib)==0 &&
-        ssName2.CompareCaseInsensitive(sMscorlib)==0 ) 
-    {
-        *pfEquivalent=TRUE;
-        return S_OK;
-    }
-
-    *pfEquivalent=FALSE;
-    
-    if (ssName1.CompareCaseInsensitive(ssName2)!=0)
-        return S_OK;
-    if (ssLocale1.CompareCaseInsensitive(ssLocale2)!=0)
-        return S_OK;
-    if(cbPublicKey1!=cbPublicKey2)
-        return S_OK;
-    if(memcmp(pvPublicKey1,pvPublicKey2,cbPublicKey1)!=0)
-        return S_OK;
-    if(dwFlags1!=dwFlags2)
-        return S_OK;
-    if(amd1.usMajorVersion!=amd2.usMajorVersion)
-        return S_OK;
-    if(amd1.usMinorVersion!=amd2.usMinorVersion)
-        return S_OK;
-    if(amd1.usBuildNumber!=amd2.usBuildNumber)
-        return S_OK;
-    if(amd1.usRevisionNumber!=amd2.usRevisionNumber)
-        return S_OK;
-    
-    *pfEquivalent=TRUE;
-    return S_OK;
-
-};
-
-//*****************************************************************************
-//*****************************************************************************
-HRESULT
-UnifiedAssemblySigComparer::_CreateTypeNameFromTypeRef(
-    mdToken tkTypeRef,
-    SString &ssName,
-    mdToken &tkParent)
-{
-    HRESULT hr;
-
-    // Get the parent token as well as the name, and return.
-    ULONG cchTypeRef;
-    IfFailRet(m_pRegMeta->GetTypeRefProps(tkTypeRef, NULL, NULL, 0, &cchTypeRef));
-    IfFailRet(m_pRegMeta->GetTypeRefProps(tkTypeRef, &tkParent, ssName.OpenUnicodeBuffer(cchTypeRef), cchTypeRef, NULL));
-    ssName.CloseBuffer();
-
-    return S_OK;
-}
-
-//*****************************************************************************
-//*****************************************************************************
-HRESULT
-UnifiedAssemblySigComparer::_CreateFullyQualifiedTypeNameFromTypeRef(
-    mdToken tkTypeRef,
-    SString &ssFullName,
-    mdToken &tkParent)
-{
-    HRESULT hr;
-
-    StackSString ssBuf;
-    StackSString ssName;
-    mdToken tok = tkTypeRef;
-    BOOL fFirstLoop = TRUE;
-
-    // Loop stops at first non-typeref parent token.
-    do
-    {
-        // Get the name for this token, as well as the parent token value.
-        IfFailRet(_CreateTypeNameFromTypeRef(tok, ssName, tok));
-
-        // If this is the first time through the loop, just assign values.
-        if (fFirstLoop)
-        {
-            ssFullName = ssName;
-            fFirstLoop = FALSE;
-        }
-        // If this isn't the first time through, make nested type name
-        else
-        {
-            ns::MakeNestedTypeName(ssBuf, ssName, ssFullName);
-            ssFullName = ssBuf;
-        }
-    } while (TypeFromToken(tok) == mdtTypeRef);
-
-    // Assign non-typeref token parent
-    tkParent = tok;
-
-    return S_OK;
-}
-
-
-
-//*****************************************************************************
-//*****************************************************************************
-HRESULT
-UnifiedAssemblySigComparer::CompareToken(
-    const mdToken &tok1,
-    const mdToken &tok2)
-{
-    HRESULT hr;
-
-    // Check binary equality
-    if (tok1 == tok2)
-    {
-        return S_OK;
-    }
-
-    // Currently only want to do extra checking on TypeRefs
-    if (TypeFromToken(tok1) != mdtTypeRef || TypeFromToken(tok2) != mdtTypeRef)
-    {
-        return E_FAIL;
-    }
-
-    // Get the fully qualified type names as well as the non-typeref parents.
-    mdToken tkParent1, tkParent2;
-    StackSString ssName1, ssName2;
-
-    IfFailRet(_CreateFullyQualifiedTypeNameFromTypeRef(tok1, ssName1, tkParent1));
-    IfFailRet(_CreateFullyQualifiedTypeNameFromTypeRef(tok2, ssName2, tkParent2));
-
-    // Currently only want to do extra checking if the parent tokens are AssemblyRefs
-    if (TypeFromToken(tkParent1) != mdtAssemblyRef || TypeFromToken(tkParent2) != mdtAssemblyRef)
-    {
-        return E_FAIL;
-    }
-
-    // If the type names are not equal, no need to check the assembly refs for unification since
-    // we know the types couldn't possibly match.
-    if (!ssName1.Equals(ssName2))
-    {
-        return E_FAIL;
-    }
-    BOOL fEquivalent;
-
-    // no redirects supported
-    IfFailRet(_CompareAssemblies(tkParent1,tkParent2,&fEquivalent));
-
-    if (!fEquivalent)
-    {
-        return E_FAIL;
-    }
-
-    return S_OK;
-}
-
-
-//*****************************************************************************
-// Helper function to validate a locale.
-//*****************************************************************************
-static const char* const g_szValidLocale_V1[] = {
-"ar","ar-SA","ar-IQ","ar-EG","ar-LY","ar-DZ","ar-MA","ar-TN","ar-OM","ar-YE","ar-SY","ar-JO","ar-LB","ar-KW","ar-AE","ar-BH","ar-QA",
-"bg","bg-BG",
-"ca","ca-ES",
-"zh-CHS","zh-TW","zh-CN","zh-HK","zh-SG","zh-MO","zh-CHT",
-"cs","cs-CZ",
-"da","da-DK",
-"de","de-DE","de-CH","de-AT","de-LU","de-LI",
-"el","el-GR",
-"en","en-US","en-GB","en-AU","en-CA","en-NZ","en-IE","en-ZA","en-JM","en-CB","en-BZ","en-TT","en-ZW","en-PH",
-"es","es-ES-Ts","es-MX","es-ES","es-GT","es-CR","es-PA","es-DO","es-VE","es-CO","es-PE","es-AR","es-EC","es-CL",
-"es-UY","es-PY","es-BO","es-SV","es-HN","es-NI","es-PR",
-"fi","fi-FI",
-"fr","fr-FR","fr-BE","fr-CA","fr-CH","fr-LU","fr-MC",
-"he","he-IL",
-"hu","hu-HU",
-"is","is-IS",
-"it","it-IT","it-CH",
-"ja","ja-JP",
-"ko","ko-KR",
-"nl","nl-NL","nl-BE",
-"no",
-"nb-NO",
-"nn-NO",
-"pl","pl-PL",
-"pt","pt-BR","pt-PT",
-"ro","ro-RO",
-"ru","ru-RU",
-"hr","hr-HR",
-"sk","sk-SK",
-"sq","sq-AL",
-"sv","sv-SE","sv-FI",
-"th","th-TH",
-"tr","tr-TR",
-"ur","ur-PK",
-"id","id-ID",
-"uk","uk-UA",
-"be","be-BY",
-"sl","sl-SI",
-"et","et-EE",
-"lv","lv-LV",
-"lt","lt-LT",
-"fa","fa-IR",
-"vi","vi-VN",
-"hy","hy-AM",
-"az",
-"eu","eu-ES",
-"mk","mk-MK",
-"af","af-ZA",
-"ka","ka-GE",
-"fo","fo-FO",
-"hi","hi-IN",
-"ms","ms-MY","ms-BN",
-"kk","kk-KZ",
-"ky","ky-KZ",
-"sw","sw-KE",
-"uz",
-"tt","tt-RU",
-"pa","pa-IN",
-"gu","gu-IN",
-"ta","ta-IN",
-"te","te-IN",
-"kn","kn-IN",
-"mr","mr-IN",
-"sa","sa-IN",
-"mn","mn-MN",
-"gl","gl-ES",
-"kok","kok-IN",
-"syr","syr-SY",
-"div"
-};
-
-static const char* const g_szValidLocale_V2[] = {
-    "bn", "bn-IN",
-    "bs-Latn-BA", "bs-Cyrl-BA",
-    "hr-BA",
-    "fil", "fil-PH",
-    "fy", "fy-NL",
-    "iu-Latn-CA",
-    "ga", "ga-IE",
-    "ky-KG",
-    "lb", "lb-LU",
-    "ml", "ml-IN",
-    "mt", "mt-MT",
-    "mi", "mi-NZ",
-    "arn", "arn-CL",
-    "moh", "moh-CA",
-    "ne", "ne-NP",
-    "ps", "ps-AF",
-    "quz", "quz-BO", "quz-EC", "quz-PE",
-    "rm", "rm-CH",
-    "smn", "smn-FI",
-    "smj" , "smj-SE", "smj-NO",
-    "se", "se-NO", "se-SE", "se-FI",
-    "sms", "sms-FI",
-    "sma", "sma-NO", "sma-SE",
-    "sr-Latn-BA", "sr-Cyrl-BA",
-    "nso", "nso-ZA"
-};
-
-// Pre-vista specific cultures (renamed on Vista)
-static const char* const g_szValidLocale_PreVista[] = {
-    "div-MV",
-    "sr-SP-Latn", "sr-SP-Cyrl",
-    "az-AZ-Latn", "az-AZ-Cyrl",
-    "uz-UZ-Latn", "uz-UZ-Cyrl",
-};
-
-// Vista only specific cultures (renamed and freshly introduced)
-static const char * const g_szValidLocale_Vista[] = {
-    "dv-MV",
-    "sr-Latn-CS", "sr-Cyrl-CS",
-    "az-Latn-AZ", "az-Cyrl-AZ",
-    "uz-Latn-UZ", "uz-Cyrl-UZ",
-    "zh-Hant", "zh-Hans",
-    "gsw", "gsw-FR",
-    "am", "am-ET",
-    "as", "as-IN",
-    "ba", "ba-RU",
-    "br", "br-FR",
-    "en-IN",
-    "kl", "kl-GL",
-    "iu-Cans-CA",
-    "km", "km-KH",
-    "lo", "lo-LA",
-    "dsb", "dsb-DE",
-    "mn-Mong-CN",
-    "oc", "oc-FR",
-    "or", "or-IN"
-};
-
-static BOOL FindInArray(LPCUTF8 szLocale, const char * const *cultureArr, const int nCultures)
-{
-    for (int i = 0; i < nCultures; i++)
-    {
-        if(!SString::_stricmp(szLocale, cultureArr[i]))
-            return TRUE;
-    }
-    return FALSE;
-}
-
-#define LENGTH_OF(x) (sizeof(x) / sizeof(x[0]))
-
-// For Everett assemblies, only the preVista cultures are valid even if running on Vista.
-static BOOL _IsValidLocale(LPCUTF8 szLocale,
-                           BOOL    fIsV2Assembly)
-{
-    if (szLocale && *szLocale)
-    {
-        // Locales valid for Everett and Whidbey
-        if (FindInArray(szLocale, g_szValidLocale_V1, LENGTH_OF(g_szValidLocale_V1)))
-            return TRUE;
-        
-        // Locales valid for Whidbey assemblies only
-        if (fIsV2Assembly &&
-            FindInArray(szLocale, g_szValidLocale_V2, LENGTH_OF(g_szValidLocale_V2)))
-            return TRUE;
-        
-        // Finally search OS specific cultures
-        if (fIsV2Assembly)
-            return FindInArray(szLocale, g_szValidLocale_Vista, LENGTH_OF(g_szValidLocale_Vista));
-        else
-            return FindInArray(szLocale, g_szValidLocale_PreVista, LENGTH_OF(g_szValidLocale_PreVista));
-    }
-
-    return TRUE;
-}
-
-#endif //FEATURE_METADATA_VALIDATOR
index f591a6e..170893e 100644 (file)
@@ -67,7 +67,6 @@ RegMeta::RegMeta() :
     m_trLanguageType(0),
     m_SetAPICaller(EXTERNAL_CALLER),
     m_ModuleType(ValidatorModuleTypeInvalid),
-    m_pVEHandler(0),
     m_bKeepKnownCa(false),
     m_pCorProfileData(NULL),
     m_ReorderingOptions(NoReordering)
@@ -156,9 +155,6 @@ RegMeta::~RegMeta()
         delete pCur;
     }
 
-    if (m_pVEHandler)
-        m_pVEHandler->Release();
-
     // If This RegMeta spun up the runtime (probably to process security 
     //  attributes), shut it down now.
     if (m_fStartedEE) 
index 04456d8..0c61246 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "rwutil.h"
 #include "mdperf.h"
-#include <ivehandler.h>
 
 #include "sigparser.h"
 
@@ -157,10 +156,6 @@ class RegMeta :
     , public IMetaDataAssemblyEmit 
 #endif
 
-#ifdef FEATURE_METADATA_VALIDATOR
-    , public IMetaDataValidate 
-#endif
-
 #ifdef FEATURE_METADATA_EMIT_ALL
     , public IMetaDataFilter 
 #endif
@@ -1195,18 +1190,6 @@ public:
 
 #endif //FEATURE_METADATA_EMIT
 
-#ifdef FEATURE_METADATA_VALIDATOR
-//*****************************************************************************
-// IMetaDataValidator
-//*****************************************************************************
-
-    STDMETHODIMP ValidatorInit(
-        DWORD      dwModuleType,    // [IN] Specifies whether the module is a PE file or an obj.
-        IUnknown * pUnk);           // [IN] Validation error handler.
-
-    STDMETHODIMP ValidateMetaData();
-#endif //FEATURE_METADATA_VALIDATOR
-
 #ifdef FEATURE_METADATA_EMIT_ALL
 //*****************************************************************************
 // IMetaDataFilter
@@ -2040,7 +2023,6 @@ private:
     SetAPICallerType m_SetAPICaller;
 
     CorValidatorModuleType      m_ModuleType;
-    IVEHandler                  *m_pVEHandler;
     CCustAttrHash               m_caHash;   // Hashed list of custom attribute types seen.
     
     bool        m_bKeepKnownCa;             // Should all known CA's be kept?
@@ -2055,28 +2037,6 @@ private:
                               // There is an equivalent state in MiniMD, and both must be
                               // TRUE in order to delete safely.
 #endif
-
-    HRESULT _ValidateErrorHelper(
-        HRESULT     VECode,
-        VEContext   Context);
-
-    HRESULT _ValidateErrorHelper(
-        HRESULT     VECode,
-        VEContext   Context,
-        ULONG       ulVal1);
-
-    HRESULT _ValidateErrorHelper(
-        HRESULT     VECode,
-        VEContext   Context,
-        ULONG       ulVal1,
-        ULONG       ulVal2);
-    
-    HRESULT _ValidateErrorHelper(
-        HRESULT     VECode,
-        VEContext   Context,
-        ULONG       ulVal1,
-        ULONG       ulVal2,
-        ULONG       ulVal3);
     
 private:
     // Returns pointer to zeros of size (cbSize).
diff --git a/src/pal/prebuilt/idl/fusionpriv_i.cpp b/src/pal/prebuilt/idl/fusionpriv_i.cpp
deleted file mode 100644 (file)
index ece9622..0000000
+++ /dev/null
@@ -1,121 +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 ALWAYS GENERATED file contains the IIDs and CLSIDs */
-
-/* link this file in with the server and any clients */
-
-
- /* File created by MIDL compiler version 8.00.0603 */
-/* @@MIDL_FILE_HEADING(  ) */
-
-#pragma warning( disable: 4049 )  /* more than 64k source lines */
-
-
-#ifdef __cplusplus
-extern "C"{
-#endif 
-
-
-#include <rpc.h>
-#include <rpcndr.h>
-
-#ifdef _MIDL_USE_GUIDDEF_
-
-#ifndef INITGUID
-#define INITGUID
-#include <guiddef.h>
-#undef INITGUID
-#else
-#include <guiddef.h>
-#endif
-
-#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
-        DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
-
-#else // !_MIDL_USE_GUIDDEF_
-
-#ifndef __IID_DEFINED__
-#define __IID_DEFINED__
-
-typedef struct _IID
-{
-    unsigned long x;
-    unsigned short s1;
-    unsigned short s2;
-    unsigned char  c[8];
-} IID;
-
-#endif // __IID_DEFINED__
-
-#ifndef CLSID_DEFINED
-#define CLSID_DEFINED
-typedef IID CLSID;
-#endif // CLSID_DEFINED
-
-#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
-        const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
-
-#endif !_MIDL_USE_GUIDDEF_
-
-MIDL_DEFINE_GUID(IID, IID_IHistoryAssembly,0xe6096a07,0xe188,0x4a49,0x8d,0x50,0x2a,0x01,0x72,0xa0,0xd2,0x05);
-
-
-MIDL_DEFINE_GUID(IID, IID_IHistoryReader,0x1d23df4d,0xa1e2,0x4b8b,0x93,0xd6,0x6e,0xa3,0xdc,0x28,0x5a,0x54);
-
-
-MIDL_DEFINE_GUID(IID, IID_IFusionBindLog,0x67E9F87D,0x8B8A,0x4a90,0x9D,0x3E,0x85,0xED,0x5B,0x2D,0xCC,0x83);
-
-
-MIDL_DEFINE_GUID(IID, IID_IAssemblyManifestImport,0xde9a68ba,0x0fa2,0x11d3,0x94,0xaa,0x00,0xc0,0x4f,0xc3,0x08,0xff);
-
-
-MIDL_DEFINE_GUID(IID, IID_IApplicationContext,0x7c23ff90,0x33af,0x11d3,0x95,0xda,0x00,0xa0,0x24,0xa8,0x5b,0x51);
-
-
-MIDL_DEFINE_GUID(IID, IID_IAssemblyNameBinder,0x56972d9d,0x0f6c,0x47de,0xa0,0x38,0xe8,0x2d,0x5d,0xe3,0xa7,0x77);
-
-
-MIDL_DEFINE_GUID(IID, IID_IAssembly,0xff08d7d4,0x04c2,0x11d3,0x94,0xaa,0x00,0xc0,0x4f,0xc3,0x08,0xff);
-
-
-MIDL_DEFINE_GUID(IID, IID_IAssemblyBindingClosureEnumerator,0xb3f1e4ed,0xcb09,0x4b85,0x9a,0x1b,0x68,0x09,0x58,0x2f,0x1e,0xbc);
-
-
-MIDL_DEFINE_GUID(IID, IID_IAssemblyBindingClosure,0x415c226a,0xe513,0x41ba,0x96,0x51,0x9c,0x48,0xe9,0x7a,0xa5,0xde);
-
-
-MIDL_DEFINE_GUID(IID, IID_IAssemblyBindSink,0xaf0bc960,0x0b9a,0x11d3,0x95,0xca,0x00,0xa0,0x24,0xa8,0x5b,0x51);
-
-
-MIDL_DEFINE_GUID(IID, IID_IAssemblyBinding,0xcfe52a80,0x12bd,0x11d3,0x95,0xca,0x00,0xa0,0x24,0xa8,0x5b,0x51);
-
-
-MIDL_DEFINE_GUID(IID, IID_IAssemblyModuleImport,0xda0cd4b0,0x1117,0x11d3,0x95,0xca,0x00,0xa0,0x24,0xa8,0x5b,0x51);
-
-
-MIDL_DEFINE_GUID(IID, IID_IAssemblyScavenger,0x21b8916c,0xf28e,0x11d2,0xa4,0x73,0x00,0xcc,0xff,0x8e,0xf4,0x48);
-
-
-MIDL_DEFINE_GUID(IID, IID_ICodebaseList,0xD8FB9BD6,0x3969,0x11d3,0xB4,0xAF,0x00,0xC0,0x4F,0x8E,0xCB,0x26);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDownloadMgr,0x0A6F16F8,0xACD7,0x11d3,0xB4,0xED,0x00,0xC0,0x4F,0x8E,0xCB,0x26);
-
-
-MIDL_DEFINE_GUID(IID, IID_IHostAssembly,0x711f7c2d,0x8234,0x4505,0xb0,0x2f,0x75,0x54,0xf4,0x6c,0xbf,0x29);
-
-
-MIDL_DEFINE_GUID(IID, IID_IHostAssemblyModuleImport,0xb6f2729d,0x6c0f,0x4944,0xb6,0x92,0xe5,0xa2,0xce,0x2c,0x6e,0x7a);
-
-#undef MIDL_DEFINE_GUID
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
diff --git a/src/pal/prebuilt/idl/ivalidator_i.cpp b/src/pal/prebuilt/idl/ivalidator_i.cpp
deleted file mode 100644 (file)
index 0edbec4..0000000
+++ /dev/null
@@ -1,76 +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 ALWAYS GENERATED file contains the IIDs and CLSIDs */
-
-/* link this file in with the server and any clients */
-
-
- /* File created by MIDL compiler version 8.00.0603 */
-/* @@MIDL_FILE_HEADING(  ) */
-
-#pragma warning( disable: 4049 )  /* more than 64k source lines */
-
-
-#ifdef __cplusplus
-extern "C"{
-#endif 
-
-
-#include <rpc.h>
-#include <rpcndr.h>
-
-#ifdef _MIDL_USE_GUIDDEF_
-
-#ifndef INITGUID
-#define INITGUID
-#include <guiddef.h>
-#undef INITGUID
-#else
-#include <guiddef.h>
-#endif
-
-#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
-        DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
-
-#else // !_MIDL_USE_GUIDDEF_
-
-#ifndef __IID_DEFINED__
-#define __IID_DEFINED__
-
-typedef struct _IID
-{
-    unsigned long x;
-    unsigned short s1;
-    unsigned short s2;
-    unsigned char  c[8];
-} IID;
-
-#endif // __IID_DEFINED__
-
-#ifndef CLSID_DEFINED
-#define CLSID_DEFINED
-typedef IID CLSID;
-#endif // CLSID_DEFINED
-
-#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
-        const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
-
-#endif !_MIDL_USE_GUIDDEF_
-
-MIDL_DEFINE_GUID(IID, IID_IValidator,0x63DF8730,0xDC81,0x4062,0x84,0xA2,0x1F,0xF9,0x43,0xF5,0x9F,0xAC);
-
-
-MIDL_DEFINE_GUID(IID, IID_ICLRValidator,0x63DF8730,0xDC81,0x4062,0x84,0xA2,0x1F,0xF9,0x43,0xF5,0x9F,0xDD);
-
-#undef MIDL_DEFINE_GUID
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
diff --git a/src/pal/prebuilt/idl/ivehandler_i.cpp b/src/pal/prebuilt/idl/ivehandler_i.cpp
deleted file mode 100644 (file)
index 44d0b96..0000000
+++ /dev/null
@@ -1,79 +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 ALWAYS GENERATED file contains the IIDs and CLSIDs */
-
-/* link this file in with the server and any clients */
-
-
- /* File created by MIDL compiler version 8.00.0603 */
-/* @@MIDL_FILE_HEADING(  ) */
-
-#pragma warning( disable: 4049 )  /* more than 64k source lines */
-
-
-#ifdef __cplusplus
-extern "C"{
-#endif 
-
-
-#include <rpc.h>
-#include <rpcndr.h>
-
-#ifdef _MIDL_USE_GUIDDEF_
-
-#ifndef INITGUID
-#define INITGUID
-#include <guiddef.h>
-#undef INITGUID
-#else
-#include <guiddef.h>
-#endif
-
-#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
-        DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
-
-#else // !_MIDL_USE_GUIDDEF_
-
-#ifndef __IID_DEFINED__
-#define __IID_DEFINED__
-
-typedef struct _IID
-{
-    unsigned long x;
-    unsigned short s1;
-    unsigned short s2;
-    unsigned char  c[8];
-} IID;
-
-#endif // __IID_DEFINED__
-
-#ifndef CLSID_DEFINED
-#define CLSID_DEFINED
-typedef IID CLSID;
-#endif // CLSID_DEFINED
-
-#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
-        const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
-
-#endif !_MIDL_USE_GUIDDEF_
-
-MIDL_DEFINE_GUID(IID, LIBID_VEHandlerLib,0x856CA1B0,0x7DAB,0x11d3,0xAC,0xEC,0x00,0xC0,0x4F,0x86,0xC3,0x09);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_VEHandlerClass,0x856CA1B1,0x7DAB,0x11d3,0xAC,0xEC,0x00,0xC0,0x4F,0x86,0xC3,0x09);
-
-
-MIDL_DEFINE_GUID(IID, IID_IVEHandler,0x856CA1B2,0x7DAB,0x11d3,0xAC,0xEC,0x00,0xC0,0x4F,0x86,0xC3,0x09);
-
-#undef MIDL_DEFINE_GUID
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
diff --git a/src/pal/prebuilt/idl/tlbimpexp_i.cpp b/src/pal/prebuilt/idl/tlbimpexp_i.cpp
deleted file mode 100644 (file)
index 0eb2791..0000000
+++ /dev/null
@@ -1,82 +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 ALWAYS GENERATED file contains the IIDs and CLSIDs */
-
-/* link this file in with the server and any clients */
-
-
- /* File created by MIDL compiler version 8.00.0603 */
-/* @@MIDL_FILE_HEADING(  ) */
-
-#pragma warning( disable: 4049 )  /* more than 64k source lines */
-
-
-#ifdef __cplusplus
-extern "C"{
-#endif 
-
-
-#include <rpc.h>
-#include <rpcndr.h>
-
-#ifdef _MIDL_USE_GUIDDEF_
-
-#ifndef INITGUID
-#define INITGUID
-#include <guiddef.h>
-#undef INITGUID
-#else
-#include <guiddef.h>
-#endif
-
-#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
-        DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
-
-#else // !_MIDL_USE_GUIDDEF_
-
-#ifndef __IID_DEFINED__
-#define __IID_DEFINED__
-
-typedef struct _IID
-{
-    unsigned long x;
-    unsigned short s1;
-    unsigned short s2;
-    unsigned char  c[8];
-} IID;
-
-#endif // __IID_DEFINED__
-
-#ifndef CLSID_DEFINED
-#define CLSID_DEFINED
-typedef IID CLSID;
-#endif // CLSID_DEFINED
-
-#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
-        const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
-
-#endif !_MIDL_USE_GUIDDEF_
-
-MIDL_DEFINE_GUID(IID, LIBID_TlbImpLib,0x20BC1825,0x06F0,0x11d2,0x8C,0xF4,0x00,0xA0,0xC9,0xB0,0xA0,0x63);
-
-
-MIDL_DEFINE_GUID(IID, IID_ITypeLibImporterNotifySink,0xF1C3BF76,0xC3E4,0x11D3,0x88,0xE7,0x00,0x90,0x27,0x54,0xC4,0x3A);
-
-
-MIDL_DEFINE_GUID(IID, IID_ITypeLibExporterNotifySink,0xF1C3BF77,0xC3E4,0x11D3,0x88,0xE7,0x00,0x90,0x27,0x54,0xC4,0x3A);
-
-
-MIDL_DEFINE_GUID(IID, IID_ITypeLibExporterNameProvider,0xFA1F3615,0xACB9,0x486d,0x9E,0xAC,0x1B,0xEF,0x87,0xE3,0x6B,0x09);
-
-#undef MIDL_DEFINE_GUID
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
diff --git a/src/pal/prebuilt/inc/ivalidator.h b/src/pal/prebuilt/inc/ivalidator.h
deleted file mode 100644 (file)
index 320022d..0000000
+++ /dev/null
@@ -1,334 +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 ALWAYS GENERATED file contains the definitions for the interfaces */
-
-
- /* File created by MIDL compiler version 8.00.0603 */
-/* @@MIDL_FILE_HEADING(  ) */
-
-#pragma warning( disable: 4049 )  /* more than 64k source lines */
-
-
-/* verify that the <rpcndr.h> version is high enough to compile this file*/
-#ifndef __REQUIRED_RPCNDR_H_VERSION__
-#define __REQUIRED_RPCNDR_H_VERSION__ 475
-#endif
-
-#include "rpc.h"
-#include "rpcndr.h"
-
-#ifndef __RPCNDR_H_VERSION__
-#error this stub requires an updated version of <rpcndr.h>
-#endif // __RPCNDR_H_VERSION__
-
-#ifndef COM_NO_WINDOWS_H
-#include "windows.h"
-#include "ole2.h"
-#endif /*COM_NO_WINDOWS_H*/
-
-#ifndef __IValidator_h__
-#define __IValidator_h__
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once
-#endif
-
-/* Forward Declarations */ 
-
-#ifndef __IValidator_FWD_DEFINED__
-#define __IValidator_FWD_DEFINED__
-typedef interface IValidator IValidator;
-
-#endif         /* __IValidator_FWD_DEFINED__ */
-
-
-#ifndef __ICLRValidator_FWD_DEFINED__
-#define __ICLRValidator_FWD_DEFINED__
-typedef interface ICLRValidator ICLRValidator;
-
-#endif         /* __ICLRValidator_FWD_DEFINED__ */
-
-
-/* header files for imported files */
-#include "ivehandler.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif 
-
-
-/* interface __MIDL_itf_IValidator_0000_0000 */
-/* [local] */ 
-
-#pragma warning(push)
-#pragma warning(disable:28718)    
-
-
-
-enum ValidatorFlags
-    {
-        VALIDATOR_EXTRA_VERBOSE        = 0x1,
-        VALIDATOR_SHOW_SOURCE_LINES    = 0x2,
-        VALIDATOR_CHECK_ILONLY = 0x4,
-        VALIDATOR_CHECK_PEFORMAT_ONLY  = 0x8,
-        VALIDATOR_NOCHECK_PEFORMAT     = 0x10,
-        VALIDATOR_TRANSPARENT_ONLY     = 0x20
-    } ;
-
-
-extern RPC_IF_HANDLE __MIDL_itf_IValidator_0000_0000_v0_0_c_ifspec;
-extern RPC_IF_HANDLE __MIDL_itf_IValidator_0000_0000_v0_0_s_ifspec;
-
-#ifndef __IValidator_INTERFACE_DEFINED__
-#define __IValidator_INTERFACE_DEFINED__
-
-/* interface IValidator */
-/* [unique][uuid][object] */ 
-
-
-EXTERN_C const IID IID_IValidator;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-    
-    MIDL_INTERFACE("63DF8730-DC81-4062-84A2-1FF943F59FAC")
-    IValidator : public IUnknown
-    {
-    public:
-        virtual HRESULT STDMETHODCALLTYPE Validate( 
-            /* [in] */ IVEHandler *veh,
-            /* [in] */ IUnknown *pAppDomain,
-            /* [in] */ unsigned long ulFlags,
-            /* [in] */ unsigned long ulMaxError,
-            /* [in] */ unsigned long token,
-            /* [in] */ LPWSTR fileName,
-            /* [size_is][in] */ BYTE *pe,
-            /* [in] */ unsigned long ulSize) = 0;
-        
-        virtual HRESULT STDMETHODCALLTYPE FormatEventInfo( 
-            /* [in] */ HRESULT hVECode,
-            /* [in] */ VEContext Context,
-            /* [out][in] */ LPWSTR msg,
-            /* [in] */ unsigned long ulMaxLength,
-            /* [in] */ SAFEARRAY * psa) = 0;
-        
-    };
-    
-    
-#else  /* C style interface */
-
-    typedef struct IValidatorVtbl
-    {
-        BEGIN_INTERFACE
-        
-        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
-            IValidator * This,
-            /* [in] */ REFIID riid,
-            /* [annotation][iid_is][out] */ 
-            _COM_Outptr_  void **ppvObject);
-        
-        ULONG ( STDMETHODCALLTYPE *AddRef )( 
-            IValidator * This);
-        
-        ULONG ( STDMETHODCALLTYPE *Release )( 
-            IValidator * This);
-        
-        HRESULT ( STDMETHODCALLTYPE *Validate )( 
-            IValidator * This,
-            /* [in] */ IVEHandler *veh,
-            /* [in] */ IUnknown *pAppDomain,
-            /* [in] */ unsigned long ulFlags,
-            /* [in] */ unsigned long ulMaxError,
-            /* [in] */ unsigned long token,
-            /* [in] */ LPWSTR fileName,
-            /* [size_is][in] */ BYTE *pe,
-            /* [in] */ unsigned long ulSize);
-        
-        HRESULT ( STDMETHODCALLTYPE *FormatEventInfo )( 
-            IValidator * This,
-            /* [in] */ HRESULT hVECode,
-            /* [in] */ VEContext Context,
-            /* [out][in] */ LPWSTR msg,
-            /* [in] */ unsigned long ulMaxLength,
-            /* [in] */ SAFEARRAY * psa);
-        
-        END_INTERFACE
-    } IValidatorVtbl;
-
-    interface IValidator
-    {
-        CONST_VTBL struct IValidatorVtbl *lpVtbl;
-    };
-
-    
-
-#ifdef COBJMACROS
-
-
-#define IValidator_QueryInterface(This,riid,ppvObject) \
-    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
-
-#define IValidator_AddRef(This)        \
-    ( (This)->lpVtbl -> AddRef(This) ) 
-
-#define IValidator_Release(This)       \
-    ( (This)->lpVtbl -> Release(This) ) 
-
-
-#define IValidator_Validate(This,veh,pAppDomain,ulFlags,ulMaxError,token,fileName,pe,ulSize)   \
-    ( (This)->lpVtbl -> Validate(This,veh,pAppDomain,ulFlags,ulMaxError,token,fileName,pe,ulSize) ) 
-
-#define IValidator_FormatEventInfo(This,hVECode,Context,msg,ulMaxLength,psa)   \
-    ( (This)->lpVtbl -> FormatEventInfo(This,hVECode,Context,msg,ulMaxLength,psa) ) 
-
-#endif /* COBJMACROS */
-
-
-#endif         /* C style interface */
-
-
-
-
-#endif         /* __IValidator_INTERFACE_DEFINED__ */
-
-
-#ifndef __ICLRValidator_INTERFACE_DEFINED__
-#define __ICLRValidator_INTERFACE_DEFINED__
-
-/* interface ICLRValidator */
-/* [unique][uuid][object] */ 
-
-
-EXTERN_C const IID IID_ICLRValidator;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-    
-    MIDL_INTERFACE("63DF8730-DC81-4062-84A2-1FF943F59FDD")
-    ICLRValidator : public IUnknown
-    {
-    public:
-        virtual HRESULT STDMETHODCALLTYPE Validate( 
-            /* [in] */ IVEHandler *veh,
-            /* [in] */ unsigned long ulAppDomainId,
-            /* [in] */ unsigned long ulFlags,
-            /* [in] */ unsigned long ulMaxError,
-            /* [in] */ unsigned long token,
-            /* [in] */ LPWSTR fileName,
-            /* [size_is][in] */ BYTE *pe,
-            /* [in] */ unsigned long ulSize) = 0;
-        
-        virtual HRESULT STDMETHODCALLTYPE FormatEventInfo( 
-            /* [in] */ HRESULT hVECode,
-            /* [in] */ VEContext Context,
-            /* [out][in] */ LPWSTR msg,
-            /* [in] */ unsigned long ulMaxLength,
-            /* [in] */ SAFEARRAY * psa) = 0;
-        
-    };
-    
-    
-#else  /* C style interface */
-
-    typedef struct ICLRValidatorVtbl
-    {
-        BEGIN_INTERFACE
-        
-        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
-            ICLRValidator * This,
-            /* [in] */ REFIID riid,
-            /* [annotation][iid_is][out] */ 
-            _COM_Outptr_  void **ppvObject);
-        
-        ULONG ( STDMETHODCALLTYPE *AddRef )( 
-            ICLRValidator * This);
-        
-        ULONG ( STDMETHODCALLTYPE *Release )( 
-            ICLRValidator * This);
-        
-        HRESULT ( STDMETHODCALLTYPE *Validate )( 
-            ICLRValidator * This,
-            /* [in] */ IVEHandler *veh,
-            /* [in] */ unsigned long ulAppDomainId,
-            /* [in] */ unsigned long ulFlags,
-            /* [in] */ unsigned long ulMaxError,
-            /* [in] */ unsigned long token,
-            /* [in] */ LPWSTR fileName,
-            /* [size_is][in] */ BYTE *pe,
-            /* [in] */ unsigned long ulSize);
-        
-        HRESULT ( STDMETHODCALLTYPE *FormatEventInfo )( 
-            ICLRValidator * This,
-            /* [in] */ HRESULT hVECode,
-            /* [in] */ VEContext Context,
-            /* [out][in] */ LPWSTR msg,
-            /* [in] */ unsigned long ulMaxLength,
-            /* [in] */ SAFEARRAY * psa);
-        
-        END_INTERFACE
-    } ICLRValidatorVtbl;
-
-    interface ICLRValidator
-    {
-        CONST_VTBL struct ICLRValidatorVtbl *lpVtbl;
-    };
-
-    
-
-#ifdef COBJMACROS
-
-
-#define ICLRValidator_QueryInterface(This,riid,ppvObject)      \
-    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
-
-#define ICLRValidator_AddRef(This)     \
-    ( (This)->lpVtbl -> AddRef(This) ) 
-
-#define ICLRValidator_Release(This)    \
-    ( (This)->lpVtbl -> Release(This) ) 
-
-
-#define ICLRValidator_Validate(This,veh,ulAppDomainId,ulFlags,ulMaxError,token,fileName,pe,ulSize)     \
-    ( (This)->lpVtbl -> Validate(This,veh,ulAppDomainId,ulFlags,ulMaxError,token,fileName,pe,ulSize) ) 
-
-#define ICLRValidator_FormatEventInfo(This,hVECode,Context,msg,ulMaxLength,psa)        \
-    ( (This)->lpVtbl -> FormatEventInfo(This,hVECode,Context,msg,ulMaxLength,psa) ) 
-
-#endif /* COBJMACROS */
-
-
-#endif         /* C style interface */
-
-
-
-
-#endif         /* __ICLRValidator_INTERFACE_DEFINED__ */
-
-
-/* interface __MIDL_itf_IValidator_0000_0002 */
-/* [local] */ 
-
-#pragma warning(pop)
-
-
-extern RPC_IF_HANDLE __MIDL_itf_IValidator_0000_0002_v0_0_c_ifspec;
-extern RPC_IF_HANDLE __MIDL_itf_IValidator_0000_0002_v0_0_s_ifspec;
-
-/* Additional Prototypes for ALL interfaces */
-
-unsigned long             __RPC_USER  LPSAFEARRAY_UserSize(     unsigned long *, unsigned long            , LPSAFEARRAY * ); 
-unsigned char * __RPC_USER  LPSAFEARRAY_UserMarshal(  unsigned long *, unsigned char *, LPSAFEARRAY * ); 
-unsigned char * __RPC_USER  LPSAFEARRAY_UserUnmarshal(unsigned long *, unsigned char *, LPSAFEARRAY * ); 
-void                      __RPC_USER  LPSAFEARRAY_UserFree(     unsigned long *, LPSAFEARRAY * ); 
-
-/* end of Additional Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
diff --git a/src/pal/prebuilt/inc/ivehandler.h b/src/pal/prebuilt/inc/ivehandler.h
deleted file mode 100644 (file)
index bdd8cb5..0000000
+++ /dev/null
@@ -1,220 +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 ALWAYS GENERATED file contains the definitions for the interfaces */
-
-
- /* File created by MIDL compiler version 8.00.0603 */
-/* @@MIDL_FILE_HEADING(  ) */
-
-#pragma warning( disable: 4049 )  /* more than 64k source lines */
-
-
-/* verify that the <rpcndr.h> version is high enough to compile this file*/
-#ifndef __REQUIRED_RPCNDR_H_VERSION__
-#define __REQUIRED_RPCNDR_H_VERSION__ 475
-#endif
-
-#include "rpc.h"
-#include "rpcndr.h"
-
-#ifndef __RPCNDR_H_VERSION__
-#error this stub requires an updated version of <rpcndr.h>
-#endif // __RPCNDR_H_VERSION__
-
-#ifndef COM_NO_WINDOWS_H
-#include "windows.h"
-#include "ole2.h"
-#endif /*COM_NO_WINDOWS_H*/
-
-#ifndef __IVEHandler_h__
-#define __IVEHandler_h__
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once
-#endif
-
-/* Forward Declarations */ 
-
-#ifndef __VEHandlerClass_FWD_DEFINED__
-#define __VEHandlerClass_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class VEHandlerClass VEHandlerClass;
-#else
-typedef struct VEHandlerClass VEHandlerClass;
-#endif /* __cplusplus */
-
-#endif         /* __VEHandlerClass_FWD_DEFINED__ */
-
-
-#ifndef __IVEHandler_FWD_DEFINED__
-#define __IVEHandler_FWD_DEFINED__
-typedef interface IVEHandler IVEHandler;
-
-#endif         /* __IVEHandler_FWD_DEFINED__ */
-
-
-/* header files for imported files */
-#include "unknwn.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif 
-
-
-/* interface __MIDL_itf_IVEHandler_0000_0000 */
-/* [local] */ 
-
-typedef struct tag_VerError
-    {
-    unsigned long flags;
-    unsigned long opcode;
-    unsigned long uOffset;
-    unsigned long Token;
-    unsigned long item1_flags;
-    int *item1_data;
-    unsigned long item2_flags;
-    int *item2_data;
-    }  _VerError;
-
-typedef _VerError VEContext;
-
-
-
-
-extern RPC_IF_HANDLE __MIDL_itf_IVEHandler_0000_0000_v0_0_c_ifspec;
-extern RPC_IF_HANDLE __MIDL_itf_IVEHandler_0000_0000_v0_0_s_ifspec;
-
-
-#ifndef __VEHandlerLib_LIBRARY_DEFINED__
-#define __VEHandlerLib_LIBRARY_DEFINED__
-
-/* library VEHandlerLib */
-/* [helpstring][version][uuid] */ 
-
-
-EXTERN_C const IID LIBID_VEHandlerLib;
-
-EXTERN_C const CLSID CLSID_VEHandlerClass;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("856CA1B1-7DAB-11d3-ACEC-00C04F86C309")
-VEHandlerClass;
-#endif
-#endif /* __VEHandlerLib_LIBRARY_DEFINED__ */
-
-#ifndef __IVEHandler_INTERFACE_DEFINED__
-#define __IVEHandler_INTERFACE_DEFINED__
-
-/* interface IVEHandler */
-/* [unique][uuid][object] */ 
-
-
-EXTERN_C const IID IID_IVEHandler;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-    
-    MIDL_INTERFACE("856CA1B2-7DAB-11d3-ACEC-00C04F86C309")
-    IVEHandler : public IUnknown
-    {
-    public:
-        virtual HRESULT STDMETHODCALLTYPE VEHandler( 
-            /* [in] */ HRESULT VECode,
-            /* [in] */ VEContext Context,
-            /* [in] */ SAFEARRAY * psa) = 0;
-        
-        virtual HRESULT STDMETHODCALLTYPE SetReporterFtn( 
-            /* [in] */ __int64 lFnPtr) = 0;
-        
-    };
-    
-    
-#else  /* C style interface */
-
-    typedef struct IVEHandlerVtbl
-    {
-        BEGIN_INTERFACE
-        
-        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
-            IVEHandler * This,
-            /* [in] */ REFIID riid,
-            /* [annotation][iid_is][out] */ 
-            _COM_Outptr_  void **ppvObject);
-        
-        ULONG ( STDMETHODCALLTYPE *AddRef )( 
-            IVEHandler * This);
-        
-        ULONG ( STDMETHODCALLTYPE *Release )( 
-            IVEHandler * This);
-        
-        HRESULT ( STDMETHODCALLTYPE *VEHandler )( 
-            IVEHandler * This,
-            /* [in] */ HRESULT VECode,
-            /* [in] */ VEContext Context,
-            /* [in] */ SAFEARRAY * psa);
-        
-        HRESULT ( STDMETHODCALLTYPE *SetReporterFtn )( 
-            IVEHandler * This,
-            /* [in] */ __int64 lFnPtr);
-        
-        END_INTERFACE
-    } IVEHandlerVtbl;
-
-    interface IVEHandler
-    {
-        CONST_VTBL struct IVEHandlerVtbl *lpVtbl;
-    };
-
-    
-
-#ifdef COBJMACROS
-
-
-#define IVEHandler_QueryInterface(This,riid,ppvObject) \
-    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
-
-#define IVEHandler_AddRef(This)        \
-    ( (This)->lpVtbl -> AddRef(This) ) 
-
-#define IVEHandler_Release(This)       \
-    ( (This)->lpVtbl -> Release(This) ) 
-
-
-#define IVEHandler_VEHandler(This,VECode,Context,psa)  \
-    ( (This)->lpVtbl -> VEHandler(This,VECode,Context,psa) ) 
-
-#define IVEHandler_SetReporterFtn(This,lFnPtr) \
-    ( (This)->lpVtbl -> SetReporterFtn(This,lFnPtr) ) 
-
-#endif /* COBJMACROS */
-
-
-#endif         /* C style interface */
-
-
-
-
-#endif         /* __IVEHandler_INTERFACE_DEFINED__ */
-
-
-/* Additional Prototypes for ALL interfaces */
-
-unsigned long             __RPC_USER  LPSAFEARRAY_UserSize(     unsigned long *, unsigned long            , LPSAFEARRAY * ); 
-unsigned char * __RPC_USER  LPSAFEARRAY_UserMarshal(  unsigned long *, unsigned char *, LPSAFEARRAY * ); 
-unsigned char * __RPC_USER  LPSAFEARRAY_UserUnmarshal(unsigned long *, unsigned char *, LPSAFEARRAY * ); 
-void                      __RPC_USER  LPSAFEARRAY_UserFree(     unsigned long *, LPSAFEARRAY * ); 
-
-/* end of Additional Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
index 45b8864..b62ab58 100644 (file)
@@ -220,7 +220,6 @@ typedef interface ICLRAppDomainResourceMonitor ICLRAppDomainResourceMonitor;
 /* header files for imported files */
 #include "unknwn.h"
 #include "gchost.h"
-#include "ivalidator.h"
 
 #ifdef __cplusplus
 extern "C"{
index 753321f..5458a76 100644 (file)
@@ -38,7 +38,6 @@ extern HRESULT  _FillVariant(
 
 // Validator declarations.
 extern DWORD g_ValModuleType;
-#include <ivehandler.h>
 
 // Tables for mapping element type to text
 const char *g_szMapElementType[] = 
@@ -312,7 +311,6 @@ void MDInfo::Init(
     strPassBackFn inPBFn,               // Callback to write text.
     DUMP_FILTER DumpFilter)             // Flags to control the dump.
 {
-    m_VEHandlerReporterPtr = 0;
     m_pbFn = inPBFn;
     m_DumpFilter = DumpFilter;
     m_pTables = NULL;
@@ -335,228 +333,6 @@ MDInfo::~MDInfo()
 } // MDInfo::~MDInfo()
 
 //=====================================================================================================================
-//#define EXTERNAL_VE_HANDLER_FOR_MD_VALIDATION
-#ifndef EXTERNAL_VE_HANDLER_FOR_MD_VALIDATION
-
-HINSTANCE GetModuleInst()
-{
-    return NULL;
-} // HINSTANCE GetModuleInst()
-
-typedef HRESULT (*REPORTFCTN)(LPCWSTR, VEContext, HRESULT);
-HRESULT DefaultReporter( // Return status.
-    LPCWSTR     szMsg,                  // Error message.
-    VEContext   Context,                // Error context (offset,token)
-    HRESULT     hrRpt)                      // Original HRESULT
-{ 
-    if(szMsg)
-    {
-        printf("%S", szMsg);
-        // include token and offset from Context
-        if(Context.Token) printf(" [token:0x%08X]",Context.Token);
-        if(Context.uOffset) printf(" [at:0x%X]",Context.uOffset);
-        printf(" [hr:0x%08X]\n",hrRpt);
-        fflush(stdout);
-    }
-    return S_OK;
-} // HRESULT DefaultReporter()
-
-
-#ifdef FEATURE_METADATA_VALIDATOR
-class MDVEHandlerClass : public IVEHandler
-{
-public: 
-    LONG        m_refCount;
-    REPORTFCTN  m_fnReport;
-
-    MDVEHandlerClass() { m_refCount=0; m_fnReport=DefaultReporter; };
-    virtual ~MDVEHandlerClass() { };
-
-    //-----------------------------------------------------------
-    // IUnknown support
-    //-----------------------------------------------------------
-    HRESULT STDMETHODCALLTYPE    QueryInterface(REFIID id, void** pInterface) 
-    {
-        if (id == IID_IVEHandler)
-            *pInterface = (IVEHandler*)this;
-        /*
-        else if (id == IID_IUnknown)
-            *pInterface = (IUnknown*)(IVEHandler*)this;
-        */
-        else
-        {
-            *pInterface = NULL;
-            return E_NOINTERFACE;
-        }
-
-        AddRef();
-        return S_OK;
-    }
-    ULONG STDMETHODCALLTYPE AddRef() 
-    {
-        return InterlockedIncrement(&m_refCount);
-    }
-
-    ULONG STDMETHODCALLTYPE Release() 
-    {
-        LONG       refCount = InterlockedDecrement(&m_refCount);
-        if (refCount == 0) delete this;
-        return (refCount);
-    }
-    //-----------------------------------------------------------
-    // IVEHandler support
-    //-----------------------------------------------------------
-    HRESULT STDMETHODCALLTYPE   SetReporterFtn(__int64 lFnPtr)
-    {
-        m_fnReport = lFnPtr ? reinterpret_cast<REPORTFCTN>(lFnPtr) 
-                             : DefaultReporter;
-        return S_OK;
-    };
-
-//*****************************************************************************
-// The Verification Event Handler itself. Declared in VEHandler.h as virtual, may be overridden
-//*****************************************************************************
-    HRESULT STDMETHODCALLTYPE VEHandler(HRESULT hrRpt, VEContext Context, SAFEARRAY *psa)
-    {
-        WCHAR       rcBuf[1024];             // Resource string.
-        WCHAR       rcMsg[1024];             // Error message.
-        BYTE       *marker;                  // User text.
-        HRESULT     hr;
-        ULONG32     k;
-        WCHAR      *pWsz[1024]; // is more than 1024 string arguments likely?
-
-        // Return warnings without text.
-        if (!FAILED(hrRpt))
-            return (hrRpt);
-        memset(pWsz,0,sizeof(pWsz));
-
-        ULONG32      nVars;
-        // Convert safearray of variants into va_list
-        if(psa && (nVars = psa->rgsabound[0].cElements))
-        {
-            WCHAR       *pwsz;
-            VARIANT     *pVar;
-            ULONG32      i,l;
-            BYTE        *pval;
-
-            _ASSERTE(psa->fFeatures & FADF_VARIANT);
-            _ASSERTE(psa->cDims == 1);
-            marker = new BYTE[nVars*sizeof(double)]; // double being the largest variant element
-            for(i=0,pVar=(VARIANT *)(psa->pvData),pval=marker; i < nVars; pVar++,i++)
-            {
-                switch(V_VT(pVar))
-                {
-                    case VT_I1:
-                        *(int *)pval = V_I1(pVar);
-                        pval += sizeof(int);
-                        break;
-                        
-                    case VT_UI1:
-                        *(int *)pval = V_UI1(pVar);
-                        pval += sizeof(int);
-                        break;
-                        
-
-                    case VT_I2:
-                        *(int *)pval = V_I2(pVar);
-                        pval += sizeof(int);
-                        break;
-                        
-                    case VT_UI2:
-                        *(int *)pval = V_UI2(pVar);
-                        pval += sizeof(int);
-                        break;
-                    
-                    case VT_I8:
-                    case VT_UI8:
-                        *(INT64 *)pval = V_I8(pVar);
-                        pval += sizeof(INT64);
-                        break;
-                        
-
-                    case VT_BYREF|VT_I1:
-                    case VT_BYREF|VT_UI1: // it's ASCII string, convert it to UNICODE
-                        {
-                        PBYTE pb = V_UI1REF(pVar);
-                        l = (ULONG32)strlen((char *)pb)+1;
-                        pwsz = new WCHAR[l];
-                        WszMultiByteToWideChar(CP_ACP,0,(char*)pb,-1,pwsz,l);
-                        for(k=0; pWsz[k]; k++);
-                        pWsz[k] = pwsz;
-                        
-                        *(WCHAR **)pval = pwsz;
-                        pval += sizeof(WCHAR *);
-                        break;
-                        }
-
-                    default:
-                        *(int *)pval = V_I4(pVar);
-                        pval += sizeof(int);
-                        break;
-                }
-            }
-        }
-        else
-            marker = NULL;
-
-        // If this is one of our errors, then grab the error from the rc file.
-        if (HRESULT_FACILITY(hrRpt) == FACILITY_URT)
-        {
-            hr = UtilLoadStringRC(LOWORD(hrRpt), rcBuf, NumItems(rcBuf), true);
-            if (hr == S_OK)
-            {
-                // Format the error.
-                vswprintf_s(rcMsg, NumItems(rcMsg), rcBuf, (va_list) marker);
-                rcMsg[NumItems(rcMsg) - 1] = 0;
-            }
-        }
-        // Otherwise it isn't one of ours, so we need to see if the system can
-        // find the text for it.
-        else
-        {
-            if (WszFormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
-                    0, hrRpt, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                    rcMsg, NumItems(rcMsg), 0))
-            {
-                hr = S_OK;
-
-                // System messages contain a trailing \r\n, which we don't want normally.
-                int iLen = lstrlenW(rcMsg);
-                if (iLen > 3 && rcMsg[iLen - 2] == '\r' && rcMsg[iLen - 1] == '\n')
-                    rcMsg[iLen - 2] = '\0';
-            }
-            else
-                hr = HRESULT_FROM_WIN32(GetLastError());
-        }
-        if(marker) delete [] marker;
-
-        // If we failed to find the message anywhere, then issue a hard coded message.
-        if (FAILED(hr))
-        {
-            swprintf_s(rcMsg, NumItems(rcMsg), W("COM+ Runtime Internal error: 0x%08x"), hrRpt);
-            //DEBUG_STMT(DbgWriteEx(rcMsg));
-        }
-
-        // delete WCHAR buffers allocated above (if any)
-        for(k=0; pWsz[k]; k++) 
-        { 
-            if(pWsz[k]) 
-            {
-                delete [] pWsz[k];
-                pWsz[k] = NULL;
-            }
-        }
-
-        return (m_fnReport(rcMsg, Context,hrRpt) == S_OK ? S_OK : E_FAIL);
-    };
-
-    static HRESULT STDMETHODCALLTYPE CreateObject(REFIID id, void **object)
-    { return E_NOTIMPL; }
-};
-#endif // FEATURE_METADATA_VALIDATOR
-
-#endif
-//=====================================================================================================================
 // DisplayMD() function
 //
 // Displays the meta data content of a file
@@ -596,84 +372,6 @@ void MDInfo::DisplayMD()
     if (m_DumpFilter & dumpUnsat)
         DisplayUnsatInfo();
     WriteLine("===========================================================");
-#ifdef FEATURE_METADATA_VALIDATOR
-    if (m_DumpFilter & dumpValidate)
-    {
-        IMetaDataValidate *pValidate = 0;
-#ifndef EXTERNAL_VE_HANDLER_FOR_MD_VALIDATION
-        MDVEHandlerClass    *pVEHandler = 0;
-#else
-        IVEHandler  *pVEHandler = 0;
-#endif
-        const char *szErrStr = 0;
-        HRESULT     hr = S_OK;
-
-        // Get a pointer to the Validator interface.
-        hr = m_pImport->QueryInterface(IID_IMetaDataValidate, (void **) &pValidate);
-        if (FAILED(hr))
-        {
-            szErrStr = "QueryInterface failed for IMetaDataValidate.";
-            goto ErrExit;
-        }
-
-        // Get a pointer to the VEHandler interface.
-#ifndef EXTERNAL_VE_HANDLER_FOR_MD_VALIDATION
-        if((pVEHandler = new MDVEHandlerClass())) hr = S_OK;
-        else hr = E_FAIL;
-#else
-        hr = CoCreateInstance(CLSID_VEHandlerClass,
-                           NULL,
-                           CLSCTX_INPROC_SERVER,
-                           IID_IVEHandler,
-                           (void **)&pVEHandler);
-#endif
-        if (FAILED(hr))
-        {
-#ifndef EXTERNAL_VE_HANDLER_FOR_MD_VALIDATION
-            szErrStr = "Failed to create VEHandler.";
-#else
-            szErrStr = "CoCreateInstance(VEHandler) failed.";
-#endif
-            goto ErrExit;
-        }
-
-        if(m_VEHandlerReporterPtr) pVEHandler->SetReporterFtn((__int64)m_VEHandlerReporterPtr);
-
-        hr = pValidate->ValidatorInit(g_ValModuleType, pVEHandler);
-        if (FAILED(hr))
-        {
-            szErrStr = "ValidatorInit failed.";
-            goto ErrExit;
-        }
-
-        hr = pValidate->ValidateMetaData();
-        if (FAILED(hr))
-        {
-            szErrStr = "ValidateMetaData failed to run successfully.";
-            goto ErrExit;
-        }
-        if (hr == S_OK)
-            WriteLine("No warnings or errors found.");
-        else if (hr == VLDTR_S_WRN)
-            WriteLine("Warnings found.");
-        else if (hr == VLDTR_S_ERR)
-            WriteLine("Errors found.");
-        else if (hr == VLDTR_S_WRNERR)
-            WriteLine("Warnings and Errors found.");
-        else
-            VWriteLine("Validator returned unexpected success code, hr=0x%08x.", hr);
-ErrExit:
-        if (pValidate)
-            pValidate->Release();
-#ifdef EXTERNAL_VE_HANDLER_FOR_MD_VALIDATION
-        if (pVEHandler)
-            pVEHandler->Release();
-#endif
-        if (szErrStr)
-            Error(szErrStr, hr);
-    }
-#endif // FEATURE_METADATA_VALIDATOR
-    WriteLine("===========================================================");
 } // MDVEHandlerClass()
 
 int MDInfo::WriteLine(__in_z __in const char *str)
index 06c0a76..acca606 100644 (file)
@@ -164,7 +164,6 @@ public:
     void DumpRawCol(ULONG ixTbl, ULONG ixCol, ULONG rid, bool bStats);
     ULONG DumpRawColStats(ULONG ixTbl, ULONG ixCol, ULONG cRows);
     const char *DumpRawNameOfType(ULONG ulType);
-    void SetVEHandlerReporter(__int64 VEHandlerReporterPtr) { m_VEHandlerReporterPtr = VEHandlerReporterPtr; };
 
     static void Error(const char *szError, HRESULT hr = S_OK);
 private:
@@ -186,7 +185,6 @@ private:
     IMetaDataImport2 *m_pImport;
     IMetaDataAssemblyImport *m_pAssemblyImport;
     strPassBackFn m_pbFn;
-    __int64 m_VEHandlerReporterPtr;
     IMetaDataTables *m_pTables;
     IMetaDataTables2 *m_pTables2;
 
diff --git a/src/utilcode/sxshelpers.cpp b/src/utilcode/sxshelpers.cpp
deleted file mode 100644 (file)
index 214c5c7..0000000
+++ /dev/null
@@ -1,1508 +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.
-//*****************************************************************************
-// 
-//  sxshelpers.cpp
-//
-//  Some helping classes and methods for SxS in mscoree and mscorwks
-//
-
-//*****************************************************************************
-
-#include "stdafx.h"
-#include "utilcode.h"
-#include "sxshelpers.h"
-
-#define SXS_GUID_INFORMATION_CLR_FLAG_IS_SURROGATE          (0x00000001)
-#define SXS_GUID_INFORMATION_CLR_FLAG_IS_CLASS              (0x00000002)
-
-typedef struct _SXS_GUID_INFORMATION_CLR
-{
-    DWORD       cbSize;
-    DWORD       dwFlags;
-    PCWSTR      pcwszRuntimeVersion;
-    PCWSTR      pcwszTypeName;
-    PCWSTR      pcwszAssemblyIdentity;
-} SXS_GUID_INFORMATION_CLR, *PSXS_GUID_INFORMATION_CLR;
-typedef const SXS_GUID_INFORMATION_CLR *PCSXS_GUID_INFORMATION_CLR;
-
-#define SXS_LOOKUP_CLR_GUID_USE_ACTCTX                      (0x00000001)
-#define SXS_LOOKUP_CLR_GUID_FIND_SURROGATE                  (0x00010000)
-#define SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS                  (0x00020000)
-#define SXS_LOOKUP_CLR_GUID_FIND_ANY                        (SXS_LOOKUP_CLR_GUID_FIND_CLR_CLASS | SXS_LOOKUP_CLR_GUID_FIND_SURROGATE)
-
-#define SXS_DLL_NAME_W                                      (W("sxs.dll"))
-#define SXS_LOOKUP_CLR_GUID                                 ("SxsLookupClrGuid")
-
-typedef BOOL (WINAPI* PFN_SXS_LOOKUP_CLR_GUID)(
-    IN DWORD       dwFlags,
-    IN LPGUID      pClsid,
-    IN HANDLE      hActCtx,
-    IN OUT PVOID   pvOutputBuffer,
-    IN SIZE_T      cbOutputBuffer,
-    OUT PSIZE_T    pcbOutputBuffer
-    );
-
-// forward declaration
-BOOL TranslateWin32AssemblyIdentityToFusionDisplayName(__deref_out_z LPWSTR *ppwzFusionDisplayName, PCWSTR lpWin32AssemblyIdentity);
-
-// The initial size of the buffer passed to SxsLookupClrGuid.
-#define INIT_GUID_LOOKUP_BUFFER_SIZE 512
-
-// Function pointer to the function to lookup a CLR type by GUID in the unmanaged
-// fusion activation context.
-PFN_SXS_LOOKUP_CLR_GUID g_pfnLookupGuid = NULL;
-Volatile<BOOL> g_fSxSInfoInitialized = FALSE;
-
-HMODULE g_hmSxsDll = NULL;
-
-// And Here are the functions for getting shim info from 
-// Win32 activation context
-
-//  FindShimInfoFromWin32
-//
-//  This method is used in ComInterop. If a COM client calls 
-//  CoCreateInstance on a managed COM server, we will use this method
-//  trying to find required info of the managed COM server from Win32 subsystem.
-//  If this fails, we will fall back to query the registry. 
-//
-//  Parameters:
-//      rclsid:              [in]  The CLSID of the managed COM server
-//      bLoadRecord:         [in]  Set to TRUE if we are looking for a record
-//      *ppwzRuntimeVersion: [out] Runtime version
-//      *ppwzClassName:      [out] Class name
-//      *ppwzAssemblyString: [out] Assembly display name
-//      *pfRegFreePIA:       [out] TRUE if the entry is <clrSurrogate>
-//  Return:
-//      FAILED(hr) if cannot find shim info from Win32
-//      SUCCEEDED(HR) if shim info is found from Win32
-
-HRESULT
-FindShimInfoFromWin32(
-    REFCLSID rClsid,
-    BOOL bLoadRecord, 
-    __deref_out_z __deref_opt_out_opt LPWSTR *ppwszRuntimeVersion,
-    __deref_out_z __deref_opt_out_opt LPWSTR *ppwszSupportedRuntimeVersions,
-    __deref_out_z __deref_opt_out_opt LPWSTR *ppwszClassName,
-    __deref_out_z __deref_opt_out_opt LPWSTR *ppwszAssemblyString,
-    BOOL *pfRegFreePIA
-    )
-{
-    STATIC_CONTRACT_NOTHROW;
-    STATIC_CONTRACT_FAULT;
-
-    CQuickBytes rDataBuffer;
-    SIZE_T cbWritten;
-    HRESULT hr = S_OK;
-    PCSXS_GUID_INFORMATION_CLR pFoundInfo = NULL;
-    SIZE_T cch;
-    GUID MyGuid = rClsid;
-    DWORD dwFlags = bLoadRecord ? SXS_LOOKUP_CLR_GUID_FIND_SURROGATE : SXS_LOOKUP_CLR_GUID_FIND_ANY;
-
-    if (!ppwszRuntimeVersion && !ppwszClassName && !ppwszAssemblyString)
-        IfFailGo(E_INVALIDARG);
-
-    if (ppwszRuntimeVersion)
-        *ppwszRuntimeVersion = NULL;
-
-    if (ppwszSupportedRuntimeVersions)
-        *ppwszSupportedRuntimeVersions = NULL;
-
-    if (ppwszClassName)
-        *ppwszClassName = NULL;
-
-    if (ppwszAssemblyString)
-        *ppwszAssemblyString = NULL;
-
-    if (pfRegFreePIA)
-        *pfRegFreePIA = FALSE;
-
-    // If we haven't initialized the SxS info yet, then do so now.
-    if (!g_fSxSInfoInitialized)
-    {
-        if (g_hmSxsDll == NULL)
-            g_hmSxsDll = WszLoadLibrary(SXS_DLL_NAME_W);
-        
-        if (g_hmSxsDll != NULL)
-        {
-            // Lookup the SxsLookupClrGuid function in the SxS DLL.
-            g_pfnLookupGuid = (PFN_SXS_LOOKUP_CLR_GUID)GetProcAddress(g_hmSxsDll, SXS_LOOKUP_CLR_GUID);
-        }
-
-        // The SxS info has been initialized.
-        g_fSxSInfoInitialized = TRUE;
-    }
-
-    // If we don't have the proc address of SxsLookupClrGuid, then return a failure.
-    if (g_pfnLookupGuid == NULL)
-        IfFailGo(E_FAIL);
-
-    // Resize the CQuickBytes to the initial buffer size.
-    IfFailGo(rDataBuffer.ReSizeNoThrow(INIT_GUID_LOOKUP_BUFFER_SIZE));
-
-    if (!g_pfnLookupGuid(dwFlags, &MyGuid, INVALID_HANDLE_VALUE, rDataBuffer.Ptr(), rDataBuffer.Size(), &cbWritten))
-    {
-        const DWORD dwLastError = ::GetLastError();
-
-        // Failed b/c we need more space? Expand and try again.
-        if (dwLastError == ERROR_INSUFFICIENT_BUFFER) 
-        {
-            IfFailGo(rDataBuffer.ReSizeNoThrow(cbWritten));
-
-            // Still failed even with enough space? Bummer.
-            if (!g_pfnLookupGuid(dwFlags, &MyGuid, INVALID_HANDLE_VALUE, rDataBuffer.Ptr(), rDataBuffer.Size(), &cbWritten))
-                IfFailGo(E_FAIL);
-        }
-        // All other failures are real failures - probably the section isn't present
-        // or some other problem.
-        else
-        {
-            IfFailGo(E_FAIL);
-        }
-    }
-
-    pFoundInfo = (PCSXS_GUID_INFORMATION_CLR)rDataBuffer.Ptr();
-
-    if (pFoundInfo->dwFlags == SXS_GUID_INFORMATION_CLR_FLAG_IS_SURROGATE && ppwszRuntimeVersion)
-    {
-        // Surrogate does not have runtime version information !!!
-        IfFailGo(E_FAIL);
-    }
-
-    //
-    // This is special - translate the win32 assembly name into a managed
-    // assembly identity.
-    //
-    if (ppwszAssemblyString && pFoundInfo->pcwszAssemblyIdentity)
-    {
-        if (!TranslateWin32AssemblyIdentityToFusionDisplayName(ppwszAssemblyString, pFoundInfo->pcwszAssemblyIdentity))
-            IfFailGo(E_FAIL);
-    }    
-
-    //
-    // For each field, allocate the outbound pointer and call through.
-    //
-    if (ppwszClassName && pFoundInfo->pcwszTypeName)
-    {
-        cch = wcslen(pFoundInfo->pcwszTypeName);
-
-        if (cch > 0)
-        {
-            IfNullGo(*ppwszClassName = new (nothrow) WCHAR[cch + 1]);
-            wcscpy_s(*ppwszClassName, cch+1, pFoundInfo->pcwszTypeName);
-        }
-        else
-            IfFailGo(E_FAIL);
-    }    
-
-    if (ppwszRuntimeVersion)
-    {
-        if (pFoundInfo->pcwszRuntimeVersion && (cch = wcslen(pFoundInfo->pcwszRuntimeVersion)) > 0)
-        {
-            IfNullGo(*ppwszRuntimeVersion = new (nothrow) WCHAR[cch + 1]);
-            wcscpy_s(*ppwszRuntimeVersion, cch+1, pFoundInfo->pcwszRuntimeVersion);
-        }
-        else
-        {
-            // Sxs.dll returns empty string even when the runtimeVersion attribute is missing so
-            // we cannot tell whether it's not there or is empty. We'll return 1.0 in both cases.
-            //
-            // The goal is to emulate pre-4.0 behavior where this function wasn't called with
-            // non-NULL ppwszRuntimeVersion on the COM activation path at all so shim loaded the
-            // latest runtime on the machine.
-            IfNullGo(*ppwszRuntimeVersion = DuplicateString(V1_VERSION_NUM));
-        }
-    }    
-
-    if (pfRegFreePIA)
-    {
-        *pfRegFreePIA = (pFoundInfo->dwFlags == SXS_GUID_INFORMATION_CLR_FLAG_IS_SURROGATE);
-    }
-
-ErrExit:
-    //
-    // Deallocate in case of failure
-    //
-    if (FAILED(hr))
-    {
-        if (ppwszRuntimeVersion && *ppwszRuntimeVersion)
-        {
-            delete [] *ppwszRuntimeVersion;
-            *ppwszRuntimeVersion = NULL;
-        }
-        if (ppwszAssemblyString && *ppwszAssemblyString)
-        {
-            delete [] *ppwszAssemblyString;
-            *ppwszAssemblyString = NULL;
-        }
-        if (ppwszClassName && *ppwszClassName)
-        {
-            delete [] *ppwszClassName;
-            *ppwszClassName = NULL;
-        }
-    }
-
-    return hr;
-}
-
-// TranslateWin32AssemblyIdentityToFusionDisplayName
-//
-// Culture info is missing in the assemblyIdentity returned from win32,
-// So Need to do a little more work here to get the correct fusion display name
-//
-// replace "language=" in assemblyIdentity to "culture=" if any.
-// If "language=" is not present in assemblyIdentity, add "culture=neutral" 
-// to it.
-//
-// Also check other attributes as well. 
-//
-// Parameters:
-//     ppwzFusionDisplayName: the corrected output of assembly displayname
-//     lpWin32AssemblyIdentity: input assemblyIdentity returned from win32
-//
-// returns:
-//     TRUE if the conversion is done.
-//     FALSE otherwise
-
-BOOL TranslateWin32AssemblyIdentityToFusionDisplayName(__deref_out_z LPWSTR *ppwzFusionDisplayName, PCWSTR lpWin32AssemblyIdentity)
-{
-    STATIC_CONTRACT_NOTHROW;
-    STATIC_CONTRACT_FAULT;
-
-    size_t size = 0;
-    LPWSTR lpAssemblyIdentityCopy = NULL;
-    LPWSTR lpVersionKey = W("version=");
-    LPWSTR lpPublicKeyTokenKey = W("publickeytoken=");
-    LPWSTR lpCultureKey = W("culture=");
-    LPWSTR lpNeutral = W("neutral");
-    LPWSTR lpLanguageKey = W("language=");
-    LPWSTR lpMatch = NULL;
-    LPWSTR lpwzFusionDisplayName = NULL;
-    
-    if (ppwzFusionDisplayName == NULL) return FALSE;
-    *ppwzFusionDisplayName = NULL;
-    
-    if (lpWin32AssemblyIdentity == NULL) return FALSE;
-
-    size = wcslen(lpWin32AssemblyIdentity);
-    if (size == 0) return FALSE;
-
-    // make a local copy
-    lpAssemblyIdentityCopy = new (nothrow) WCHAR[size+1];
-    if (!lpAssemblyIdentityCopy)
-        return FALSE;
-
-    wcscpy_s(lpAssemblyIdentityCopy, size+1, lpWin32AssemblyIdentity);
-
-    // convert to lower case
-    _wcslwr_s(lpAssemblyIdentityCopy, size+1);
-
-    // check if "version" key is presented
-    if (!wcsstr(lpAssemblyIdentityCopy, lpVersionKey))
-    {
-        // version is not presented, append it
-        size += wcslen(lpVersionKey)+8; // length of ","+"0.0.0.0"
-        lpwzFusionDisplayName = new (nothrow) WCHAR[size+1];
-        if (!lpwzFusionDisplayName)
-        {
-            // clean up
-            delete[] lpAssemblyIdentityCopy;
-            return FALSE;
-        }
-
-        //copy old one
-        wcscpy_s(lpwzFusionDisplayName, size+1, lpAssemblyIdentityCopy);
-        wcscat_s(lpwzFusionDisplayName, size+1, W(","));
-        wcscat_s(lpwzFusionDisplayName, size+1, lpVersionKey);
-        wcscat_s(lpwzFusionDisplayName, size+1, W("0.0.0.0"));
-
-        // delete the old copy
-        delete[] lpAssemblyIdentityCopy;
-
-        // lpAssemblyIdentityCopy has the new copy
-        lpAssemblyIdentityCopy = lpwzFusionDisplayName;
-        lpwzFusionDisplayName = NULL;
-    }
-
-    // check if "publickeytoken" key is presented
-    if (!wcsstr(lpAssemblyIdentityCopy, lpPublicKeyTokenKey))
-    {
-        // publickeytoken is not presented, append it
-        size += wcslen(lpPublicKeyTokenKey)+5; //length of ","+"null"
-        lpwzFusionDisplayName = new (nothrow) WCHAR[size+1];
-        if (!lpwzFusionDisplayName)
-        {
-            // clean up
-            delete[] lpAssemblyIdentityCopy;
-            return FALSE;
-        }
-
-        // copy the old one
-        wcscpy_s(lpwzFusionDisplayName, size+1, lpAssemblyIdentityCopy);
-        wcscat_s(lpwzFusionDisplayName, size+1, W(","));
-        wcscat_s(lpwzFusionDisplayName, size+1, lpPublicKeyTokenKey);
-        wcscat_s(lpwzFusionDisplayName, size+1, W("null"));
-
-        // delete the old copy
-        delete[] lpAssemblyIdentityCopy;
-
-        // lpAssemblyIdentityCopy has the new copy
-        lpAssemblyIdentityCopy = lpwzFusionDisplayName;
-        lpwzFusionDisplayName = NULL;
-    }
-    
-    if (wcsstr(lpAssemblyIdentityCopy, lpCultureKey))
-    {
-        // culture info is already included in the assemblyIdentity
-        // nothing need to be done
-        lpwzFusionDisplayName = lpAssemblyIdentityCopy;
-        *ppwzFusionDisplayName = lpwzFusionDisplayName;
-        return TRUE;
-    }
-
-    if ((lpMatch = wcsstr(lpAssemblyIdentityCopy, lpLanguageKey)) !=NULL )
-    {
-        // language info is included in the assembly identity
-        // need to replace it with culture
-        
-        // final size 
-        size += wcslen(lpCultureKey)-wcslen(lpLanguageKey);
-        lpwzFusionDisplayName = new (nothrow) WCHAR[size + 1];
-        if (!lpwzFusionDisplayName)
-        {
-            // clean up
-            delete[] lpAssemblyIdentityCopy;
-            return FALSE;
-        }
-        wcsncpy_s(lpwzFusionDisplayName, size+1, lpAssemblyIdentityCopy, lpMatch-lpAssemblyIdentityCopy);
-        lpwzFusionDisplayName[lpMatch-lpAssemblyIdentityCopy] = W('\0');
-        wcscat_s(lpwzFusionDisplayName, size+1, lpCultureKey);
-        wcscat_s(lpwzFusionDisplayName, size+1, lpMatch+wcslen(lpLanguageKey));
-        *ppwzFusionDisplayName = lpwzFusionDisplayName;
-        
-        // clean up
-        delete[] lpAssemblyIdentityCopy;
-        return TRUE;
-    }
-    else 
-    {
-        // neither culture or language key is presented
-        // let us attach culture info key to the identity
-        size += wcslen(lpCultureKey)+wcslen(lpNeutral)+1;
-        lpwzFusionDisplayName = new (nothrow) WCHAR[size + 1];
-        if (!lpwzFusionDisplayName)
-        {
-            // clean up
-            delete[] lpAssemblyIdentityCopy;
-            return FALSE;
-        }
-            
-        wcscpy_s(lpwzFusionDisplayName, size+1, lpAssemblyIdentityCopy);
-        wcscat_s(lpwzFusionDisplayName, size+1, W(","));
-        wcscat_s(lpwzFusionDisplayName, size+1, lpCultureKey);
-        wcscat_s(lpwzFusionDisplayName, size+1, lpNeutral);
-        *ppwzFusionDisplayName = lpwzFusionDisplayName;
-
-        // clean up
-        delete[] lpAssemblyIdentityCopy;
-        return TRUE;
-    }
-}
-
-//****************************************************************************
-//  AssemblyVersion
-//  
-//  class to handle assembly version
-//  Since only functions in this file will use it,
-//  we declare it in the cpp file so other people won't use it.
-//
-//****************************************************************************
-
-// Extract version info from pwzVersion, expecting "a.b.c.d",
-// where a,b,c and d are all digits.
-HRESULT AssemblyVersion::Init(__in_z LPCWSTR pcwzVersion, BOOL bStartsWithV)
-{
-    STATIC_CONTRACT_NOTHROW;
-    STATIC_CONTRACT_FAULT;
-
-    HRESULT hr = S_OK;
-    LPWSTR  pwzVersionCopy = NULL;
-    LPWSTR  pwzTokens = NULL;
-    LPWSTR  pwzToken = NULL;
-    size_t  size = 0;
-    int iVersion = 0;
-
-    if ((pcwzVersion == NULL) || (*pcwzVersion == W('\0')))
-        IfFailGo(E_INVALIDARG);
-
-    // If fStartsWithV is true, then the version string should start with a v.
-    // Verify this and if it is the case, start tokenizing at the character after the v.
-    if (bStartsWithV)
-    {
-        if (*pcwzVersion == W('v') || *pcwzVersion == W('V'))
-            pcwzVersion++;
-        else
-            IfFailGo(E_INVALIDARG);
-    }
-
-    IfFailGo(ValidateVersion(pcwzVersion));
-    
-    size = wcslen(pcwzVersion);
-    
-    IfNullGo(pwzVersionCopy = new (nothrow) WCHAR[size + 1]);
-   
-    wcscpy_s(pwzVersionCopy, size+1, pcwzVersion);
-    pwzTokens = pwzVersionCopy;
-    
-    // parse major version
-    pwzToken = wcstok_s(pwzTokens, W("."),&pwzTokens);
-    if (pwzToken != NULL)
-    {
-        iVersion = _wtoi(pwzToken);
-        if (iVersion > 0xffff)
-            IfFailGo(E_INVALIDARG);
-        _major = (WORD)iVersion;
-    }
-
-    // parse minor version
-    pwzToken = wcstok_s(pwzTokens, W("."),&pwzTokens);
-    if (pwzToken != NULL)
-    {
-        iVersion = _wtoi(pwzToken);
-        if (iVersion > 0xffff)
-            IfFailGo(E_INVALIDARG);
-        _minor = (WORD)iVersion;
-    }
-
-    // parse build version
-    pwzToken = wcstok_s(pwzTokens, W("."),&pwzTokens);
-    if (pwzToken != NULL)
-    {
-        iVersion = _wtoi(pwzToken);
-        if (iVersion > 0xffff)
-            IfFailGo(E_INVALIDARG);
-        _build = (WORD)iVersion;
-    }
-
-    // parse revision version
-    pwzToken = wcstok_s(pwzTokens, W("."),&pwzTokens);
-    if (pwzToken != NULL)
-    {
-        iVersion = _wtoi(pwzToken);
-        if (iVersion > 0xffff)
-            IfFailGo(E_INVALIDARG);
-        _revision = (WORD)iVersion;
-    }
-   
-ErrExit:
-    if (pwzVersionCopy)
-        delete[] pwzVersionCopy;
-    return hr;
-}
-
-// pcwzVersion must be in format of a.b.c.d, where a, b, c, d are numbers
-HRESULT AssemblyVersion::ValidateVersion(LPCWSTR pcwzVersion)
-{
-    STATIC_CONTRACT_NOTHROW;
-    STATIC_CONTRACT_FAULT;
-
-    LPCWSTR   pwCh = pcwzVersion;
-    INT       dots = 0; // number of dots
-    BOOL      bIsDot = FALSE; // is previous char a dot?
-
-    // first char cannot be .
-    if (*pwCh == W('.'))
-        return E_INVALIDARG;
-    
-    for(;*pwCh != W('\0');pwCh++)
-    {
-        if (*pwCh == W('.'))
-        {
-            if (bIsDot) // ..
-                return E_INVALIDARG;
-            else 
-            {
-                dots++;
-                bIsDot = TRUE;
-            }
-        }
-        /*
-        // We can't do this sort of validation, because then our v1.2.x86chk version numbers will be invalid
-        else if (!iswdigit(*pwCh))
-            return E_INVALIDARG;
-        */
-        else
-            bIsDot = FALSE;
-    }
-
-    if (dots > 3)
-        return E_INVALIDARG;
-
-    return S_OK;
-}
-
-BOOL operator==(const AssemblyVersion& version1, 
-                const AssemblyVersion& version2)
-{
-    LIMITED_METHOD_CONTRACT;
-
-    return ((version1._major == version2._major)
-            && (version1._minor == version2._minor)
-            && (version1._build == version2._build)
-            && (version1._revision == version2._revision));
-}
-
-BOOL operator>=(const AssemblyVersion& version1,
-                const AssemblyVersion& version2)
-{
-    LIMITED_METHOD_CONTRACT;
-
-    ULONGLONG ulVersion1;
-    ULONGLONG ulVersion2;
-
-    ulVersion1 = version1._major;
-    ulVersion1 = (ulVersion1<<16)|version1._minor;
-    ulVersion1 = (ulVersion1<<16)|version1._build;
-    ulVersion1 = (ulVersion1<<16)|version1._revision;
-
-    ulVersion2 = version2._major;
-    ulVersion2 = (ulVersion2<<16)|version2._minor;
-    ulVersion2 = (ulVersion2<<16)|version2._build;
-    ulVersion2 = (ulVersion2<<16)|version2._revision;
-
-    return (ulVersion1 >= ulVersion2);
-}
-
-enum RegistryBasePath
-{
-    RegistryBasePath_Record,
-    RegistryBasePath_CLSID_InprocServer32,
-    RegistryBasePath_CLSID_LocalServer32_32Key,
-    RegistryBasePath_CLSID_LocalServer32_64Key,
-};
-
-// Find which subkey has the highest verion
-// If return S_OK, *ppwzHighestVersion has the highest version string.
-//      *pbIsTopKey indicates if top key is the one with highest version.
-// If return S_FALSE, cannot find any version. *ppwzHighestVersion is set
-//      to NULL, and *pbIsTopKey is TRUE.
-// If failed, *ppwzHighestVersion will be set to NULL, and *pbIsTopKey is 
-// undefined.
-// Note: If succeeded, this function will allocate memory for *ppwzVersion. 
-//      Caller is responsible to release them
-HRESULT FindHighestVersion(REFCLSID rclsid, RegistryBasePath basePath, AssemblyVersion *prvHighestAllowed, 
-                           __deref_out_z LPWSTR *ppwzHighestVersion, BOOL *pbIsTopKey, BOOL *pbIsUnmanagedObject)
-{
-    STATIC_CONTRACT_NOTHROW;
-    STATIC_CONTRACT_FAULT;
-
-    HRESULT     hr = S_OK;
-    WCHAR       szID[64];
-    WCHAR       clsidKeyname[128];
-    WCHAR       wzSubKeyName[32]; 
-    DWORD       cwSubKeySize;
-    DWORD       dwIndex;          // subkey index
-    HKEY        hKeyCLSID = NULL;
-    HKEY        hSubKey = NULL;
-    DWORD       type;
-    DWORD       size;
-    BOOL        bIsTopKey = FALSE;   // Does top key have the highest version?
-    BOOL        bGotVersion = FALSE; // Do we get anything out of registry?
-    LONG        lResult;
-    LPWSTR      wzAssemblyString = NULL;
-    DWORD       numSubKeys = 0;
-    AssemblyVersion avHighest; WCHAR wzHighest[32];
-    AssemblyVersion avCurrent; WCHAR wzCurrent[32];
-
-    _ASSERTE(pbIsUnmanagedObject != NULL);
-    *pbIsUnmanagedObject = FALSE;
-
-    if ((ppwzHighestVersion == NULL) || (pbIsTopKey == NULL))
-        IfFailGo(E_INVALIDARG);
-
-    *ppwzHighestVersion = NULL;
-    *pbIsTopKey = FALSE;
-
-    if (!GuidToLPWSTR(rclsid, szID, NumItems(szID))) 
-        IfFailGo(E_INVALIDARG);
-
-    if (basePath == RegistryBasePath_Record)
-    {
-        wcscpy_s(clsidKeyname, 128, W("Record\\"));
-        wcscat_s(clsidKeyname, 128, szID);
-    }
-    else
-    {
-        wcscpy_s(clsidKeyname, 128, W("CLSID\\"));
-        wcscat_s(clsidKeyname, 128, szID);
-        if (basePath == RegistryBasePath_CLSID_InprocServer32)
-        {
-            wcscat_s(clsidKeyname, 128, W("\\InprocServer32"));
-        }
-        else
-        {
-            _ASSERTE(basePath == RegistryBasePath_CLSID_LocalServer32_32Key || basePath == RegistryBasePath_CLSID_LocalServer32_64Key);
-            wcscat_s(clsidKeyname, 128, W("\\LocalServer32"));
-        }
-    }
-
-    // Open HKCR\CLSID\<clsid> , or HKCR\Record\<RecordId>
-    REGSAM accessFlags = KEY_ENUMERATE_SUB_KEYS | KEY_READ;
-    if (basePath == RegistryBasePath_CLSID_LocalServer32_32Key)
-    {
-        // open the WoW key
-        accessFlags |= KEY_WOW64_32KEY;
-    }
-    else if (basePath == RegistryBasePath_CLSID_LocalServer32_64Key)
-    {
-        // open the 64-bit key
-        accessFlags |= KEY_WOW64_64KEY;
-    }
-
-    IfFailWin32Go(WszRegOpenKeyEx(
-                    HKEY_CLASSES_ROOT,
-                    clsidKeyname,
-                    0, 
-                    accessFlags,
-                    &hKeyCLSID));
-
-
-    //
-    // Start by looking for a version subkey.
-    //
-
-    IfFailWin32Go(WszRegQueryInfoKey(hKeyCLSID, NULL, NULL, NULL,
-                  &numSubKeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL));
-    
-    for ( dwIndex = 0; dwIndex < numSubKeys;  dwIndex++)
-    {
-        cwSubKeySize = NumItems(wzSubKeyName);
-        
-        IfFailWin32Go(WszRegEnumKeyEx(hKeyCLSID, //HKCR\CLSID\<clsid>\InprocServer32
-                        dwIndex,             // which subkey
-                        wzSubKeyName,        // subkey name
-                        &cwSubKeySize,       // size of subkey name
-                        NULL,                // lpReserved
-                        NULL,                // lpClass
-                        NULL,                // lpcbClass
-                        NULL));              // lpftLastWriteTime
-       
-        hr = avCurrent.Init(wzSubKeyName, FALSE);
-        if (FAILED(hr))
-        {
-            // not valid version subkey, ignore
-            continue;
-        }
-        wcscpy_s(wzCurrent, COUNTOF(wzCurrent), wzSubKeyName);
-
-        IfFailWin32Go(WszRegOpenKeyEx(
-                    hKeyCLSID,
-                    wzSubKeyName,
-                    0,
-                    accessFlags,
-                    &hSubKey));
-
-        // Check if this is a non-interop scenario
-        lResult = WszRegQueryValueEx(
-                        hSubKey,
-                        SBSVERSIONVALUE,
-                        NULL,
-                        &type,
-                        NULL,
-                        &size);  
-        if (lResult == ERROR_SUCCESS)
-        {
-            *pbIsUnmanagedObject = TRUE;
-        }
-        // This is an interop assembly
-        else
-        {
-            lResult = WszRegQueryValueEx(
-                            hSubKey,
-                            W("Assembly"),
-                            NULL,
-                            &type,
-                            NULL,
-                            &size);  
-            if (!((lResult == ERROR_SUCCESS)&&(type == REG_SZ)&&(size > 0)))
-            {
-                // do not have value "Assembly"
-                RegCloseKey(hSubKey);
-                hSubKey = NULL;
-                continue;
-            }
-
-            lResult = WszRegQueryValueEx(
-                            hSubKey,
-                            W("Class"),
-                            NULL,
-                            &type,
-                            NULL,
-                            &size);
-            if (!((lResult == ERROR_SUCCESS)&&(type == REG_SZ)&&(size > 0)))
-            {
-                // do not have value "Class"
-                RegCloseKey(hSubKey);
-                hSubKey = NULL;
-                continue;
-            }
-
-            lResult = WszRegQueryValueEx(
-                            hSubKey,
-                            W("RuntimeVersion"),
-                            NULL,
-                            &type,
-                            NULL,
-                            &size);
-            if (!((lResult == ERROR_SUCCESS)&&(type == REG_SZ)&&(size > 0)))
-            {
-                // We didn't find a RuntimeVersion value. This is fine for Records since
-                // in V1.1, Records didn't have a RuntimeVersion value. However if we aren't
-                // dealing with a Record, then this version subkey is invalid.
-                if (basePath != RegistryBasePath_Record)
-                {
-                    // do not have value "RuntimeVersion"
-                    RegCloseKey(hSubKey);
-                    hSubKey = NULL;
-                    continue;
-                }
-            }
-            else
-            {               
-                // If a highest allowed runtime version was specified, make sure that the component
-                // was built with a runtime version lower or equal to the highest.
-                if (prvHighestAllowed)
-                {
-                    NewArrayHolder<WCHAR> wzRuntimeVersionString = 
-                        new (nothrow) WCHAR[(size/sizeof(WCHAR)) + 1];
-                    IfNullGo(wzRuntimeVersionString);
-                    // RegQueryValueEx() does not guarantee NULL-terminated strings
-                    wzRuntimeVersionString[size/sizeof(WCHAR)] = W('\0');
-                    IfFailWin32Go(WszRegQueryValueEx(
-                                  hSubKey,
-                                  W("RuntimeVersion"),
-                                  NULL,
-                                  &type,
-                                  (LPBYTE)(WCHAR*)wzRuntimeVersionString,
-                                  &size));
-
-                    AssemblyVersion rvCurrent;
-                    rvCurrent.Init(wzRuntimeVersionString, TRUE);
-
-                    // We only care about major and minor version number.
-                    rvCurrent.SetBuild(0);
-                    rvCurrent.SetRevision(0);
-
-                    if ((*prvHighestAllowed) < rvCurrent)
-                    {                   
-                        // This version of the component was built with a runtime version higher
-                        // than maximum allowed one so we don't want to consider it.
-                        RegCloseKey(hSubKey);
-                        hSubKey = NULL;
-                        continue;
-                    }                                       
-                }
-            }
-        }
-                
-        // ok. Now I believe this is a valid subkey
-        RegCloseKey(hSubKey);
-        hSubKey = NULL;
-
-        if (bGotVersion)
-        {
-            if (avCurrent >= avHighest)
-            {
-                avHighest = avCurrent;
-                wcscpy_s(wzHighest, COUNTOF(wzHighest), wzCurrent);
-            }
-        }
-        else
-        {
-            avHighest = avCurrent;
-            wcscpy_s(wzHighest, COUNTOF(wzHighest), wzCurrent);
-        }
-
-        bGotVersion = TRUE;
-    }
-
-
-    //
-    // If there are no subkeys, then look at the top level key.
-    //
-    
-    if (!bGotVersion)
-    {
-        // make sure value Class exists
-        // If not dealing with record, also make sure RuntimeVersion exists.
-        if ((WszRegQueryValueEx(hKeyCLSID, W("Class"), NULL, &type, NULL, &size) == ERROR_SUCCESS) && (type == REG_SZ) && (size > 0))
-        {
-            // If there is no RuntimeVersion value, we will assume the component was built against
-            // the V1.0 CLR.
-            BOOL bSupportedVersion = TRUE;
-            
-            lResult = WszRegQueryValueEx(
-                            hKeyCLSID,
-                            W("RuntimeVersion"),
-                            NULL,
-                            &type,
-                            NULL,
-                            &size);
-            if ((lResult == ERROR_SUCCESS) && (type == REG_SZ) && (size > 0))
-            {                      
-                // If a highest allowed runtime version was specified, make sure that the component
-                // was built with a runtime version lower or equal to the highest.
-                if (prvHighestAllowed)
-                {
-                    NewArrayHolder<WCHAR> wzRuntimeVersionString = 
-                        new (nothrow) WCHAR[(size/sizeof(WCHAR)) + 1];
-                    IfNullGo(wzRuntimeVersionString);
-                    // RegQueryValueEx() does not guarantee NULL-terminated strings
-                    wzRuntimeVersionString[size/sizeof(WCHAR)] = W('\0');
-                    IfFailWin32Go(WszRegQueryValueEx(
-                                  hKeyCLSID,
-                                  W("RuntimeVersion"),
-                                  NULL,
-                                  &type,
-                                  (LPBYTE)(WCHAR*)wzRuntimeVersionString,
-                                  &size));
-
-                    AssemblyVersion rvCurrent;
-                    rvCurrent.Init(wzRuntimeVersionString, TRUE);
-
-                    // We only care about major and minor version number.
-                    rvCurrent.SetBuild(0);
-                    rvCurrent.SetRevision(0);
-
-                    if ((*prvHighestAllowed) < rvCurrent)
-                    {                   
-                        // This version of the component was built with a runtime version higher
-                        // than maximum allowed one so we don't want to consider it.
-                        bSupportedVersion = FALSE;
-                    }                                       
-                }
-            }
-
-            if (bSupportedVersion)
-            {           
-                // Get the size of assembly display name
-                lResult = WszRegQueryValueEx(
-                                hKeyCLSID,
-                                W("Assembly"),
-                                NULL,
-                                &type,
-                                NULL,
-                                &size);
-            
-                if ((lResult == ERROR_SUCCESS) && (type == REG_SZ) && (size > 0))
-                {
-                    IfNullGo(wzAssemblyString = new (nothrow) WCHAR[size + 1]);
-                    IfFailWin32Go(WszRegQueryValueEx(
-                                  hKeyCLSID,
-                                  W("Assembly"),
-                                  NULL,
-                                  &type,
-                                  (LPBYTE)wzAssemblyString,
-                                  &size));
-                
-                    // Now we have the assembly display name.
-                    // Extract the version out.
-
-                    // first lowercase display name
-                    _wcslwr_s(wzAssemblyString,size+1);
-
-                    // locate "version="
-                    LPWSTR pwzVersion = wcsstr(wzAssemblyString, W("version="));
-                    if (pwzVersion) {
-                        // point to the character after "version="
-                        pwzVersion += 8; // length of W("version=")
-
-                        // Now find the next W(',')
-                        LPWSTR pwzEnd = pwzVersion;
-
-                        while((*pwzEnd != W(',')) && (*pwzEnd != W('\0')))
-                            pwzEnd++;
-
-                        // terminate version string
-                        *pwzEnd = W('\0');
-
-                        // trim version string
-                        while(iswspace(*pwzVersion)) 
-                            pwzVersion++;
-
-                        pwzEnd--;
-                        while(iswspace(*pwzEnd)&&(pwzEnd > pwzVersion))
-                        {
-                            *pwzEnd = W('\0');
-                            pwzEnd--;
-                        }
-                               
-                        // Make sure the version is valid.
-                        if(SUCCEEDED(avHighest.Init(pwzVersion, FALSE)))
-                        {
-                            // This is the first version found, so it is the highest version
-                            wcscpy_s(wzHighest, COUNTOF(wzHighest), pwzVersion);
-                            bIsTopKey = TRUE;
-                            bGotVersion = TRUE;
-                        }
-                    }
-                }
-            }
-        } // end of handling of key HKCR\CLSID\<clsid>\InprocServer32
-    }
-
-    if (bGotVersion)
-    {
-        // Now we have the highest version. Copy it out
-        size_t cchHighest = wcslen(wzHighest) + 1; 
-        *ppwzHighestVersion = new (nothrow) WCHAR[cchHighest];
-        wcscpy_s(*ppwzHighestVersion, cchHighest, wzHighest);
-
-        *pbIsTopKey = bIsTopKey;
-
-        // return S_OK to indicate we successfully found the highest version.
-        hr = S_OK;
-    }
-    else
-    {
-        // return E_CLASSNOTREG to indicate that we didn't find anything
-        hr = REGDB_E_CLASSNOTREG;
-    }
-
-ErrExit:
-    if (hKeyCLSID)
-        RegCloseKey(hKeyCLSID);
-    if (hSubKey)
-        RegCloseKey(hSubKey);
-    if (wzAssemblyString)
-        delete[] wzAssemblyString;
-
-    return hr;
-}
-
-// If the value exists and is retrieved successfully, returns S_OK
-// If the value does not exist, returns S_FALSE
-// If some other error occurs, returns error-specific HRESULT
-static
-HRESULT ReadRegistryStringValue(
-    HKEYHolder &hKey,
-    LPCWSTR     wszName,
-    __deref_out_z __deref_out_opt LPWSTR *pwszValue)
-{
-    HRESULT hr = S_OK;
-
-    _ASSERTE(pwszValue != NULL);
-    *pwszValue = NULL;
-    
-    // extract the string value.
-    DWORD dwSize;
-    DWORD dwType;
-    NewArrayHolder<WCHAR> wszValue(NULL);
-    hr = HRESULT_FROM_WIN32(WszRegQueryValueEx(hKey, wszName, NULL, &dwType, NULL, &dwSize));
-
-    // If the function succeeds, the return value is ERROR_SUCCESS.
-    // If the wszName registry value does not exist, the function returns ERROR_FILE_NOT_FOUND.
-    if (hr == HRESULT_FROM_WIN32(ERROR_SUCCESS))
-    {
-        // The value is not a string
-        if (dwType != REG_SZ)
-            return E_INVALIDARG;
-
-        if(!ClrSafeInt<DWORD>::addition(dwSize, 1, dwSize))
-            IfFailWin32Ret(ERROR_ARITHMETIC_OVERFLOW);
-
-        IfNullRet(wszValue = new (nothrow) WCHAR[dwSize]);
-        IfFailWin32Ret(WszRegQueryValueEx(hKey, wszName, NULL, NULL, (LPBYTE)static_cast<LPCWSTR>(wszValue), &dwSize));
-        hr = S_OK;
-    }
-    else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
-    {
-        return S_FALSE;
-    }
-
-    _ASSERTE(hr == S_OK);
-    wszValue.SuppressRelease();
-    *pwszValue = wszValue;
-    return hr;
-}
-
-// FindRuntimeVersionFromRegistry
-//
-// Find the runtimeVersion corresponding to the highest version
-HRESULT FindRuntimeVersionFromRegistry(
-    REFCLSID rclsid,
-    __deref_out_z __deref_out_opt LPWSTR *ppwzRuntimeVersion,
-    __deref_out_z __deref_out_opt LPWSTR *ppwzSupportedVersions)
-{
-    STATIC_CONTRACT_NOTHROW;
-    STATIC_CONTRACT_FAULT;
-
-    HRESULT               hr = S_OK;
-    HKEYHolder            userKey;
-    WCHAR                 szID[64];
-    WCHAR                 keyname[256];
-    DWORD                 size;
-    DWORD                 type;
-    NewArrayHolder<WCHAR> pwzVersion = NULL;
-    BOOL                  bIsTopKey;
-    BOOL                  bIsUnmanagedObject = FALSE;
-    NewArrayHolder<WCHAR> pwzRuntimeVersion = NULL;
-    NewArrayHolder<WCHAR> pwzSupportedRuntimeVersions = NULL;
-
-    if (ppwzRuntimeVersion == NULL)
-        IfFailRet(E_INVALIDARG);
-
-    // Initialize the string passed in to NULL.
-    *ppwzRuntimeVersion = NULL;
-
-    if (ppwzSupportedVersions != NULL)
-        *ppwzSupportedVersions = NULL;
-
-    // Convert the GUID to its string representation.
-    if (GuidToLPWSTR(rclsid, szID, NumItems(szID)) == 0)
-        IfFailRet(E_INVALIDARG);
-    
-    // retrieve the highest version.
-    IfFailRet(FindHighestVersion(rclsid, RegistryBasePath_CLSID_InprocServer32, NULL, &pwzVersion, &bIsTopKey, &bIsUnmanagedObject));
-
-    if (!bIsUnmanagedObject)
-    {
-        // if highest version is in top key,
-        // we will look at HKCR\CLSID\<clsid>\InprocServer32 or HKCR\Record\<RecordId>
-        // Otherwise we will look at HKCR\CLSID\<clsid>\InprocServer32\<version> or HKCR\Record\<RecordId>\<Version>
-        wcscpy_s(keyname, 256, W("CLSID\\"));
-        wcscat_s(keyname, 256, szID);
-        wcscat_s(keyname, 256, W("\\InprocServer32"));
-        if (!bIsTopKey)
-        {
-            wcscat_s(keyname, 256, W("\\"));
-            wcscat_s(keyname, 256, pwzVersion);
-        }
-   
-        // open the registry key
-        IfFailWin32Ret(WszRegOpenKeyEx(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &userKey));
-
-        // extract the runtime version.
-        IfFailRet(ReadRegistryStringValue(userKey, W("RuntimeVersion"), &pwzRuntimeVersion));
-        if (hr == S_FALSE)
-        {
-            IfNullRet(pwzRuntimeVersion = DuplicateString(V1_VERSION_NUM));
-        }
-
-        // extract the supported runtime versions
-        if (ppwzSupportedVersions != NULL)
-            IfFailRet(ReadRegistryStringValue(userKey, W("SupportedRuntimeVersions"), &pwzSupportedRuntimeVersions));
-    }
-
-    else
-    {
-        // We need to prepend the 'v' to the version string
-        IfNullRet(pwzRuntimeVersion = new (nothrow) WCHAR[wcslen(pwzVersion)+1+1]); // +1 for the v, +1 for the null
-        *pwzRuntimeVersion = W('v');
-        wcscpy_s(pwzRuntimeVersion+1, wcslen(pwzVersion)+1, pwzVersion);
-    }
-
-    _ASSERTE(SUCCEEDED(hr));
-
-    // now we have the data, copy it out
-    pwzRuntimeVersion.SuppressRelease();
-    *ppwzRuntimeVersion = pwzRuntimeVersion;
-
-    if (ppwzSupportedVersions != NULL)
-    {
-        pwzSupportedRuntimeVersions.SuppressRelease();
-        *ppwzSupportedVersions = pwzSupportedRuntimeVersions;
-    }
-
-    return hr;
-}
-
-// FindShimInfoFromRegistry
-//
-HRESULT FindShimInfoFromRegistryWorker(
-    REFCLSID rclsid,
-    RegistryBasePath basePath,
-    WORD wHighestRuntimeMajorVersion, 
-    WORD wHighestRuntimeMinorVersion,
-    __deref_out_z LPWSTR *ppwzClassName,
-    __deref_out_z LPWSTR *ppwzAssemblyString, 
-    __deref_out_z LPWSTR *ppwzCodeBase)
-{
-    STATIC_CONTRACT_NOTHROW;
-    STATIC_CONTRACT_FAULT;
-
-    HRESULT hr = S_OK;
-    HKEY    userKey = NULL;
-    WCHAR   szID[64];
-    WCHAR   keyname[256];
-    DWORD   size;
-    DWORD   type;
-    LPWSTR  pwzVersion = NULL;
-    BOOL    bIsTopKey;
-    NewArrayHolder<WCHAR> wzClassName = NULL;
-    NewArrayHolder<WCHAR> wzAssemblyString = NULL;
-    NewArrayHolder<WCHAR> wzCodeBase = NULL;
-    LONG    lResult;
-    AssemblyVersion highestRuntimeVersion;
-        
-    // at least one should be specified.
-    // codebase is optional
-    if ((ppwzClassName == NULL) && (ppwzAssemblyString == NULL))
-        IfFailGo(E_INVALIDARG);
-
-    // Initialize the strings passed in to NULL.
-    if (ppwzClassName)
-        *ppwzClassName = NULL;
-    if (ppwzAssemblyString)
-        *ppwzAssemblyString = NULL;
-    if (ppwzCodeBase)
-        *ppwzCodeBase = NULL;
-
-    // Convert the GUID to its string representation.
-    if (GuidToLPWSTR(rclsid, szID, NumItems(szID)) == 0)
-        IfFailGo(E_INVALIDARG);
-    
-    // retrieve the highest version.
-    BOOL bIsUnmanaged = FALSE;
-
-    // Initialize the highest runtime version based on the passed in major and minor version numbers.
-    highestRuntimeVersion.Init(wHighestRuntimeMajorVersion, wHighestRuntimeMinorVersion, 0, 0);
-    
-    IfFailGo(FindHighestVersion(rclsid, basePath, &highestRuntimeVersion, &pwzVersion, &bIsTopKey, &bIsUnmanaged));
-
-    // if highest version is in top key,
-    // we will look at HKCR\CLSID\<clsid>\{Inproc,Local}Server32 or HKCR\Record\<RecordId>
-    // Otherwise we will look at HKCR\CLSID\<clsid>\{Inproc,Local}Server32\<version> or HKCR\Record\<RecordId>\<Version>
-    if (basePath == RegistryBasePath_Record)
-    {
-        wcscpy_s(keyname, 256, W("Record\\"));
-        wcscat_s(keyname, 256, szID);
-    }
-    else
-    {
-        wcscpy_s(keyname, 256, W("CLSID\\"));
-        wcscat_s(keyname, 256, szID);
-        if (basePath == RegistryBasePath_CLSID_InprocServer32)
-        {
-            wcscat_s(keyname, 256, W("\\InprocServer32"));
-        }
-        else
-        {
-            _ASSERTE(basePath == RegistryBasePath_CLSID_LocalServer32_32Key || basePath == RegistryBasePath_CLSID_LocalServer32_64Key);
-            wcscat_s(keyname, 256, W("\\LocalServer32"));
-        }
-    }
-    if (!bIsTopKey)
-    {
-         wcscat_s(keyname, 256, W("\\"));
-         wcscat_s(keyname, 256, pwzVersion);
-    }
-  
-    // open the registry
-    REGSAM accessFlags = KEY_READ;
-    if (basePath == RegistryBasePath_CLSID_LocalServer32_32Key)
-    {
-        // open the WoW key
-        accessFlags |= KEY_WOW64_32KEY;
-    }
-    else if (basePath == RegistryBasePath_CLSID_LocalServer32_64Key)
-    {
-        // open the 64-bit key
-        accessFlags |= KEY_WOW64_64KEY;
-    }
-
-    IfFailWin32Go(WszRegOpenKeyEx(HKEY_CLASSES_ROOT, keyname, 0, accessFlags, &userKey));
-  
-    // get the class name
-    IfFailWin32Go(WszRegQueryValueEx(userKey, W("Class"), NULL, &type, NULL, &size));
-    IfNullGo(wzClassName = new (nothrow) WCHAR[size + 1]);
-    IfFailWin32Go(WszRegQueryValueEx(userKey, W("Class"), NULL, NULL, (LPBYTE)wzClassName.GetValue(), &size));
-
-    // get the assembly string 
-    IfFailWin32Go(WszRegQueryValueEx(userKey, W("Assembly"), NULL, &type, NULL, &size));
-    IfNullGo(wzAssemblyString = new (nothrow) WCHAR[size + 1]);
-    IfFailWin32Go(WszRegQueryValueEx(userKey, W("Assembly"), NULL, NULL, (LPBYTE)wzAssemblyString.GetValue(), &size));
-
-    // get the code base if requested
-    if (ppwzCodeBase)
-    {
-        // get the codebase, however not finding it does not constitute
-        // a fatal error.
-        lResult = WszRegQueryValueEx(userKey, W("CodeBase"), NULL, &type, NULL, &size);
-        if ((lResult == ERROR_SUCCESS) && (type == REG_SZ) && (size > 0))
-        {
-            IfNullGo(wzCodeBase = new (nothrow) WCHAR[size + 1]);
-            IfFailWin32Go(WszRegQueryValueEx(userKey, W("CodeBase"), NULL, NULL, (LPBYTE)wzCodeBase.GetValue(), &size));                        
-        }
-    }
-
-    // now we got everything. Copy them out
-    if (ppwzClassName)
-        *ppwzClassName = wzClassName.Extract();
-
-    if (ppwzAssemblyString)
-        *ppwzAssemblyString = wzAssemblyString.Extract();
-
-    if (ppwzCodeBase)
-        *ppwzCodeBase = wzCodeBase.Extract();
-
-    hr = S_OK;
-
-ErrExit:
-    if (userKey)
-        RegCloseKey(userKey);
-    
-    if (pwzVersion)
-        delete[] pwzVersion;
-
-    return hr;
-}
-
-// Find shim info corresponding to the highest version
-HRESULT FindShimInfoFromRegistry(
-    REFCLSID rclsid,
-    BOOL bLoadRecord,
-    WORD wHighestRuntimeMajorVersion, 
-    WORD wHighestRuntimeMinorVersion,
-    __deref_out_z LPWSTR *ppwzClassName,
-    __deref_out_z LPWSTR *ppwzAssemblyString, 
-    __deref_out_z LPWSTR *ppwzCodeBase)
-{
-    STATIC_CONTRACT_NOTHROW;
-    STATIC_CONTRACT_FAULT;
-
-    if (bLoadRecord)
-    {
-        return FindShimInfoFromRegistryWorker(rclsid,
-                                              RegistryBasePath_Record,
-                                              wHighestRuntimeMajorVersion,
-                                              wHighestRuntimeMinorVersion,
-                                              ppwzClassName,
-                                              ppwzAssemblyString,
-                                              ppwzCodeBase);
-    }
-
-    // try InprocServer32 first
-    HRESULT hr = FindShimInfoFromRegistryWorker(rclsid,
-                                                RegistryBasePath_CLSID_InprocServer32,
-                                                wHighestRuntimeMajorVersion,
-                                                wHighestRuntimeMinorVersion,
-                                                ppwzClassName,
-                                                ppwzAssemblyString,
-                                                ppwzCodeBase);
-
-    // if it fails try both 64-bit and WoW LocalServer32
-    if (FAILED(hr))
-    {
-        // prefer the bitness of the process, use the other bitness as a fallback
-        hr = FindShimInfoFromRegistryWorker(rclsid,
-#ifdef _WIN64
-                                            RegistryBasePath_CLSID_LocalServer32_64Key,
-#else // _WIN64
-                                            RegistryBasePath_CLSID_LocalServer32_32Key,
-#endif // _WIN64
-                                            wHighestRuntimeMajorVersion,
-                                            wHighestRuntimeMinorVersion,
-                                            ppwzClassName,
-                                            ppwzAssemblyString,
-                                            ppwzCodeBase);
-
-        if (FAILED(hr)
-#ifndef _WIN64
-            && RunningInWow64()
-#endif // !_WIN64
-            )
-        {
-            hr = FindShimInfoFromRegistryWorker(rclsid,
-#ifdef _WIN64
-                                                RegistryBasePath_CLSID_LocalServer32_32Key,
-#else // _WIN64
-                                                RegistryBasePath_CLSID_LocalServer32_64Key,
-#endif // _WIN64
-                                                wHighestRuntimeMajorVersion,
-                                                wHighestRuntimeMinorVersion,
-                                                ppwzClassName,
-                                                ppwzAssemblyString,
-                                                ppwzCodeBase);
-        }
-    }
-    return hr;
-}
-
-
-// ----------------------------------------------------------------------------------------------------------
-// 
-// Gets config file name from Win32 manifest file. Strips the last extension (.manifest) from the manifest 
-// file name. Doesn't strip the last extension if it is '.exe'.
-// 
-// Note: Config file name could be already set in activation context by COM+ (out-of-process COM) - they 
-// pick up CLR version information from registry.
-// 
-// Arguments:
-//   wszBuffer  - [in, out] The buffer to fill the configuration file name (can be NULL)
-//   cBuffer    - [in] Size of the buffer in wide characters
-//   pcNameSize - [out] Size of the name filled in the buffer (in wide characters including terminating null).
-//                Can be NULL.
-// 
-// Return value:
-//   S_OK   - Success. Buffer (wszBuffer) and config file name size (pcNameSize) are filled.
-//   HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) - Buffer is too small for filling config file name. 
-//                  Sets pcNameSize (if not NULL) to the size of config file name including null terminator.
-//
-HRESULT GetConfigFileFromWin32Manifest(__out_ecount(cBuffer) WCHAR *wszBuffer, 
-                                       SIZE_T                       cBuffer, 
-                                       SIZE_T                      *pcNameSize)
-{
-    STATIC_CONTRACT_NOTHROW;
-    STATIC_CONTRACT_FAULT;
-    
-    HRESULT hr = S_OK;
-    
-    HANDLE hActCtx         = NULL;
-    SIZE_T cbInfo          = 0;
-    SIZE_T cConfigFileName = 0;
-    
-    // Get detailed information about activation activation context
-    if (!WszQueryActCtxW(0,         // Flags
-                         hActCtx,   // Activation context being queried
-                         NULL,      // Specific to the information class
-                         ActivationContextDetailedInformation, 
-                                    // Information class - detailed information
-                         NULL,      // [out] Buffer
-                         0,         // [in] Buffer size
-                         &cbInfo))  // [out] Written/required sized in buffer
-    {
-        if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
-        {
-            CQuickBytes                              qbInfo;
-            ACTIVATION_CONTEXT_DETAILED_INFORMATION *pInfo = NULL;
-            
-            pInfo = (ACTIVATION_CONTEXT_DETAILED_INFORMATION *)qbInfo.AllocNoThrow(cbInfo);
-            IfNullGo(pInfo);
-            
-            if (WszQueryActCtxW(0,          // Flags
-                                hActCtx,    // Activation context being queried
-                                NULL,       // Specific to the information class
-                                ActivationContextDetailedInformation, 
-                                            // Information class - detailed information
-                                pInfo,      // [out] Buffer
-                                cbInfo,     // [in] Buffer size
-                                &cbInfo) && // [out] Written size in the buffer
-                pInfo->ulAppDirPathType == ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE) 
-            {   // Application manifest was loaded from Win32 file (not an URL, AssemblyRef etc.)
-                WCHAR     *wszConfigFileName = NULL;
-                CQuickWSTR qwszConfigFileName;
-                
-                if (pInfo->lpRootConfigurationPath != NULL)
-                {   // Configuration file name is provided, use it
-                    wszConfigFileName = (WCHAR *)pInfo->lpRootConfigurationPath;
-                }
-                else if (pInfo->lpRootManifestPath != NULL)
-                {   // Manifest file name is provided, use it
-                    SIZE_T cManifestFileName = wcslen(pInfo->lpRootManifestPath);
-                    if (cManifestFileName != 0)
-                    {   // Manifest file does exist
-                        WCHAR  wszConfigFileExtension[] = W(".config");
-                        SIZE_T cConfigFileExtension     = sizeof(wszConfigFileExtension) / sizeof(WCHAR);
-                        // Allocate space for manifest file name + .config + terminating null 
-                        // (included in .config extension)
-                        SIZE_T cConfigFileNameAllocated = cManifestFileName + cConfigFileExtension;
-                        wszConfigFileName = qwszConfigFileName.AllocNoThrow(cConfigFileNameAllocated);
-                        IfNullGo(wszConfigFileName);
-                        // Use manifest file name as the template for config file name
-                        wcscpy_s(wszConfigFileName, cConfigFileNameAllocated, pInfo->lpRootManifestPath);
-                        
-                        // Find the last extension in the manifest file name (or NULL if not found)
-                        LPWSTR wszLastExtension = wcsrchr(wszConfigFileName, W('.'));
-                        // Is the manifest file in an external separate file?
-                        if ((wszLastExtension != NULL) && (_wcsicmp(wszLastExtension, W(".exe")) != 0))
-                        {   // It is an external manifest file (with .manifest or similar extension)
-                            // Excluded are files without an extension and with .exe extension (embeded 
-                            // manifest in executable resources)
-                            
-                            // Strip the last extension in the manifest file name
-                            *wszLastExtension = 0;
-                        }
-                        // Manifest file name has stripped last extension (.manifest)
-                        
-                        // Append the .config extension behind the manifest file name
-                        wcscat_s(wszConfigFileName, 
-                                 cConfigFileNameAllocated, 
-                                 wszConfigFileExtension);
-                    }
-                }
-                
-                // Do we have a configuration file name?
-                if (wszConfigFileName != NULL)
-                {   // We have a configuration file name
-                    // Get the real configuration file name length (including terminating null)
-                    cConfigFileName = wcslen(wszConfigFileName) + 1;
-                    // Check the output buffer - is its size sufficient?
-                    if ((wszBuffer == NULL) || (cConfigFileName > cBuffer))
-                    {   // Insufficient output buffer (too small or not passed)
-                        IfFailGo(HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER));
-                    }
-                    else 
-                    {   // Fill output buffer
-                        wcscpy_s(wszBuffer, cConfigFileName, wszConfigFileName);
-                    }
-                }
-            }
-        }
-    }
-    
-ErrExit:
-    // Should we return config file name size?
-    if (pcNameSize != NULL)
-    {   // We should return name size
-        // Return either copied size or potentially copied size
-        *pcNameSize = cConfigFileName;
-    }
-    return hr;
-}
-
-HRESULT GetApplicationPathFromWin32Manifest(__out_ecount(dwBuffer) WCHAR* buffer, SIZE_T dwBuffer, SIZE_T* pSize)
-{
-    STATIC_CONTRACT_NOTHROW;
-    STATIC_CONTRACT_FAULT;
-
-    HRESULT hr = S_OK;
-
-    // Get the basic activation context first.
-    ACTIVATION_CONTEXT_DETAILED_INFORMATION* pInfo = NULL;
-    SIZE_T length = 0;
-
-    HANDLE hActCtx = NULL;
-    SIZE_T nCount = 0;
-
-    if (!WszQueryActCtxW(0, hActCtx, NULL, ActivationContextDetailedInformation, 
-                         NULL, nCount, &nCount))
-    {
-        
-        if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) 
-        {
-           
-            pInfo = (ACTIVATION_CONTEXT_DETAILED_INFORMATION*) alloca(nCount);
-            
-            if (WszQueryActCtxW(0, hActCtx, NULL, ActivationContextDetailedInformation, 
-                                pInfo, nCount, &nCount) &&
-                pInfo->ulAppDirPathType == ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE) 
-            {
-                
-                if(pInfo->lpAppDirPath) {
-                    length = wcslen(pInfo->lpAppDirPath) + 1;
-                    if(length > dwBuffer || buffer == NULL) {
-                        hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
-                    }
-                    else {
-                        wcscpy_s(buffer, dwBuffer, pInfo->lpAppDirPath);
-                    }
-                }
-
-            }
-        }
-    }
-    if(pSize) *pSize = length;
-    return hr;
-}
index 9a7c652..6ec129c 100644 (file)
@@ -46,7 +46,6 @@
 
 #ifdef FEATURE_COMINTEROP
 #include "comtoclrcall.h"
-#include "sxshelpers.h"
 #include "runtimecallablewrapper.h"
 #include "mngstdinterfaces.h"
 #include "olevariant.h"
diff --git a/src/vm/vertable.h b/src/vm/vertable.h
deleted file mode 100644 (file)
index 9fbf5fd..0000000
+++ /dev/null
@@ -1,380 +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.
-
-/*
- * Types for pop stack/push stack
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * 1  I1/U1
- * 2  I2/U2
- * 4  I4/U4
- * 8  I8/U8
- * r  R4
- * d  R8
- * o  objref (can be an array or null)
- * [  single dimensional array of (prefix)
- * &  byref/managed ptr (prefix)
- *
- * Pop only
- * ~~~~~~~~
- * R  real number
- * N  number -any integer or real number
- * Q  number or unmanaged pointer
- * X  number, unmanaged pointer, managed pointer, or objref [Obsolete]
- * Y  integer (I1..I4), unmanaged pointer, managed pointer, or objref
- * I  Integral type (1, 2, 4, or 8 byte, or platform-independent integer type)
- * A  Anything
- *
- * CE "ceq" semantics - pop 2 arguments, do type checking as if for "ceq" instruction:
- *                      Integer     Real     ManagedPtr     UnmanagedPtr   Objref
- *       Integer           y               
- *       Real                        y
- *       ManagedPtr                             y                             y
- *       UnmanagedPtr                                            y
- *       Objref                                 y                             y
- *
- * CG "cgt" semantics - pop 2 arguments, do type checking as if for "cgt" instruction:
- *                      Integer     Real     ManagedPtr     UnmanagedPtr   Objref
- *       Integer           y               
- *       Real                        y
- *       ManagedPtr                                                           y
- *       UnmanagedPtr                                            
- *       Objref                                 y                             
- * 
- * =  Pop another item off the stack, and it must be the same type (int,real,objref,etc.) as the 
- *    last item popped (note, System.Int32 <-> I4 etc. are allowed).  Other value 
- *    classes are NOT allowed.
- *
- * i  (deprecated) Platform independent size value, but NOT an objref (I4/R4/ptr on 32-bit, I8/R8/ptr on 64-bit)
- * p  (deprecated) Platform independent size value OR objref 
- * *  (deprecated) anything
-
- * Push only
- * ~~~~~~~~~
- * n  null objref (valid for push only)
- * -  Rewind the stack to undo the last pop (you cannot have trashed that location, though)
- *
- * Usage: <pop stack> : <operand checks> <push stack> <branches> <!>
- *
- * Order is important!  Operand checks come after pop stack and before push stack.
- * For example, to check the operand being a valid local variable number (only), do ":L"
- *
- * If there is a "!" at the end, it means the instruction is either invalid, not supported, or that
- * there is a case statement to handle the instruction.  If no case statement exists, the verifier
- * will fail verification of the method.
- *
- * ! can be used to perform some operand checks and/or stack pops/pushes, while still allowing specific
- * behavior; e.g. verifying that the inline operand is a valid local variable number.
- *
- * <operand checks>
- * ~~~~~~~~~~~~~~~~
- * #d Overwrite inline operand with digit "d" (must be in 0...9 range)
- * L  Check that the operand is a valid local variable number.
- * A  Check that the operand is a valid argument number.
- *
- * <branches>
- * ~~~~~~~~~~
- * b1 - one byte conditional branch
- * b4 - four byte conditional branch
- * u1 - one byte unconditional branch
- * u4 - four byte unconditional branch
- * l1 - one byte leave
- * l4 - one byte leave
- *
- */
-
-VEROPCODE(CEE_NOP,                      ":")
-VEROPCODE(CEE_BREAK,                    ":")
-VEROPCODE(CEE_LDARG_0,                  ":#0A!")
-VEROPCODE(CEE_LDARG_1,                  ":#1A!")
-VEROPCODE(CEE_LDARG_2,                  ":#2A!")
-VEROPCODE(CEE_LDARG_3,                  ":#3A!")
-VEROPCODE(CEE_LDLOC_0,                  ":#0L!")
-VEROPCODE(CEE_LDLOC_1,                  ":#1L!")
-VEROPCODE(CEE_LDLOC_2,                  ":#2L!")
-VEROPCODE(CEE_LDLOC_3,                  ":#3L!")
-VEROPCODE(CEE_STLOC_0,                  ":#0L!")
-VEROPCODE(CEE_STLOC_1,                  ":#1L!")
-VEROPCODE(CEE_STLOC_2,                  ":#2L!")
-VEROPCODE(CEE_STLOC_3,                  ":#3L!")
-VEROPCODE(CEE_LDARG_S,                  ":A!")
-VEROPCODE(CEE_LDARGA_S,                 ":A!")
-VEROPCODE(CEE_STARG_S,                  ":A!")
-VEROPCODE(CEE_LDLOC_S,                  ":L!")
-VEROPCODE(CEE_LDLOCA_S,                 ":L!")
-VEROPCODE(CEE_STLOC_S,                  ":L!")
-VEROPCODE(CEE_LDNULL,                   ":n")
-VEROPCODE(CEE_LDC_I4_M1,                ":4")
-VEROPCODE(CEE_LDC_I4_0,                 ":4")
-VEROPCODE(CEE_LDC_I4_1,                 ":4")
-VEROPCODE(CEE_LDC_I4_2,                 ":4")
-VEROPCODE(CEE_LDC_I4_3,                 ":4")
-VEROPCODE(CEE_LDC_I4_4,                 ":4")
-VEROPCODE(CEE_LDC_I4_5,                 ":4")
-VEROPCODE(CEE_LDC_I4_6,                 ":4")
-VEROPCODE(CEE_LDC_I4_7,                 ":4")
-VEROPCODE(CEE_LDC_I4_8,                 ":4")
-VEROPCODE(CEE_LDC_I4_S,                 ":4")
-VEROPCODE(CEE_LDC_I4,                   ":4")
-VEROPCODE(CEE_LDC_I8,                   ":8")
-VEROPCODE(CEE_LDC_R4,                   ":r")
-VEROPCODE(CEE_LDC_R8,                   ":d")
-VEROPCODE(CEE_UNUSED49,                 "!") 
-VEROPCODE(CEE_DUP,                      "!")
-VEROPCODE(CEE_POP,                      "A:")
-VEROPCODE(CEE_JMP,                      "!")            // Unverifiable !
-VEROPCODE(CEE_CALL,                     "!")
-VEROPCODE(CEE_CALLI,                    "!")
-VEROPCODE(CEE_RET,                      "!")
-VEROPCODE(CEE_BR_S,                     ":u1")
-VEROPCODE(CEE_BRFALSE_S,                "Y:b1")
-VEROPCODE(CEE_BRTRUE_S,                 "Y:b1")
-VEROPCODE(CEE_BEQ_S,                    "CE:b1")
-VEROPCODE(CEE_BGE_S,                    "CG:b1")
-VEROPCODE(CEE_BGT_S,                    "CG:b1")
-VEROPCODE(CEE_BLE_S,                    "CG:b1")
-VEROPCODE(CEE_BLT_S,                    "CG:b1")
-VEROPCODE(CEE_BNE_UN_S,                 "CE:b1")
-VEROPCODE(CEE_BGE_UN_S,                 "CG:b1")
-VEROPCODE(CEE_BGT_UN_S,                 "CG:b1")
-VEROPCODE(CEE_BLE_UN_S,                 "CG:b1")
-VEROPCODE(CEE_BLT_UN_S,                 "CG:b1")
-VEROPCODE(CEE_BR,                       ":u4")
-VEROPCODE(CEE_BRFALSE,                  "Y:b4")
-VEROPCODE(CEE_BRTRUE,                   "Y:b4")
-VEROPCODE(CEE_BEQ,                      "CE:b4")
-VEROPCODE(CEE_BGE,                      "CG:b4")
-VEROPCODE(CEE_BGT,                      "CG:b4")
-VEROPCODE(CEE_BLE,                      "CG:b4")
-VEROPCODE(CEE_BLT,                      "CG:b4")
-VEROPCODE(CEE_BNE_UN,                   "CE:b4")
-VEROPCODE(CEE_BGE_UN,                   "CG:b4")
-VEROPCODE(CEE_BGT_UN,                   "CG:b4")
-VEROPCODE(CEE_BLE_UN,                   "CG:b4")
-VEROPCODE(CEE_BLT_UN,                   "CG:b4")
-VEROPCODE(CEE_SWITCH,                   "!")
-VEROPCODE(CEE_LDIND_I1,                 "&1:4")
-VEROPCODE(CEE_LDIND_U1,                 "&1:4")
-VEROPCODE(CEE_LDIND_I2,                 "&2:4")
-VEROPCODE(CEE_LDIND_U2,                 "&2:4")
-VEROPCODE(CEE_LDIND_I4,                 "&4:4")
-VEROPCODE(CEE_LDIND_U4,                 "&4:4")
-VEROPCODE(CEE_LDIND_I8,                 "&8:8")
-VEROPCODE(CEE_LDIND_I,                  "&i:i") // <TODO> not correct on 64 bit</TODO>
-VEROPCODE(CEE_LDIND_R4,                 "&r:r")
-VEROPCODE(CEE_LDIND_R8,                 "&d:d")
-VEROPCODE(CEE_LDIND_REF,                "!")
-VEROPCODE(CEE_STIND_REF,                "!")
-VEROPCODE(CEE_STIND_I1,                 "4&1:")
-VEROPCODE(CEE_STIND_I2,                 "4&2:")
-VEROPCODE(CEE_STIND_I4,                 "4&4:")
-VEROPCODE(CEE_STIND_I8,                 "8&8:")
-VEROPCODE(CEE_STIND_R4,                 "r&r:")
-VEROPCODE(CEE_STIND_R8,                 "d&d:")
-VEROPCODE(CEE_ADD,                      "N=:-")
-VEROPCODE(CEE_SUB,                      "N=:-")
-VEROPCODE(CEE_MUL,                      "N=:-")
-VEROPCODE(CEE_DIV,                      "N=:-")
-VEROPCODE(CEE_DIV_UN,                   "I=:-")
-VEROPCODE(CEE_REM,                      "N=:-")
-VEROPCODE(CEE_REM_UN,                   "I=:-")
-VEROPCODE(CEE_AND,                      "I=:-")
-VEROPCODE(CEE_OR,                       "I=:-")
-VEROPCODE(CEE_XOR,                      "I=:-")
-VEROPCODE(CEE_SHL,                      "4I:-")
-VEROPCODE(CEE_SHR,                      "4I:-")
-VEROPCODE(CEE_SHR_UN,                   "4I:-")
-VEROPCODE(CEE_NEG,                      "N:-")
-VEROPCODE(CEE_NOT,                      "I:-")
-VEROPCODE(CEE_CONV_I1,                  "Q:4")
-VEROPCODE(CEE_CONV_I2,                  "Q:4")
-VEROPCODE(CEE_CONV_I4,                  "Q:4")
-VEROPCODE(CEE_CONV_I8,                  "Q:8")
-VEROPCODE(CEE_CONV_R4,                  "N:r")
-VEROPCODE(CEE_CONV_R8,                  "N:d")
-VEROPCODE(CEE_CONV_U4,                  "Q:4")
-VEROPCODE(CEE_CONV_U8,                  "Q:8")
-VEROPCODE(CEE_CALLVIRT,                 "!")
-VEROPCODE(CEE_CPOBJ,                    "!")
-VEROPCODE(CEE_LDOBJ,                    "!")
-VEROPCODE(CEE_LDSTR,                    "!")
-VEROPCODE(CEE_NEWOBJ,                   "!")
-VEROPCODE(CEE_CASTCLASS,                "!")
-VEROPCODE(CEE_ISINST,                   "!")
-VEROPCODE(CEE_CONV_R_UN,                "Q:r")
-VEROPCODE(CEE_UNUSED58,                 "!")
-VEROPCODE(CEE_UNUSED1,                  "!")
-VEROPCODE(CEE_UNBOX,                    "!")
-VEROPCODE(CEE_THROW,                    "!")
-VEROPCODE(CEE_LDFLD,                    "!")
-VEROPCODE(CEE_LDFLDA,                   "!")
-VEROPCODE(CEE_STFLD,                    "!")
-VEROPCODE(CEE_LDSFLD,                   "!")
-VEROPCODE(CEE_LDSFLDA,                  "!")
-VEROPCODE(CEE_STSFLD,                   "!")
-VEROPCODE(CEE_STOBJ,                    "!")
-VEROPCODE(CEE_CONV_OVF_I1_UN,           "Q:4")
-VEROPCODE(CEE_CONV_OVF_I2_UN,           "Q:4")
-VEROPCODE(CEE_CONV_OVF_I4_UN,           "Q:4")
-VEROPCODE(CEE_CONV_OVF_I8_UN,           "Q:8")
-VEROPCODE(CEE_CONV_OVF_U1_UN,           "Q:4")
-VEROPCODE(CEE_CONV_OVF_U2_UN,           "Q:4")
-VEROPCODE(CEE_CONV_OVF_U4_UN,           "Q:4")
-VEROPCODE(CEE_CONV_OVF_U8_UN,           "Q:8")
-VEROPCODE(CEE_CONV_OVF_I_UN,            "Q:i")
-VEROPCODE(CEE_CONV_OVF_U_UN,            "Q:i")
-VEROPCODE(CEE_BOX,                      "!")
-VEROPCODE(CEE_NEWARR,                   "!")
-VEROPCODE(CEE_LDLEN,                    "[*:4")
-VEROPCODE(CEE_LDELEMA,                  "!")
-VEROPCODE(CEE_LDELEM_I1,                "4[1:4")
-VEROPCODE(CEE_LDELEM_U1,                "4[1:4")
-VEROPCODE(CEE_LDELEM_I2,                "4[2:4")
-VEROPCODE(CEE_LDELEM_U2,                "4[2:4")
-VEROPCODE(CEE_LDELEM_I4,                "4[4:4")
-VEROPCODE(CEE_LDELEM_U4,                "4[4:4")
-VEROPCODE(CEE_LDELEM_I8,                "4[8:8")
-VEROPCODE(CEE_LDELEM_I,                 "4[i:i")
-VEROPCODE(CEE_LDELEM_R4,                "4[r:r")
-VEROPCODE(CEE_LDELEM_R8,                "4[d:d")
-VEROPCODE(CEE_LDELEM_REF,               "!")
-VEROPCODE(CEE_STELEM_I,                 "i4[i:")
-VEROPCODE(CEE_STELEM_I1,                "44[1:")
-VEROPCODE(CEE_STELEM_I2,                "44[2:")
-VEROPCODE(CEE_STELEM_I4,                "44[4:")
-VEROPCODE(CEE_STELEM_I8,                "84[8:")
-VEROPCODE(CEE_STELEM_R4,                "r4[r:")
-VEROPCODE(CEE_STELEM_R8,                "d4[d:")
-VEROPCODE(CEE_STELEM_REF,               "!")
-VEROPCODE(CEE_LDELEM,               "!")
-VEROPCODE(CEE_STELEM,               "!")
-VEROPCODE(CEE_UNBOX_ANY,                "!")
-VEROPCODE(CEE_UNUSED5,                  "!")
-VEROPCODE(CEE_UNUSED6,                  "!")
-VEROPCODE(CEE_UNUSED7,                  "!")
-VEROPCODE(CEE_UNUSED8,                  "!")
-VEROPCODE(CEE_UNUSED9,                  "!")
-VEROPCODE(CEE_UNUSED10,                 "!")
-VEROPCODE(CEE_UNUSED11,                 "!")
-VEROPCODE(CEE_UNUSED12,                 "!")
-VEROPCODE(CEE_UNUSED13,                 "!")
-VEROPCODE(CEE_UNUSED14,                 "!")
-VEROPCODE(CEE_UNUSED15,                 "!")
-VEROPCODE(CEE_UNUSED16,                 "!")
-VEROPCODE(CEE_UNUSED17,                 "!")
-VEROPCODE(CEE_CONV_OVF_I1,              "Q:4")
-VEROPCODE(CEE_CONV_OVF_U1,              "Q:4")
-VEROPCODE(CEE_CONV_OVF_I2,              "Q:4")
-VEROPCODE(CEE_CONV_OVF_U2,              "Q:4")
-VEROPCODE(CEE_CONV_OVF_I4,              "Q:4")
-VEROPCODE(CEE_CONV_OVF_U4,              "Q:4")
-VEROPCODE(CEE_CONV_OVF_I8,              "Q:8")
-VEROPCODE(CEE_CONV_OVF_U8,              "Q:8")
-VEROPCODE(CEE_UNUSED50,                 "!")
-VEROPCODE(CEE_UNUSED18,                 "!")
-VEROPCODE(CEE_UNUSED19,                 "!")
-VEROPCODE(CEE_UNUSED20,                 "!")
-VEROPCODE(CEE_UNUSED21,                 "!")
-VEROPCODE(CEE_UNUSED22,                 "!")
-VEROPCODE(CEE_UNUSED23,                 "!")
-VEROPCODE(CEE_REFANYVAL,                "!")
-VEROPCODE(CEE_CKFINITE,                 "R:-")
-VEROPCODE(CEE_UNUSED24,                 "!")
-VEROPCODE(CEE_UNUSED25,                 "!")
-VEROPCODE(CEE_MKREFANY,                 "!")
-VEROPCODE(CEE_UNUSED59,                 "!")
-VEROPCODE(CEE_UNUSED60,                 "!")
-VEROPCODE(CEE_UNUSED61,                 "!")
-VEROPCODE(CEE_UNUSED62,                 "!")
-VEROPCODE(CEE_UNUSED63,                 "!")
-VEROPCODE(CEE_UNUSED64,                 "!")
-VEROPCODE(CEE_UNUSED65,                 "!")
-VEROPCODE(CEE_UNUSED66,                 "!")
-VEROPCODE(CEE_UNUSED67,                 "!")
-VEROPCODE(CEE_LDTOKEN,                  "!")
-VEROPCODE(CEE_CONV_U2,                  "Q:4")
-VEROPCODE(CEE_CONV_U1,                  "Q:4")
-VEROPCODE(CEE_CONV_I,                   "Q:i")
-VEROPCODE(CEE_CONV_OVF_I,               "Q:i")
-VEROPCODE(CEE_CONV_OVF_U,               "Q:i")
-VEROPCODE(CEE_ADD_OVF,                  "I=:-")
-VEROPCODE(CEE_ADD_OVF_UN,               "I=:-")
-VEROPCODE(CEE_MUL_OVF,                  "I=:-")
-VEROPCODE(CEE_MUL_OVF_UN,               "I=:-")
-VEROPCODE(CEE_SUB_OVF,                  "I=:-")
-VEROPCODE(CEE_SUB_OVF_UN,               "I=:-")
-VEROPCODE(CEE_ENDFINALLY,               "!")
-VEROPCODE(CEE_LEAVE,                    ":l4")
-VEROPCODE(CEE_LEAVE_S,                  ":l1")
-VEROPCODE(CEE_STIND_I,                  "i&i:") // <TODO> : 64 bit</TODO>
-VEROPCODE(CEE_CONV_U,                   "Q:i")
-VEROPCODE(CEE_UNUSED26,                 "!")
-VEROPCODE(CEE_UNUSED27,                 "!")
-VEROPCODE(CEE_UNUSED28,                 "!")
-VEROPCODE(CEE_UNUSED29,                 "!")
-VEROPCODE(CEE_UNUSED30,                 "!")
-VEROPCODE(CEE_UNUSED31,                 "!")
-VEROPCODE(CEE_UNUSED32,                 "!")
-VEROPCODE(CEE_UNUSED33,                 "!")
-VEROPCODE(CEE_UNUSED34,                 "!")
-VEROPCODE(CEE_UNUSED35,                 "!")
-VEROPCODE(CEE_UNUSED36,                 "!")
-VEROPCODE(CEE_UNUSED37,                 "!")
-VEROPCODE(CEE_UNUSED38,                 "!")
-VEROPCODE(CEE_UNUSED39,                 "!")
-VEROPCODE(CEE_UNUSED40,                 "!")
-VEROPCODE(CEE_UNUSED41,                 "!")
-VEROPCODE(CEE_UNUSED42,                 "!")
-VEROPCODE(CEE_UNUSED43,                 "!")
-VEROPCODE(CEE_UNUSED44,                 "!")
-VEROPCODE(CEE_UNUSED45,                 "!")
-VEROPCODE(CEE_UNUSED46,                 "!")
-VEROPCODE(CEE_UNUSED47,                 "!")
-VEROPCODE(CEE_UNUSED48,                 "!")
-VEROPCODE(CEE_PREFIX7,                  "!")
-VEROPCODE(CEE_PREFIX6,                  "!")
-VEROPCODE(CEE_PREFIX5,                  "!")
-VEROPCODE(CEE_PREFIX4,                  "!")
-VEROPCODE(CEE_PREFIX3,                  "!")
-VEROPCODE(CEE_PREFIX2,                  "!")
-VEROPCODE(CEE_PREFIX1,                  "!")
-VEROPCODE(CEE_PREFIXREF,                "!")
-VEROPCODE(CEE_ARGLIST,                  "!")
-VEROPCODE(CEE_CEQ,                      "CE:4")
-VEROPCODE(CEE_CGT,                      "CG:4")
-VEROPCODE(CEE_CGT_UN,                   "CE:4")
-VEROPCODE(CEE_CLT,                      "CG:4")
-VEROPCODE(CEE_CLT_UN,                   "CG:4")
-VEROPCODE(CEE_LDFTN,                    "!")
-VEROPCODE(CEE_LDVIRTFTN,                "!")
-VEROPCODE(CEE_UNUSED56,                 "!") 
-VEROPCODE(CEE_LDARG,                    ":A!")
-VEROPCODE(CEE_LDARGA,                   ":A!")
-VEROPCODE(CEE_STARG,                    ":A!")
-VEROPCODE(CEE_LDLOC,                    ":L!")
-VEROPCODE(CEE_LDLOCA,                   ":L!")
-VEROPCODE(CEE_STLOC,                    ":L!")
-VEROPCODE(CEE_LOCALLOC,                 "i:i!")     // Unverifiable !
-VEROPCODE(CEE_UNUSED57,                 "!")
-VEROPCODE(CEE_ENDFILTER,                "4:!")
-VEROPCODE(CEE_UNALIGNED,                ":")
-VEROPCODE(CEE_VOLATILE,                 ":")
-VEROPCODE(CEE_TAILCALL,                 ":")
-VEROPCODE(CEE_INITOBJ,                  "!")
-VEROPCODE(CEE_CONSTRAINED,               ":")
-VEROPCODE(CEE_CPBLK,                    "ii4:!")    // Unverifiable !
-VEROPCODE(CEE_INITBLK,                  "i44:!")    // Unverifiable !
-VEROPCODE(CEE_UNUSED69,                 "!")
-VEROPCODE(CEE_RETHROW,                  "!")
-VEROPCODE(CEE_UNUSED51,                 "!")
-VEROPCODE(CEE_SIZEOF,                   "!")
-VEROPCODE(CEE_REFANYTYPE,               "!")
-VEROPCODE(CEE_READONLY,                 ":")
-VEROPCODE(CEE_UNUSED53,                "!")
-VEROPCODE(CEE_UNUSED54,                 "!")
-VEROPCODE(CEE_UNUSED55,                 "!")
-VEROPCODE(CEE_UNUSED70,                 "!")
-VEROPCODE(CEE_ILLEGAL,                  "!")
-VEROPCODE(CEE_MACRO_END,                "!")
-VEROPCODE(CEE_COUNT,                           "!")
-
index 5e964b4..3765135 100644 (file)
@@ -5,12 +5,6 @@
 
 #include "common.h"
 
-
-#ifndef FEATURE_MERGE_JIT_AND_ENGINE
-#include "metahost.h"
-#endif
-
-
 #include "coregen.h"
 
 #include "clr/fs/dir.h"
@@ -444,15 +438,6 @@ Zapper::Zapper(ZapperOptions *pOptions)
     Init(pOptions);
 }
 
-#ifndef FEATURE_MERGE_JIT_AND_ENGINE
-
-//
-// Pointer to the activated CLR interface provided by the shim.
-//
-extern ICLRRuntimeInfo *g_pCLRRuntime;
-
-#endif // FEATURE_MERGE_JIT_AND_ENGINE
-
 void Zapper::Init(ZapperOptions *pOptions, bool fFreeZapperOptions)
 {
     m_pEEJitInfo = NULL;