DosQueryMem provides the capability to determine the type and access protection of a range of pages within the virtual-address space of the subject process. This is the only memory-management function that accepts an address range that is not entirely contained within a previously allocated memory object.
The state of the first page within the region is determined, then subsequent entries in the virtual-address space of the process are scanned from the base address upward until either the entire range of pages has been scanned, a page with a nonmatching set of attributes is encountered, or the first page in an adjacent allocated memory object is encountered. The region attributes, the length of the range of pages with matching attributes, and an appropriate error code are returned.
If the entire requested range of pages does not have a matching set of attributes, then the returned pcb parameter value can be used to calculate the address and length of the range of pages that were not scanned.
Page scanning stops when the first page in an adjacent allocated memory object is encountered. This allows the calling application to determine the appearance of the virtual memory map, including object boundaries.
A region of pages that is neither committed nor free is considered reserved, that is, it is contained within an allocated memory object but has an access protection of "no access".
If the allocation type returned indicates that the pages are reserved, that is, neither PAG_COMMIT nor PAG_FREE is set, then the access protection returned is the same as was specified when the object was allocated in the address space of the requesting process.
With the Intel 80386 processor, execute and read access are equivalent. Also, write access implies both read and execute access.
Note: DosAllocMem and DosAllocSharedMem both allocate a block of memory of the size requested rounded to the nearest page. On OS/2 Warp, the system allocates a 64K object without attributes on every allocation.
For example, for a DosAllocMem call with a size of 1, the following occurs:
Note:
When you allocate a memory object with the PAG_EXECUTE attribute, it is implied that this memory object also has the PAG_READ attribute. However, when querying the attributes of a memory object, you will get the following results: