Example #1
0
        public static void FailedAllocation(bool fIsOverflow)
        {
            // Throw the out of memory or overflow exception defined by the classlib, using the return address from this helper
            // to find the correct classlib.

            ExceptionIDs exID = fIsOverflow ? ExceptionIDs.Overflow : ExceptionIDs.OutOfMemory;

            IntPtr    returnAddr = BinderIntrinsics.GetReturnAddress();
            Exception e          = GetClasslibException(exID, returnAddr);

            BinderIntrinsics.TailCall_RhpThrowEx(e);
        }
Example #2
0
        public static void ThrowClasslibIndexOutOfRangeException()
        {
            // Throw the index out of range exception defined by the classlib, using the return address from
            // this helper to find the correct classlib.

            ExceptionIDs exID = ExceptionIDs.IndexOutOfRange;

            IntPtr    returnAddr = BinderIntrinsics.GetReturnAddress();
            Exception e          = GetClasslibException(exID, returnAddr);

            BinderIntrinsics.TailCall_RhpThrowEx(e);
            throw e;
        }
Example #3
0
        public static void ThrowClasslibArithmeticException()
        {
            // Throw the arithmetic exception defined by the classlib, using the return address from this
            // helper to find the correct classlib.

            ExceptionIDs exID = ExceptionIDs.Arithmetic;

            IntPtr    returnAddr = BinderIntrinsics.GetReturnAddress();
            Exception e          = GetClasslibException(exID, returnAddr);

            BinderIntrinsics.TailCall_RhpThrowEx(e);
            throw e;
        }
Example #4
0
        public static IntPtr RhHandleAllocVariable(object value, uint type)
        {
            IntPtr h = InternalCalls.RhpHandleAllocVariable(value, type);

            if (h == IntPtr.Zero)
            {
                // Throw the out of memory exception defined by the classlib, using the return address of this method
                // to find the correct classlib.

                ExceptionIDs exID = ExceptionIDs.OutOfMemory;

                IntPtr    returnAddr = BinderIntrinsics.GetReturnAddress();
                Exception e          = EH.GetClasslibException(exID, returnAddr);
                throw e;
            }

            return(h);
        }
Example #5
0
        public static IntPtr RhHandleAllocDependent(object primary, object secondary)
        {
            IntPtr h = InternalCalls.RhpHandleAllocDependent(primary, secondary);

            if (h == IntPtr.Zero)
            {
                // Throw the out of memory exception defined by the classlib, using the return address of this method
                // to find the correct classlib.

                ExceptionIDs exID = ExceptionIDs.OutOfMemory;

                IntPtr    returnAddr = BinderIntrinsics.GetReturnAddress();
                Exception e          = EH.GetClasslibException(exID, returnAddr);
                throw e;
            }

            return(h);
        }
Example #6
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);
            }
        }