#include <stdio.h>
#include <stdlib.h>
#include <dos.h>

struct win_info {
    unsigned char type;
    unsigned long length;
    unsigned long base;
    unsigned short parent;
};

extern  int get_window_info(unsigned short, struct win_info *);
static void info(char *, void far *);

main()
{
    int size;
    static int data;
    char *heap;

    info("stack", (void far *)&size);
    info("data", (void far *)&data);
    info("text", (void far *)main);
    size = 0x10000 - 4;
    while (heap = malloc(size))
	    info("heap", (void far *)heap);
    perror("malloc");
    info("text", (void far *)main);
}

static void
info(name, addr)
char *name;
void far *addr;
{
    struct win_info info;

    printf("%s: %#x:%#x ", name, FP_SEG(addr), FP_OFF(addr));
    if (get_window_info(FP_SEG(addr), &info) < 0) {
	fflush(stdout);
	perror(name);
	putchar('\n');
    } else
	printf("type %#x base %#x length %#x\n", info.type, info.base, info.length);
}
