コード例 #1
0
        public static unsafe object GetTransaction()
        {
            object              objectForIUnknown;
            IUnknown *          unknownPtr = null;
            IObjectContextInfo *infoPtr    = null;

            int modopt(IsLong) context = GetContext(&IID_IObjectContextInfo, (void **)&infoPtr);

            if ((context >= 0) && (null != infoPtr))
            {
                context = **(((int *)infoPtr))[0x10](infoPtr, &unknownPtr);
                * *(((int *)infoPtr))[8](infoPtr);
            }
            if (context == -2147467262)
            {
                context = -2147164156;
            }
            else if (context >= 0)
            {
                goto Label_004E;
            }
            Marshal.ThrowExceptionForHR(context);
Label_004E:
            objectForIUnknown = null;
            if (unknownPtr != null)
            {
                try
                {
                    IntPtr pUnk = new IntPtr((void *)unknownPtr);
                    objectForIUnknown = Marshal.GetObjectForIUnknown(pUnk);
                }
                finally
                {
                    * *(((int *)unknownPtr))[8](unknownPtr);
                }
            }
            return(objectForIUnknown);
        }
コード例 #2
0
        public static unsafe Guid GetTransactionId()
        {
            Guid guid2 = new Guid();
            IObjectContextInfo *infoPtr = null;

            int modopt(IsLong) context = GetContext(&IID_IObjectContextInfo, (void **)&infoPtr);

            if ((context >= 0) && (null != infoPtr))
            {
                _GUID _guid;
                context = **(((int *)infoPtr))[20](infoPtr, &_guid);
                * *(((int *)infoPtr))[8](infoPtr);
                if (context == 0)
                {
                    return(new Guid(*((uint *)&_guid), *((ushort *)(&_guid + 4)), *((ushort *)(&_guid + 6)), *((byte *)(&_guid + 8)), *((byte *)(&_guid + 9)), *((byte *)(&_guid + 10)), *((byte *)(&_guid + 11)), *((byte *)(&_guid + 12)), *((byte *)(&_guid + 13)), *((byte *)(&_guid + 14)), *((byte *)(&_guid + 15))));
                }
            }
            if (context == -2147467262)
            {
                context = -2147164156;
            }
            Marshal.ThrowExceptionForHR(context);
            return(guid2);
        }
コード例 #3
0
        public static unsafe bool GetTransactionProxyOrTransaction(ref object ppTx, TxInfo pTxInfo)
        {
            IObjectContext *contextPtr = null;

            pTxInfo.isDtcTransaction = false;
            bool flag = false;

            ppTx = null;
            int modopt(IsLong) context = GetContext(&IID_IObjectContext, (void **)&contextPtr);

            if ((context < 0) || (null == contextPtr))
            {
                if (context == -2147467262)
                {
                    return(flag);
                }
                goto Label_019C;
            }
            if (**(((int *)contextPtr))[0x20](contextPtr) != 0)
            {
                flag = true;
            }
            else
            {
                flag = false;
                goto Label_0186;
            }
            IContextTransactionInfoPrivate *privatePtr = null;

            context = **(*((int *)contextPtr))(contextPtr, &_GUID_7d40fcc8_f81e_462e_bba1_8a99ebdc826c, &privatePtr);
            switch (context)
            {
            case 0:
                try
                {
                    IUnknown *unknownPtr = null;
                    context = **(((int *)privatePtr))[12](privatePtr, &unknownPtr);
                    if (context >= 0)
                    {
                        if (unknownPtr == null)
                        {
                            uint modopt(IsLong) num2;
                            int modopt(IsLong) num3;

                            pTxInfo.isDtcTransaction = false;
                            context = **(((int *)privatePtr))[20](privatePtr, &num3, &num2);
                            if (context >= 0)
                            {
                                pTxInfo.IsolationLevel = num3;
                                pTxInfo.timeout        = num2;
                            }
                            break;
                        }
                        IUnknown *unknownPtr3 = null;
                        context = **(*((int *)unknownPtr))(unknownPtr, &_GUID_0fb15084_af41_11ce_bd2b_204c4f4f5020, &unknownPtr3);
                        switch (context)
                        {
                        case 0:
                            pTxInfo.isDtcTransaction = true;
                            * *(((int *)unknownPtr3))[8](unknownPtr3);
                            break;

                        case -2147467262:
                            context = 0;
                            break;
                        }
                        try
                        {
                            if (context >= 0)
                            {
                                IntPtr pUnk = new IntPtr((void *)unknownPtr);
                                ppTx = Marshal.GetObjectForIUnknown(pUnk);
                            }
                        }
                        finally
                        {
                            * *(((int *)unknownPtr))[8](unknownPtr);
                        }
                    }
                    break;
                }
                finally
                {
                    * *(((int *)privatePtr))[8](privatePtr);
                }
                break;

            case -2147467262:
            {
                IObjectContextInfo *infoPtr     = null;
                IUnknown *          unknownPtr2 = null;
                context = **(*((int *)contextPtr))(contextPtr, &IID_IObjectContextInfo, &infoPtr);
                if (context >= 0)
                {
                    try
                    {
                        context = **(((int *)infoPtr))[0x10](infoPtr, &unknownPtr2);
                        if (context >= 0)
                        {
                            pTxInfo.isDtcTransaction = true;
                            try
                            {
                                IntPtr ptr = new IntPtr((void *)unknownPtr2);
                                ppTx = Marshal.GetObjectForIUnknown(ptr);
                            }
                            finally
                            {
                                * *(((int *)unknownPtr2))[8](unknownPtr2);
                            }
                        }
                    }
                    finally
                    {
                        * *(((int *)infoPtr))[8](infoPtr);
                    }
                }
                break;
            }
            }
Label_0186:
            **(((int *)contextPtr))[8](contextPtr);
Label_019C:
            if (context < 0)
            {
                Marshal.ThrowExceptionForHR(context);
            }
            return(flag);
        }