Can I create an application that starts under
Windows using GUI (32-bit) and under DOS as
16-bit console application? Now every 32-bit
app started under DOS writes:
"This is a Win32 program."
How can I change it?

Thanks to all, Mike
Posted on 2002-10-11 03:56:08 by Mike

Yes, you can...
There is a part in any PE executables called the dos stub...
It is this dos stub that displays the "This is a Win32 program." message...

Have a look at FASM... it allows to specify a dos stub very easily... and IIRC, fasm itself uses this technique to run under dos and windows using the api...
Posted on 2002-10-11 04:01:15 by JCP
Thank you, Radiosys.
But I do the same using Microsoft assembler and linker.
Posted on 2002-10-11 06:00:08 by Mike
That's example of using DOS stub.
Posted on 2002-10-11 06:02:41 by Mike
OR maybe you can try hand ediitng the dos stub :grin:
Posted on 2002-10-11 06:33:47 by roticv
Yes, but you are limited in size unless to do tricky stuff... it is better to let the linker do its job imho...
Posted on 2002-10-11 06:37:50 by JCP
If the string you want to add is shorter than the standard windows message, then fill it with blanks. However if you want to add a longer string, you need to manually editing the offset etc and could be extremely troublesome.
Posted on 2002-10-11 06:55:18 by roticv
This is Interesting....
I use RadAsm how to change the parameter. I saw a parameter /STUB:mkstub.exe, what it is do?.
First the prosessor read MZ and nothing happen, then CD 19 (or int 0x19) and then it is folowed with a string 'This Program cannot Run under DOS$'. I dont found any jmp instruction here.... (Let me know if you found it).:confused:
Is Windows Executing a 32-bit App after the '$' sign ?....
For Dos Program I using Emux8086.
Posted on 2003-01-18 08:46:58 by realvampire
>/STUB:mkstub.exe, what it is do?
It's only one format; linker can make windows pe or com etc.

>I dont found any jmp instruction here...
You don't need jmp. When program works under Windows loader load windows pe,
otherwise under dos loading stub. There are two different programs in
one exe module. Please note that I use different linkers for making stub
and pe.

>For Dos Program I using Emux8086.
This dos program dont need emulator - it is 16-bit. But 32-bit dos program
with dos extender can works under dos and windows without any stubs.

Posted on 2003-01-19 08:24:00 by Mike
Originally posted by Mike
>For Dos Program I using Emux8086.
This dos program dont need emulator - it is 16-bit. But 32-bit dos program
with dos extender can works under dos and windows without any stubs.


What is DOS extender, how to use it. Can anyone give me the Sample Code on Binary or Asm code?. I see that a Program 32-bit was Executed after PE sign, on my understanding is the loader mean The Emulator.
"Give me some tutorial".
Posted on 2003-01-20 08:46:26 by realvampire
All DOS programs use small, medium, large or huge models and never flat. Why? DOS is 16-bit system. But if you add some dos extender you can execute 32-bit program with flat model under DOS. And under Windows too. You can see one example in attached file; DOS32 is name of DOS extender, you don't run it - simply start FREQ.EXE; without DOS32 you can't run it. Except all I recommend you to search in this forum for "WDOSX" - that's a name of another popular DOS extender and we discuss it approximately half year ago.

Posted on 2003-01-20 10:01:39 by Mike
I have been see the code, I dont know what is port 0x43 and 0x40 used for. Hmmm...., it is use mode 0x13 ( psst...pssstt thats why it is fullscreen). NICE. I Try to compile it with MASM but it is Crashes why?. This code is for DOS but able to use 32-bit Register(this is strange... :confused: ). Where is the Detailed info MIKE? which website?. I should learn a lot more of DOS32 or DOS extender. :alright:
Posted on 2003-01-20 11:32:26 by realvampire
you can use 32bit registers even in 16bit real mode. memory addressing is "somewhat" different though... then of course there's voodoo/realflat/realbig/whatever_that_hack_has_been_called.
Posted on 2003-01-20 11:35:04 by f0dder
Use <tasm %1.asm> and <dlink %1>. Description below in attached file.

Posted on 2003-01-21 09:27:14 by Mike

Your attachment "" seems to be empty:it doesn't contain any file. :confused:


Posted on 2003-01-21 09:46:56 by Vortex
Are you talking about "unreal mode" or the 0x66/0x67 hack :)
Posted on 2003-01-21 10:57:18 by SpooK
Another copy of file.

Posted on 2003-01-22 10:11:01 by Mike