Click to See Complete Forum and Search --> : Enumerate threads in process
ZwOOp
February 7th, 2005, 04:39 AM
I'm using CreateProcess to start an external application that I have no code for. The CreateProcess function provides me whit a PROCESS_INFORMATION structure so i get the process id and handle for it. I now want to get the thredID for all the threads that runs in that process.
Any tipps how i can do this?
Mick
February 7th, 2005, 04:42 AM
Tool Help API. (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/taking_a_snapshot_and_viewing_processes.asp)
ZwOOp
February 7th, 2005, 06:25 AM
He he ok thanks. What is this Tool Help Functions libary? Is it something deliverd whit windows like the standard API or is it something else?
Mick
February 7th, 2005, 06:30 AM
He he ok thanks. What is this Tool Help Functions libary? Is it something deliverd whit windows like the standard API or is it something else?
It is part of the Platform SDK [the latests headers/libs for the WINAPI] which you can download from msdn.microsoft.com. Depending on your compiler you may have some functionality included but the SDk contains the latests and greatest :)
ZwOOp
February 7th, 2005, 07:22 AM
Ok now when i have all the threads running under a specific process I whant to set a hook for every thread. That is i want to set a "process wide" hook.
The hook i am gonig to install on every thread is WH_CALLWNDPROC, in this hook i have to specify the modul and function for the messages to be handled in what i now wonder is if the threads in the same process is gonig to share the dll accosiated whit the hook or if they are going to load there own instace of it???
In general how will it work, do i need some syncronization or?
Any idde on how to do this "process wide" hook?
Mick
February 7th, 2005, 07:30 AM
Ok now when i have all the threads running under a specific process I whant to set a hook for every thread. That is i want to set a "process wide" hook.
The hook i am gonig to install on every thread is WH_CALLWNDPROC, in this hook i have to specify the modul and function for the messages to be handled in what i now wonder is if the threads in the same process is gonig to share the dll accosiated whit the hook or if they are going to load there own instace of it???
In general how will it work, do i need some syncronization or?
Any idde on how to do this "process wide" hook?
Images [ie: dlls] are mapped in the process memory space.
Read (http://www.thecodeproject.com/system/hooksys.asp)
JohnCz
February 7th, 2005, 04:51 PM
Ok now when i have all the threads running under a specific process I whant to set a hook for every thread. That is i want to set a "process wide" hook.
First of all, if you want to monitor threads for particular process that is not yours, you would have to setup hooks for each thread in that process, or globally hook all threads running in the same desktop. That means your hook must be global.
ToolHelp library was provided for Windows 9x. Windows 9x did not have tools that retrieving wide system info.
Windows NT (since NT 4) has Performance Monitoring tool that resides in Pdh.dll. see MSDN for Performance Monitoring Functions topic.
This set of Performance Monitoring APIs will allow you to retrieve thread IDs running in given process by accessing information about performance counters. It is not easy though.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.