Hello everyone!
I present to you a small project - Add-in that allows to some extent alleviate debugging some programs as well expand compilation possibilities. All the source codes are in the attachment.
This Add-in has the following features:
Fixes the bug with Not Not Array statement that causes error "Expression too complex" if you'll work with float numbers;
Allows to utilize the automatic conditional constants depending on run mode (IDE/EXE) look like in C++ (NDEBUG);
Allows to disable integer overflow checking in IDE;
Allows to disable floating point result checking in IDE;
Allows to disable array bounds checking in IDE;
Provides the compilation/linking events (both in IDE and EXE), i.e. you can run the commands before/after this events. By using this events you can do many useful things (encryption, replace OBJ files, static linking, etc.)
How does it work?
For fixing Not Not bug and disabling checking it uses the module of replacing of the opcodes handlers (P_Code) to ours. Firstly it finds the table of the opcodes by the signature in the ENGINE section of VBA6.dll module. There are two opcodes types - single-byte and double-bytes. Teh single-byte opcodes is less that 0xFB. It uses the length dissasembler by Ms-Rem that i ported to VB6. Besides it finds the subroutine that redirectes performing to the next opcode as well the subroutine that handles the errors. Since now it is very easy to get an access violation error i kept some checking. For example, access to uninitialized array causes the memory violation error - it handles that error. Because of there isn't an official documentation about VB6 opcodes (i've not found it) i did all the investigations, therefore some opcodes can raise error. In this case you can write them - i'll add handlers.
For others features it uses splicing of the following functions:
TipCompileProject;
TipCompileProjectFull;
TipMakeExe2;
TipFinishExe2.
TipSetConstantValues/TipGetConstantValues functions are used in order to set/get the conditional compilation arguments. The events is just calling of ShellExecuteEx function. There are events before/after project compilation (IDE/EXE) and linking. This project was weakly testing therefore it can contain bugs.
Regading,
Кривоус Анатолий (The trick)
Last edited by The trick; Sep 29th, 2016 at 08:49 AM.
line 63: retOpcode = Opcode Or (cPtrData & &H100&)
I would think possibly "And" if the code is meant to clear the bits in a bit field (but leave bit 9 unaltered) before Or'ing the Opcode into the return value.
retOpcode = Opcode Or (cPtrData And &H100&)
I didn't look at the actual code though to get a sense of the context, but & is the binary operand "And" in C and C++ (and possibly other languages I'm not familiar with).
I would think possibly "And" if the code is meant to clear the bits in a bit field (but leave bit 9 unaltered) before Or'ing the Opcode into the return value.
retOpcode = Opcode Or (cPtrData And &H100&)
I didn't look at the actual code though to get a sense of the context, but & is the binary operand "And" in C and C++ (and possibly other languages I'm not familiar with).
you would think that yes - That was my first assumption. I should have posted more context of the code. It's supposed to be combining 2 1 byte opcodes, to a single 2 byte opcode. So it's definitely supposed to be a *
I would think possibly "And" if the code is meant to clear the bits in a bit field (but leave bit 9 unaltered) before Or'ing the Opcode into the return value.
retOpcode = Opcode Or (cPtrData And &H100&)
I didn't look at the actual code though to get a sense of the context, but & is the binary operand "And" in C and C++ (and possibly other languages I'm not familiar with).
̶Y̶o̶u̶ ̶a̶r̶e̶ ̶r̶i̶g̶h̶t̶!̶
Originally Posted by xxdoc123
sometimes can you complete tool for vb addin about png? i see the video you upload to youtube!
Yes, i'm working on it. It nicely works in IDE, i'm working on adding this feature to EXE. In the compiled form it's just an OBJ module that is linked to main exe and starts before main executable code will be launched.
a) You're combining 2 1 byte Opcodes according to the comments. ie: w = b1 Or (b2 * &H100&)
b) cPtrData is Byte. If you And any Byte with &H100 - it becomes 0
edit: Thanks for posting this!
Last edited by DEXWERX; Sep 29th, 2016 at 09:07 AM.
Kunical , hi. Please show the code that causes the error. Thank.
Hellow the trick,
Here is the code
Code:
' --For themed style, we are not able to draw borders
' --after drawing the caption. i mean the whole button is painted at once.
If m_ButtonStyle = eWindowsTheme Then
If .Left < 4 Then .Left = 4
If .Right > ScaleWidth - 4 Then .Right = ScaleWidth - 4
If .Top < 4 Then .Top = 4
If .Bottom > ScaleHeight - 4 Then .Bottom = ScaleHeight - 4
End If
End With
This Addin is great! Especially the events to intercept in the linking process to replace .obj files.
Compiling the source to dll works and is properly registered.
However, any further attempt with regsvr32 (register or unregister) fails with the error "LoadLibrary("TrickAdvancedTools.dll") failed - The specified module could not be found"
So that makes it a pain to ship the dll to another computer.
I tested to replace all the typelib functions, consts etc. into the project as normal declarations and it solved the issue and I see no difference in the functionality.
Attached is the modified source. I hope that is OK by the trick? If not, please let me know I will remove it.
First, Thanks for the many great contributions to The Trick and Krool!
I agree it's a great Addin but when it's loaded i experience an issue in many projects that is using sub classing while using Krools mod. TrickAdvancedTools_NoTypeLib.zip
First, Thanks for the many great contributions to The Trick and Krool!
I agree it's a great Addin but when it's loaded i experience an issue in many projects that is using sub classing while using Krools mod. TrickAdvancedTools_NoTypeLib.zip
This happen when the Addin is loaded (even when no settings are active)
As soon as the Addin is unloaded the code work again without the runtime error
It must be something with the modCheckingOptions
If I comment them out in the conAddIn designer and re-compile then it works without that error.
But then of course you loose some functionality.
dear the trick, how can we hack vba6.dll functions to do more jobs
take TipCreateStdModule as example
1.how can we do our job after StdModule created
2.can we choose whether to execute our own TipCreateStdModule_user or the original TipCreateStdModule?
Class VBComponentsEvents
Member of VBIDE
Returned by the VBComponentsEvents property. This object is the source of events that occur when an object is added, removed, selected, renamed, or activated.
thanks The trick, i found the Member you gived very useful
but i'm still interest in how to do this with hooking or subclassing
because with these technics, we can hack every exe or dll
can you share something to make it?
hook before function or after function
Is there a way to compile each form, module, class into a * .obj file and not delete it unless the code file is modified. If a project has 20 code files and only one function is modified, only one obj file needs to be generated. The goal is to quickly compile. If you can, you can compile in memory without generating temporary files, and use the principle of reading and writing hook (link.exe, c2.exe) files.
Now I am developing some plugins for the freebasic IDE, and I also want to use the function of memory compilation and incremental compilation. Now there is a visualFreebasic5 ide tool developed by a Chinese that is very powerful. I hope that fans of vb will participate in the plug-in development, just like the development of addin (activex dll) for vb6.
And "b4a" Android development tool also uses visual basic code.
have a new idea.
for IDE, the toolbar items and the menubar items are always missing
so i need to click: View-> Tools -> Customize, and select MenuBar Standard Edit, to click Reset button to reset them to normal.
maybe you can add BeforePrjClose event, so we can do that before project close.
Private Declare Sub EbGetExecutingProj Lib "vba6" (ByRef lpPrjObj As IUnknown)
Private Declare Function TipGetConstantValues Lib "vba6" (ByVal hProj As Long, ByVal v As Long) As Long
Private Declare Function TipSetConstantValues Lib "vba6" (ByVal hProj As Long, ByVal v As Any) As Long
Private Declare Function EbSetMode Lib "vba6" (ByVal Mode As Long) As Long
Sub Main()
Dim objProj As IUnknown
EbGetExecutingProj objProj
Dim str As String
TipGetConstantValues ObjPtr(objProj), VarPtr(str) 'Unicode
Debug.Print str
'EbSetMode 2
TipSetConstantValues ObjPtr(objProj), StrPtr("loquat = 1")
'EbSetMode 1
End Sub