Purpose
DosQueryMemState gets the status of a range of pages in memory. Its input parameters are an address and size. The address is rounded down to page boundary and size is rounded up to a whole number of pages. The status of the pages in the range is returned in the state parameter, and the size of the range queried is returned in the size parameter. If the pages in the range have conflicting states, then the state of the first page is returned.
Syntax
#define INCL_PROFILE #include os2.h>
APIRET APIENTRY DosQueryMemState
Parameters
pMem (PVOID) input
PAG_NPOUT 0x00000000
Returns
ulrc (APIRET) returns
DosQueryMemState returns one of the following values
87
Related Functions
Example Code
int main(int argc, char *argv[], char *envp[]){ APIRET rc=0; PVOID pMem; ULONG status; ULONG size; ULONG pages; ULONG onepage = 0x1000; if (argc 3) { printf("Syntax MEMSTATE address> size>\n"); return 0; } else { pMem = (PVOID) strtoul(argv[1], NULL, 0); size = strtoul(argv[2], NULL, 0); pages = (size+0x0fff) >> 12; printf("address state\n"); while (pages--) { rc = DosQueryMemState(pMem, onepage, status); if (rc) printf("0x%08x DosQueryMemState returned %u\n",pMem, rc); else { printf("0x%08x 0x%08x ", pMem, status); if ((status PAG_PRESMASK) == PAG_NPOUT) printf("not present, not in-core, "); else if (status PAG_PRESENT) printf("present, in-core, "); else if (status PAG_NPIN) printf("not present, in-core, "); if ((status PAG_TYPEMASK) == PAG_INVALID) printf("invalid\n"); if ((status PAG_TYPEMASK) == PAG_RESIDENT) printf("resident\n"); if ((status PAG_TYPEMASK) == PAG_SWAPPABLE) printf("swappable\n"); if ((status PAG_TYPEMASK) == PAG_DISCARDABLE) printf("discardable\n"); } pMem = (PVOID)((ULONG)pMem + 0x1000); } /* endwhile */ } /* end if*/ return rc; }