🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #2078

Re: HELP with GlobalDosAlloc

#2078
From: Tony Gosling
Date: Sun, 14 Apr 1991 08:14
33 lines
2277 bytes
In article <26158@hydra.gatech.EDU>, go3@prism.gatech.EDU (OLIVE JR,GEORGE A) writes:
> 
> We are trying to use GlobalDosAlloc to allocate a block of memory to be
> shared by a Windows application and a DOS application which has been
> started using WinExec.  The following code shows the basic calls that
> we are using.  wDosSeg is the real mode segment which is being sent as
> a parameter to the DOS program.  hDos is a global memory handle which
> is created from the selector in the LOWORD of the value returned by
> GlobalDosAlloc and is used to access the memory from within Windows.
> Unfortunately, this doesn't seem to work.  Data written to the memory
> area pointed to by lpDos doesn't appear in the memory area wDosSeg:0000
> when read by the DOS application.  We would be extremely grateful to 
> anyone who can point out what we are doing wrong.

Sorry, but this is not going to work.  GlobalDOSAlloc only allocates memory
addressable in the Windows context.  This complete context is swapped
when you run a DOS application.  The name 'Global' in GlobalDOSAlloc is
misleading in this case.

So now you ask, how can memory be shared between a DOS application
and Windows.  The only way I know of is to write a TSR which is run
BEFORE Windows is started.  This TSR reserves the memory required
and passes the memory address via some private interface to either
Windows or DOS applications.

There is a DPMI call to allocate DOS memory in protected mode.
This is unlikely to succeed since Windows takes all the DOS memory
it can find.  Don't bother trying to use this.

Tony Gosling,
aka tonyg@microsoft

The above are my opinions only and may not agree with those of Microsoft.
Technical Details
Message-ID: <3761@polari.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!ogicse!milton!sumax!polari!tonyg
References: <26158@hydra.gatech.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!ogicse!milton!sumax!polari!tonyg
From: tonyg@polari.UUCP (Tony Gosling)
Newsgroups: comp.windows.ms.programmer
Subject: Re: HELP with GlobalDosAlloc
Summary: Sharing memory outside windows...
Keywords: Windows Arggg help GlobalDosAlloc
Message-ID: <3761@polari.UUCP>
Date: 14 Apr 91 08:14:15 GMT
Article-I.D.: polari.3761
References: <26158@hydra.gatech.EDU>
Distribution: na
Organization: Seattle Online Public Unix (206) 328-4944
Lines: 33