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?
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
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.
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.
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.
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.
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
#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.
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.
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.
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.
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.
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.
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.
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.
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.
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
#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.
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.
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:
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:-))
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.
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.
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.
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!
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?