| 311 | } |
| 312 | |
| 313 | void ProcessTrackerBackendWindows::checkProcess(qint64 pid) |
| 314 | { |
| 315 | GammaRay::ProcessTrackerInfo pinfo(pid); |
| 316 | |
| 317 | if (qt_NtQuerySystemInformation()) { |
| 318 | BOOL traced = false; |
| 319 | if (pid == QCoreApplication::applicationPid()) { |
| 320 | traced = IsDebuggerPresent(); |
| 321 | } else { |
| 322 | LocalHandlePtr processHandle(OpenProcess(READ_CONTROL | PROCESS_QUERY_INFORMATION | PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid)); // krazy:exclude=captruefalse |
| 323 | if (!CheckRemoteDebuggerPresent(processHandle.get(), &traced)) { |
| 324 | qWarning("Can not check remote debugger presence."); |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | pinfo.traced = traced; |
| 329 | |
| 330 | // There is no way getting a thread state using public api as i'm aware of... |
| 331 | /*{ |
| 332 | // Get threads status |
| 333 | HANDLE_UNIQUE_PTR threadsHandle(CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, pid)); |
| 334 | |
| 335 | if (threadsHandle.get() == INVALID_HANDLE_VALUE) { |
| 336 | Q_ASSERT(false); |
| 337 | return false; |
| 338 | } |
| 339 | |
| 340 | QVector<qint64> threadsId; |
| 341 | THREADENTRY32 te32; |
| 342 | |
| 343 | // Fill in the size of the structure before using it. |
| 344 | te32.dwSize = sizeof(THREADENTRY32); |
| 345 | |
| 346 | // Retrieve information about the first thread, and exit if unsuccessful |
| 347 | if (!Thread32First(threadsHandle.get(), &te32)) { |
| 348 | qWarning("Thread32First"); // Show cause of failure |
| 349 | return false; |
| 350 | } |
| 351 | |
| 352 | // Now walk the thread list of the system, and display information about each thread |
| 353 | // associated with the specified process |
| 354 | do { |
| 355 | if (te32.th32OwnerProcessID == pid) { |
| 356 | threadsId << te32.th32ThreadID; |
| 357 | } |
| 358 | } while (Thread32Next(threadsHandle.get(), &te32)); |
| 359 | }*/ |
| 360 | |
| 361 | // The only way to get threads state is using private stuff... |
| 362 | |
| 363 | // Get SYSTEM_PROCESS array |
| 364 | // This must run in a loop because in the mean time a new process may have started and we need |
| 365 | // more buffer than bufferNeededSize !! |
| 366 | LocalBuffer buffer(1000); |
| 367 | while (true) { |
| 368 | WIN_ERROR_ASSERT(buffer.isValid(), break); |
| 369 | |
| 370 | ULONG bufferNeededSize = 0; |