Example #1
0
 public static void RhpReversePInvokeBadTransition(IntPtr returnAddress)
 {
     EH.FailFastViaClasslib(
         RhFailFastReason.IllegalNativeCallableEntry,
         null,
         returnAddress);
 }
Example #2
0
        unsafe private static IntPtr RhpCastableObjectResolve(IntPtr callerTransitionBlockParam, IntPtr pCell)
        {
            IntPtr locationOfThisPointer = callerTransitionBlockParam + TransitionBlock.GetThisOffset();
            object pObject = Unsafe.As <IntPtr, Object>(ref *(IntPtr *)locationOfThisPointer);

            DispatchCellInfo cellInfo;

            InternalCalls.RhpGetDispatchCellInfo(pCell, out cellInfo);
            if (cellInfo.CellType != DispatchCellType.InterfaceAndSlot)
            {
                // Dispatch cell used for castable object resolve is not InterfaceAndSlot. This should not be possible
                // as all metadata based cells should have been converted to interface and slot cells by this time.
                EH.FallbackFailFast(RhFailFastReason.InternalError, null);
                return(IntPtr.Zero);
            }

            EEType *pInterfaceType = cellInfo.InterfaceType.ToPointer();

            Exception e            = null;
            object    targetObject = GetCastableTargetIfPossible((ICastableObject)pObject, pInterfaceType, false, ref e);

            if (targetObject == null)
            {
                EH.FailFastViaClasslib(RhFailFastReason.InternalError, null, pObject.EEType->GetAssociatedModuleAddress());
            }

            Unsafe.As <IntPtr, Object>(ref *(IntPtr *)locationOfThisPointer) = targetObject;

            InternalCalls.RhpSetTLSDispatchCell(pCell);
            return(InternalCalls.RhpGetTailCallTLSDispatchCell());
        }
Example #3
0
        public static void RhpReversePInvokeBadTransition()
        {
            IntPtr returnAddress = BinderIntrinsics.GetReturnAddress();

            if (returnAddress != IntPtr.Zero)
            {
                EH.FailFastViaClasslib(
                    RhFailFastReason.IllegalNativeCallableEntry,
                    null,
                    returnAddress);
            }
            else
            {
                // @HACKHACK: we need to force the method to have an EBP frame so that we can use the
                // GetReturnAddress() intrinsic above.  This seems to be the smallest way to do this.
                EH.FailFast(RhFailFastReason.InternalError, null);
                throw EH.GetClasslibException(ExceptionIDs.Arithmetic, returnAddress);
            }
        }