home *** CD-ROM | disk | FTP | other *** search
- /* showmem.c (emx+gcc) */
-
- #define INCL_DOSMEMMGR
- #include <os2.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- int main (void)
- {
- ULONG rc, size, flags, base, esp;
- char big[10000], *heap;
-
- heap = malloc (1);
- big[0] = 0;
- base = 0x10000;
- esp = (ULONG)&esp;
- for (;;)
- {
- size = 0xffffffff;
- rc = DosQueryMem ((PVOID)base, &size, &flags);
- if (rc != 0)
- {
- printf ("DosQueryMem failed, rc=%lu\n", rc);
- return (1);
- }
- printf ("%.8lx - %.8lx (%.8lx)", base, base + size - 1, size);
- if (flags & PAG_FREE) printf (" FREE ");
- if (flags & PAG_COMMIT) printf (" COMMIT");
- if (flags & PAG_GUARD) printf (" GUARD ");
- if (flags & PAG_SHARED) printf (" share ");
- if (flags & PAG_READ) printf (" read ");
- if (flags & PAG_READ) printf (" write ");
- if (flags & PAG_EXECUTE) printf (" exec ");
- if (base <= esp && esp < base + size) printf ("<-- ESP");
- putchar ('\n');
- base += size;
- if (base == 0) break;
- }
- return (0);
- }
-