}
else if (IsFile())
{
- PEImageLayoutHolder pLayout(PEImageLayout::Map(GetFileHandle(),this));
+ PEImageLayoutHolder pLayout(PEImageLayout::Map(this));
bool fMarkAnyCpuImageAsLoaded = false;
// Avoid mapping another image if we can. We can only do this for IL-ONLY images
_ASSERTE(m_pLayouts[IMAGE_FLAT] == NULL);
- PTR_PEImageLayout pFlatLayout = PEImageLayout::LoadFlat(GetFileHandle(),this);
+ PTR_PEImageLayout pFlatLayout = PEImageLayout::LoadFlat(this);
if (!bPermitWriteableSections
&& pFlatLayout->CheckNTHeaders()
else
{
_ASSERTE(!m_path.IsEmpty());
- SetLayout(IMAGE_LOADED,PEImageLayout::LoadFlat(GetFileHandle(),this));
+ SetLayout(IMAGE_LOADED,PEImageLayout::LoadFlat(this));
}
}
STANDARD_VM_CONTRACT;
#if defined(CROSSGEN_COMPILE) || defined(FEATURE_PAL)
- return PEImageLayout::Map(pOwner->GetFileHandle(), pOwner);
+ return PEImageLayout::Map(pOwner);
#else
PEImageLayoutHolder pAlloc(new LoadedImageLayout(pOwner,bNTSafeLoad,bThrowOnError));
if (pAlloc->GetBase()==NULL)
#endif
}
-PEImageLayout* PEImageLayout::LoadFlat(HANDLE hFile,PEImage* pOwner)
+PEImageLayout* PEImageLayout::LoadFlat(PEImage* pOwner)
{
STANDARD_VM_CONTRACT;
- return new FlatImageLayout(hFile,pOwner);
+ return new FlatImageLayout(pOwner);
}
-PEImageLayout* PEImageLayout::Map(HANDLE hFile, PEImage* pOwner)
+PEImageLayout* PEImageLayout::Map(PEImage* pOwner)
{
CONTRACT(PEImageLayout*)
{
}
CONTRACT_END;
- PEImageLayoutHolder pAlloc(new MappedImageLayout(hFile,pOwner));
+ PEImageLayoutHolder pAlloc(new MappedImageLayout(pOwner));
if (pAlloc->GetBase()==NULL)
{
//cross-platform or a bad image
- PEImageLayoutHolder pFlat(new FlatImageLayout(hFile, pOwner));
+ PEImageLayoutHolder pFlat(new FlatImageLayout(pOwner));
if (!pFlat->CheckFormat())
ThrowHR(COR_E_BADIMAGEFORMAT);
#endif
}
-MappedImageLayout::MappedImageLayout(HANDLE hFile, PEImage* pOwner)
+MappedImageLayout::MappedImageLayout(PEImage* pOwner)
{
CONTRACTL
{
m_Layout=LAYOUT_MAPPED;
m_pOwner=pOwner;
+ HANDLE hFile = pOwner->GetFileHandle();
+
// If mapping was requested, try to do SEC_IMAGE mapping
LOG((LF_LOADER, LL_INFO100, "PEImage: Opening OS mapped %S (hFile %p)\n", (LPCWSTR) GetPath(), hFile));
}
#endif // !CROSSGEN_COMPILE && !FEATURE_PAL
-FlatImageLayout::FlatImageLayout(HANDLE hFile, PEImage* pOwner)
+FlatImageLayout::FlatImageLayout(PEImage* pOwner)
{
CONTRACTL
{
CONTRACTL_END;
m_Layout=LAYOUT_FLAT;
m_pOwner=pOwner;
+
+ HANDLE hFile = pOwner->GetFileHandle();
+
LOG((LF_LOADER, LL_INFO100, "PEImage: Opening flat %S\n", (LPCWSTR) GetPath()));
COUNT_T size = SafeGetFileSize(hFile, NULL);
public:
#ifndef DACCESS_COMPILE
static PEImageLayout* CreateFlat(const void *flat, COUNT_T size,PEImage* pOwner);
- static PEImageLayout* CreateFromStream(IStream* pIStream, PEImage* pOwner);
static PEImageLayout* CreateFromHMODULE(HMODULE mappedbase,PEImage* pOwner, BOOL bTakeOwnership);
static PEImageLayout* LoadFromFlat(PEImageLayout* pflatimage);
static PEImageLayout* Load(PEImage* pOwner, BOOL bNTSafeLoad, BOOL bThrowOnError = TRUE);
- static PEImageLayout* LoadFlat(HANDLE hFile, PEImage* pOwner);
- static PEImageLayout* Map (HANDLE hFile, PEImage* pOwner);
+ static PEImageLayout* LoadFlat(PEImage* pOwner);
+ static PEImageLayout* Map(PEImage* pOwner);
#endif
PEImageLayout();
virtual ~PEImageLayout();
#endif
public:
#ifndef DACCESS_COMPILE
- MappedImageLayout(HANDLE hFile, PEImage* pOwner);
+ MappedImageLayout(PEImage* pOwner);
#endif
};
CLRMapViewHolder m_FileView;
public:
#ifndef DACCESS_COMPILE
- FlatImageLayout(HANDLE hFile, PEImage* pOwner);
+ FlatImageLayout(PEImage* pOwner);
#endif
};