Results 1 to 18 of 18

Thread: Can someone tell me about undocumented sections in VBP files?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    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.

  2. #2

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: Can someone tell me about undocumented sections in VBP files?

    Quote Originally Posted by The trick View Post
    http://bbs.vbstreets.ru/viewtopic.php?f=9&t=43618



    To make a console application you need to add SUBSYSTEM:CONSOLE
    Thanks.Thats's what I was looking for.
    Last edited by Ben321; Sep 8th, 2021 at 07:44 PM.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: Can someone tell me about undocumented sections in VBP files?

    Quote Originally Posted by dilettante View Post
    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.

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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

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

    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.

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: Can someone tell me about undocumented sections in VBP files?

    Quote Originally Posted by dilettante View Post
    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?

  10. #10
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,687

    Re: Can someone tell me about undocumented sections in VBP files?

    Quote Originally Posted by dilettante View Post
    LinkAfter={other command line}
    There is no LinkAfter option. This option can be added by my TrickAdvancedTools.

    Quote Originally Posted by dilettante View Post
    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.

    Quote Originally Posted by Ben321 View Post
    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).

    Quote Originally Posted by Ben321 View Post
    Or was that discovered originally by hackers and reverse engineers?
    This guy have found this keys.

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Can someone tell me about undocumented sections in VBP files?

    Quote Originally Posted by The trick View Post
    There is no LinkAfter option. This option can be added by my TrickAdvancedTools.
    Good to know. Thank you for setting the record straight.

  12. #12
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  13. #13
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: Can someone tell me about undocumented sections in VBP files?

    Quote Originally Posted by The trick View Post
    http://bbs.vbstreets.ru/viewtopic.php?f=9&t=43618


    To make a console application you need to add SUBSYSTEM:CONSOLE

    I don't want to be picky, but is it possible for the same EXE to run on the Console and on Windows?

    Thanks.

  14. #14
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  15. #15
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: Can someone tell me about undocumented sections in VBP files?

    Quote Originally Posted by dilettante View Post
    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?

    This isn't just some guy. Raymond is in a good position to make this statement.



    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.

  16. #16
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,064

    Re: Can someone tell me about undocumented sections in VBP files?

    Quote Originally Posted by Episcopal View Post
    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.

  17. #17
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,068

    Re: Can someone tell me about undocumented sections in VBP files?

    Quote Originally Posted by Episcopal View Post
    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

  18. #18
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: Can someone tell me about undocumented sections in VBP files?

    Quote Originally Posted by dz32 View Post
    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
  •  



Click Here to Expand Forum to Full Width