コード例 #1
0
        internal WindowInstance(int ProcessID, bool IsAdminProcess, bool Is64bit, WindowGDI GDI)
        {
            this.ProcessID      = ProcessID;
            this.IsAdminProcess = IsAdminProcess;
            this.Is64bit        = Is64bit;
            this.GDI            = GDI;

            AsyncConstruction();
        }
コード例 #2
0
        static void AddWindow(Process p, bool delay = false, bool isRetry = false)
        {
            Task.Run(async() =>
            {
                if (delay)
                {
                    await Task.Delay(TimeSpan.FromSeconds(4D));
                }

                try
                {
                    if (!Windows.Any(x => x.ProcessID.Equals(p.Id)) && !Blacklist.Contains(p.ProcessName.ToLower()))
                    {
                        WindowGDI GDI = WindowGDI.None;

                        ProcessModule[] modules = new ProcessModule[p.Modules.Count];
                        p.Modules.CopyTo(modules, 0);

                        bool IsDirectX = modules.Any(x => x.FileName.ToLower().Contains("d3d"));
                        bool IsOpenGL  = modules.Any(x => x.FileName.ToLower().Contains("opengl32"));

                        if (IsDirectX && IsOpenGL)
                        {
                            GDI = WindowGDI.Hybrid;
                        }
                        else if (IsDirectX && !IsOpenGL)
                        {
                            GDI = WindowGDI.DirectX;
                        }
                        else if (!IsDirectX && IsOpenGL)
                        {
                            GDI = WindowGDI.OpenGL;
                        }
                        // Not sure why this doesnt work - Vulkan shows no DLL presence?
                        else if (modules.Any(x => x.FileName.ToLower().Contains("vulkan")))
                        {
                            GDI = WindowGDI.Vulkan;
                        }

                        if (WinAPI.IsWindow(p.MainWindowHandle))
                        {
                            Windows.Add(new WindowInstance(p.Id, UAC.IsProcessElevated(p.Handle), ProcessUtils.IsInWin64Emulator(p), GDI));
                            Logger.LogInfo("Adding Process with Window -> '" + p.MainWindowTitle + "' : [" + p.ProcessName + " | " + p.Id + "]");
                        }
                    }
                }
                catch (Win32Exception)
                {
                    Logger.LogError("Current iterated process is inaccessible! [PASS]");
                    return;
                }
                catch (InvalidOperationException e)
                {
                    Logger.LogWarn("Detected process that closed immediatly [RETRY]");
                    Retry();
                }

                void Retry()
                {
                    if (RetriesLeft != 0)
                    {
                        if (RetriesLeft == MaxRetries || isRetry)
                        {
                            RetriesLeft--;
                        }
                        p.Refresh();
                        AddWindow(p, delay, true);
                    }
                    else
                    {
                        RetriesLeft = MaxRetries;
                    }
                }
            });
        }