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. Prevent from getting Window Handle

Prevent from getting Window Handle

Scheduled Pinned Locked Moved C / C++ / MFC
8 Posts 3 Posters 0 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.
  • N Offline
    N Offline
    NitramR
    wrote on last edited by
    #1

    Hi As far as I know it is possible for other applications to get a handle of the window from my application (e.g.: FindWindow), and then it is possible for this application to write into my window. Does anyone know a method to prevent this? Thanks in advance :confused:

    T N 2 Replies Last reply
    0
    • N NitramR

      Hi As far as I know it is possible for other applications to get a handle of the window from my application (e.g.: FindWindow), and then it is possible for this application to write into my window. Does anyone know a method to prevent this? Thanks in advance :confused:

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      It's not possible to hide a HWND. You may try to make FindWindow harder to use - for example, by generating class name randomly each time your program starts, but this doesn't give you 100% protection - it's possible to iterate over all windows in the system. BTW: What are you afraid of? Tomasz Sowinski -- http://www.shooltz.com

      N 1 Reply Last reply
      0
      • T Tomasz Sowinski

        It's not possible to hide a HWND. You may try to make FindWindow harder to use - for example, by generating class name randomly each time your program starts, but this doesn't give you 100% protection - it's possible to iterate over all windows in the system. BTW: What are you afraid of? Tomasz Sowinski -- http://www.shooltz.com

        N Offline
        N Offline
        NitramR
        wrote on last edited by
        #3

        I'm writing a high security digital signature ActiveX control. And I thought it would be bad if another program writes into my window and then the signer thinks he signs something different then he really signs. I try know with Win32 Hooks. I hope this helps.

        T 1 Reply Last reply
        0
        • N NitramR

          I'm writing a high security digital signature ActiveX control. And I thought it would be bad if another program writes into my window and then the signer thinks he signs something different then he really signs. I try know with Win32 Hooks. I hope this helps.

          T Offline
          T Offline
          Tomasz Sowinski
          wrote on last edited by
          #4

          What if another program displays its own window looking like yours? Assuming that users's machine is infected by worm or virus targeting your ActiveX, there's not much you can do. I'd keep a checksum (or even a verbatim copy) of displayed text somewhere. Even if this program writes its own text, you'd be able to detect data corruption. Tomasz Sowinski -- http://www.shooltz.com

          N 1 Reply Last reply
          0
          • T Tomasz Sowinski

            What if another program displays its own window looking like yours? Assuming that users's machine is infected by worm or virus targeting your ActiveX, there's not much you can do. I'd keep a checksum (or even a verbatim copy) of displayed text somewhere. Even if this program writes its own text, you'd be able to detect data corruption. Tomasz Sowinski -- http://www.shooltz.com

            N Offline
            N Offline
            NitramR
            wrote on last edited by
            #5

            The text is already secured through a hash value, so it can't be corrupted. But this other program is able to write into my window and the user sees something different than he signs! This other thing, with the virus looking like my ActiveX is a problem too. I thought I can do something in correspondence with the server programm to which the signed file is sended. Do you have any ideas? Martin

            S 1 Reply Last reply
            0
            • N NitramR

              The text is already secured through a hash value, so it can't be corrupted. But this other program is able to write into my window and the user sees something different than he signs! This other thing, with the virus looking like my ActiveX is a problem too. I thought I can do something in correspondence with the server programm to which the signed file is sended. Do you have any ideas? Martin

              S Offline
              S Offline
              Stephen Kellett
              wrote on last edited by
              #6

              Hello NitramR, Try this idea. I haven't checked it out, but it should work. There are a few different ways of acheiving the end result. 1a) System wide hook that hooks each process. This loads your spy DLL into their process when their process starts. 1b) Use CreateRemoteThread() to inject your DLL into the running process. You'll need a thread to watch for new processes and then inject your DLL into each new process. This is more complicated than a system wide hook, but acheives the same result. 2) Your DLL will then hook the Kernel/User/GDI/whatever DLL functions that you think are appropriate. In this case you'll want to be hooking User32 functions related to finding windows. In your hooks you'll let the function execute then examine the return value before returning. If the value indicates your window you'll overwrite the value to indicate failure. 3) Their program will search for the window and fail. There is info on hooking technique elsewhere on this site and also in MSJ/MSDN website/magazine. Caveats. -------- If they know which DLL you are loading they may be able to write code to hook LoadLibrary and LoadLibraryEx and prevent the library from loading dy diverting the function call and returning a library not loaded return code. Not hard to do. If they get their hooks in before you get your hooks in, you have lost the battle. Cheers Stephen Kellett -- C++/Java/Win NT/Unix variants Memory leaks/corruptions/performance/system problems. UK based. Problems with RSI/WRULD? Contact me for advice.

              1 Reply Last reply
              0
              • N NitramR

                Hi As far as I know it is possible for other applications to get a handle of the window from my application (e.g.: FindWindow), and then it is possible for this application to write into my window. Does anyone know a method to prevent this? Thanks in advance :confused:

                N Offline
                N Offline
                NitramR
                wrote on last edited by
                #7

                Ok guys I did some research on hooks and I'm know convinced that there is know solution for this problem. The only thing to do, in my opinion, is to warn the user and give him the responsibility to keep his computer free of viruses and stuff like that. Thanks anyway. X|

                N 1 Reply Last reply
                0
                • N NitramR

                  Ok guys I did some research on hooks and I'm know convinced that there is know solution for this problem. The only thing to do, in my opinion, is to warn the user and give him the responsibility to keep his computer free of viruses and stuff like that. Thanks anyway. X|

                  N Offline
                  N Offline
                  NitramR
                  wrote on last edited by
                  #8

                  There is a mistake in the previous message. Of course I meant: "I'm NOW convinced that there is NO solution for this problem." SPEED KILLS :eek:

                  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