home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 191.lha / MungeII / checkmunge.c < prev    next >
C/C++ Source or Header  |  1988-04-28  |  2KB  |  70 lines

  1. /************************************************
  2.  *  checkmunge - the companion to Bryce            *
  3.  *        Nesbitt's munge and my munge II            *
  4.  *                                                *
  5.  *  by Joe Pearce, El Cajon, CA (8/20/88)        *
  6.  ************************************************
  7.  *  Checkmunge will give a count of the            *
  8.  *  number of changed memory locations and        *
  9.  *  the addresses of the first twenty since        *
  10.  *  munge (or munge II) was run. If the            *
  11.  *  option 0 if given, it will instead check    *
  12.  *  for changs since munge II was put into        *
  13.  *  zeroing mode.                                *
  14.  *                                                *
  15.  *  USAGE: checkmunge [0]                        *
  16.  *    Note: only use after running munge (II)        *
  17.  *                                                *
  18.  *  Manx compile:                                *
  19.  *        cc checkmunge.c                            *
  20.  *        ln checkmunge.o -lc (ignore error msg)    *
  21.  ************************************************/
  22.  
  23. #include "exec/types.h"
  24. #include "exec/memory.h"
  25. #include "exec/execbase.h"
  26.  
  27. extern struct ExecBase *SysBase;
  28. long Output();
  29.  
  30. _main(alen,aptr) long alen; char *aptr;
  31. {    long    *addr[20],
  32.             *check;
  33.     long     i,
  34.             val = (alen && *aptr == '0' ? 0 : 0x01010101);
  35.     WORD     hits = 0;
  36.     ULONG    total = 0;
  37.     struct MemHeader *mh;
  38.     struct MemChunk *mc;
  39.     char buf[60];
  40.  
  41.     Write(Output(),"Working...\n",12L);
  42.  
  43.     Forbid();
  44.     for ( mh = (struct MemHeader *)SysBase->MemList.lh_Head;
  45.           mh->mh_Node.ln_Succ;
  46.           mh = (struct MemHeader *)mh->mh_Node.ln_Succ )
  47.     {    for (mc = mh->mh_First; mc; mc = mc->mc_Next)
  48.         {    i = mc->mc_Bytes - 8 >> 2;  /* number of longwords */
  49.             if (i == 0) continue;
  50.             check = (long *)mc + 2;
  51.             while (i--)
  52.             {    if (*check != val)
  53.                 {    total++;
  54.                     if (hits < 19) addr[hits++] = check;
  55.                 }
  56.                 check++;
  57.             }
  58.         }
  59.     }
  60.     Permit();
  61.  
  62.     sprintf(buf,"Number of changed longwords in memory: %lu.\n",total);
  63.     Write(Output(),buf,(long)strlen(buf));
  64.  
  65.     for (i=0; i<hits; i++)
  66.     {    sprintf(buf,"#%2ld: %08lx\n",i,addr[i]);
  67.         Write(Output(),buf,(long)strlen(buf));
  68.     }
  69. }
  70.