Mail Archives: djgpp/1997/09/23/19:46:45
----=_3427fbfd10238430b2b6d09.MFSBCHJLHS
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
On Wed, 17 Sep 1997 07:42:39 -0700, Mitchell Spector
<spector AT EnchantedLearning DOT com> wrote:
> Can a DJGPP program running in a DOS box under Windows 95
> communicate with another currently-running program (either
> another DJGPP program in a different DOS box or a regular
> Win32 app)?
I wrote a quick demo that allows "talking" between DJGPP programs
sitting inside different DOS boxes. You'll have to install a TSR before
you start Win95. The TSR is written in NASM (search for nasm095.zip).
Currently, the "talking" capability is limited to set and retrieve one
word value.
Regards...
Michael
----=_3427fbfd10238430b2b6d09.MFSBCHJLHS
Content-Type: text/plain; charset=us-ascii; name=Tdbx.c
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=Tdbx.c
#include <stdio.h>
#include <stdlib.h>
#include <dpmi.h>
int Usage()
{
puts("Syntax: tdbx a_word_value\n\n"
"\ta_word_value will be stored inside the TDOSBox TSR.");
puts("Syntax: tdbx\n\n"
"\tRetrieves the word_value that has been stored inside the TDOSBox TSR.");
return 1;
}
int main(int argc,char* argv[])
{
__dpmi_regs regs;
enum { get,set } Action;
if(argc>1)
if(*argv[1]<'0' || *argv[1]>'9')
return Usage();
else
Action = set, regs.x.bx = 0x1111, regs.x.cx = atoi(argv[1]);
else
Action = get, regs.x.bx = 0x2222;
regs.x.ax = 0xCE00;
__dpmi_int(0x2F,®s);
if(0xFFFF!=regs.x.ax)
puts("TDOSBox TSR is not installed.");
else
if(get==Action)
printf("Value retrieved from TDOSBox TSR: %d\n",regs.x.bx);
else
puts("Value stored in TDOSBox TSR.");
return 0;
}
----=_3427fbfd10238430b2b6d09.MFSBCHJLHS
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
; To assemble, say 'nasm tdosbox.asm -o tdosbox.com' (tested with NASM 0.95).
;
;
; Purpose:
;
; Enables "talking" between two or more DOS boxes in Windows(95).
; See tdbx.c for a usage example.
;
; Usage:
;
; TDOSBox installs a new INT handler for INT2F, AX=CE00.
; If it is the last installed TSR in the INT2F chain, it uninstalls itsself.
;
; Install TDOSbox before starting Windows(95) if you want to communicate
; between two (or more) DOS boxes. You can use LoadHigh. Takes 320 bytes.
;
; Problems:
;
; TDOSBox is far from perfect,
; e.g. it does not check if another TSR already uses INT 2Fh, AX=CE00.
;
; Use at own risk. Released to the public domain by michael DOT mauch AT gmx DOT de
;
;
; INT 2F CE00 TDOSBox Installation check
;
; Inp.:
; AX = CE00h
; Return:
; AX = FFFFh
;
;
; INT 2F CE00 BX=1111 TDOSBox Set Flag
;
; Inp.:
; AX = CE00h
; BX = 1111h
; CX = TheFlag: a word that you want to be stored inside the TSR
; Return:
; AX = FFFFh
; BX = TheFlag
;
;
; INT 2F CE00 BX=2222 TDOSBox Get Flag
;
; Inp.:
; AX = CE00h
; BX = 2222h
; Return:
; AX = FFFFh
; BX = TheFlag: the word that has been stored by a previous call
; of "INT 2F CE00 BX=1111 TDOSBox Set Flag"
;
BITS 16
ORG 0x100
%define w word
%macro Say 1
mov dx,%1
mov ah,9 ; write a DOS string
int 21h
%endmacro
IntNum EQU 2Fh
ID EQU "tdbx"
; resident part:
Start: jmp TestInstall
OldInt dd 0
TheFlag dw 0
NewInt:
jmp short StartNewInt
dd ID ; ID for TestInstall
StartNewInt:
pushf
cmp ax,0CE00h
jne NotMe
ItsMe:
popf
cmp bx,1111h
jne NotSetFlag
mov [cs:TheFlag],cx
NotSetFlag:
cmp bx,2222h
mov bx,[cs:TheFlag]
jne GoHome
GoHome:
mov ax,0FFFFh
iret
NotMe:
popf
jmp far [cs:OldInt]
InstEnd:
; transient part (install/uninstall):
Copyleft db 13,10,"M.Mauch"
Installed db 13,10,"TDOSBox installed.",13,10,"$"
DeInstalled db 13,10,"TDOSBox uninstalled.",13,10,"$"
TestInstall:
push cs
pop ds
mov ax,3500h + IntNum ; get vector
int 21h ; (=> ES:BX)
cmp dword [es:bx+2],ID ; compare with ID
jne Install
DeInstall:
lds dx,[es:OldInt] ; load DS:DX with [OldInt]
mov ax,2500h + IntNum ; reset vector
int 21h
mov bx,es ; get segment adress of the program
mov ax,[es:2Ch] ; get segadr. of environment from PSP
or ax,ax
je EnvWasFreed
mov es,ax
mov ah,49h ; release memory of environment
int 21h
mov es,bx
EnvWasFreed:
mov ah,49h ; release memory of TSR
int 21h
push cs
pop ds
Say DeInstalled
mov ax,4C01h ; terminate with exit code 1
int 21h
Install:
mov ax,3500h+IntNum ; get vector
int 21h
mov w [OldInt+2],es ; store segment
mov w [OldInt],bx ; & offset
push cs
pop ds
mov ax,2500h + IntNum ; set vector
mov dx,NewInt ; DS:DX
int 21h
mov es,[ds:2Ch] ; release environment memory
mov ah,49h
int 21h
mov w [ds:2Ch],0 ; store address of environment in the PSP
Say Installed
InstallIt:
mov dx,InstEnd
mov cl,4
shr dx,cl
inc dx ; calc. paragraphs to keep
mov ax,3100h ; terminate with exit code 0
int 21h ; but stay resident
; End of tdosbox.asm
----=_3427fbfd10238430b2b6d09.MFSBCHJLHS--
- Raw text -