Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/coreclr/binder/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include "clr/fs/path.h"
using namespace clr::fs;

// Forward declaration - see src/vm/util.cpp
BOOL RuntimeFileNotFound(HRESULT hr);
Comment thread
jkotas marked this conversation as resolved.

namespace BINDER_SPACE
{
namespace
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "peimagelayout.inl"
#include "datatargetadapter.h"
#include "readonlydatatargetfacade.h"
#include "metadataexports.h"
#include "excep.h"
#include "debugger.h"
#include "dwreport.h"
Expand Down
14 changes: 0 additions & 14 deletions src/coreclr/debug/daccess/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@

#include "stdafx.h"

// XXX Microsoft - Why aren't these extra MD APIs in a header?
STDAPI GetMDPublicInterfaceFromInternal(
void *pIUnkPublic, // [IN] Given scope.
REFIID riid, // [in] The interface desired.
void **ppIUnkInternal); // [out] Return interface on success.

STDAPI GetMetaDataPublicInterfaceFromInternal(
void *pv, // [IN] Given interface.
REFIID riid, // [IN] desired interface.
void **ppv) // [OUT] returned interface
{
return GetMDPublicInterfaceFromInternal(pv, riid, ppv);
}

//----------------------------------------------------------------------------
//
// ClrDataTask.
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/debug/di/cordb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "classfactory.h"
#include "corsym.h"
#include "contract.h"
#include "metadataexports.h"
#if defined(FEATURE_DBGIPC_TRANSPORT_DI)
#include "dbgtransportsession.h"
#include "dbgtransportmanager.h"
Expand Down
28 changes: 1 addition & 27 deletions src/coreclr/debug/di/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,13 @@
#include "stdafx.h"
#include "winbase.h"

#include "metadataexports.h"

#include "winbase.h"
#include "corpriv.h"
#include "corsym.h"

#include "pedecoder.h"
#include "stgpool.h"

//---------------------------------------------------------------------------------------
// Update an existing metadata importer with a buffer
//
// Arguments:
// pUnk - IUnknoown of importer to update.
// pData - local buffer containing new metadata
// cbData - size of buffer in bytes.
// dwReOpenFlags - metadata flags to pass for reopening.
//
// Returns:
// S_OK on success. Else failure.
//
// Notes:
// This will call code:MDReOpenMetaDataWithMemoryEx from the metadata engine.
STDAPI ReOpenMetaDataWithMemoryEx(
void *pUnk,
LPCVOID pData,
ULONG cbData,
DWORD dwReOpenFlags)
{
HRESULT hr = MDReOpenMetaDataWithMemoryEx(pUnk,pData, cbData, dwReOpenFlags);
return hr;
}

//---------------------------------------------------------------------------------------
// Initialize a new CordbModule around a Module in the target.
//
Expand Down Expand Up @@ -1063,7 +1037,7 @@ void CordbModule::UpdatePublicMetaDataFromRemote(TargetBuffer bufferRemoteMetaDa
// Now tell our current IMetaDataImport object to re-initialize by swapping in the new memory block.
// This allows us to keep manipulating metadata objects on other threads without crashing.
// This will also invalidate an existing associated Internal MetaData.
hr = ReOpenMetaDataWithMemoryEx(m_pIMImport, pLocalMetaDataPtr, dwMetaDataSize, ofTakeOwnership );
hr = MDReOpenMetaDataWithMemory(m_pIMImport, pLocalMetaDataPtr, dwMetaDataSize, ofTakeOwnership );
IfFailThrow(hr);

// Success. MetaData now owns the metadata memory
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/debug/di/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
// @dbgtodo shim: process has some private hooks into the shim.
#include "shimpriv.h"

#include "metadataexports.h"
#include "readonlydatatargetfacade.h"
#include "metahost.h"

Expand Down
220 changes: 2 additions & 218 deletions src/coreclr/dlls/mscoree/mscoree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@
#include "stdafx.h" // Standard header.

#include <utilcode.h> // Utility helpers.
#include <posterror.h> // Error handlers
#define INIT_GUIDS
#include <corpriv.h>
#include <winwrap.h>
#include <mscoree.h>
#include "shimload.h"
#include "metadataexports.h"
#include "ex.h"

#include <dbgenginemetrics.h>

#if !defined(CORECLR_EMBEDDED)

Expand Down Expand Up @@ -45,18 +36,16 @@ BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)

#endif // !defined(CORECLR_EMBEDDED)

extern void* GetClrModuleBase();

// ---------------------------------------------------------------------------
// %%Function: MetaDataGetDispenser
// This function gets the Dispenser interface given the CLSID and REFIID.
// Exported from coreclr and used by external profilers.
// ---------------------------------------------------------------------------
STDAPI DLLEXPORT MetaDataGetDispenser( // Return HRESULT
STDAPI DLLEXPORT MetaDataGetDispenser( // Return HRESULT
REFCLSID rclsid, // The class to desired.
REFIID riid, // Interface wanted on class factory.
LPVOID FAR *ppv) // Return interface pointer here.
{

CONTRACTL {
NOTHROW;
GC_NOTRIGGER;
Expand All @@ -69,208 +58,3 @@ STDAPI DLLEXPORT MetaDataGetDispenser( // Return HRESULT

return CreateMetaDataDispenser(riid, ppv);
}

// ---------------------------------------------------------------------------
// %%Function: GetMetaDataInternalInterface
// This function gets the IMDInternalImport given the metadata on memory.
// ---------------------------------------------------------------------------
STDAPI DLLEXPORT GetMetaDataInternalInterface(
LPVOID pData, // [IN] in memory metadata section
ULONG cbData, // [IN] size of the metadata section
DWORD flags, // [IN] MDInternal_OpenForRead or MDInternal_OpenForENC
REFIID riid, // [IN] desired interface
void **ppv) // [OUT] returned interface
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
ENTRY_POINT;
PRECONDITION(CheckPointer(pData));
PRECONDITION(CheckPointer(ppv));
} CONTRACTL_END;

return GetMDInternalInterface(pData, cbData, flags, riid, ppv);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact same thing was exposed under two different names. None of this is exported in CoreCLR, so it is fine to delete the extra layer.

}

// ---------------------------------------------------------------------------
// %%Function: GetMetaDataInternalInterfaceFromPublic
// This function gets the internal scopeless interface given the public
// scopeless interface.
// ---------------------------------------------------------------------------
STDAPI DLLEXPORT GetMetaDataInternalInterfaceFromPublic(
IUnknown *pv, // [IN] Given interface.
REFIID riid, // [IN] desired interface
void **ppv) // [OUT] returned interface
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
ENTRY_POINT;
PRECONDITION(CheckPointer(pv));
PRECONDITION(CheckPointer(ppv));
} CONTRACTL_END;

return GetMDInternalInterfaceFromPublic(pv, riid, ppv);
}

// ---------------------------------------------------------------------------
// %%Function: GetMetaDataPublicInterfaceFromInternal
// This function gets the public scopeless interface given the internal
// scopeless interface.
// ---------------------------------------------------------------------------
STDAPI DLLEXPORT GetMetaDataPublicInterfaceFromInternal(
void *pv, // [IN] Given interface.
REFIID riid, // [IN] desired interface.
void **ppv) // [OUT] returned interface
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
PRECONDITION(CheckPointer(pv));
PRECONDITION(CheckPointer(ppv));
ENTRY_POINT;
} CONTRACTL_END;

return GetMDPublicInterfaceFromInternal(pv, riid, ppv);
}


// ---------------------------------------------------------------------------
// %%Function: ReopenMetaDataWithMemory
// This function gets the public scopeless interface given the internal
// scopeless interface.
// ---------------------------------------------------------------------------
STDAPI ReOpenMetaDataWithMemory(
void *pUnk, // [IN] Given scope. public interfaces
LPCVOID pData, // [in] Location of scope data.
ULONG cbData) // [in] Size of the data pointed to by pData.
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
ENTRY_POINT;
PRECONDITION(CheckPointer(pUnk));
PRECONDITION(CheckPointer(pData));
} CONTRACTL_END;

return MDReOpenMetaDataWithMemory(pUnk, pData, cbData);
}

// ---------------------------------------------------------------------------
// %%Function: ReopenMetaDataWithMemoryEx
// This function gets the public scopeless interface given the internal
// scopeless interface.
// ---------------------------------------------------------------------------
STDAPI ReOpenMetaDataWithMemoryEx(
void *pUnk, // [IN] Given scope. public interfaces
LPCVOID pData, // [in] Location of scope data.
ULONG cbData, // [in] Size of the data pointed to by pData.
DWORD dwReOpenFlags) // [in] ReOpen flags
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
ENTRY_POINT;
PRECONDITION(CheckPointer(pUnk));
PRECONDITION(CheckPointer(pData));
} CONTRACTL_END;

return MDReOpenMetaDataWithMemoryEx(pUnk, pData, cbData, dwReOpenFlags);
}

static DWORD g_dwSystemDirectory = 0;
static WCHAR * g_pSystemDirectory = NULL;

HRESULT GetInternalSystemDirectory(_Out_writes_to_opt_(*pdwLength,*pdwLength) LPWSTR buffer, __inout DWORD* pdwLength)
{
CONTRACTL {
NOTHROW;
GC_NOTRIGGER;
PRECONDITION(CheckPointer(buffer, NULL_OK));
PRECONDITION(CheckPointer(pdwLength));
} CONTRACTL_END;

if (g_dwSystemDirectory == 0)
SetInternalSystemDirectory();

//
// g_dwSystemDirectory includes the NULL in its count!
//
if(*pdwLength < g_dwSystemDirectory)
{
*pdwLength = g_dwSystemDirectory;
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
}

if (buffer != NULL)
{
//
// wcsncpy_s will automatically append a null and g_dwSystemDirectory
// includes the null in its count, so we have to subtract 1.
//
wcsncpy_s(buffer, *pdwLength, g_pSystemDirectory, g_dwSystemDirectory-1);
}
*pdwLength = g_dwSystemDirectory;
return S_OK;
}


LPCWSTR GetInternalSystemDirectory(_Out_ DWORD* pdwLength)
{
LIMITED_METHOD_CONTRACT;

if (g_dwSystemDirectory == 0)
{
SetInternalSystemDirectory();
}

if (pdwLength != NULL)
{
* pdwLength = g_dwSystemDirectory;
}

return g_pSystemDirectory;
}


HRESULT SetInternalSystemDirectory()
{
CONTRACTL {
NOTHROW;
GC_NOTRIGGER;
} CONTRACTL_END;

HRESULT hr = S_OK;
if(g_dwSystemDirectory == 0) {

DWORD len = 0;
NewArrayHolder<WCHAR> pSystemDirectory;
EX_TRY{

// use local buffer for thread safety
PathString wzSystemDirectory;
hr = GetClrModuleDirectory(wzSystemDirectory);

if (FAILED(hr)) {
wzSystemDirectory.Set(W('\0'));
}

pSystemDirectory = wzSystemDirectory.GetCopyOfUnicodeString();
if (pSystemDirectory == NULL)
{
hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
}
len = wzSystemDirectory.GetCount() + 1;

}
EX_CATCH_HRESULT(hr);

// publish results idempotently with correct memory ordering
g_pSystemDirectory = pSystemDirectory.Extract();

(void)InterlockedExchange((LONG *)&g_dwSystemDirectory, len);
}

return hr;
}

1 change: 0 additions & 1 deletion src/coreclr/ilasm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "asmparse.h"
#include "clrversion.h"
#include "shimload.h"

#include "strsafe.h"
#define ASSERTE_ALL_BUILDS(expr) _ASSERTE_ALL_BUILDS((expr))
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/ilasm/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include "ceefilegenwriter.h"
#include "sha256.h"

#include "metadataexports.h"

#ifndef _MSC_VER
//cloned definition from ntimage.h that is removed for non MSVC builds
typedef VOID
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/ildasm/dasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <metamodelpub.h>
#include "formattype.h"
#include "readytorun.h"
#include "metadataexports.h"

#define DECLARE_DATA
#include "dasmenum.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/ildasm/dman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include "dynamicarray.h"
#include "resource.h"

#include "metadataexports.h"

#ifndef MAX_LOCALE_NAME
#define MAX_LOCALE_NAME (32)
#endif
Expand Down
Loading