Ejemplo n.º 1
0
        // used by And/Or conditions to allocate an array of pointers to other conditions
        internal static SafeConditionMemoryHandle AllocateConditionArrayHandle(Condition [] conditions)
        {
            // Allocate SafeHandle first to avoid failure later.
            SafeConditionMemoryHandle sh = new SafeConditionMemoryHandle();

            int intPtrSize = Marshal.SizeOf(typeof(IntPtr));

            try { }
            finally
            {
                IntPtr mem = Marshal.AllocCoTaskMem(conditions.Length * intPtrSize);
                sh.SetHandle(mem);
            }

            unsafe
            // Suppress "Exposing unsafe code thru public interface" UiaCoreApi is trusted
#pragma warning suppress 56505
            {
                IntPtr *pdata = (IntPtr *)sh.handle;
                for (int i = 0; i < conditions.Length; i++)
                {
                    *pdata++ = conditions[i]._safeHandle.handle;
                }
            }
            return(sh);
        }
Ejemplo n.º 2
0
        // used by And/Or conditions to allocate an array of pointers to other conditions
        internal static SafeConditionMemoryHandle AllocateConditionArrayHandle(Condition [] conditions)
        {
            // Allocate SafeHandle first to avoid failure later.
            SafeConditionMemoryHandle sh = new SafeConditionMemoryHandle();

            int intPtrSize = Marshal.SizeOf(typeof(IntPtr));

            #pragma warning disable SYSLIB0004          // The Constrained Execution Region (CER) feature is not supported.
            RuntimeHelpers.PrepareConstrainedRegions(); // ensures that the following finally block is atomic
            #pragma warning restore SYSLIB0004          // The Constrained Execution Region (CER) feature is not supported.
            try { }
            finally
            {
                IntPtr mem = Marshal.AllocCoTaskMem(conditions.Length * intPtrSize);
                sh.SetHandle(mem);
            }

            unsafe
            // Suppress "Exposing unsafe code thru public interface" UiaCoreApi is trusted
#pragma warning suppress 56505
            {
                IntPtr *pdata = (IntPtr *)sh.handle;
                for (int i = 0; i < conditions.Length; i++)
                {
                    *pdata++ = conditions[i]._safeHandle.handle;
                }
            }
            return(sh);
        }
Ejemplo n.º 3
0
        // uiaCondition is one of the Uia condition structs - eg UiaCoreApi.UiaAndOrCondition
        internal static SafeConditionMemoryHandle AllocateConditionHandle(object uiaCondition)
        {
            // Allocate SafeHandle first to avoid failure later.
            SafeConditionMemoryHandle sh = new SafeConditionMemoryHandle();
            int size = Marshal.SizeOf(uiaCondition);

            try { }
            finally
            {
                IntPtr mem = Marshal.AllocCoTaskMem(size);
                sh.SetHandle(mem);
            }
            Marshal.StructureToPtr(uiaCondition, sh.handle, false);
            return(sh);
        }
Ejemplo n.º 4
0
        // uiaCondition is one of the Uia condition structs - eg UiaCoreApi.UiaAndOrCondition
        internal static SafeConditionMemoryHandle AllocateConditionHandle(object uiaCondition)
        {
            // Allocate SafeHandle first to avoid failure later.
            SafeConditionMemoryHandle sh = new SafeConditionMemoryHandle();
            int size = Marshal.SizeOf(uiaCondition);

            RuntimeHelpers.PrepareConstrainedRegions(); // ensures that the following finally block is atomic
            try { }
            finally
            {
                IntPtr mem = Marshal.AllocCoTaskMem(size);
                sh.SetHandle(mem);
            }
            Marshal.StructureToPtr(uiaCondition, sh.handle, false);
            return(sh);
        }
Ejemplo n.º 5
0
        // uiaCondition is one of the Uia condition structs - eg UiaCoreApi.UiaAndOrCondition
        internal static SafeConditionMemoryHandle AllocateConditionHandle(object uiaCondition)
        {
            // Allocate SafeHandle first to avoid failure later.
            SafeConditionMemoryHandle sh = new SafeConditionMemoryHandle();
            int size = Marshal.SizeOf(uiaCondition);

            #pragma warning disable SYSLIB0004          // The Constrained Execution Region (CER) feature is not supported.
            RuntimeHelpers.PrepareConstrainedRegions(); // ensures that the following finally block is atomic
            #pragma warning restore SYSLIB0004          // The Constrained Execution Region (CER) feature is not supported.
            try { }
            finally
            {
                IntPtr mem = Marshal.AllocCoTaskMem(size);
                sh.SetHandle(mem);
            }
            Marshal.StructureToPtr(uiaCondition, sh.handle, false);
            return(sh);
        }