comparison dep/animone/src/win/win32.cc @ 337:a7d4e5107531

dep/animone: REFACTOR ALL THE THINGS 1: animone now has its own syntax divergent from anisthesia, making different platforms actually have their own sections 2: process names in animone are now called `comm' (this will probably break things). this is what its called in bsd/linux so I'm just going to use it everywhere 3: the X11 code now checks for the existence of a UTF-8 window title and passes it if available 4: ANYTHING THATS NOT LINUX IS 100% UNTESTED AND CAN AND WILL BREAK! I still actually need to test the bsd code. to be honest I'm probably going to move all of the bsds into separate files because they're all essentially different operating systems at this point
author Paper <paper@paper.us.eu.org>
date Wed, 19 Jun 2024 12:51:15 -0400
parents b1f625b0227c
children adb79bdde329
comparison
equal deleted inserted replaced
336:d260549151d6 337:a7d4e5107531
64 } 64 }
65 65
66 static bool VerifyClassName(const std::wstring& name) { 66 static bool VerifyClassName(const std::wstring& name) {
67 static const std::set<std::wstring> invalid_names = { 67 static const std::set<std::wstring> invalid_names = {
68 // System classes 68 // System classes
69 L"#32770", // Dialog box 69 "#32770", // Dialog box
70 L"CabinetWClass", // Windows Explorer 70 "CabinetWClass", // Windows Explorer
71 L"ComboLBox", 71 "ComboLBox",
72 L"DDEMLEvent", 72 "DDEMLEvent",
73 L"DDEMLMom", 73 "DDEMLMom",
74 L"DirectUIHWND", 74 "DirectUIHWND",
75 L"GDI+ Hook Window Class", 75 "GDI+ Hook Window Class",
76 L"IME", 76 "IME",
77 L"Internet Explorer_Hidden", 77 "Internet Explorer_Hidden",
78 L"MSCTFIME UI", 78 "MSCTFIME UI",
79 L"tooltips_class32", 79 "tooltips_class32",
80 };
81
82 return !name.empty() && !invalid_names.count(name);
83 }
84
85 static bool VerifyProcessPath(const std::wstring& path) {
86 return !path.empty() && !IsSystemDirectory(path);
87 }
88
89 static bool VerifyProcessFileName(const std::wstring& name) {
90 static const std::set<std::wstring> invalid_names = {
91 // System files
92 L"explorer", // Windows Explorer
93 L"taskeng", // Task Scheduler Engine
94 L"taskhost", // Host Process for Windows Tasks
95 L"taskhostex", // Host Process for Windows Tasks
96 L"Taskmgr", // Task Manager
97 }; 80 };
98 81
99 return !name.empty() && !invalid_names.count(name); 82 return !name.empty() && !invalid_names.count(name);
100 } 83 }
101 84
107 90
108 if (!VerifyWindowStyle(hwnd)) 91 if (!VerifyWindowStyle(hwnd))
109 return TRUE; 92 return TRUE;
110 93
111 Window window; 94 Window window;
95 window.platform = WindowPlatform::Win32;
112 window.id = static_cast<unsigned int>(reinterpret_cast<ULONG_PTR>(hwnd)); 96 window.id = static_cast<unsigned int>(reinterpret_cast<ULONG_PTR>(hwnd));
113 window.text = ToUtf8String(GetWindowText(hwnd)); 97 window.text = ToUtf8String(GetWindowText(hwnd));
114 98 window.class_name = ToUtf8String(GetWindowClassName(hwnd));
115 { 99 if (!VerifyClassName(window.class_name))
116 std::wstring class_name = GetWindowClassName(hwnd); 100 return TRUE;
117 window.class_name = ToUtf8String(class_name);
118 if (!VerifyClassName(class_name))
119 return TRUE;
120 }
121 101
122 Process process; 102 Process process;
103 process.platform = ExecutablePlatform::Win32;
123 process.pid = GetWindowProcessId(hwnd); 104 process.pid = GetWindowProcessId(hwnd);
124 GetProcessName(process.pid, process.name); 105 GetProcessName(process.pid, process.comm);
125 106
126 auto& window_proc = *reinterpret_cast<window_proc_t*>(param); 107 auto& window_proc = *reinterpret_cast<window_proc_t*>(param);
127 if (!window_proc(process, window)) 108 if (!window_proc(process, window))
128 return FALSE; 109 return FALSE;
129 110