Anybody knows how to call a Win32 program from a DOS program, in assembler?
Posted on 2003-07-22 05:54:27 by miguelossa
Posted on 2003-07-22 20:28:56 by P2M
That's the problem. It doesn't work. I paste details from another previous thread:

I've tried to call a Windows program from a DOS program (using tiny model, a .com file). The program is able to call another DOS program (I tested it and works ok), and restores the execution after the call point but, when I use it with my Windows program, the function returns me 'ok', the program is not executed, and the control returns to the main.

NOTE: I am using int 21h, ax=4b00h to execute the program.
Previously, the memory is released with ah=4ah
All the registers are recovered after the call.
Posted on 2003-07-23 00:02:09 by miguelossa
Try this code

; runfromdos.asm
; Microsoft (R) Macro Assembler Version 6.15.8803
; ml.exe /nologo /Cp /WX /W3 /AT runfromdos.asm

.model tiny



mov ax,end_programm + STACK_SIZE
mov sp,ax

mov cl,4
shr ax,cl
inc ax
mov bx,ax
mov ah,4Ah
int 21h

push ds
push es
push bp

mov WORD PTR cs:OldStk[0],sp
mov WORD PTR cs:OldStk[2],ss

mov bx,offset Env
mov dx,offset Spec2k
; mov dx,offset Spec9x

mov ax,4B00h
int 21h

mov sp, WORD PTR cs:OldStk[0]
mov ss, WORD PTR cs:OldStk[2]

pop bp
pop es
pop ds


OldStk dw 2 dup(0)
Env dw 14 dup(0)
Spec2k db 'c:\winnt\system32\calc.exe', 0
;Spec9x db 'c:\windows\calc.exe', 0

end_programm = $

I checked it on w9x and w2k
He works.

PS I hope you start programm from dosbox under win.
Posted on 2003-07-23 01:13:47 by P2M
It really works. Comparing with my program, I saw some differences. There must be a bug in my program, and it works with another DOS file, but nothing happens with a windows prog. You've give me a really good example to investigate.

Thank you :)
Posted on 2003-07-23 03:28:18 by miguelossa
Posted on 2003-07-23 06:22:23 by Vortex
i am only getting bits of your goal, but you already have dos structure. can you start a bat file and issue a start "windows program like you would from reg dos?

Posted on 2003-07-26 15:35:01 by dhicks586
The programs worked fine. I finally established communication between them using a text file. The Win prog. creates a file which is after accessed from the DOS prog. to obtain the response.

I don't know if exist another way to pass parameters between these two programs. If I were working entirely in Windows or DOS, I will use shared memory. But the win prog is working in protected mode and I suppose the VMM does the same, then I think it's impossible share anything between them.

I suppose... :confused:
Posted on 2003-07-26 17:02:43 by miguelossa