-
Sep 8th, 2021, 02:59 PM
#1
Thread Starter
Frenzied Member
Can someone tell me about undocumented sections in VBP files?
These are sections (and lines within those sections) in VBP files that VB6 will act upon when loading a VBP file, but that VB6 will never actually generate from any possible conditions in the VB6 IDE itself at the time of saving a VBP file. Fortunately though, VB6 won't overwrite them when re-saving a VBP file.
I know one of them actually tells the VB6 IDE to treat a given project as a console project! This isn't officially supported and isn't documented anywhere on the MS website. I remember reading it in an article YEARS ago when searching for how to make a console project. But now I can't find that same article, no matter what search terms I use in Google to specifically search for that article. I have typed in very specific things that should help Google narrow down what I'm looking for, search strings like "Make VB6 compile console project with undocumented lines in the VBP file", but Google isn't finding the article for me.
I don't think this is widely known knowledge either, as in my entire life I've only seen ONE ARTICLE ever mentioned this trick. I don't even know how it was originally discovered. Maybe some hacker decompiled vb6.exe?
Whatever the case, I've since forgotten myself what the name of this special line in the VBP file is to turn it into a console project, and so I'm hoping someone here can tell me. Furthermore, if you are aware of any other undocumented VBP lines like this, that perform various other unsupported tricks in VB6, please let me know.
Thanks in advance.
-
Sep 8th, 2021, 04:11 PM
#2
Re: Can someone tell me about undocumented sections in VBP files?
http://bbs.vbstreets.ru/viewtopic.php?f=9&t=43618
C2Switches - compiler options;
LinkSwitches - linker options
To make a console application you need to add SUBSYSTEM:CONSOLE
-
Sep 8th, 2021, 07:32 PM
#3
Thread Starter
Frenzied Member
Re: Can someone tell me about undocumented sections in VBP files?
Originally Posted by The trick
Thanks.Thats's what I was looking for.
Last edited by Ben321; Sep 8th, 2021 at 07:44 PM.
-
Sep 8th, 2021, 07:55 PM
#4
Re: Can someone tell me about undocumented sections in VBP files?
I think the section you want is [VBCompiler]:
Code:
[VBCompiler]
LinkBefore={some command line}
LinkSwitches=/LARGEADDRESSAWARE /SUBSYSTEM:WINDOWS,5.0
LinkAfter={other command line}
C2Switches works as well, but most of those can be set via Project Properties. Project Properties also sets some of the Link.exe switches so you'll want to know what you are doing or you may confuse yourself: the strings in [VBCompiler] probably overwrite settings made via Project Properties. I wouldn't expect any intelligent merging to be done.
I think there is even a [Comments] section that accepts text that gets ignored, though the lines of text should adhere to INI format conventions ("nameornumber = text" lines).
As far as I can tell these got added and documented for companies with a Microsoft Partner agreement back in the day. General users were not supposed to use them.
-
Sep 8th, 2021, 08:01 PM
#5
Re: Can someone tell me about undocumented sections in VBP files?
You might also want to look here: Microsoft KB Archive/307211
This was documented for everyone, but few seem to know about it or when to use it.
You can configure the Unattended Execution option and the Retained In Memory option in the latest version of Msvbvm60.dll
For example, a program written for batch execution (Windows Scheduler) should have both Unattended Execution requested and SUBSYSTEM:CONSOLE linked in.
-
Sep 9th, 2021, 12:44 AM
#6
Thread Starter
Frenzied Member
Re: Can someone tell me about undocumented sections in VBP files?
Originally Posted by dilettante
I think the section you want is [VBCompiler]:
Code:
[VBCompiler]
LinkBefore={some command line}
LinkSwitches=/LARGEADDRESSAWARE /SUBSYSTEM:WINDOWS,5.0
LinkAfter={other command line}
Cool! Big thanks! Where did you figure that out? Was that ever officially documented by MS? Or was that discovered originally by hackers and reverse engineers?
Is there also a releated trick to getting it to output a standard DLL instead of an ActiveX DLL, when using the DLL project type in VB6? Like a linker switch to tell the linker to NOT export the the ActiveX DLL functions like DllRegisterServer and DllUnregisterServer?
Last edited by Ben321; Sep 9th, 2021 at 12:52 AM.
-
Sep 9th, 2021, 02:42 AM
#7
Re: Can someone tell me about undocumented sections in VBP files?
I don't think there was ever any public documentation for this. It might have been leaked by Partners, insiders writing VB6 books, or through sheer reverse-engineering.
Maybe look up Link.exe options, but I did find this in some old notes:
Code:
LinkSwitches=/BASE:0x77170000 /DLL /ENTRY:DllMain /EXPORT:GetECC /OPT:NOWIN98
-
Sep 9th, 2021, 04:31 AM
#8
Re: Can someone tell me about undocumented sections in VBP files?
No, this was never leaked/documented by MS but was reversed by the guys at vbstreets.ru it seems. The original “author” even cried out loud here for not being credited for some other reversing work he’s done.
Another thing to notice is that obviously even Karl Peterson did not know about LinkSwitches when he produced his console helper modules.
-
Sep 9th, 2021, 09:16 AM
#9
Thread Starter
Frenzied Member
Re: Can someone tell me about undocumented sections in VBP files?
Originally Posted by dilettante
I don't think there was ever any public documentation for this. It might have been leaked by Partners, insiders writing VB6 books, or through sheer reverse-engineering.
Maybe look up Link.exe options, but I did find this in some old notes:
Code:
LinkSwitches=/BASE:0x77170000 /DLL /ENTRY:DllMain /EXPORT:GetECC /OPT:NOWIN98
What does the /OPT:NOWIN98 option actually do? I can't find anything for it on Google, not even (possibly broken) links to old MSDN Visual Studio articles about it. Nothing at all. All I see are links to people asking questions about why it was removed in newer versions of Visual Studio. Could you possibly enlighten me on what it's actually supposed to do?
-
Sep 9th, 2021, 01:20 PM
#10
Re: Can someone tell me about undocumented sections in VBP files?
Originally Posted by dilettante
LinkAfter={other command line}
There is no LinkAfter option. This option can be added by my TrickAdvancedTools.
Originally Posted by dilettante
I think there is even a [Comments] section that accepts text that gets ignored, though the lines of text should adhere to INI format conventions ("nameornumber = text" lines).
Any Add-in can add arbitrary sections using WriteProperty method.
Originally Posted by Ben321
Is there also a releated trick to getting it to output a standard DLL instead of an ActiveX DLL, when using the DLL project type in VB6? Like a linker switch to tell the linker to NOT export the the ActiveX DLL functions like DllRegisterServer and DllUnregisterServer?
This is a quite non-trivial task. I already have done a bas module to make native DLLs in VB6 but you should follows some restrictions. See this post (there are some Native DLLs examples).
Originally Posted by Ben321
Or was that discovered originally by hackers and reverse engineers?
This guy have found this keys.
-
Sep 9th, 2021, 01:42 PM
#11
Re: Can someone tell me about undocumented sections in VBP files?
Originally Posted by The trick
There is no LinkAfter option. This option can be added by my TrickAdvancedTools.
Good to know. Thank you for setting the record straight.
-
Sep 9th, 2021, 01:45 PM
#12
Re: Can someone tell me about undocumented sections in VBP files?
This might help, from MS KB Q235956:
SUMMARY
Microsoft Visual C++ 6.0 introduces two new linker optimization options -- /OPT:WIN98, which is set by default, and /OPT:NOWIN98. The default sets the file alignment at 4K instead of the previous 512 bytes. This results in a larger module size, but one which loads faster on Windows 98 with reduced file swapping. A release build of an AppWizard-generated MDI application is approximately 14K larger than when the /OPT:NOWIN98 option is used, and a ReleaseMinSize build of a standard ATL DLL with no objects added is approximately 17K larger.
MORE INFORMATION
The default WIN98 optimization for file alignment places the base of sections in the portable executable image on Windows 98's page boundary, resulting in decreased load times and reduced need for file swapping. The percentage increase in module size is less for larger applications, and the benefits normally justify the increase in size. However, if module size is a critical factor, /OPT:NOWIN98 can be used to revert to the original 512-byte alignment.
NOTE: The /ALIGN:512 option also has this effect, but will produce linker warning 4108, as this option is normally reserved for drivers.
-
Sep 9th, 2022, 02:03 PM
#13
Re: Can someone tell me about undocumented sections in VBP files?
Originally Posted by The trick
I don't want to be picky, but is it possible for the same EXE to run on the Console and on Windows?
Thanks.
-
Sep 9th, 2022, 02:31 PM
#14
Re: Can someone tell me about undocumented sections in VBP files?
I'm pretty sure we have covered this again fairly recently. Maybe we need a "Hopeless Wishes" forum?
How do I write a program that can be run either as a console or a GUI application?
You can’t, but you can try to fake it.
This isn't just some guy. Raymond is in a good position to make this statement.
-
Sep 9th, 2022, 02:44 PM
#15
Re: Can someone tell me about undocumented sections in VBP files?
Originally Posted by dilettante
Okay Dilettante......
Actually I wanted to create a console program to apply commands, and restore database, INI file, among other things (for the administrator).
So it will be an EXE for each windows, and another for the console.
-
Sep 9th, 2022, 03:15 PM
#16
Re: Can someone tell me about undocumented sections in VBP files?
Originally Posted by Episcopal
I don't want to be picky, but is it possible for the same EXE to run on the Console and on Windows?
Thanks.
No, it is not possible (I have to answer like this since it will be a workaround).
But you can nevertheless do it.
-
Sep 9th, 2022, 08:42 PM
#17
Re: Can someone tell me about undocumented sections in VBP files?
Originally Posted by Episcopal
Actually I wanted to create a console program to apply commands, and restore database, INI file, among other things (for the administrator).
So it will be an EXE for each windows, and another for the console.
You can shell another instance of your exe with command line parameters.
Look for these at startup, if found process then quit. If not show the gui and startup normal.
No need for a true console app
-
Sep 10th, 2022, 05:13 AM
#18
Re: Can someone tell me about undocumented sections in VBP files?
Originally Posted by dz32
You can shell another instance of your exe with command line parameters.
Look for these at startup, if found process then quit. If not show the gui and startup normal.
No need for a true console app
Hello dz32 ...
Your idea is valid ..... but I see a need to interact with the system user.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|