Jump to content

DevHelp VMGlobalToProcess: Difference between revisions

From EDM2
Created page with "This service maps an address in the system region of the global address space into an address in the address space of the current process. ==Syntax== ===C=== <PRE> USHORT AP..."
 
Ak120 (talk | contribs)
Line 114: Line 114:
<PRE>
<PRE>
           Before                              After
           Before                              After
  ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 4 Gigabytes ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  ┌───────────────────────┐ 4 Gigabytes ┌───────────────────────┐
  ³                       ³             ³                       ³
                                                         
  ³     System Region    ³             ³     System Region    ³
      System Region                    System Region   
  ³                       ³             ³                       ³
                                                         
  ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´             ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  ├───────────────────────┤             ├───────────────────────┤
  ³       Object A        ³             ³       Object A        ³
        Object A                          Object A       
  ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´             ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  ├───────────────────────┤             ├───────────────────────┤
  ³                       ³             ³                       ³
                                                         
  ÃÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄ´             ÃÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄ´
  ├───────┬───────┬───────┤             ├───────┬───────┬───────┤
  ³       ³       ³       ³             ³       ³       ³       ³
                                                 
  ³Process³Process³Process³             ³Process³Process³Process³
  │Process│Process│Process│             │Process│Process│Process│
  ³   A  ³   B  ³   C  ³             ³   A  ³   B  ³   C  ³
    A    B    C                A    B    C 
  ³Address³Address³Address³             ³Address³Address³Address³
  │Address│Address│Address│             │Address│Address│Address│
  ³ Space ³ Space ³ Space ³             ³ Space ³ Space ³ Space ³
  Space Space Space             Space Space Space
  ³       ³       ³       ³             ÃÄÄÄÄÄÄÄ´       ³       ³
                                ├───────┤            
  ³       ³       ³       ³             ³ Obj A ³       ³       ³
                                Obj A            
  ³       ³       ³       ³             ÃÄÄÄÄÄÄÄ´       ³       ³
                                ├───────┤            
  ³       ³       ³       ³             ³       ³       ³       ³
                                                 
  ÀÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÙ     0      ÀÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÙ
  └───────┴───────┴───────┘     0      └───────┴───────┴───────┘
</PRE>
</PRE>



Revision as of 14:56, 10 April 2019

This service maps an address in the system region of the global address space into an address in the address space of the current process.

Syntax

C

USHORT APIENTRY DevHelp_VMGlobalToProcess( ULONG Flags,
                                           LIN   LinearAddr,
                                           ULONG Length,
                                           PLIN  ProcessLinearAddr)

Assembler

MOV   EBX,LinearAddress     ; Linear Address in global address space
MOV   ECX,Length            ; Length (in bytes) of the memory object to be mapped
MOV   EAX,ActionFlags       ; Actions to perform on user region
                            ; If bit 0 (0001B) is set, the process context is
                            ;    mapped for read/write access to the object.  If
                            ;    this bit is clear, then read only permission is
                            ;    given (Note:  Some hardware may not support read
                            ;    only mapping).
                            ; If bit 1 (0010B) is set, 16-bit selectors are
                            ;    allocated to map the 32-bit region at 64KB
                            ;    boundaries similar to DosAllocHuge.
                            ; If bit 2 (0100B) is set, the mapping is tracked for
                            ;    validation and invalidation of screen buffers.
                            ; If bit 3 (1000B) is set, the memory is allocated on
                            ;    a 4MB boundary which improves performance on the
                            ;    screen group validation/invalidation.  This also
                            ;    reserves the entire 4MB region starting at the
                            ;    4MB boundary.
                            ; All other bits must be clear.

MOV   DL,DevHlp_VMGlobalToProcess

CALL  [Device_Help]

Parameters

C

Flags (ULONG)
Actions to perform on user region:
                        VMDHGP_WRITE - If bit 0 (0001B) is set, the process
                          context is mapped for read/write access to the
                          object. If this bit is clear, then read only
                          permission is given.
                        VMDHGP_SELMAP - If bit 1 (0010B) is set, 16-bit
                          selectors are allocated to map the 32-bit region
                          at 64KB boundaries similar to DosAllocHuge.
                        VMDGP_SGSCONTROL - If bit 2 (0100B) is set,
                          the mapping is tracked for validation and
                          invalidation of screen buffers.
                        VMDHGP_4MEG - If bit 3 (1000B) is set, the memory
                          is allocated on a 4MB boundary which improves
                          performance on the screen group
                          validation/invalidation. This also reserves
                          the entire 4MB region starting at the 4MB
                          boundary.
                       All other bits must be clear.
LinearAddr (LIN)
Linear address in global address space.
Length (ULONG)
Length in bytes of memory object to be mapped.
ProcessLinearAddr (PLIN)
Linear address within process' address space to be returned.

Assembler

MOV   EBX,LinearAddress     ; Linear Address in global address space
MOV   ECX,Length            ; Length (in bytes) of the memory object to be mapped
MOV   EAX,ActionFlags       ; Actions to perform on user region
                            ; If bit 0 (0001B) is set, the process context is
                            ;    mapped for read/write access to the object.  If
                            ;    this bit is clear, then read only permission is
                            ;    given (Note:  Some hardware may not support read
                            ;    only mapping).
                            ; If bit 1 (0010B) is set, 16-bit selectors are
                            ;    allocated to map the 32-bit region at 64KB
                            ;    boundaries similar to DosAllocHuge.
                            ; If bit 2 (0100B) is set, the mapping is tracked for
                            ;    validation and invalidation of screen buffers.
                            ; If bit 3 (1000B) is set, the memory is allocated on
                            ;    a 4MB boundary which improves performance on the
                            ;    screen group validation/invalidation.  This also
                            ;    reserves the entire 4MB region starting at the
                            ;    4MB boundary.
                            ; All other bits must be clear.

Return Code

C

Success Indicator: 0 if conversion performed - returns ProcessLinearAddr.

Possible errors: Carry flag set if conversion not performed.

Assembler

   'C' Clear if conversion performed.
       EAX = Linear address within process's address space.

   'C' Set if conversion not performed.
       EAX = Error code.

Remarks

The mapping created by this function must be released with VMFree. The address range must not cross object boundaries. The address space used in this service is of the current process. In the following figure, VMGlobalToProcess maps the memory allocated with VMAlloc into Process A's private address space.

The following figure shows Mapping Performed by VMGlobalToProcess.

           Before                               After
 ┌───────────────────────┐ 4 Gigabytes ┌───────────────────────┐
 │                       │             │                       │
 │     System Region     │             │     System Region     │
 │                       │             │                       │
 ├───────────────────────┤             ├───────────────────────┤
 │       Object A        │             │       Object A        │
 ├───────────────────────┤             ├───────────────────────┤
 │                       │             │                       │
 ├───────┬───────┬───────┤             ├───────┬───────┬───────┤
 │       │       │       │             │       │       │       │
 │Process│Process│Process│             │Process│Process│Process│
 │   A   │   B   │   C   │             │   A   │   B   │   C   │
 │Address│Address│Address│             │Address│Address│Address│
 │ Space │ Space │ Space │             │ Space │ Space │ Space │
 │       │       │       │             ├───────┤       │       │
 │       │       │       │             │ Obj A │       │       │
 │       │       │       │             ├───────┤       │       │
 │       │       │       │             │       │       │       │
 └───────┴───────┴───────┘      0      └───────┴───────┴───────┘

Example Code

C

#include  "dhcalls.h"

USHORT APIENTRY DevHelp_VMGlobalToProcess( ULONG Flags,
                                           LIN   LinearAddr,
                                           ULONG Length,
                                           PLIN  ProcessLinearAddr)

Related Functions