Is there a way to enumerate handles?

This is a discussion on Is there a way to enumerate handles? within the Windows Programming forums, part of the Platform Specific Boards category; I have a piece of code that is behaving badly. Unfortunately I didnt write it and I dont have access ...

  1. #1
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189

    Is there a way to enumerate handles?

    I have a piece of code that is behaving badly. Unfortunately I didnt write it and I dont have access to the source code, just the OBJ. The problem is that this code is leaking handles and I need to close them post facto. Is there a method for enumerating the allocated handles so that I can check their state and close them if they are signalled?
    Last edited by abachler; 10-29-2007 at 12:42 PM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    sysinternals.com have tools that "dig around in the kernel", such as "Process Explorer". I'm not sure if this is:
    1. exactly what you want
    2. roughly what you want
    3. not at all what you want

    But I think it's worth getting for the odd occasion when some application says "I can't open <filename> because it's locked", and it turns out that some cruddy app has that file open - you can FORCE close the file from Process Explorer.

    You can also look at all sorts of handles in it, so it may help you.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Interesting, but Ill have to go with option 3. What I need is a way to programmatically enumerate the handles, so I can close them from my application.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  4. #4
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    What I need is a way to programmatically enumerate the handles
    You'll have to use the undocumented (NT)ZwQuerySystemInformation and (NT)ZWQueryObject functions.

  5. #5
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    thx
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  6. #6
    Registered User
    Join Date
    Apr 2007
    Posts
    137
    complete code posted on news://comp.os.ms-windows.programmer.win32
    a long time ago...

  7. #7
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    ah usenet, those were the days.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with DB handles
    By pokks in forum C Programming
    Replies: 4
    Last Post: 01-04-2006, 11:06 AM
  2. organizing window handles
    By FOOTOO in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:53 PM
  3. Handles to visible programs
    By Snip in forum Windows Programming
    Replies: 3
    Last Post: 03-26-2005, 07:52 PM
  4. [code] Enumerate IE instances and retrieve interfaces.
    By anonytmouse in forum Windows Programming
    Replies: 1
    Last Post: 05-05-2004, 08:01 AM
  5. Enumerate type
    By dv007 in forum C Programming
    Replies: 8
    Last Post: 07-15-2002, 03:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21