Exemplo n.º 1
0
        private static void InspectWindows10AppWindow(IntPtr hWnd, ICollection <IWindowEntry> windows, string className)
        {
            Log.Debug("- Found Window 10 App");

            // check if windows is not cloaked
            const int DWMWA_CLOAKED = 14;

            DwmGetWindowAttribute(hWnd, DWMWA_CLOAKED, out int cloaked, sizeof(int));
            if (cloaked != 0)
            {
                return;
            }

            var foundChildren = false;

            GetWindowThreadProcessId(hWnd, out uint processId);

            EnumChildWindows(hWnd, (childHWnd, lparam) =>
            {
                GetWindowThreadProcessId(childHWnd, out uint childProcessId);
                Log.Debug("  - Checking process: " + childProcessId);
                if (processId != childProcessId)
                {
                    var childClassName = GetClassName(hWnd);

                    var window = WindowEntryFactory.Create(childHWnd, childProcessId);
                    if (window.Title != null)
                    {
                        UpdateProcessName(window);

                        if (IsKnownWindows10Exception(window))
                        {
                            return(true);
                        }

                        //TODO: Windows 10 App Icons
                        // 1. Get the window.ProcessFileName
                        // 2. Look in the folder for AppManifest.xml
                        // 3. Look for Package/Properties/Logo
                        // 4. Load that file (should be a PNG)

                        windows.Add(window);
                        foundChildren = true;
                        LogDebugWindow("	- Found window: ", window, childClassName);
                    }
                }
                return(true);
            }, IntPtr.Zero);

            if (!foundChildren)
            {
                var window = WindowEntryFactory.Create(hWnd, processId);
                if (window.Title != null)
                {
                    window.ProcessName = "Windows 10 App";
                    windows.Add(window);
                    LogDebugWindow("	- No windows found: ", window, className);
                }
            }
        }
Exemplo n.º 2
0
        private static void InspectNormalWindow(IntPtr hWnd, int currentProcessId, ICollection <IWindowEntry> windows, string className)
        {
            if (!ClassEligibleForActivation(className))
            {
                return;
            }

            var window = WindowEntryFactory.Create(hWnd);

            if (IsKnownException(window))
            {
                return;
            }

            if (window.ProcessId == currentProcessId || window.Title == null)
            {
                return;
            }

            UpdateProcessName(window);
            windows.Add(window);
            LogDebugWindow("- Found normal window: ", window, className);
        }