Create real Console mode programs in SB RRS feed

  • General discussion

  • Sometimes badly wanted to write a real console mode program in SB, that works like a real command line program and not via SB TextWindow. And i think, i finally found a way to make that possible. See screenshots:

    These demos show 4 SB programs to perform simple calculations, directory listings (similar CMD internal 'dir' command), download/response header check from commandline and playing music/sound/speech from command line (CMD.exe). This is NOT the SB TextWindow, but inputs and outputs are directly in/from cmd.exe StdIn, StdOut.

    Compiled a simple demo extension (SBCmd.dll with all used methods in a single class) for this demos to work (all sources and infos included). Modify as you like it. All of the demos use SBCmd.dll (+ JSEval.dll ) and 2 of them also LitDev extension.

    Additionally you will need AppModeChanger from Nir Sofer to patch the original .exes compiled via SBIDE or from SmallBasicCompiler.exe. Links also included. If someone is interested, here are the needed bits and infos...

    Download: (393 KB)

    PS: Changed link, after found out that and  contained class names, that would not be found on other systems. Should fit now. Hope so!

    Saturday, October 4, 2014 6:32 PM

All replies

  • Did some testings with mentioned AppModeChanger on compiled SB exes (with original SB TextWindow. commands only). And what shall i say: It works as well !!

    So the modified TextWindow commands in SBCmd (like Pause, Clear, PauseNoMessage, Read, ReadKey, ResetColors, Write and WriteLine) may be forgotten, because all the original SB TextWindow I/O commands
    will work in the Console after patching with AppModeChanger. As well as the original TextWindow...Color and TextWindow.Cursor..  methods.
    Sample ID: SZP374 (SBConType) uses the original TextWindow commands and only changed 0xDC from 02 to 03 in SBConType.exe to run in console mode.

    Thereby only the single byte (lowest bit from 10 to 11) for 'WORD Subsystem' in the PE Header is changed (between) from 0x02 to 0x03 when changing from TW to Console mode.

    see eg: An In-Depth Look into the Win32 Portable Executable File Format (PEDump.exe)

    PE Format (Wiki) ff.

    Comparison in console:
    fc.exe SBConType.exe SBConType_TW.exe    (as for  WINDOWS_CUI : WINDOWS_GUI)
    000000DC: 03 02
    (dez 220)

    It's an easy with any HexEditor or from extension (FileStream) to change byte value in address DC.
    The only problem is to find the correct location of the 'Subsystem' byte for a specified exe.
    Although most of the time at position 0xDC (220) in the SB exes i examined, it may also be at a higher position. Perhaps anyone knows a simple algorithm to determine the correct position of this single byte? and ensure that the given exe is a SB exe?
    Else i'll study and go deeper through the vb source of appmodechanger, esp. the ReadFile and CopyMemory functions in there.

    And maybe anyone has an idea how to get (inside of the program), if it's been called from the console (in Console mode) or in TW mode, eg. "Am i TW or console mode?" (Another way than checking for 'Subsystem' byte)

    Monday, October 20, 2014 8:00 PM
  • Pappa Lapub,

    I removed link to because your page in the site has two links to malware (adware) site beside the true download link to . 

    I strongly recommend to use TechNet Gallery to upload this kind of binaries. 

    Nonki Takahashi

    Monday, January 12, 2015 2:51 PM
  • @Nonki,

    Thanks for info on that. When you mention 'has two links' you sure mean and in the embedded js (and others, besides G spyware which in the meantime almost collard the whole web)

    Never noticed that, because such crap is (and should) generally be blocked by everyone and about the both addresses from above, they are eg. contained in (Fanboy's) EasyList here  or here for every browser available and/or systemwide blockable via hosts file and in my opinion is/should be used by everyone who takes care about a minimum of security and privacy.

    But now i see clearer about - i think - JR once mentioned having probs there. For me it's just comfortable there, no registration, login and all's done with 2 clicks, but I'll consider using TN Gallery for future ups or point out to block any trash there (and everywhere else).
    Did'nt use datafilehost because sometimes people forget to uncheck the checkbox there and would get a suspicious installer Exe then. Therefor i chose FUpnet. I hope for LitDev its OK here about the De.xml !?

    Wednesday, January 14, 2015 9:08 PM
  • Now we can get Application Mode Changer by NirSoft from following site.

    Nonki Takahashi

    Sunday, April 16, 2017 4:47 AM