| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | |
| 6 | #ifndef __CLRPRIVBINDERASSEMBLYLOADCONTEXT_H__ |
| 7 | #define __CLRPRIVBINDERASSEMBLYLOADCONTEXT_H__ |
| 8 | |
| 9 | #include "coreclrbindercommon.h" |
| 10 | #include "applicationcontext.hpp" |
| 11 | #include "clrprivbindercoreclr.h" |
| 12 | |
| 13 | #if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) |
| 14 | |
| 15 | namespace BINDER_SPACE |
| 16 | { |
| 17 | class AssemblyIdentityUTF8; |
| 18 | }; |
| 19 | |
| 20 | class AppDomain; |
| 21 | |
| 22 | class Object; |
| 23 | class Assembly; |
| 24 | class LoaderAllocator; |
| 25 | |
| 26 | class CLRPrivBinderAssemblyLoadContext : |
| 27 | public IUnknownCommon<ICLRPrivBinder> |
| 28 | { |
| 29 | public: |
| 30 | |
| 31 | //========================================================================= |
| 32 | // ICLRPrivBinder functions |
| 33 | //------------------------------------------------------------------------- |
| 34 | STDMETHOD(BindAssemblyByName)( |
| 35 | /* [in] */ IAssemblyName *pIAssemblyName, |
| 36 | /* [retval][out] */ ICLRPrivAssembly **ppAssembly); |
| 37 | |
| 38 | STDMETHOD(GetBinderID)( |
| 39 | /* [retval][out] */ UINT_PTR *pBinderId); |
| 40 | |
| 41 | STDMETHOD(GetLoaderAllocator)( |
| 42 | /* [retval][out] */ LPVOID *pLoaderAllocator); |
| 43 | |
| 44 | public: |
| 45 | //========================================================================= |
| 46 | // Class functions |
| 47 | //------------------------------------------------------------------------- |
| 48 | |
| 49 | static HRESULT SetupContext(DWORD dwAppDomainId, |
| 50 | CLRPrivBinderCoreCLR *pTPABinder, |
| 51 | LoaderAllocator* pLoaderAllocator, |
| 52 | void* loaderAllocatorHandle, |
| 53 | UINT_PTR ptrAssemblyLoadContext, |
| 54 | CLRPrivBinderAssemblyLoadContext **ppBindContext); |
| 55 | |
| 56 | void PrepareForLoadContextRelease(INT_PTR ptrManagedStrongAssemblyLoadContext); |
| 57 | void ReleaseLoadContext(); |
| 58 | |
| 59 | CLRPrivBinderAssemblyLoadContext(); |
| 60 | |
| 61 | inline BINDER_SPACE::ApplicationContext *GetAppContext() |
| 62 | { |
| 63 | return &m_appContext; |
| 64 | } |
| 65 | |
| 66 | inline INT_PTR GetManagedAssemblyLoadContext() |
| 67 | { |
| 68 | return m_ptrManagedAssemblyLoadContext; |
| 69 | } |
| 70 | |
| 71 | HRESULT BindUsingPEImage( /* in */ PEImage *pPEImage, |
| 72 | /* in */ BOOL fIsNativeImage, |
| 73 | /* [retval][out] */ ICLRPrivAssembly **ppAssembly); |
| 74 | |
| 75 | //========================================================================= |
| 76 | // Internal implementation details |
| 77 | //------------------------------------------------------------------------- |
| 78 | private: |
| 79 | HRESULT BindAssemblyByNameWorker(BINDER_SPACE::AssemblyName *pAssemblyName, BINDER_SPACE::Assembly **ppCoreCLRFoundAssembly); |
| 80 | |
| 81 | BINDER_SPACE::ApplicationContext m_appContext; |
| 82 | |
| 83 | CLRPrivBinderCoreCLR *m_pTPABinder; |
| 84 | |
| 85 | INT_PTR m_ptrManagedAssemblyLoadContext; |
| 86 | |
| 87 | LoaderAllocator* m_pAssemblyLoaderAllocator; |
| 88 | void* m_loaderAllocatorHandle; |
| 89 | }; |
| 90 | |
| 91 | #endif // !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) |
| 92 | #endif // __CLRPRIVBINDERASSEMBLYLOADCONTEXT_H__ |
| 93 | |