how to change the "this program cannot be run in the DOS mode" message in Win32 program when it runs in the pure DOS mode ?
Posted on 2002-07-24 01:58:07 by shazanhar
Modify fasm sources and recompile it, or modify the stub message using an hex editor or your own tool...
Posted on 2002-07-24 02:04:42 by JCP
You can write your own stub (it should be MZ .exe program, but fasm can also convert binary .com into MZ stub), and then use it for your PE programs by putting "on" operator with quoted file name at the end of "format PE" directive.
For example you can assemble the following code into mystub.exe:

format MZ

push cs
pop ds
mov dx,_msg
mov ah,9
int 21h

mov ax,4CFFh
int 21h

_msg db 'This is my own stub program!',0Dh,0Ah,24h

and the create Win32 program using this stub, this is the simpliest:

format PE on 'mystub.exe'

Posted on 2002-07-24 03:33:02 by Tomasz Grysztar
Another point for the 1.40 docs :tongue:
Posted on 2002-07-24 03:46:08 by bazik
thankyou !

"what i want is what i get"
Posted on 2002-07-25 01:16:31 by shazanhar
is this means that when i compile the code, the output is 2-in-1 program (one for MZ and one for PE) ?

is that mean that i can create program can work in both DOS mode and Win32 ?
Posted on 2002-07-26 01:29:30 by shazanhar
Certainly, and this is what FASM.EXE is! :)
Posted on 2002-07-26 02:10:59 by bitRAKE
yes you can !

by using "on" operator. for example :

; 2-in-1 program example (using "on" operator)

format PE GUI 4.0 on 'life.com' ; if in dos mode, it will run life.com automaticly

; life.asm can be found in '*\fasm\examples\life'.

include 'include\kernel.inc'
include 'include\user.inc'
include 'include\macro\stdcall.inc'
include 'include\macro\resource.inc'
include 'include\macro\import.inc'

repeat 5
invoke meb,NULL,mesej,tajuk,MB_OK
end repeat

invoke keluar

tajuk db 'win32',0
mesej db 'this is in win32',0

data import

library kdll,'kernel32.dll',\

import keluar,'ExitProcess'

import meb,'MessageBoxA'

end data

section '.rscr' resource data readable
directory RT_ICON,ikon,\

resource 2,LANG_NEUTRAL,data_ikon

resource 3,LANG_NEUTRAL,ikonutama

icon ikonutama,data_ikon,'c:\windows\asm.ico'

data fixups

end data

Posted on 2002-07-26 07:08:59 by shazanhar