main2rdp.c 907 Bytes
#include <stdio.h>
#include <stdlib.h>

#define LIST_ADDR   (8*4)
#define COUNT_ADDR  (9*4)

main (int argc,  char *argv[])
{
    FILE *fp;
    int startaddr;
    int countaddr;
    int count;
    unsigned char *cp;
    
    if (argc != 2) {
	fprintf(stderr, "Usage: %s memory_file\n", argv[0]);
	exit(1);
    }
    
    if ( (fp = fopen(argv[1], "r")) == NULL) {
	fprintf(stderr, "Could not open %s\n", argv[1]);
	exit(1);
    }
    
    fseek(fp, LIST_ADDR, SEEK_SET);
    fread(&startaddr, sizeof (startaddr), 1, fp);
    fseek(fp, COUNT_ADDR, SEEK_SET);
    fread(&countaddr, sizeof (countaddr), 1, fp);
    fseek(fp, countaddr, SEEK_SET);
    fread(&count, sizeof (count), 1, fp);
    
/*fprintf(stderr, "start 0x%x, count 0x%x\n", startaddr, count);*/
    
    cp = (unsigned char *)malloc(count*4);
    fseek(fp, startaddr, SEEK_SET);
    fread(cp, count, 1, fp);
    fwrite(cp, count, 1, stdout);
}