Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Enumerating GDI Handles in (own) process. [modified]

Enumerating GDI Handles in (own) process. [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelpquestion
11 Posts 6 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Iain Clarke Warrior Programmer
    wrote on last edited by
    #1

    Modification: I didn't mention that I'm working under W7! Morning all! I have a GDI leak in a program that I'm trying to track down. I've found various programs (GDIView, MemoryValidator, DPus, Deleaker), and none of them do what I want (though they have been useful to narrow the issue down). What I want to do, is to be able to get a list of all the GDI handles that exist in my process - then I can make a before / after comparison to see which ones should be around, and which not. The nearest functions I can find are GetObject, and GetObjectType - but to use those I have to loop around 4 billion times, and I get a lot of false positives - not to mention, it takes a LONG time to do 4 billion calls in an out of kernel mode. There's also GetGuiResources, but that just gives a total. Where's my EnumGuiResourcesEx function!? Any hints? I've had a look at DbgHelp.dll too, and it does not seem useful in this case. Here's hoping y'all can say "Oh, just look at the frobble sdk - it's perfect!" Iain.

    I have now moved to Sweden for love (awwww).

    modified on Tuesday, May 25, 2010 7:46 AM

    CPalliniC P A S C 5 Replies Last reply
    0
    • I Iain Clarke Warrior Programmer

      Modification: I didn't mention that I'm working under W7! Morning all! I have a GDI leak in a program that I'm trying to track down. I've found various programs (GDIView, MemoryValidator, DPus, Deleaker), and none of them do what I want (though they have been useful to narrow the issue down). What I want to do, is to be able to get a list of all the GDI handles that exist in my process - then I can make a before / after comparison to see which ones should be around, and which not. The nearest functions I can find are GetObject, and GetObjectType - but to use those I have to loop around 4 billion times, and I get a lot of false positives - not to mention, it takes a LONG time to do 4 billion calls in an out of kernel mode. There's also GetGuiResources, but that just gives a total. Where's my EnumGuiResourcesEx function!? Any hints? I've had a look at DbgHelp.dll too, and it does not seem useful in this case. Here's hoping y'all can say "Oh, just look at the frobble sdk - it's perfect!" Iain.

      I have now moved to Sweden for love (awwww).

      modified on Tuesday, May 25, 2010 7:46 AM

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      I don't know if you have already checked out this [^] (moreover I don't know if it might be helpful, as it is a bit outdated). :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      I 1 Reply Last reply
      0
      • CPalliniC CPallini

        I don't know if you have already checked out this [^] (moreover I don't know if it might be helpful, as it is a bit outdated). :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        I Offline
        I Offline
        Iain Clarke Warrior Programmer
        wrote on last edited by
        #3

        Yes, I had... But it's out of date now. I did miss out a vital fact that I'm working under Windows 7. Thanks for trying though! Iain.

        I have now moved to Sweden for love (awwww).

        1 Reply Last reply
        0
        • I Iain Clarke Warrior Programmer

          Modification: I didn't mention that I'm working under W7! Morning all! I have a GDI leak in a program that I'm trying to track down. I've found various programs (GDIView, MemoryValidator, DPus, Deleaker), and none of them do what I want (though they have been useful to narrow the issue down). What I want to do, is to be able to get a list of all the GDI handles that exist in my process - then I can make a before / after comparison to see which ones should be around, and which not. The nearest functions I can find are GetObject, and GetObjectType - but to use those I have to loop around 4 billion times, and I get a lot of false positives - not to mention, it takes a LONG time to do 4 billion calls in an out of kernel mode. There's also GetGuiResources, but that just gives a total. Where's my EnumGuiResourcesEx function!? Any hints? I've had a look at DbgHelp.dll too, and it does not seem useful in this case. Here's hoping y'all can say "Oh, just look at the frobble sdk - it's perfect!" Iain.

          I have now moved to Sweden for love (awwww).

          modified on Tuesday, May 25, 2010 7:46 AM

          P Offline
          P Offline
          Peter_in_2780
          wrote on last edited by
          #4

          This might be completely useless, but Sysinternals do a utility called, IIRC, Handle. I think you can run it against a single process. Probably shows way too much, but filtering the output sounds a lot less painful than 2^32. You might need to cobble up some way of suspending your process at appropriate before/afters. Good luck! Leaks are the original and best PITA.

          Software rusts. Simon Stephenson, ca 1994.

          I 1 Reply Last reply
          0
          • P Peter_in_2780

            This might be completely useless, but Sysinternals do a utility called, IIRC, Handle. I think you can run it against a single process. Probably shows way too much, but filtering the output sounds a lot less painful than 2^32. You might need to cobble up some way of suspending your process at appropriate before/afters. Good luck! Leaks are the original and best PITA.

            Software rusts. Simon Stephenson, ca 1994.

            I Offline
            I Offline
            Iain Clarke Warrior Programmer
            wrote on last edited by
            #5

            I thought I looked at Handle - and on a further check, I had. Sadly, it's great for events, file handles, etc - but completely skips gdi handles. I checked out devenv.exe. I can't believe VS2008 doesn't have any bitmap objects open for it's toolbars... So, nul point, but keep trying! Iain. ps. I didn't think this would be hard either, but...

            I have now moved to Sweden for love (awwww).

            1 Reply Last reply
            0
            • I Iain Clarke Warrior Programmer

              Modification: I didn't mention that I'm working under W7! Morning all! I have a GDI leak in a program that I'm trying to track down. I've found various programs (GDIView, MemoryValidator, DPus, Deleaker), and none of them do what I want (though they have been useful to narrow the issue down). What I want to do, is to be able to get a list of all the GDI handles that exist in my process - then I can make a before / after comparison to see which ones should be around, and which not. The nearest functions I can find are GetObject, and GetObjectType - but to use those I have to loop around 4 billion times, and I get a lot of false positives - not to mention, it takes a LONG time to do 4 billion calls in an out of kernel mode. There's also GetGuiResources, but that just gives a total. Where's my EnumGuiResourcesEx function!? Any hints? I've had a look at DbgHelp.dll too, and it does not seem useful in this case. Here's hoping y'all can say "Oh, just look at the frobble sdk - it's perfect!" Iain.

              I have now moved to Sweden for love (awwww).

              modified on Tuesday, May 25, 2010 7:46 AM

              A Offline
              A Offline
              Aescleal
              wrote on last edited by
              #6

              There are probably shed loads of functions to hook, but could you hook the various Creates and Deletes for GDI objects and keep a count of what's using what that way? There was a time when everyone under the sun was writing API hooks so there are plenty of implementations out there for 32 bit code at least. Cheers, Ash

              I 1 Reply Last reply
              0
              • A Aescleal

                There are probably shed loads of functions to hook, but could you hook the various Creates and Deletes for GDI objects and keep a count of what's using what that way? There was a time when everyone under the sun was writing API hooks so there are plenty of implementations out there for 32 bit code at least. Cheers, Ash

                I Offline
                I Offline
                Iain Clarke Warrior Programmer
                wrote on last edited by
                #7

                I think this will end up being the way I go... This is for my day job, but maybe I'll end up with an article out of it! This looks like a good start: API Hooking with MS Detours[^] Thanks, Iain.

                I have now moved to Sweden for love (awwww).

                1 Reply Last reply
                0
                • I Iain Clarke Warrior Programmer

                  Modification: I didn't mention that I'm working under W7! Morning all! I have a GDI leak in a program that I'm trying to track down. I've found various programs (GDIView, MemoryValidator, DPus, Deleaker), and none of them do what I want (though they have been useful to narrow the issue down). What I want to do, is to be able to get a list of all the GDI handles that exist in my process - then I can make a before / after comparison to see which ones should be around, and which not. The nearest functions I can find are GetObject, and GetObjectType - but to use those I have to loop around 4 billion times, and I get a lot of false positives - not to mention, it takes a LONG time to do 4 billion calls in an out of kernel mode. There's also GetGuiResources, but that just gives a total. Where's my EnumGuiResourcesEx function!? Any hints? I've had a look at DbgHelp.dll too, and it does not seem useful in this case. Here's hoping y'all can say "Oh, just look at the frobble sdk - it's perfect!" Iain.

                  I have now moved to Sweden for love (awwww).

                  modified on Tuesday, May 25, 2010 7:46 AM

                  S Offline
                  S Offline
                  sashoalm
                  wrote on last edited by
                  #8

                  hope this[^] helps oops, didn't refresh the page, now i saw you already had this answer, sorry

                  There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

                  I 1 Reply Last reply
                  0
                  • S sashoalm

                    hope this[^] helps oops, didn't refresh the page, now i saw you already had this answer, sorry

                    There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

                    I Offline
                    I Offline
                    Iain Clarke Warrior Programmer
                    wrote on last edited by
                    #9

                    sashoalm wrote:

                    oops, didn't refresh the page, now i saw you already had this answer, sorry

                    I've *never* done that.... erm... Thanks for the thought though! Iain.

                    I have now moved to Sweden for love (awwww).

                    1 Reply Last reply
                    0
                    • I Iain Clarke Warrior Programmer

                      Modification: I didn't mention that I'm working under W7! Morning all! I have a GDI leak in a program that I'm trying to track down. I've found various programs (GDIView, MemoryValidator, DPus, Deleaker), and none of them do what I want (though they have been useful to narrow the issue down). What I want to do, is to be able to get a list of all the GDI handles that exist in my process - then I can make a before / after comparison to see which ones should be around, and which not. The nearest functions I can find are GetObject, and GetObjectType - but to use those I have to loop around 4 billion times, and I get a lot of false positives - not to mention, it takes a LONG time to do 4 billion calls in an out of kernel mode. There's also GetGuiResources, but that just gives a total. Where's my EnumGuiResourcesEx function!? Any hints? I've had a look at DbgHelp.dll too, and it does not seem useful in this case. Here's hoping y'all can say "Oh, just look at the frobble sdk - it's perfect!" Iain.

                      I have now moved to Sweden for love (awwww).

                      modified on Tuesday, May 25, 2010 7:46 AM

                      C Offline
                      C Offline
                      Code o mat
                      wrote on last edited by
                      #10

                      Hey! Don't know if this question is still actual or not (better late then never i guess) but i found this: http://www.codeguru.com/forum/archive/index.php/t-176997.html[^], they talk about a way to query all the handles of a process and their "types", don't know if this can help you at all or not, maybe it doesn't even include GDI handles, didn't try it but i thought i share, perhaps it has some usefull info.

                      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Computers are evil, EVIL i tell you!! <

                      I 1 Reply Last reply
                      0
                      • C Code o mat

                        Hey! Don't know if this question is still actual or not (better late then never i guess) but i found this: http://www.codeguru.com/forum/archive/index.php/t-176997.html[^], they talk about a way to query all the handles of a process and their "types", don't know if this can help you at all or not, maybe it doesn't even include GDI handles, didn't try it but i thought i share, perhaps it has some usefull info.

                        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Computers are evil, EVIL i tell you!! <

                        I Offline
                        I Offline
                        Iain Clarke Warrior Programmer
                        wrote on last edited by
                        #11

                        Nice search, thanks. It does talk about the sysinternals utilities - and they skip over GDI handles, so I'm not overly optimistic. But trying it out has to be easier than writing my own hooking stuff! Thanks, Iain.

                        I have now moved to Sweden for love (awwww).

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups