Results 1 to 28 of 28

Thread: Immediate Window ... a weird animal

  1. #1

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    8,716

    Immediate Window ... a weird animal

    That IDE Immediate window is a weird animal. I subclassed every window (and all their children) in the IDE, and then executed the following:

    Code:
    Private Sub Form_Click()
        Debug.Print "asdf"
    End Sub
    When the form is clicked, the only Windows messages going through the message pump are SBM_SETSCROLLINFO and WM_CTLCOLORSCROLLBAR. (Well, I isolated out WM_GETTEXTLENGTH and WM_GETTEXT, as those seem to go on perpetually for a variety of windows.) But there's certainly no WM_SETTEXT.

    I know that Immediate window is basically a full-blown VB interpreter, as well as having awareness of the current scope of the active VB project. But apparently, it does most (if not all) of its operations outside the use of standard Windows libraries.

    I thought I'd just grab the text that was in the Immediate window, but I'm finding that virtually impossible (short of some SendKeys gymnastics and using the clipboard, which I'm not going to do).
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,660

    Re: Immediate Window ... a weird animal

    Why do you want to retrieve the immediate window's content? Perhaps there's another way of accomplishing what you want without it.

    Which tools did you use to scan for messages? Perhaps figuring out which dll is responsible for the immediate window and decompiling it would work, but that is something I found to be easier said than done.

  3. #3

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    8,716

    Re: Immediate Window ... a weird animal

    Quote Originally Posted by Peter Swinkels View Post
    Why do you want to retrieve the immediate window's content? Perhaps there's another way of accomplishing what you want without it.

    Which tools did you use to scan for messages? Perhaps figuring out which dll is responsible for the immediate window and decompiling it would work, but that is something I found to be easier said than done.
    I want to because I'd like to have a single module (could be a Class) that captures all the output from Debug.Print. The Trick posted a way to do it, but it was over my head, so I thought I'd just subclass the Immediate window. But that was to no avail. I thought maybe there was some hidden window, but there doesn't seem to be. It's apparently just all done outside the Windows message pump.

    Which tools did I use to scan for messages? None. I just subclassed every single window that reported the VB6 IDE's ProcessID, and spewed out all the messages to an external reporter. As an FYI, I just stuffed them all in a Collection, and then un-subclassed them when the program was exiting, to keep the IDE from crashing. I could post all of that, but it'd take a bit, as it's two separate programs (the subclassing program, and the external reporter program, both written by me).

    Also, I went through all the typical VB6 related DLLs and examined the API entry-point names. Nothing even sounded like "EbOutputToImmediate" which was what I was hoping to find.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  4. #4
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,660

    Re: Immediate Window ... a weird animal

    Why did you make your own subclassing program when vb6 comes with Microsoft Spy++? I tried it, and detects loads of messages. Unfortunately none are related to editing the immediate window's contents. I am seriously wondering how they implemented that thing atm.

  5. #5

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    8,716

    Re: Immediate Window ... a weird animal

    Quote Originally Posted by Peter Swinkels View Post
    Why did you make your own subclassing program when vb6 comes with Microsoft Spy++? I tried it, and detects loads of messages. Unfortunately none are related to editing the immediate window's contents. I am seriously wondering how they implemented that thing atm.
    I actually checked with Spy++ before I wrote my own. But Spy++ isn't going to catch any hidden windows, or redirections that the IDE may be doing. And, it was no biggie to write my own. I just took code I had for finding the IDE's main window (or Immediate window, or Project Explorer window) and took out the specific checks, returning an array of hWnd handles of every IDE handle (and then also did that for all the children of each), and subclassed them all, spewing the messages out to another "reporting" program (actually, my Persistent Debug program).

    But, as stated, it revealed nothing about how that Immediate window is receiving the output from a simple Debug.Print "asdf".
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  6. #6
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,660

    Re: Immediate Window ... a weird animal

    fyi: In my case Spy++ had no trouble finding the Immediate window. So something else than what Spy++, your program or similar does is needed. I have no idea what however.

  7. #7

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    8,716

    Re: Immediate Window ... a weird animal

    Peter, your Spy++ did not see any Windows messages coming onto the Immediate window when you do something like Debug.Print "asdf". And that's all I said! *shakes head*
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  8. #8
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,660

    Re: Immediate Window ... a weird animal

    In short, scanning for window messages is pointless. Another solution is required.

  9. #9

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    8,716

    Re: Immediate Window ... a weird animal

    Quote Originally Posted by Peter Swinkels View Post
    In short, scanning for window messages is pointless. Another solution is required.
    Yes, precisely. The whole point of this thread ... and just wondering if anyone has any insights on what such a solution would be.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  10. #10
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,660

    Re: Immediate Window ... a weird animal

    You should try a specialized forum. This question must be too technical. Otherwise others would have replied by now.

  11. #11

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    8,716

    Re: Immediate Window ... a weird animal

    Peter, it's all good. Yeah, it is technical, but there is an answer out there. Whether anyone knows the answer or not is a question. But, a detailed disassembly of the responsible code would reveal the answer. I'm certainly not up for that though. I just thought I'd ask.

    Also, it's not something I absolutely have to have. It's just something I was exploring.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  12. #12

  13. #13
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    848

    Re: Immediate Window ... a weird animal

    You might be able to wack the vb parsers internal name of the debug object so that your own debug.print ends up being the one which gets resolved ?

    Nevermind, not sure how to dynamically find the dwin pointer for hook through. Hard coded offset would be easy but limited in version
    Last edited by dz32; Nov 6th, 2022 at 08:32 PM.

  14. #14
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,660

    Re: Immediate Window ... a weird animal

    @elroy, I know there's no problem. I am just fascinated by it as well. I know the feeling of wanting to just find out how a piece of software works and just being stuck. It's frustrating.

    So you tried disassembling as well? Too bad, otherwise I would have suggested using PE Explorer.

  15. #15
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    848

    Re: Immediate Window ... a weird animal

    well it was pretty easy to break the IDE support for the debug. object just with a string overwrite.
    I havent been able to declare my own sub Print yet though.

    nope nevermind, even with debug. broken it wont find module named debug easier to just hook it
    and stay within the known
    Last edited by dz32; Nov 7th, 2022 at 10:33 AM.

  16. #16
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,660

    Re: Immediate Window ... a weird animal

    @Elroy:
    After playing with Spy++ compatability settings and making them identical to the settings I use for vb6 it's detecting keyboard related messages when I type. If you need more info, I will see what I can provide, later. Ok?

    EDIT:
    Confirmed, right after changing the compatibility settings for Spy++ it stops working. Also here's a link to a Google Drive folder containining a few screenshots:
    https://drive.google.com/drive/folde...mh?usp=sharing
    Last edited by Peter Swinkels; Nov 9th, 2022 at 03:22 PM.

  17. #17

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    8,716

    Re: Immediate Window ... a weird animal

    Sounds like y'all might be making some progress. As the title states, that Debug Window is a weird animal. I really think it all has to do with the fact that it's a full interpreter (and not just a place to dump messages, as we often use it for).
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  18. #18
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,660

    Re: Immediate Window ... a weird animal

    What do you mean some progress? Perhaps you can use the same kind of API's as used by Microsoft Narrator to retrieve text in the Immediate window. Although it doesn't appear to detect the text.
    Last edited by Peter Swinkels; Nov 10th, 2022 at 05:14 AM.

  19. #19
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    3,705

    Re: Immediate Window ... a weird animal

    Does Microsoft Narrator get the Immediate window caption ("Immediate"), but not that actual text?

    I was investigating using accessibility APIs to read it and I could get the caption but not the text.

  20. #20
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,660

    Re: Immediate Window ... a weird animal

    It detects the caption but not the actual text inside it.

  21. #21
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    3,705

    Re: Immediate Window ... a weird animal

    Yeah it's probably using accessibility APIs too then.

    For some reason it doesn't provide a value for IAccessible->accValue, even though it provides the caption in accName. The children listed aren't actual children, just unrelated windows, so that's going to be a dead end.

  22. #22
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    848

    Re: Immediate Window ... a weird animal

    What was that commercial addin that added code folding and red squiggles and crazy features to the vb editor windows? Always wondered how they did that. Maybe the replaced the vbawindow class entirely with thier own editor component ? Might be a lead anyway they obviously figured out some magic . Does rubberduck have any similar tricks ?

  23. #23
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    3,705

    Re: Immediate Window ... a weird animal

    I've never seen an addin like that. I have Axtools CodeSMART which has a ton of fancy features like drawing lines connecting If/End If and similar and buttons placed in code that jump to start/end of function or block, and a history panel that's just awesome, but not red squiggles and code folding.

    Name:  Codesmart1.jpg
Views: 93
Size:  110.6 KB

  24. #24
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    848

    Re: Immediate Window ... a weird animal

    That’s probably what I was thinking of. Does a window spy show the class name as vbawindow with a wndproc in vba6.dll?

  25. #25
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    3,705

    Re: Immediate Window ... a weird animal

    It's a VBAWindow yeah I just have Spy++ though and don't know how to find the wndproc module... it reports the owning process/thread as vb6.exe. What tool do you use to trace the wndproc?

    ProcessHacker identifies the owning thread's start address as vb6.exe!VB_CALLBACK_REVOKE_+0x18b30

  26. #26
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    848

    Re: Immediate Window ... a weird animal

    to see the wndproc you can attach ollydbg native debugger to the vb6.exe process

    view->windows then find the immediate window in the list the clsproc is the target

    Windows, item 76
    Handle=K00290798
    Title=Immediate
    Parent=002C0642
    Style=54000000 WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE
    Thread=Main
    ClsProc=00483E2D VB6.00483E2D
    Class=VbaWindow

    They probably use GetWindowLong GWL_WNDPROC behind the scenes to get it, I should add that the window spy app I use

    Added: https://github.com/dzzie/tools/tree/master/winhack
    Last edited by dz32; Nov 10th, 2022 at 06:41 PM.

  27. #27

  28. #28
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    848

    Re: Immediate Window ... a weird animal

    it must be subclassed, dont know how to enumerate a subclass chain though
    Last edited by dz32; Nov 10th, 2022 at 09:43 PM.

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