| 1 | /* $Id: QueryMemStat.c 1276 2004-02-20 22:08:31Z bird $ */
|
|---|
| 2 | /** @file
|
|---|
| 3 | * DosQueryMemState() exploration.
|
|---|
| 4 | * Based on toolkit example (addendum.inf).
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | /*******************************************************************************
|
|---|
| 8 | * Header Files *
|
|---|
| 9 | *******************************************************************************/
|
|---|
| 10 | #include <os2.h>
|
|---|
| 11 | #include <stdio.h>
|
|---|
| 12 | #include <string.h>
|
|---|
| 13 | #include <stdlib.h>
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | int main(int argc, char *argv[], char *envp[])
|
|---|
| 17 | {
|
|---|
| 18 | APIRET rc=0;
|
|---|
| 19 | PVOID pvMem;
|
|---|
| 20 | ULONG onepage = 0x1000;
|
|---|
| 21 |
|
|---|
| 22 | if (argc < 3)
|
|---|
| 23 | {
|
|---|
| 24 | printf("Syntax MEMSTATE <address> <cbMem>\n");
|
|---|
| 25 | return 0;
|
|---|
| 26 | }
|
|---|
| 27 | else
|
|---|
| 28 | {
|
|---|
| 29 | PVOID pvMem = (PVOID) strtoul(argv[1], NULL, 0);
|
|---|
| 30 | ULONG cbMem = strtoul(argv[2], NULL, 0);
|
|---|
| 31 | ULONG cPages = (cbMem+0x0fff) >> 12;
|
|---|
| 32 |
|
|---|
| 33 | printf(" address state\n");
|
|---|
| 34 | while (cPages > 0)
|
|---|
| 35 | {
|
|---|
| 36 | ULONG cbQuery = argc == 4 ? 0x1000 : cPages * 0x1000;
|
|---|
| 37 | ULONG fulFlags = 0xffffffff;
|
|---|
| 38 | rc = DosQueryMemState(pvMem, &cbQuery, &fulFlags);
|
|---|
| 39 | if (rc)
|
|---|
|
|---|