예제 #1
0
        [System.Security.SecurityCritical]  // auto-generated
        private static void ValidateCspFlags (CspProviderFlags flags) {
            // check that the flags are consistent.
            if ((flags & CspProviderFlags.UseExistingKey) != 0) {
                CspProviderFlags keyFlags = (CspProviderFlags.UseNonExportableKey | CspProviderFlags.UseArchivableKey | CspProviderFlags.UseUserProtectedKey);
                if ((flags & keyFlags) != CspProviderFlags.NoFlags)
                    throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"));
            }

            // make sure we are allowed to display the key protection UI if a user protected key is requested.
            if ((flags & CspProviderFlags.UseUserProtectedKey) != 0) {
                // UI only allowed in interactive session.
                if (!System.Environment.UserInteractive)
                    throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NotInteractive"));

                // we need to demand UI permission here.
                UIPermission uiPermission = new UIPermission(UIPermissionWindow.SafeTopLevelWindows);
                uiPermission.Demand();
            }
        }
		/// <summary>
		/// Filters out a message before it is dispatched
		/// </summary>
		/// <param name="m">The message to be dispatched. You cannot modify 
		/// this message</param>
		/// <returns>true to filter the message and prevent it from being 
		/// dispatched; false to allow the message to continue to the next 
		/// filter or control</returns>
		public bool PreFilterMessage(ref Message m)
		{
			// make sure we have a client
			if (this.Client == null)
			{
				return false;
			}
			
			// make sure the message is a key message
			if (m.Msg != (int) WindowMessage.WM_KEYDOWN && m.Msg != (int) WindowMessage.WM_SYSKEYDOWN && 
				m.Msg != (int) WindowMessage.WM_KEYUP && m.Msg != (int) WindowMessage.WM_SYSKEYUP)
			{
				return false;
			}

			// try to get the target control
			UIPermission uiPermission = new UIPermission(UIPermissionWindow.AllWindows);
			uiPermission.Demand();
			Control target = Control.FromChildHandle(m.HWnd);

			return this.Client.ProcessKeyMessage(target, (WindowMessage) m.Msg, m.WParam.ToInt32(), m.LParam.ToInt32());
		}
        /// <summary>
        /// Filters out a message before it is dispatched
        /// </summary>
        /// <param name="m">The message to be dispatched. You cannot modify 
        /// this message</param>
        /// <returns>true to filter the message and prevent it from being 
        /// dispatched; false to allow the message to continue to the next 
        /// filter or control</returns>
        public bool PreFilterMessage(ref Message m)
        {
            // make sure we have a client
            if (this.Client == null)
            {
                return false;
            }

            // make sure the message is a mouse message
            if ((m.Msg >= (int) WindowMessage.WM_MOUSEMOVE && m.Msg <= (int) WindowMessage.WM_XBUTTONDBLCLK) ||
                (m.Msg >= (int) WindowMessage.WM_NCMOUSEMOVE && m.Msg <= (int) WindowMessage.WM_NCXBUTTONUP))
            {
                // try to get the target control
                UIPermission uiPermission = new UIPermission(UIPermissionWindow.AllWindows);
                uiPermission.Demand();
                Control target = Control.FromChildHandle(m.HWnd);

                return this.Client.ProcessMouseMessage(target, (WindowMessage) m.Msg, m.WParam, m.LParam);
            }

            return false;
        }
		// Loads any steps 
		protected override void OnLoad(System.EventArgs e)
		{
			base.OnLoad(e);

			if( !DesignMode )
			{
				OnLoadSteps(EventArgs.Empty);
			
				if( FirstStepName == "" )
					throw new InvalidOperationException("FirstStepName must be be a non-empty string.");

				ResetSteps();

				SetCurrentStep(FirstStepName, StepDirection.InitialStep);
			}
			else
			{
				UpdateLayout(currentLayout);
			}

			UIPermission uiP = new UIPermission(UIPermissionWindow.AllWindows);
			uiP.Demand();
		}
		// Updated May 20, 2003, switched from event handler to overriding the protected method
		protected override void OnLoad(System.EventArgs e)
		{
			base.OnLoad(e);

			UpdateLayout(pageLayout);

			UIPermission uiP = new UIPermission(UIPermissionWindow.AllWindows);
			uiP.Demand();
		}
예제 #6
0
        internal static bool CryptUIDlgViewCertificateW (
            [In, MarshalAs(UnmanagedType.LPStruct)] CRYPTUI_VIEWCERTIFICATE_STRUCTW ViewInfo,
            [In, Out] IntPtr pfPropertiesChanged) {

            // UI only allowed in interactive session.
            if (!System.Environment.UserInteractive)
                throw new InvalidOperationException(SecurityResources.GetResourceString("Environment_NotInteractive"));

            // we need to demand UI permission here.
            UIPermission uiPermission = new UIPermission(UIPermissionWindow.SafeTopLevelWindows);
            uiPermission.Demand();

            return CAPIUnsafe.CryptUIDlgViewCertificateW(ViewInfo, pfPropertiesChanged);
        }
예제 #7
0
        internal static SafeCertContextHandle CryptUIDlgSelectCertificateW (
            [In, Out, MarshalAs(UnmanagedType.LPStruct)]
            CRYPTUI_SELECTCERTIFICATE_STRUCTW csc) {

            // UI only allowed in interactive session.
            if (!System.Environment.UserInteractive)
                throw new InvalidOperationException(SecurityResources.GetResourceString("Environment_NotInteractive"));

            // we need to demand UI permission here.
            UIPermission uiPermission = new UIPermission(UIPermissionWindow.SafeTopLevelWindows);
            uiPermission.Demand();

            return CAPIUnsafe.CryptUIDlgSelectCertificateW(csc);
        }