Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Rename BundleLoc to BundleFileLocation
Browse files Browse the repository at this point in the history
Also fix an error during initialization of Bundle() structure.
  • Loading branch information
swaroop-sridhar committed Sep 11, 2019
1 parent b7601e5 commit d2a0846
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 73 deletions.
18 changes: 9 additions & 9 deletions src/binder/assemblybinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1407,21 +1407,21 @@ namespace BINDER_SPACE
}

/* static */
HRESULT AssemblyBinder::GetAssembly(SString &assemblyPath,
BOOL fIsInGAC,
HRESULT AssemblyBinder::GetAssembly(SString &assemblyPath,
BOOL fIsInGAC,

// When binding to the native image, should we
// assume assemblyPath explicitly specifies that
// NI? (If not, infer the path to the NI
// implicitly.)
BOOL fExplicitBindToNativeImage,
BOOL fExplicitBindToNativeImage,

Assembly **ppAssembly,
Assembly **ppAssembly,

// If assemblyPath refers to a native image without metadata,
// szMDAssemblyPath gives the alternative file to get metadata.
LPCTSTR szMDAssemblyPath,
BundleLoc bundleLoc)
LPCTSTR szMDAssemblyPath,
BundleFileLocation bundleFileLocation)
{
HRESULT hr = S_OK;

Expand All @@ -1445,7 +1445,7 @@ namespace BINDER_SPACE
LPCTSTR szAssemblyPath = const_cast<LPCTSTR>(assemblyPath.GetUnicode());

BINDER_LOG_ENTER(W("BinderAcquirePEImage"));
hr = BinderAcquirePEImage(szAssemblyPath, &pPEImage, &pNativePEImage, fExplicitBindToNativeImage, bundleLoc);
hr = BinderAcquirePEImage(szAssemblyPath, &pPEImage, &pNativePEImage, fExplicitBindToNativeImage, bundleFileLocation);
BINDER_LOG_LEAVE_HR(W("BinderAcquirePEImage"), hr);
IF_FAIL_GO(hr);

Expand All @@ -1462,7 +1462,7 @@ namespace BINDER_SPACE
BinderReleasePEImage(pNativePEImage);

BINDER_LOG_ENTER(W("BinderAcquirePEImageIL"));
hr = BinderAcquirePEImage(szAssemblyPath, &pPEImage, &pNativePEImage, false, bundleLoc);
hr = BinderAcquirePEImage(szAssemblyPath, &pPEImage, &pNativePEImage, false, bundleFileLocation);
BINDER_LOG_LEAVE_HR(W("BinderAcquirePEImageIL"), hr);
IF_FAIL_GO(hr);
}
Expand Down Expand Up @@ -1492,7 +1492,7 @@ namespace BINDER_SPACE
else
{
BINDER_LOG_ENTER(W("BinderAcquirePEImage"));
hr = BinderAcquirePEImage(szMDAssemblyPath, &pPEImage, NULL, FALSE, bundleLoc);
hr = BinderAcquirePEImage(szMDAssemblyPath, &pPEImage, NULL, FALSE, bundleFileLocation);
BINDER_LOG_LEAVE_HR(W("BinderAcquirePEImage"), hr);
IF_FAIL_GO(hr);

Expand Down
10 changes: 5 additions & 5 deletions src/binder/inc/assembly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#endif // !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
#include "bundle.h"

STDAPI BinderAcquirePEImage(LPCTSTR szAssemblyPath,
PEImage **ppPEImage,
PEImage **ppNativeImage,
BOOL fExplicitBindToNativeImage,
BundleLoc bundleLoc);
STDAPI BinderAcquirePEImage(LPCTSTR szAssemblyPath,
PEImage **ppPEImage,
PEImage **ppNativeImage,
BOOL fExplicitBindToNativeImage,
BundleFileLocation bundleFileLocation);

STDAPI BinderAcquireImport(PEImage *pPEImage,
IMDInternalImport **pIMetaDataAssemblyImport,
Expand Down
12 changes: 6 additions & 6 deletions src/binder/inc/assemblybinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ namespace BINDER_SPACE
/* in */ PEImage *pNativePEImage,
/* out */ Assembly **ppAssembly);

static HRESULT GetAssembly(/* in */ SString &assemblyPath,
/* in */ BOOL fIsInGAC,
/* in */ BOOL fExplicitBindToNativeImage,
/* out */ Assembly **ppAssembly,
/* in */ LPCTSTR szMDAssemblyPath = NULL,
/* in */ BundleLoc bundleLoc = BundleLoc::Invalid());
static HRESULT GetAssembly(/* in */ SString &assemblyPath,
/* in */ BOOL fIsInGAC,
/* in */ BOOL fExplicitBindToNativeImage,
/* out */ Assembly **ppAssembly,
/* in */ LPCTSTR szMDAssemblyPath = NULL,
/* in */ BundleFileLocation bundleFileLocation = BundleFileLocation::Invalid());

#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
static HRESULT BindUsingHostAssemblyResolver (/* in */ INT_PTR pManagedAssemblyLoadContextToBindWithin,
Expand Down
45 changes: 24 additions & 21 deletions src/dlls/mscoree/unixinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ static void ConvertConfigPropertiesToUnicode(
const char** propertyValues,
int propertyCount,
LPCWSTR** propertyKeysWRef,
LPCWSTR** propertyValuesWRef)
LPCWSTR** propertyValuesWRef,
BundleProbe** bundleProbe)
{
LPCWSTR* propertyKeysW = new (nothrow) LPCWSTR[propertyCount];
ASSERTE_ALL_BUILDS(propertyKeysW != nullptr);
Expand All @@ -129,8 +130,20 @@ static void ConvertConfigPropertiesToUnicode(

for (int propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex)
{
if (strcmp(propertyKeys[propertyIndex], "BUNDLE_PROBE") == 0)
{
// If this application is a single-file bundle, the bundle-probe callback
// is passed in as the value of "BUNDLE_PROBE" property (masquarading as char *).
// Therefore obtain the value; don't convert it to Unicode.

*bundleProbe = (BundleProbe *)propertyValues[propertyIndex];
propertyKeysW[propertyIndex] = W("BUNDLE_PROBE");
propertyValuesW[propertyIndex] = W("");
continue;
}

propertyKeysW[propertyIndex] = StringToUnicode(propertyKeys[propertyIndex]);
propertyValuesW[propertyIndex] = propertyValues[propertyIndex] != nullptr ? StringToUnicode(propertyValues[propertyIndex]) : nullptr;
propertyValuesW[propertyIndex] = StringToUnicode(propertyValues[propertyIndex]);
}

*propertyKeysWRef = propertyKeysW;
Expand Down Expand Up @@ -192,34 +205,24 @@ int coreclr_initialize(
hr = CorHost2::CreateObject(IID_ICLRRuntimeHost4, (void**)&host);
IfFailRet(hr);

// If this application is a single-file bundle, the bundle-probe callback
// is passed in as the value of "BUNDLE_PROBE" property (masquarading as char *).
// Therefore obtain the value before converting property keys/values to unicode.
for (int i = 0; i < propertyCount; i++)
{
if (strcmp(propertyKeys[i], "BUNDLE_PROBE") == 0)
{
BundleProbe* bundleProbe = (BundleProbe*)propertyValues[i];

if (bundleProbe != nullptr)
{
static Bundle bundle(StringToUnicode(exePath), bundleProbe);
Bundle::AppBundle = &bundle;
}
break;
}
}

ConstWStringHolder appDomainFriendlyNameW = StringToUnicode(appDomainFriendlyName);

LPCWSTR* propertyKeysW;
LPCWSTR* propertyValuesW;
BundleProbe* bundleProbe = nullptr;
ConvertConfigPropertiesToUnicode(
propertyKeys,
propertyValues,
propertyCount,
&propertyKeysW,
&propertyValuesW);
&propertyValuesW,
&bundleProbe);

if (bundleProbe != nullptr)
{
static Bundle bundle(StringToUnicode(exePath), bundleProbe);
Bundle::AppBundle = &bundle;
}

// This will take ownership of propertyKeysWTemp and propertyValuesWTemp
Configuration::InitializeConfigurationKnobs(propertyCount, propertyKeysW, propertyValuesW);
Expand Down
10 changes: 5 additions & 5 deletions src/inc/bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@

class Bundle;

struct BundleLoc
struct BundleFileLocation
{
INT64 Size;
INT64 Offset;

BundleLoc()
BundleFileLocation()
{
LIMITED_METHOD_CONTRACT;

Size = 0;
Offset = 0;
}

static BundleLoc Invalid() { LIMITED_METHOD_CONTRACT; return BundleLoc(); }
static BundleFileLocation Invalid() { LIMITED_METHOD_CONTRACT; return BundleFileLocation(); }

LPCWSTR Path() const;

Expand All @@ -41,14 +41,14 @@ class Bundle
{
public:
Bundle(LPCWSTR bundlePath, BundleProbe *probe);
BundleLoc Probe(LPCWSTR path, bool pathIsBundleRelative = false) const;
BundleFileLocation Probe(LPCWSTR path, bool pathIsBundleRelative = false) const;

LPCWSTR Path() const { LIMITED_METHOD_CONTRACT; return m_path; }
LPCWSTR BasePath() const { LIMITED_METHOD_CONTRACT; return m_basePath; }

static Bundle* AppBundle; // The BundleInfo for the current app, initialized by coreclr_initialize.
static bool AppIsBundle() { LIMITED_METHOD_CONTRACT; return AppBundle != nullptr; }
static BundleLoc ProbeAppBundle(LPCWSTR path, bool pathIsBundleRelative = false);
static BundleFileLocation ProbeAppBundle(LPCWSTR path, bool pathIsBundleRelative = false);

private:

Expand Down
14 changes: 7 additions & 7 deletions src/vm/bundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ static LPCSTR UnicodeToUtf8(LPCWSTR str)
return result;
}

LPCWSTR BundleLoc::Path() const
LPCWSTR BundleFileLocation::Path() const
{
LIMITED_METHOD_CONTRACT;

// Currently, there is only one bundle -- the bundle for the main App.
// Therefore, obtain the path from the global AppBundle.
// If there is more than one bundle in one application (ex: single file plugins)
// the BundlePath may be stored in the BundleLoc structure.
// the BundlePath may be stored in the BundleFileLocation structure.

_ASSERTE(IsValid());
_ASSERTE(Bundle::AppBundle != nullptr);
Expand Down Expand Up @@ -74,14 +74,14 @@ Bundle::Bundle(LPCWSTR bundlePath, BundleProbe *probe)
_ASSERTE(pos != nullptr);

size_t baseLen = pos - bundlePath + 1; // Include DIRECTORY_SEPARATOR_CHAR_W in m_basePath
m_basePath.Set(bundlePath, baseLen);
m_basePath.Set(bundlePath, (COUNT_T)baseLen);
}

BundleLoc Bundle::Probe(LPCWSTR path, bool pathIsBundleRelative) const
BundleFileLocation Bundle::Probe(LPCWSTR path, bool pathIsBundleRelative) const
{
STANDARD_VM_CONTRACT;

BundleLoc loc;
BundleFileLocation loc;

// Skip over m_base_path, if any.
// TODO: Normalize paths
Expand All @@ -106,10 +106,10 @@ BundleLoc Bundle::Probe(LPCWSTR path, bool pathIsBundleRelative) const
return loc;
}

BundleLoc Bundle::ProbeAppBundle(LPCWSTR path, bool pathIsBundleRelative)
BundleFileLocation Bundle::ProbeAppBundle(LPCWSTR path, bool pathIsBundleRelative)
{
STANDARD_VM_CONTRACT;

return AppIsBundle() ? AppBundle->Probe(path, pathIsBundleRelative) : BundleLoc::Invalid();
return AppIsBundle() ? AppBundle->Probe(path, pathIsBundleRelative) : BundleFileLocation::Invalid();
}

14 changes: 7 additions & 7 deletions src/vm/coreassemblyspec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ VOID AssemblySpec::Bind(AppDomain *pAppDomain,
}


STDAPI BinderAcquirePEImage(LPCWSTR wszAssemblyPath,
PEImage **ppPEImage,
PEImage **ppNativeImage,
BOOL fExplicitBindToNativeImage,
BundleLoc bundleLoc)
STDAPI BinderAcquirePEImage(LPCWSTR wszAssemblyPath,
PEImage **ppPEImage,
PEImage **ppNativeImage,
BOOL fExplicitBindToNativeImage,
BundleFileLocation bundleFileLocation)
{
HRESULT hr = S_OK;

Expand All @@ -218,7 +218,7 @@ STDAPI BinderAcquirePEImage(LPCWSTR wszAssemblyPath,
// fExplicitBindToNativeImage is set on Phone when we bind to a list of native images and have no IL on device for an assembly
if (fExplicitBindToNativeImage)
{
pNativeImage = PEImage::OpenImage(wszAssemblyPath, MDInternalImport_TrustedNativeImage, bundleLoc);
pNativeImage = PEImage::OpenImage(wszAssemblyPath, MDInternalImport_TrustedNativeImage, bundleFileLocation);

// Make sure that the IL image can be opened if the native image is not available.
hr=pNativeImage->TryOpenFile();
Expand All @@ -230,7 +230,7 @@ STDAPI BinderAcquirePEImage(LPCWSTR wszAssemblyPath,
else
#endif
{
pImage = PEImage::OpenImage(wszAssemblyPath, MDInternalImport_Default, bundleLoc);
pImage = PEImage::OpenImage(wszAssemblyPath, MDInternalImport_Default, bundleFileLocation);

// Make sure that the IL image can be opened if the native image is not available.
hr=pImage->TryOpenFile();
Expand Down
10 changes: 5 additions & 5 deletions src/vm/peimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class PEImage
static PTR_PEImage OpenImage(
LPCWSTR pPath,
MDInternalImportFlags flags = MDInternalImport_Default,
BundleLoc bundleLoc = BundleLoc::Invalid());
BundleFileLocation bundleFileLocation = BundleFileLocation::Invalid());

// clones the image with new flags (this is pretty much about cached / noncached difference)
void Clone(MDInternalImportFlags flags, PTR_PEImage* ppImage)
Expand Down Expand Up @@ -242,7 +242,7 @@ class PEImage
// Private routines
// ------------------------------------------------------------

void Init(LPCWSTR pPath, BundleLoc bundleLoc);
void Init(LPCWSTR pPath, BundleFileLocation bundleFileLocation);
void Init(IStream* pStream, UINT64 uStreamAsmId,
DWORD dwModuleId, BOOL resourceFile);

Expand Down Expand Up @@ -278,9 +278,9 @@ class PEImage
SString m_path;
LONG m_refCount;

BundleLoc m_bundleLoc; // If this image is located within a single-file bundle,
// the location within the bundle. If m_bundleLoc is vaild,
// it takes precedence over m_path for loading.
BundleFileLocation m_bundleFileLocation; // If this image is located within a single-file bundle,
// the location within the bundle. If m_bundleFileLocation is vaild,
// it takes precedence over m_path for loading.

// This variable will have the data of module name.
// It is only used by DAC to remap fusion loaded modules back to
Expand Down
16 changes: 8 additions & 8 deletions src/vm/peimage.inl
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ inline const SString PEImage::GetPathToLoad()
{
LIMITED_METHOD_DAC_CONTRACT;

return m_bundleLoc.IsValid() ? (SString)m_bundleLoc.Path() : m_path;
return m_bundleFileLocation.IsValid() ? (SString)m_bundleFileLocation.Path() : m_path;
}

inline INT64 PEImage::GetOffset() const
{
LIMITED_METHOD_CONTRACT;

return m_bundleLoc.Offset;
return m_bundleFileLocation.Offset;
}

inline INT64 PEImage::GetSize() const
{
LIMITED_METHOD_CONTRACT;
return m_bundleLoc.Size;
return m_bundleFileLocation.Size;
}

inline void PEImage::SetModuleFileNameHintForDAC()
Expand Down Expand Up @@ -439,7 +439,7 @@ inline CHECK PEImage::CheckFormat()
CHECK_OK;
}

inline void PEImage::Init(LPCWSTR pPath, BundleLoc bundleLoc)
inline void PEImage::Init(LPCWSTR pPath, BundleFileLocation bundleFileLocation)
{
CONTRACTL
{
Expand All @@ -451,7 +451,7 @@ inline void PEImage::Init(LPCWSTR pPath, BundleLoc bundleLoc)

m_path = pPath;
m_path.Normalize();
m_bundleLoc = bundleLoc;
m_bundleFileLocation = bundleFileLocation;
SetModuleFileNameHintForDAC();
}
#ifndef DACCESS_COMPILE
Expand Down Expand Up @@ -483,14 +483,14 @@ inline PTR_PEImage PEImage::FindByPath(LPCWSTR pPath)
}

/* static */
inline PTR_PEImage PEImage::OpenImage(LPCWSTR pPath, MDInternalImportFlags flags /* = MDInternalImport_Default */, BundleLoc bundleLoc)
inline PTR_PEImage PEImage::OpenImage(LPCWSTR pPath, MDInternalImportFlags flags /* = MDInternalImport_Default */, BundleFileLocation bundleFileLocation)
{
BOOL fUseCache = !((flags & MDInternalImport_NoCache) == MDInternalImport_NoCache);

if (!fUseCache)
{
PEImageHolder pImage(new PEImage);
pImage->Init(pPath, bundleLoc);
pImage->Init(pPath, bundleFileLocation);
return dac_cast<PTR_PEImage>(pImage.Extract());
}

Expand All @@ -511,7 +511,7 @@ inline PTR_PEImage PEImage::OpenImage(LPCWSTR pPath, MDInternalImportFlags flags
if (flags & MDInternalImport_TrustedNativeImage)
pImage->SetIsTrustedNativeImage();
#endif
pImage->Init(pPath, bundleLoc);
pImage->Init(pPath, bundleFileLocation);

pImage->AddToHashMap();
return dac_cast<PTR_PEImage>(pImage.Extract());
Expand Down

0 comments on commit d2a0846

Please sign in to comment.