[comp.windows.ms.programmer] How to use GlobalDosAlloc

wilcox@wucs1.wustl.edu (Don Wilcox) (06/07/91)

Another question on talking to TSRs.  I have attempted to use a block of
memory allocated by GlobalDosAlloc() as follows:
    I allocated the memory, and separated the paragraph from the descriptor.
    I used WinExec() to start a DOS program which will fill this new buffer.
        The program takes on command-line parameter which is the HIWORD of the
        values returned from GlobalDosAlloc().
    When I have discovered that the DOS program has done its work, I GlobalLock
        the LOWORD from GDA() (not necessary since I am in 386Enh, but I do it
        anyways), and attempt to display the data using StretchDIBits().

The data is not in the buffer.  In fact, further investigation shows that the
2 buffers do not point to the same part of memory.  Anyone know what I am
doing wrong?  Just so you know, I am shifting the paragraph value 4 bits left
before trying to use it as an address in the DOS program.

Thanks for listening and helping (I love you all),

Don

Don Wilcox                         | "Hear, O Israel, the Lord your God, the
Washington University in St. Louis |     Lord is One."
email: wilcox@cs.wustl.edu         |

Thomas_Hornschuh@p1.f36.n245.z2.fidonet.org (Thomas Hornschuh) (06/13/91)

DW> Another question on talking to TSRs.  I have attempted to use a block of
DW> memory allocated by GlobalDosAlloc() as follows:
DW>     I allocated the memory, and separated the paragraph from the
DW> descriptor.
DW>     I used WinExec() to start a DOS program which will fill this new
DW> buffer.

[...]

DW> The data is not in the buffer.  In fact, further investigation shows that
DW> the
DW> 2 buffers do not point to the same part of memory.  Anyone know what I am
DW> doing wrong?  Just so you know, I am shifting the paragraph value 4 bits

In enhanced mode Windows in every DOS window got their own virtual mashines.
Each virtual mashine has a own adress space. GlobalDosAlloc allocates memory in 
the adress space of the "system virtual mashine" wich is shared by all windows 
apps. This memory is not mapped in the adress space of the DOS window.
The only way to pass data and control between windows and DOS-software is using 
the DPMI-services.

You should order the DPMI-specification (Intel Order Number: 240763-001) from 
Intel. DPMI provides support for communication between DOS-TSR's and protected 
mode software like windows. 

Send your order to the following address:
DPMI Committee Secretary
Software Focus Group
Intel Corp. NW1-18
2801 Northwestern Parkway
Santa Clara, CA 95051


+-----------+                         Thomas Hornschuh
|           |                     SoftStream Development
|   *       |           Obermarkstr. 72, D-4600 Dortmund 30, FRG
| *   *     |         Tel ++49-231-48 64 60  Fax ++49-231-48 85 98
|   *       |                        FidoNet 2:245/36.1
+-----------+ UseNet: Thomas_Hornschuh%p1.f36.n245.z2@hippo.dfv.rwth-aachen.de