internal void AddRawInputHandler()
 {
     try
     {
         if (PromotionObject.Instance == null || !PromotionObject.Instance.IsSecurityMetricsEnable)
         {
             return;
         }
         this.mRawInput = new RawInputClass(new WindowInteropHelper((Window)this.mWindowInstance).Handle);
         Logger.Info("Adding raw input handle");
     }
     catch (Exception ex)
     {
         Logger.Error("Error while adding raw input handle: {0}", (object)ex.ToString());
     }
 }
        internal IntPtr WndProc(
            IntPtr hwnd,
            int msg,
            IntPtr wParam,
            IntPtr lParam,
            ref bool handled)
        {
            if (WindowWndProcHandler.isLogWndProc)
            {
                Logger.Info("WndProcMessage: " + msg.ToString() + "~~" + wParam.ToString() + "~~" + lParam.ToString() + "~~");
            }
            switch ((WindowWndProcHandler.WM)msg)
            {
            case WindowWndProcHandler.WM.SETFOCUS:
                ThreadPool.QueueUserWorkItem((WaitCallback)(obj => this.mWindowInstance.Dispatcher.Invoke((Delegate)(() =>
                {
                    try
                    {
                        bool flag2 = true;
                        foreach (Window ownedWindow in this.mWindowInstance.OwnedWindows)
                        {
                            if (ownedWindow is CustomWindow customWindow)
                            {
                                if (!customWindow.IsShowGLWindow && !KMManager.sIsInScriptEditingMode)
                                {
                                    flag2 = false;
                                    Logger.Debug("OnFocusChanged window IsShowGLWindow false: " + customWindow.Name);
                                }
                            }
                            else
                            {
                                Logger.Debug("OnFocusChanged Non Custom window found! " + ownedWindow.Name);
                            }
                        }
                        if (flag2 && !this.mWindowInstance.mIsFocusComeFromImap && this.mWindowInstance.AllowFrontendFocusOnClientClick)
                        {
                            this.mWindowInstance.mFrontendHandler.ShowGLWindow();
                        }
                        this.mWindowInstance.mIsFocusComeFromImap = false;
                    }
                    catch
                    {
                    }
                }))));
                break;

            case WindowWndProcHandler.WM.SYSCOLORCHANGE:
            case WindowWndProcHandler.WM.WININICHANGE:
            case WindowWndProcHandler.WM.DISPLAYCHANGE:
            case WindowWndProcHandler.WM.DEVICECHANGE:
            case WindowWndProcHandler.WM.THEMECHANGED:
                using (new Timer((TimerCallback)(x => WindowWndProcHandler.SetMenuDropDownAlignment()), (object)null, TimeSpan.FromMilliseconds(2.0), TimeSpan.FromMilliseconds(-1.0)))
                    break;

            case WindowWndProcHandler.WM.GETMINMAXINFO:
                this.WmGetMinMaxInfo(hwnd, lParam);
                handled = true;
                break;

            case WindowWndProcHandler.WM.WINDOWPOSCHANGING:
                WindowWndProcHandler.WINDOWPOS structure = (WindowWndProcHandler.WINDOWPOS)Marshal.PtrToStructure(lParam, typeof(WindowWndProcHandler.WINDOWPOS));
                if ((structure.flags & 2) != 0 || (Window)HwndSource.FromHwnd(hwnd).RootVisual == null || this.mWindowInstance.WindowState != WindowState.Normal)
                {
                    return(IntPtr.Zero);
                }
                bool flag1 = true;
                if (this.mWindowInstance.MinWidthScaled > structure.cx)
                {
                    structure.cx = this.mWindowInstance.MinWidthScaled;
                    structure.cy = (int)this.mWindowInstance.GetHeightFromWidth((double)structure.cx, true, false);
                    flag1        = false;
                }
                else if (this.mWindowInstance.MinHeightScaled > structure.cy)
                {
                    structure.cy = this.mWindowInstance.MinHeightScaled;
                    structure.cx = (int)this.mWindowInstance.GetWidthFromHeight((double)structure.cy, true, false);
                    flag1        = false;
                }
                if (structure.cx > this.mWindowInstance.MaxWidthScaled || structure.cy > this.mWindowInstance.MaxHeightScaled)
                {
                    structure.cx = this.mWindowInstance.MaxWidthScaled;
                    structure.cy = this.mWindowInstance.MaxHeightScaled;
                    flag1        = false;
                }
                if (flag1)
                {
                    if (this.mAdjustingWidth)
                    {
                        structure.cy = (int)this.mWindowInstance.GetHeightFromWidth((double)structure.cx, true, false);
                    }
                    else
                    {
                        structure.cx = (int)this.mWindowInstance.GetWidthFromHeight((double)structure.cy, true, false);
                    }
                }
                Marshal.StructureToPtr((object)structure, lParam, true);
                handled = true;
                break;

            case WindowWndProcHandler.WM.INPUT:
                int num = -1;
                if (this.mRawInput != null)
                {
                    num = RawInputClass.GetDeviceID(lParam);
                }
                if (num == 0 && SecurityMetrics.SecurityMetricsInstanceList.ContainsKey(this.mWindowInstance.mVmName))
                {
                    SecurityMetrics.SecurityMetricsInstanceList[this.mWindowInstance.mVmName].AddSecurityBreach(SecurityBreach.SYNTHETIC_INPUT, string.Empty);
                    break;
                }
                break;

            case WindowWndProcHandler.WM.SYSCOMMAND:
                if (wParam == (IntPtr)61696)
                {
                    handled = true;
                    break;
                }
                break;

            case WindowWndProcHandler.WM.ENTERMENULOOP:
                handled = true;
                break;
            }
            return(IntPtr.Zero);
        }