Results 1 to 34 of 34

Thread: [RESOLVED] Increase number of undos in VBIDE

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    190

    Resolved [RESOLVED] Increase number of undos in VBIDE

    Hello,
    Is it possible to increase number of undo levels in VB IDE like most normal programs can?
    By search through options, tools etc. I can' t find this option.
    Maybe registry, some "ini file" or what?

    Thanks, nime.

  2. #2

  3. #3

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    190

    Re: Increase number of undos in VBIDE

    When I open my projects IDE asks me "do you want to... ... source safe". That could mean that it is installed by default?
    I allways say no.
    Please in few short words: what is Source safe and why is useful regarding of undos?
    I allways backup my projects by hand. Well, almost allways

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,927

    Re: Increase number of undos in VBIDE

    Source Safe is a good version control (aka "code backup") system, which lets you easily compare code files to previous versions (which could be used for undo's, but not easily), lets you have multiple people work on the same project at the same time, and much more. It does sound like you've got it installed already.

    In terms of the amount of undo's that the IDE gives, I've never seen a limit - except for the last point that you saved the project.

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: Increase number of undos in VBIDE

    Quote Originally Posted by si_the_geek View Post
    Source Safe is a good version control (aka "code backup") system, which lets you easily compare code files to previous versions (which could be used for undo's, but not easily), lets you have multiple people work on the same project at the same time, and much more. It does sound like you've got it installed already.

    In terms of the amount of undo's that the IDE gives, I've never seen a limit - except for the last point that you saved the project.
    I don't think that's true. Create a new project and add a, b, c, … z on separate lines. If you then try to undo you can only undo about 20 of them.

  7. #7
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Increase number of undos in VBIDE

    Quote Originally Posted by MartinLiss View Post
    If you then try to undo you can only undo about 20 of them.
    That is precisely correct -20 is the max. And that number applies only to text (code editor) - in comparison .net can undo practically any action including (but not limited to) designer.

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,927

    Re: Increase number of undos in VBIDE

    So it is... it seems that with my coding style I don't have the need for undo that many times in a row.

  9. #9

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    190

    Re: Increase number of undos in VBIDE

    Of course, I also don't need powerful undos every day.
    Maybe it is not needed for coding 1000 files, and then "those one" will come, when you realize that you need it but you haven't this option...

    Thanks for describing situation and explanations to all.
    nime.

  11. #11
    New Member
    Join Date
    Mar 2013
    Posts
    5

    Re: [RESOLVED] Increase number of undos in VBIDE

    Yes we can.
    I just extended the available undo steps from 20 to 23.
    Probably to what it was originally intended.

    Or that's an other M$ joke a-la:
    640 K ought to be enough for anybody.

    Anyway let's take it as a challenge and debug that bug.


    Wow I can't believe it that *** ba*** at Microf*** harded that value.

    So were's
    The long part
    #1 go into VBA6.dll.EbGetRedoText and follow next call after call EbMode - I'll name that IsUndo
    1a inside IsUndo follow first two conditional Branches 'Jnz'
    1b you'll get to some location where there is push 1;pop eax; jmp back
    1c from there about 9 command below there is <83FB 14> cmp ebx,14; <0F87 xx> ja [far above]
    ->patch that 0x14 (20 as Decimal) to what you like
    Code:
    0009D9B1    83FB 14         CMP     EBX, 14
    0009D9B4    0F87 43C1FCFF   JA      00069AFD
    0009D9BA    8B4D 0C         MOV     ECX, [EBP+C]

    #2 Now the allocation part - without that patch the previous will just crash at more that 20 entries...
    2a well right at IsUndo there is some MOV EAX, [...] at +14 UndoObject +18 RedoObject at some objects I set a hardware breakpoint on write to get to the location that set's these values.
    Alternatively you can search for Command 'ADD EDI, 19' which seem to be pretty unique to located the same function I got in with the hwbp on write. hardware breakpoint on write. Search for const '0DEB9' should also lead you to there. I just labeled that function 'Store Undo'.
    2b find references to Store Undo. Here there are 5. Check them all for their parameters. That last has as Arg5 some 'PUSH 14' that the second patch target.
    Code:
    0012B304    6A 14           PUSH    14
    0012B306    50              PUSH    EAX
    0012B307    6A 00           PUSH    0
    Change that 14 to the same value you patch in at patch #1.

    That's it.
    Tools: Ollydbg or X64dbg or IDA.
    If you're lucky and got also version 6.0.9782 of vba6.dll you may also just use some hexeditor slam in the offset from above and hope the bytes there are same and so suitable for the two patches.

    ...and the short one
    https://player.vimeo.com/video/256087873
    This f** Vimeo tells me i'm a spammer - well anyway I think you'll get it even without the video.

    So here's a Dup2 Patch that will do these two patches:
    http://www.mediafire.com/file/s99dob...s_to_128_1.zip
    Attached Files Attached Files
    Last edited by cw2k; Apr 11th, 2018 at 03:29 AM.

  12. #12
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,092

    Re: [RESOLVED] Increase number of undos in VBIDE

    Best would be if you could make an add-in that tries to patch VBA6.dll in memory (and probably notifies on failure).

    That would be very useful IMHO.

    cheers,
    </wqw>

  13. #13
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by wqweto View Post
    Best would be if you could make an add-in that tries to patch VBA6.dll in memory (and probably notifies on failure).

    That would be very useful IMHO.

    cheers,
    </wqw>
    I vote for that too.
    I don't like to modify the dll file in disk.

  14. #14
    Addicted Member
    Join Date
    Nov 2016
    Location
    GB
    Posts
    141

    Re: [RESOLVED] Increase number of undos in VBIDE

    Sorry: why can't download the file "VB6-ide_fix_undos_to_128.zip"? Is it a broken link?

  15. #15
    New Member
    Join Date
    Mar 2013
    Posts
    5

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by fabel358 View Post
    Sorry: why can't download the file "VB6-ide_fix_undos_to_128.zip"? Is it a broken link?
    Hmm seem that the attachment system here on this board is broken.
    -> It somehow tries to show the attached zip as an image. But in the end there is nothing than a blank screen shown
    -> Reuploading the file also silently fails without any error, I also rename the file before uploading but it's the same
    -> there is no delete option for your attachments, I have not tested if that auto delete unlinked attachments after one hour works. I my eye such a clean up is nice, but just relaying on that is somehow ******. I want delete button so I can keep order - now. I don't wanna wait one hour until old crap get's maybe deleted.

    Well in the end I uploaded it at mediafire and posted the link here. >So also guesses may access it.
    Last edited by cw2k; Apr 11th, 2018 at 03:48 AM.

  16. #16
    New Member
    Join Date
    Mar 2013
    Posts
    5

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by wqweto View Post
    Best would be if you could make an add-in that tries to patch VBA6.dll in memory (and probably notifies on failure).

    That would be very useful IMHO.
    I guess that is not possible. Normally such plug in interfaces can only access certain functions/areas.
    I've not checked the specs yet but I've doubts that an addin / plugin can gain complete control about undo & redo.

    What is possible to encapsulated this patch as some in-memory-patch. So as soon as plugin main is executed it seek in VBA6.dll.text for the required patch pattern to apply these two patches.
    Thats more effort and gives more room about what can go wrong.
    I like the static way. There is a patched VBA6.dll and the original VBA6.dll.bak for reference and backup.

    But yes there is that addin that'll enable the scrolling with mouse wheel that function seems to go beyond the scope a 'normal' add-in. Someday I may have closer look to this.

  17. #17
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by cw2k View Post
    I guess that is not possible. Normally such plug in interfaces can only access certain functions/areas.
    I've not checked the specs yet but I've doubts that an addin / plugin can gain complete control about undo & redo.
    .
    what? There's nothing stopping a plugin from patching up memory locations, that's why wqweto suggested it.
    The plugin would do in memory what you're by hand on disk.

    If you need an API to tell you where the DLL is in Memory try GetModuleHandle.

  18. #18
    Addicted Member
    Join Date
    Nov 2016
    Location
    GB
    Posts
    141

    Re: [RESOLVED] Increase number of undos in VBIDE

    So here's a Dup2 Patch that will do these two patches:
    http://www.mediafire.com/file/s99dob...s_to_128_1.zip
    This links leads to a page where you can read:
    "Dangerous File Blocked

    The file you attempted to download was determined to be dangerous. For your protection, MediaFire does not enable distribution of dangerous files.

    Still have questions, or think we've made a mistake? Please contact support for further assistance."

  19. #19
    Member
    Join Date
    Dec 2009
    Location
    Germany
    Posts
    47

    Re: [RESOLVED] Increase number of undos in VBIDE

    cwk2,

    very useful instructions - thanks much.
    Environment: VB6 Enterprise German with SP6 installed on Win10 (v.1709) and vba6.dll v.6.0.9782.

    I did a short, sucessful test and would like to share my experience.

    As usual, in IDE I was able to do 20 undos only (=Hex14).
    Open vba6.dll with a good hex-editor (certainly after you made a backup copy of vba6.dll).
    Search for hex-sequence "83FB140F8743C1FCFF8B4D0C". For me, it starts at offset 0009D9A5.
    Change "14" to "80" for example.

    At this point and in contrary to your suggested changes of part 2, there was nothing more to do for me.
    In IDE, I was able to do 128 undos (no crashes).
    In spite, when these were applied a MessageBox appears before any input in the IDE (Translated: Warning. Process cannot be reverted. Are you sure?).
    However, I could find your hex-sequence "6A14506A00" at offset "0012B2F6".

    Zphere
    Last edited by Zphere; Apr 13th, 2018 at 08:51 AM.

  20. #20
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,625

    Re: [RESOLVED] Increase number of undos in VBIDE

    Can you re-post the file? The VBForums attachment is broken (it's not the forums, all the other threads with attachments work... not sure what happened here, maybe the name? sometimes normal looking names cause weird problems here) and MediaFire blocked it as malware.

  21. #21
    Registered User
    Join Date
    Aug 2018
    Posts
    2

    Re: [RESOLVED] Increase number of undos in VBIDE

    Have followed the instructions and can confirm it works. I've made it available to download with the links below as the forum does not allow DLL files and only 500kb zip files.


    To make the changes I used a hex editor called HxD:


    Run it as administrator, open the vba6.dll file, search for 83FB140F8743C1FCFF8B4D0C (remember to change the datatype to hex values on the search screen) and change the 14 to 80, then save it.
    Last edited by Shaggy Hiker; Oct 29th, 2018 at 02:45 PM. Reason: Removed some links.

  22. #22
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,943

    Re: [RESOLVED] Increase number of undos in VBIDE

    Actually, the forum doesn't just not allow compiled code. We also don't approve of linking to compiled code unless the source is included (and then only over in Utilities) or if it is posted on GitHub. The reasons for this are a bit complicated, and would likely start a fire. Essentially, we can't say anything one way or another about compiled code, and don't want the links on the site in case there is something bad in them.

    If you can post the source, we'd be happy to see it, just not with compiled code.
    My usual boring signature: Nothing

  23. #23
    Lively Member
    Join Date
    Aug 2006
    Posts
    87

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by cw2k View Post
    Yes we can.
    I just extended the available undo steps from 20 to 23.
    Probably to what it was originally intended.

    Or that's an other M$ joke a-la:


    Anyway let's take it as a challenge and debug that bug.


    Wow I can't believe it that *** ba*** at Microf*** harded that value.

    So were's
    The long part
    #1 go into VBA6.dll.EbGetRedoText and follow next call after call EbMode - I'll name that IsUndo
    1a inside IsUndo follow first two conditional Branches 'Jnz'
    1b you'll get to some location where there is push 1;pop eax; jmp back
    1c from there about 9 command below there is <83FB 14> cmp ebx,14; <0F87 xx> ja [far above]
    ->patch that 0x14 (20 as Decimal) to what you like
    Code:
    0009D9B1    83FB 14         CMP     EBX, 14
    0009D9B4    0F87 43C1FCFF   JA      00069AFD
    0009D9BA    8B4D 0C         MOV     ECX, [EBP+C]

    #2 Now the allocation part - without that patch the previous will just crash at more that 20 entries...
    2a well right at IsUndo there is some MOV EAX, [...] at +14 UndoObject +18 RedoObject at some objects I set a hardware breakpoint on write to get to the location that set's these values.
    Alternatively you can search for Command 'ADD EDI, 19' which seem to be pretty unique to located the same function I got in with the hwbp on write. hardware breakpoint on write. Search for const '0DEB9' should also lead you to there. I just labeled that function 'Store Undo'.
    2b find references to Store Undo. Here there are 5. Check them all for their parameters. That last has as Arg5 some 'PUSH 14' that the second patch target.
    Code:
    0012B304    6A 14           PUSH    14
    0012B306    50              PUSH    EAX
    0012B307    6A 00           PUSH    0
    Change that 14 to the same value you patch in at patch #1.

    That's it.
    Tools: Ollydbg or X64dbg or IDA.
    If you're lucky and got also version 6.0.9782 of vba6.dll you may also just use some hexeditor slam in the offset from above and hope the bytes there are same and so suitable for the two patches.

    ...and the short one
    https://player.vimeo.com/video/256087873
    This f** Vimeo tells me i'm a spammer - well anyway I think you'll get it even without the video.

    So here's a Dup2 Patch that will do these two patches:
    http://www.mediafire.com/file/s99dob...s_to_128_1.zip
    Thanks to this information, I've been able to completely remove the Undo/Redo limitations in the IDE. While your patch is limited to 127 operations, a very simple tweak on the first section patching to CMP EBX, 0 and JB instead of JA will allow the IDE to always perform undos and redos. From my testing this appears to be stable, I've filled the IDE up to 50k lines in a single module and was able to undo and redo without issues.

    So again, very nice find!

    Anyone who wishes to get ahold of my patch may do so through the ModernVB release thread, as it is now officially a feature of my modpack:

    http://www.vbforums.com/showthread.p...29#post5471629

  24. #24
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,092

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by LinkFX View Post
    Anyone who wishes to get ahold of my patch may do so through the ModernVB release thread, as it is now officially a feature of my modpack:

    http://www.vbforums.com/showthread.p...29#post5471629
    Which reminds me that the in-memory patching for your add-in is much more preferred than modifying executables on disk.

    If I might guess at least 95% of potential users are not willing to take this risk if only imaginary as backups are trivial to make. (The other 5% are using french editions and are failing anyway:-))

    cheers,
    </wqw>

  25. #25
    Lively Member
    Join Date
    Aug 2006
    Posts
    87

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by wqweto View Post
    Which reminds me that the in-memory patching for your add-in is much more preferred than modifying executables on disk.

    If I might guess at least 95% of potential users are not willing to take this risk if only imaginary as backups are trivial to make. (The other 5% are using french editions and are failing anyway:-))

    cheers,
    </wqw>
    Ordinarily I would agree with you but since the modpack makes extensive changes to the resource sections of those files it makes no sense to memory patch when you're already changing the binaries significantly.

  26. #26
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,092

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by LinkFX View Post
    Ordinarily I would agree with you but since the modpack makes extensive changes to the resource sections of those files it makes no sense to memory patch when you're already changing the binaries significantly.
    Hmmm, this makes sense now.

    Too bad you cannot ship pre-patched binaries.

    cheers,
    </wqw>

  27. #27
    Lively Member
    Join Date
    Aug 2006
    Posts
    87

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by wqweto View Post
    Hmmm, this makes sense now.

    Too bad you cannot ship pre-patched binaries.

    cheers,
    </wqw>
    It's a one click process to patch the files anyway, it really couldn't be any easier.

  28. #28
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,092

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by LinkFX View Post
    It's a one click process to patch the files anyway, it really couldn't be any easier.
    Sure! If it works at all :-))

    cheers,
    </wqw>

  29. #29
    Lively Member
    Join Date
    Aug 2006
    Posts
    87

    Re: [RESOLVED] Increase number of undos in VBIDE

    The only reason it wouldn't work is if you're not running the SP6. Since VB is no longer in development and that's effectively the final version and a free update to boot, there's no reason to be running anything else.

    And if somehow you're not, you can just download the SP6 setup file for your language and use the binaries from that.

  30. #30
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,625

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by wqweto View Post
    Which reminds me that the in-memory patching for your add-in is much more preferred than modifying executables on disk.

    If I might guess at least 95% of potential users are not willing to take this risk if only imaginary as backups are trivial to make. (The other 5% are using french editions and are failing anyway:-))

    cheers,
    </wqw>
    C'est pas possible! Les Français n'abandonnent jamais!

  31. #31
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    685

    Re: [RESOLVED] Increase number of undos in VBIDE

    I've been working on this feature for my addin, but not by using assembly. I added two custom buttons undo/redo to replace the feature.
    I'm using the splice method posted by Trick (TrickAdvancedTools) to hook the API EbGetRedoText and EbGetUndoText and gather codemodule changes/differences.
    These API's fire off when there is a possible code change, from typing on the keyboard, or clicking/selecting with the mouse.

    Addin module code:
    Code:
       Dim hVba As Long
       If mIsHookInit = True Then
          InitializeHooks = True
          Exit Function
       End If
       hVba = apiGetModuleHandle(StrPtr("vba6.dll"))
       If hVba = 0 Then
          Exit Function
       End If
       
       pfnEbGetUndoText = apiGetProcAddress(hVba, "EbGetUndoText")
       If pfnEbGetUndoText = 0 Then Exit Function
       If HookFunction(pfnEbGetUndoText, AddressOf EbGetUndoText_user) = False Then
          Exit Function
       End If
    Callback standard module:
    Code:
    Public pfnEbGetRedoText        As Long
    Public pfnEbGetUndoText        As Long
    Public Function EbGetRedoText_user(ByVal pVBProjectNative As Long) As Long
       On Error GoTo error_handler
       PauseHook pfnEbGetRedoText
    
       ' spliced before the Redotext trigger event
       AddCurrentModuleText
    
       EbGetRedoText_user = CallByPointer(pfnEbGetRedoText, vbLong, pVBProjectNative)
    
       ' spliced after the Redotext event!
    
       ResumeHook pfnEbGetRedoText
       Exit Function
    error_handler:
    End Function
    The array could be stored when the application closes, and reloaded on the next session.
    Has anyone ever tried this approach?

  32. #32
    Addicted Member
    Join Date
    Jun 2017
    Posts
    236

    Re: [RESOLVED] Increase number of undos in VBIDE

    hi~ ALL

    where can download path file ????

  33. #33
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    685

    Re: [RESOLVED] Increase number of undos in VBIDE

    There is a working prototype on our Github VBForumsCommunity. The number of undos is set to 1000. No assembly required, in pure VB.

  34. #34
    Addicted Member
    Join Date
    Jun 2017
    Posts
    236

    Re: [RESOLVED] Increase number of undos in VBIDE

    Quote Originally Posted by TTn View Post
    There is a working prototype on our Github VBForumsCommunity. The number of undos is set to 1000. No assembly required, in pure VB.
    thank you

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