示例#1
0
		public void Refresh()
		{
			this.windows.Clear();

			Dispatcher.BeginInvoke
			(
				System.Windows.Threading.DispatcherPriority.Loaded,
				(DispatcherOperationCallback)delegate
				{
					try
					{
						Mouse.OverrideCursor = Cursors.Wait;

						foreach (IntPtr windowHandle in NativeMethods.ToplevelWindows)
						{
							WindowInfo window = new WindowInfo(windowHandle);
							if (window.IsValidProcess && !this.HasProcess(window.OwningProcess))
							{
								new AttachFailedHandler(window, this);
								this.windows.Add(window);
							}
						}

						if (this.windows.Count > 0)
							this.windowsView.MoveCurrentTo(this.windows[0]);
					}
					finally
					{
						Mouse.OverrideCursor = null;
					}
					return null;
				},
				null
			);
		}
示例#2
0
		static string Suffix(IntPtr windowHandle)
		{
			var window = new WindowInfo(windowHandle);
			string bitness = IntPtr.Size == 8 ? "64" : "32";
			string clr = "3.5";


			foreach (var module in window.Modules)
			{
				// a process is valid to snoop if it contains a dependency on PresentationFramework, PresentationCore, or milcore (wpfgfx).
				// this includes the files:
				// PresentationFramework.dll, PresentationFramework.ni.dll
				// PresentationCore.dll, PresentationCore.ni.dll
				// wpfgfx_v0300.dll (WPF 3.0/3.5)
				// wpfgrx_v0400.dll (WPF 4.0)

				// note: sometimes PresentationFramework.dll doesn't show up in the list of modules.
				// so, it makes sense to also check for the unmanaged milcore component (wpfgfx_vxxxx.dll).
				// see for more info: http://snoopwpf.codeplex.com/Thread/View.aspx?ThreadId=236335

				// sometimes the module names aren't always the same case. compare case insensitive.
				// see for more info: http://snoopwpf.codeplex.com/workitem/6090

				if
				(
					module.szModule.StartsWith("PresentationFramework", StringComparison.OrdinalIgnoreCase) ||
					module.szModule.StartsWith("PresentationCore", StringComparison.OrdinalIgnoreCase) ||
					module.szModule.StartsWith("wpfgfx", StringComparison.OrdinalIgnoreCase)
				)
				{
					if (FileVersionInfo.GetVersionInfo(module.szExePath).FileMajorPart > 3)
					{
						clr = "4.0";
					}
				}
				if (module.szModule.Contains("wow64.dll"))
				{
					if (FileVersionInfo.GetVersionInfo(module.szExePath).FileMajorPart > 3)
					{
						bitness = "32";
					}
				}
			}
			return bitness + "-" + clr;
		}
示例#3
0
 public AttachFailedHandler(WindowInfo window, AppChooser appChooser = null)
 {
     window.AttachFailed += OnSnoopAttachFailed;
     _appChooser = appChooser;
 }
 private void HandleRefreshCommand(object sender, ExecutedRoutedEventArgs e)
 {
     // clear out cached process info to make the force refresh do the process check over again.
     WindowInfo.ClearCachedWindowHandleInfo();
     this.Refresh();
 }
示例#5
0
 public AttachFailedHandler(WindowInfo window, AppChooser appChooser = null)
 {
     window.AttachFailed += OnSnoopAttachFailed;
     _appChooser          = appChooser;
 }
示例#6
0
        private void WindowFinderMouseMove(object sender, MouseEventArgs e)
        {
            if (!IsDragging) return;

            if (Mouse.LeftButton == MouseButtonState.Released)
            {
                StopSnoopTargetsSearch();
                return;
            }

            var windowUnderCursor = NativeMethods.GetWindowUnderMouse();
            if (_windowUnderCursor == null)
            {
                _windowUnderCursor = new WindowInfo(windowUnderCursor);
            }

            if (IsVisualFeedbackWindow(windowUnderCursor))
            {
                // if the window under the cursor is the feedback window, just ignore it.
                return;
            }

            if (windowUnderCursor != _windowUnderCursor.HWnd)
            {
                // the window under the cursor has changed

                RemoveVisualFeedback();
                _windowUnderCursor = new WindowInfo(windowUnderCursor);
                if (_windowUnderCursor.IsValidProcess)
                {
                    ShowVisualFeedback();
                }
            }

            UpdateFeedbackWindowPosition();
        }
示例#7
0
 private void StartSnoopTargetsSearch()
 {
     CaptureMouse();
     IsDragging = true;
     Cursor = _crosshairsCursor;
     snoopCrosshairsImage.Visibility = Visibility.Hidden;
     _windowUnderCursor = null;
 }