summaryrefslogtreecommitdiff
path: root/src/vm/peimagelayout.h
diff options
context:
space:
mode:
authordotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
committerdotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
commitef1e2ab328087c61a6878c1e84f4fc5d710aebce (patch)
treedee1bbb89e9d722e16b0d1485e3cdd1b6c8e2cfa /src/vm/peimagelayout.h
downloadcoreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.gz
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.bz2
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.zip
Initial commit to populate CoreCLR repo
[tfs-changeset: 1407945]
Diffstat (limited to 'src/vm/peimagelayout.h')
-rw-r--r--src/vm/peimagelayout.h200
1 files changed, 200 insertions, 0 deletions
diff --git a/src/vm/peimagelayout.h b/src/vm/peimagelayout.h
new file mode 100644
index 0000000000..51830f8f91
--- /dev/null
+++ b/src/vm/peimagelayout.h
@@ -0,0 +1,200 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+// --------------------------------------------------------------------------------
+// PEImageLayout.h
+//
+
+// --------------------------------------------------------------------------------
+
+
+#ifndef PEIMAGELAYOUT_H_
+#define PEIMAGELAYOUT_H_
+
+// --------------------------------------------------------------------------------
+// Required headers
+// --------------------------------------------------------------------------------
+
+#include "clrtypes.h"
+#include "pedecoder.h"
+#include "holder.h"
+
+// --------------------------------------------------------------------------------
+// Forward declarations
+// --------------------------------------------------------------------------------
+
+class Crst;
+class PEImage;
+
+
+typedef VPTR(class PEImageLayout) PTR_PEImageLayout;
+
+class PEImageLayout : public PEDecoder
+{
+ VPTR_BASE_CONCRETE_VTABLE_CLASS(PEImageLayout)
+ friend class PEModule;
+#ifdef FEATURE_INCLUDE_ALL_INTERFACES
+ friend class CCLRDebugManager;
+#endif // FEATURE_INCLUDE_ALL_INTERFACES
+public:
+ // ------------------------------------------------------------
+ // Public constants
+ // ------------------------------------------------------------
+ enum
+ {
+ LAYOUT_MAPPED =1,
+ LAYOUT_FLAT =2,
+ LAYOUT_LOADED =4,
+ LAYOUT_LOADED_FOR_INTROSPECTION =8,
+ LAYOUT_ANY =0xf
+ };
+
+
+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);
+#endif
+ PEImageLayout();
+ virtual ~PEImageLayout();
+ static void Startup();
+ static CHECK CheckStartup();
+ static BOOL CompareBase(UPTR path, UPTR mapping);
+
+ // Refcount above images.
+ void AddRef();
+ ULONG Release();
+ const SString& GetPath();
+#ifdef MDIL
+ BOOL GetILSizeFromMDILCLRCtlData(DWORD* pdwActualILSize);
+#endif // MDIL
+
+#ifdef FEATURE_PREJIT
+ void ApplyBaseRelocations();
+#endif
+
+public:
+#ifdef DACCESS_COMPILE
+ void EnumMemoryRegions(CLRDataEnumMemoryFlags flags);
+#endif
+
+#if defined(_WIN64) && !defined(DACCESS_COMPILE)
+ bool ConvertILOnlyPE32ToPE64();
+private:
+ bool ConvertILOnlyPE32ToPE64Worker();
+#endif // defined(_WIN64) && !defined(DACCESS_COMPILE)
+
+private:
+ Volatile<LONG> m_refCount;
+public:
+ PEImage* m_pOwner;
+ DWORD m_Layout;
+};
+
+typedef ReleaseHolder<PEImageLayout> PEImageLayoutHolder;
+
+
+//RawImageView is built on external data, does not need cleanup
+class RawImageLayout: public PEImageLayout
+{
+ VPTR_VTABLE_CLASS(RawImageLayout,PEImageLayout)
+protected:
+ CLRMapViewHolder m_DataCopy;
+#ifndef FEATURE_PAL
+ HModuleHolder m_LibraryHolder;
+#endif // !FEATURE_PAL
+
+public:
+ RawImageLayout(const void *flat, COUNT_T size,PEImage* pOwner);
+ RawImageLayout(const void *mapped, PEImage* pOwner, BOOL bTakeOwnerShip, BOOL bFixedUp);
+};
+
+// ConvertedImageView is for the case when we manually layout a flat image
+class ConvertedImageLayout: public PEImageLayout
+{
+ VPTR_VTABLE_CLASS(ConvertedImageLayout,PEImageLayout)
+protected:
+ HandleHolder m_FileMap;
+ CLRMapViewHolder m_FileView;
+public:
+#ifndef DACCESS_COMPILE
+ ConvertedImageLayout(PEImageLayout* source);
+#endif
+};
+
+class MappedImageLayout: public PEImageLayout
+{
+ VPTR_VTABLE_CLASS(MappedImageLayout,PEImageLayout)
+ VPTR_UNIQUE(0x15)
+protected:
+ HandleHolder m_FileMap;
+ CLRMapViewHolder m_FileView;
+public:
+#ifndef DACCESS_COMPILE
+ MappedImageLayout(HANDLE hFile, PEImage* pOwner);
+#endif
+};
+
+#if !defined(CROSSGEN_COMPILE) && !defined(FEATURE_PAL)
+class LoadedImageLayout: public PEImageLayout
+{
+ VPTR_VTABLE_CLASS(LoadedImageLayout,PEImageLayout)
+protected:
+ HINSTANCE m_Module;
+public:
+#ifndef DACCESS_COMPILE
+ LoadedImageLayout(PEImage* pOwner, BOOL bNTSafeLoad, BOOL bThrowOnError);
+ ~LoadedImageLayout()
+ {
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_TRIGGERS;
+ MODE_ANY;
+ }
+ CONTRACTL_END;
+ if (m_Module)
+ CLRFreeLibrary(m_Module);
+ }
+#endif // !DACCESS_COMPILE
+};
+#endif // !CROSSGEN_COMPILE && !FEATURE_PAL
+
+class FlatImageLayout: public PEImageLayout
+{
+ VPTR_VTABLE_CLASS(FlatImageLayout,PEImageLayout)
+ VPTR_UNIQUE(0x59)
+protected:
+ HandleHolder m_FileMap;
+ CLRMapViewHolder m_FileView;
+public:
+#ifndef DACCESS_COMPILE
+ FlatImageLayout(HANDLE hFile, PEImage* pOwner);
+#endif
+
+};
+
+#ifdef FEATURE_FUSION
+class StreamImageLayout: public PEImageLayout
+{
+ VPTR_VTABLE_CLASS(StreamImageLayout,PEImageLayout)
+ VPTR_UNIQUE(0x71)
+protected:
+ HandleHolder m_FileMap;
+ CLRMapViewHolder m_FileView;
+public:
+#ifndef DACCESS_COMPILE
+ StreamImageLayout(IStream* pIStream,PEImage* pOwner);
+#endif
+};
+#endif // FEATURE_FUSION
+
+
+#endif // PEIMAGELAYOUT_H_
+