예제 #1
0
        public static unsafe ThunksHeap?CreateThunksHeap(IntPtr commonStubAddress)
        {
            try
            {
                ThunksHeap newHeap = new ThunksHeap(commonStubAddress);

                if (newHeap._nextAvailableThunkPtr != IntPtr.Zero)
                {
                    return(newHeap);
                }
            }
            catch (Exception) { }

            return(null);
        }
예제 #2
0
        internal static unsafe IntPtr GetCastableObjectDispatchCellThunk(EEType *pInstanceType, IntPtr pDispatchCell)
        {
            IntPtr pTargetCode = CacheLookup(s_ThunkBasedDispatchCellTargets, pDispatchCell);

            if (pTargetCode != default(IntPtr))
            {
                return(pTargetCode);
            }

            InternalCalls.RhpAcquireCastCacheLock();
            {
                // Look in the cache again after taking the lock

                pTargetCode = CacheLookup(s_ThunkBasedDispatchCellTargets, pDispatchCell);
                if (pTargetCode != default(IntPtr))
                {
                    return(pTargetCode);
                }

                // Allocate a new thunk. Failure to allocate one will result in a fail-fast. We don't return nulls from this API.

                if (s_thunksHeap == null)
                {
                    s_thunksHeap = ThunksHeap.CreateThunksHeap(InternalCalls.RhpGetCastableObjectDispatch_CommonStub());
                    if (s_thunksHeap == null)
                    {
                        EH.FallbackFailFast(RhFailFastReason.InternalError, null);
                    }
                }

                pTargetCode = s_thunksHeap.AllocateThunk();
                if (pTargetCode == IntPtr.Zero)
                {
                    EH.FallbackFailFast(RhFailFastReason.InternalError, null);
                }

                s_thunksHeap.SetThunkData(pTargetCode, pDispatchCell, InternalCalls.RhpGetCastableObjectDispatchHelper_TailCalled());

                AddToThunkCache(pDispatchCell, pTargetCode);
            }
            InternalCalls.RhpReleaseCastCacheLock();

            return(pTargetCode);
        }
예제 #3
0
 public static object RhCreateThunksHeap(IntPtr commonStubAddress)
 {
     return(ThunksHeap.CreateThunksHeap(commonStubAddress));
 }
예제 #4
0
        public static unsafe ThunksHeap CreateThunksHeap(IntPtr commonStubAddress)
        {
            try
            {
                ThunksHeap newHeap = new ThunksHeap(commonStubAddress);

                if (newHeap._nextAvailableThunkPtr != IntPtr.Zero)
                    return newHeap;
            }
            catch { }

            return null;
        }