CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2005
    Posts
    42

    Talking Enumerate threads in process

    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?

  2. #2
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: Enumerate threads in process


  3. #3
    Join Date
    Feb 2005
    Posts
    42

    Re: Enumerate threads in process

    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?

  4. #4
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: Enumerate threads in process

    Quote Originally Posted by ZwOOp
    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

  5. #5
    Join Date
    Feb 2005
    Posts
    42

    Re: Enumerate threads in process

    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?

  6. #6
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: Enumerate threads in process

    Quote Originally Posted by ZwOOp
    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

  7. #7
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Enumerate threads in process

    Quote Originally Posted by ZwOOp
    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.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured