Skip to content

Commit c248c07

Browse files
committed
Update IsInBundle checks
1 parent a88d820 commit c248c07

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

src/coreclr/vm/peassembly.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ PEAssembly *PEAssembly::Create(IMetaDataAssemblyEmit *pAssemblyEmit)
850850
#ifndef DACCESS_COMPILE
851851

852852
// Supports implementation of the legacy Assembly.CodeBase property.
853-
// Returns false if the assembly was loaded from a bundle, true otherwise
853+
// Returns false if the assembly was loaded via reflection emit or from a probe extension, true otherwise
854854
BOOL PEAssembly::GetCodeBase(SString &result)
855855
{
856856
CONTRACTL
@@ -864,7 +864,7 @@ BOOL PEAssembly::GetCodeBase(SString &result)
864864
CONTRACTL_END;
865865

866866
PEImage* ilImage = GetPEImage();
867-
if (ilImage != NULL && !ilImage->IsInBundle())
867+
if (ilImage != NULL && !ilImage->IsInBundle() && !ilImage->IsExternalData())
868868
{
869869
// All other cases use the file path.
870870
result.Set(ilImage->GetPath());

src/coreclr/vm/peassembly.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ inline const SString& PEAssembly::GetPath()
150150
}
151151
CONTRACTL_END;
152152

153-
if (IsReflectionEmit() || m_PEImage->IsInBundle ())
153+
if (IsReflectionEmit() || m_PEImage->IsInBundle() || m_PEImage->IsExternalData())
154154
{
155155
return SString::Empty();
156156
}

src/coreclr/vm/peimage.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,10 @@ BOOL PEImage::CompareImage(UPTR u1, UPTR u2)
240240
PEImage *pImage = (PEImage *) u2;
241241

242242
if (pLocator->m_bIsInBundle != pImage->IsInBundle())
243-
{
244243
return FALSE;
245-
}
244+
245+
if (pLocator->m_bIsExternalData != pImage->IsExternalData())
246+
return FALSE;
246247

247248
BOOL ret = FALSE;
248249
HRESULT hr;

src/coreclr/vm/peimage.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class PEImage final
121121
MDInternalImportFlags flags = MDInternalImport_Default,
122122
ProbeExtensionResult probeExtensionResult = ProbeExtensionResult::Invalid());
123123

124-
static PTR_PEImage FindByPath(LPCWSTR pPath, BOOL isInBundle);
124+
static PTR_PEImage FindByPath(LPCWSTR pPath, BOOL isInBundle, BOOL isExternalData);
125125
void AddToHashMap();
126126
#endif
127127

@@ -138,6 +138,7 @@ class PEImage final
138138

139139
BOOL IsFile();
140140
BOOL IsInBundle() const;
141+
BOOL IsExternalData() const;
141142
void* GetExternalData(INT64* size);
142143
INT64 GetOffset() const;
143144
INT64 GetSize() const;
@@ -211,20 +212,22 @@ class PEImage final
211212

212213
struct PEImageLocator
213214
{
214-
215215
LPCWSTR m_pPath;
216216
BOOL m_bIsInBundle;
217+
BOOL m_bIsExternalData;
217218

218-
PEImageLocator(LPCWSTR pPath, BOOL bIsInBundle)
219-
: m_pPath(pPath),
220-
m_bIsInBundle(bIsInBundle)
219+
PEImageLocator(LPCWSTR pPath, BOOL bIsInBundle, BOOL bIsExternalData)
220+
: m_pPath(pPath)
221+
, m_bIsInBundle(bIsInBundle)
222+
, m_bIsExternalData(bIsExternalData)
221223
{
222224
}
223225

224226
PEImageLocator(PEImage * pImage)
225227
: m_pPath(pImage->m_path.GetUnicode())
228+
, m_bIsInBundle(pImage->IsInBundle())
229+
, m_bIsExternalData(pImage->IsExternalData())
226230
{
227-
m_bIsInBundle = pImage->IsInBundle();
228231
}
229232
};
230233

src/coreclr/vm/peimage.inl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ inline BOOL PEImage::IsInBundle() const
6868
return m_probeExtensionResult.Type == ProbeExtensionResult::Type::Bundle;
6969
}
7070

71+
inline BOOL PEImage::IsExternalData() const
72+
{
73+
LIMITED_METHOD_CONTRACT;
74+
75+
return m_probeExtensionResult.Type == ProbeExtensionResult::Type::External;
76+
}
77+
7178
inline INT64 PEImage::GetSize() const
7279
{
7380
LIMITED_METHOD_CONTRACT;
@@ -304,7 +311,7 @@ inline void PEImage::Init(ProbeExtensionResult probeExtensionResult)
304311

305312

306313
/*static*/
307-
inline PTR_PEImage PEImage::FindByPath(LPCWSTR pPath, BOOL isInBundle)
314+
inline PTR_PEImage PEImage::FindByPath(LPCWSTR pPath, BOOL isInBundle, BOOL isExternalData)
308315
{
309316
CONTRACTL
310317
{
@@ -318,7 +325,7 @@ inline PTR_PEImage PEImage::FindByPath(LPCWSTR pPath, BOOL isInBundle)
318325

319326
int CaseHashHelper(const WCHAR *buffer, COUNT_T count);
320327

321-
PEImageLocator locator(pPath, isInBundle);
328+
PEImageLocator locator(pPath, isInBundle, isExternalData);
322329
DWORD dwHash = CaseHashHelper(pPath, (COUNT_T) u16_strlen(pPath));
323330
return (PEImage *) s_Images->LookupValue(dwHash, &locator);
324331
}
@@ -336,7 +343,7 @@ inline PTR_PEImage PEImage::OpenImage(LPCWSTR pPath, MDInternalImportFlags flags
336343

337344
CrstHolder holder(&s_hashLock);
338345

339-
PEImage* found = FindByPath(pPath, probeExtensionResult.IsValid());
346+
PEImage* found = FindByPath(pPath, probeExtensionResult.Type == ProbeExtensionResult::Type::Bundle, probeExtensionResult.Type == ProbeExtensionResult::Type::External);
340347
if (found == (PEImage*) INVALIDENTRY)
341348
{
342349
// We did not find the entry in the Cache, and we've been asked to only use the cache.

0 commit comments

Comments
 (0)