| 1182 | } |
| 1183 | |
| 1184 | bool IsConsoleWindow(HWND hWnd) |
| 1185 | { |
| 1186 | wchar_t szClass[64] = L""; |
| 1187 | |
| 1188 | if (!hWnd) |
| 1189 | return false; |
| 1190 | if (!GetClassName(hWnd, szClass, countof(szClass))) |
| 1191 | return false; |
| 1192 | if (!IsConsoleClass(szClass)) |
| 1193 | return false; |
| 1194 | |
| 1195 | // But when process is hooked, GetConsoleClass will return "proper" name |
| 1196 | // even if hWnd points to our VirtualConsole |
| 1197 | |
| 1198 | // RealConsole handle is stored in the Window DATA |
| 1199 | wchar_t szClassPtr[64] = L""; |
| 1200 | HWND h = (HWND)GetWindowLongPtr(hWnd, WindowLongDCWnd_ConWnd); |
| 1201 | if (h && (h != hWnd) && IsWindow(h)) |
| 1202 | { |
| 1203 | if (GetClassName(h, szClassPtr, countof(szClassPtr))) |
| 1204 | { |
| 1205 | if (IsConsoleClass(szClassPtr)) |
| 1206 | { |
| 1207 | _ASSERTE(FALSE && "RealConsole handle was not retrieved properly!"); |
| 1208 | return false; |
| 1209 | } |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | // Well, it's a RealConsole |
| 1214 | return true; |
| 1215 | } |
| 1216 | |
| 1217 | bool IsPseudoConsoleWindow(HWND hWnd) |
| 1218 | { |
no test coverage detected