Announcement

Collapse
No announcement yet.

Capture Gridviev/Listview text

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #21
    Found this

    MainDlg_OnKeyDown intercepts two keys: F5 refreshes the list view (i.e. populates it with some sample items), and DEL erases its content. Nothing ensures that the list view is stable at the moment of operations (i.e. you can press DEL during a list view update). You have to protect the list view on your own. Perhaps the best (and simplest) mechanism is to reflect the notifications (as the ON_NOTIFY_REFLECT does) to the list view, so the control will know how to operate on its data, styles, content etc. and how to avoid side effects or concurrent access.
    at

    List view sort on header click and showing 'No items' with 'More' tooltip


    It may be of some help although I don´t understand C
    Francisco J Castanedo
    Software Developer
    Distribuidora 3HP, C.A.
    [URL]http://www.distribuidora3hp.com[/URL]

    Comment


      #22
      well, right here....
      Code:
      CASE %LVN_GETDISPINFO
                                       ' Obtain the LV_DISPINFO pointer from CBLPARAM
                                       pLVDI = CBLPARAM
      
                                       'virtual ListView asks for Item text
                                       IF (@pLVDI.item.mask AND %LVIF_TEXT) THEN
                                           ' TELL ALL: 
      [COLOR="Red"]                                      @pLVDI.item.pszText = VARPTR(szName)[/COLOR]
      You tell Windows (or whomever is asking) what the text is for that row and column

      Y'all cannot tell ANYONE if you want it to remain a secret.
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


        #23
        Well then, how are you supposed to get the data into the listview?

        Nevertheless, since we want to protect the data that is already IN the listview control we must find ways to deceive the intruder.

        The first thing Listview Spy (and any other spy program) does is to identify the window that contains the listview: hDlgSource = FindWindow(BYVAL %NULL, zCaption) where zCaption MUST be supplied by the hacker (read from the screen is the primary way of obtaining the name).
        Replacing all empty spaces (CHR$(32)) with CHR$(160) in the Window or Dialog Caption helps confuse the intruder. CHR$(160) is the only other ASCII character I found to be shown as an empty space, just like CHR$(32). This little decepcion works as our first line of defense but is not enough.

        I tested it with Listview Spy (can´t recognize the window), NewSpy and Winspector (this two shows the name of the window but you see SPACES instead of CHR$(160))

        If there's a more thorough or refined spy-and-hack program, the hacker won´t ever know that we changed CHR$(32)s with CHR$(160)s, so let me see if I can find something else that might work.

        BTW, ANY help will be greatly appreciated.
        Last edited by Francisco Castanedo; 24 Jan 2009, 09:01 PM.
        Francisco J Castanedo
        Software Developer
        Distribuidora 3HP, C.A.
        [URL]http://www.distribuidora3hp.com[/URL]

        Comment


          #24
          >Well then, how are you supposed to get the data into the listview?

          You don't. You must use a VIRTUAL listview (LVS_OWNERDATA) and store the data "somewhere else."

          You must also completely draw the items and subitems yourself on NM_CUSTOMDRAW. ie, every response to the NM_CUSTOMDRAW notifications must be CDRF_SKIPDEFAULT.

          Here's how I do this (code edited )...

          Code:
                                         CASE %NM_CUSTOMDRAW    ' returns nmcd
          
                                             SELECT CASE AS LONG @plvu.LVCD.nmcd.dwDrawStage
          
                                                 CASE %CDDS_PREPAINT
                                                    'STDOUT "Got CDDS_PREPAINT"
                                                   ' tell Windows we want separate notify for each item
                                                     FUNCTION           = %CDRF_NOTIFYITEMDRAW
                                                     EXIT                 FUNCTION
          
                                                   ' we expect this message because we requested the NOTOFYITEMDRAW
                                                 CASE    %CDDS_ITEMPREPAINT
          
                                                     [' much edited here]
          
                                                      ' get the correct icon from the image list (or other source)
                                                     iImageIndex     = GetNodeImageIndex (BYVAL pNode)
                                                      ' draw the image with X offset by %IMAGE_WIDTH * depth
                                                     ImageList_Draw  _
                                                            hIl,_
                                                            iImageIndex, _                           ' image index
                                                            @plvu.lvcd.nmcd.hdc, _                   ' device context
                                                            R.nLeft + (%IMAGE_WIDTH*@pNode.Level), _ ' X
                                                            R.nTop, _                                ' Y
                                                            %ILD_NORMAL                              ' flags
          
                                                         ' add the text in the assigned area, with ellipses if necessary..
                                                     DrawText  @plvu.lvcd.nmcd.hdc, _
                                                              szText, _
                                                              lstrlen(szText), _
                                                              TextRect, _
                                                              %DT_NOPREFIX OR %DT_END_ELLIPSIS
          
                                                     ' and tell Windows the painting has been handled
                                                     FUNCTION         = %CDRF_SKIPDEFAULT
                                                     EXIT               FUNCTION
          
                                             END SELECT   ' of draw stage under NM_CUSTOMDRAW for VTV
          This example is from application with only one column, but the demo you looked at earlier shows you can also do this at the subitem level, completely drawing the subitem when dwDrawState = (%CDDS_ITEMPREPAINT OR %CDDS_SUBITEM) and returning CDRF_SKIPDEFAULT.

          That demo, you will note, saves the text with the control, it is NOT virtual listview; AND it tells Windows to handle the painting normally on the non-checkbox columns. For those non-checkbox columns, the text is stored with the item/subitem so there is no need to intercept WM_NOTIFY/LVN_GETDISPINFO (if it's even sent)

          MCM
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


            #25
            Ok Michael. I followed your lead but my knwoledge base is not as big as yours so I got to a point where I got stuck.

            I took a sample Virtual Listview program and modified it with the code you showed above. Only thing is I can´t seem to get it to work.

            I attached the code for you to review and fix (if you choose to do so, of course).

            I commented out all code I think is not relevant.

            ADDED LATER: GOT IT!. It´s working now. After adjusting some things, I finally made it work. I´ll throw Listview Spy at it and see what happens.

            I posted the working code instead.
            Attached Files
            Last edited by Francisco Castanedo; 25 Jan 2009, 02:20 PM.
            Francisco J Castanedo
            Software Developer
            Distribuidora 3HP, C.A.
            [URL]http://www.distribuidora3hp.com[/URL]

            Comment


              #26
              Well, after making a working virtual listview (just working enough to test) and having Listview Spy try to steal the text data, I must say that you were right Michael. Listview Spy couldn´t get the data out from the control.

              I now wonder if this is enough protection against other spyware?.

              If they all use the same method (allocating a virtual memory for the listview) then, for now, we are safe.


              I noticed that after drawing the text, the selected bar was missing. my question is if by using this method are we supposed to draw EVERYTHING in the lsitview?
              Francisco J Castanedo
              Software Developer
              Distribuidora 3HP, C.A.
              [URL]http://www.distribuidora3hp.com[/URL]

              Comment


                #27
                I noticed that after drawing the text, the selected bar was missing. my question is if by using this method are we supposed to draw EVERYTHING in the lsitview?
                Yes.

                The code which does this is in my post above, repeated here:
                Code:
                [' much edited here]
                I think I do pretty much the same thing I edited out above in the multiple-checkbox demo.

                But the key is here (from above, not from multi-checkbox demo):
                Code:
                 
                 CASE    %CDDS_ITEMPREPAINT
                               iSelRow     = @plvu.LVCD.nmcd.dwItemSpec  'which row to draw
                This tells you which row to draw. Later you can ..

                Code:
                   bSelected = (Listview_GetItemSTate (@plvu.nmhdr.HwndFrom, iSelRow, %LVIS_SELECTED) AND %LVIS_SELECTED)
                This tells you if this row is selected or not. If it's selected, you set the text color and background differently than if that row is not selected, and pass the appropriate parameters to FillRect (to erase previous text/image) and drawText (to set text color and the background color).

                MCM
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                  #28
                  I now wonder if this is enough protection against other spyware?.

                  If they all use the same method (allocating a virtual memory for the listview) then, for now, we are safe.
                  I personally cannot think of any way to get the text in a control other than asking for it. And if it does not answer?...

                  Hmm, that line has reminded me of the old Mickey and Sylvia song...

                  Oh, Listview?
                  And if he doesn't answer?

                  Oh, my sweet listview?
                  And if he still doesn't answer?

                  ....


                  MCM
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                    #29
                    Got it!. Thanks Michael.

                    Edite Out. Found the answer.

                    ---------------------------------------------

                    As they say: This is not a drill!!!.

                    I´m really turning all this to my app in order to defeat a spy program (which one, I don´t know) that is already been used to leech the data. We encrypt this data since is the real value of our software. Whomever is reading it, is already selling it in the black market. We want to stop this. It´ll take a couple of month (maybe less) for us to find out.

                    Whatever the outcome, I´ll let you know.

                    I just hope the listview behaves just the same without further re-writing.
                    But I suspect that M$ never intended that.
                    Last edited by Francisco Castanedo; 26 Jan 2009, 12:57 PM.
                    Francisco J Castanedo
                    Software Developer
                    Distribuidora 3HP, C.A.
                    [URL]http://www.distribuidora3hp.com[/URL]

                    Comment


                      #30
                      >As they say: This is not a drill!!!...that is already been used to leech the data.

                      Had I known that, I would have billed you.
                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment

                      Working...
                      X
                      😀
                      🥰
                      🤢
                      😎
                      😡
                      👍
                      👎