home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d533 / vtest.lha / VTest / VTest.c < prev    next >
C/C++ Source or Header  |  1991-08-26  |  10KB  |  337 lines

  1. /*****************************************
  2.  ***
  3.  *** FILE   : VirusTest.c
  4.  *** ------------------------------------
  5.  *** DATE   : 07.08.91
  6.  *** ------------------------------------
  7.  *** AUTHOR : Frank Enderle
  8.  *** ------------------------------------
  9.  *** VERSION: 1.0
  10.  ***
  11.  *****************************************/
  12.  
  13.  
  14. #include <exec/types.h>
  15. #include <exec/execbase.h>
  16. #include <graphics/text.h>
  17. #include <graphics/gfxbase.h>
  18. #include <intuition/intuitionbase.h>
  19.  
  20. #define WINNAME     "                    W A R N I N G                     "
  21.  
  22. #define NOERROR     0L
  23. #define ILLEGALMSG  1L
  24. #define NOGFX       2L
  25. #define NOINTUITION 3L
  26. #define NOWINDOW    4L
  27. #define NOFONT      5L
  28.  
  29. #define QUIT        3L
  30. #define HARDRESET   2L
  31. #define CLRVECS     1L
  32.  
  33. struct ExecBase         *ExecBase;
  34. struct GfxBase          *GfxBase;
  35. struct IntuitionBase    *IntuitionBase;
  36. struct Window           *MyWin;
  37. struct IntuiMessage     *MyIMsg;
  38. struct TextFont         *MyFont;
  39.  
  40. extern ULONG            SysBase;
  41.  
  42. struct Gadget           Gad3    = {NULL,299,148,114,14,GADGHCOMP,
  43.                                    RELVERIFY,BOOLGADGET,NULL,
  44.                                    NULL,NULL,NULL,NULL,QUIT,NULL};
  45. struct Gadget           Gad2    = {&Gad3,162,148,114,14,GADGHCOMP,
  46.                                    RELVERIFY,BOOLGADGET,NULL,
  47.                                    NULL,NULL,NULL,NULL,HARDRESET,NULL};
  48. struct Gadget           Gad1    = {&Gad2,25,148,114,14,GADGHCOMP,
  49.                                    RELVERIFY,BOOLGADGET,NULL,
  50.                                    NULL,NULL,NULL,NULL,CLRVECS,NULL};
  51.  
  52. struct NewWindow        MyWinNW = {90,5,445,183,-1,-1,GADGETUP,
  53.                                    ACTIVATE|GIMMEZEROZERO,&Gad1,
  54.                                    NULL,(UBYTE *)WINNAME,NULL,NULL,0,0,
  55.                                    0,0,WBENCHSCREEN};
  56.  
  57. struct TextAttr         MyAttr  = {"topaz.font",TOPAZ_EIGHTY,FS_NORMAL,
  58.                                    FPF_ROMFONT|FPF_DESIGNED};
  59.  
  60. USHORT  MyCode;
  61. ULONG   MyClass;
  62. APTR    MyAdr;
  63.  
  64. CheckVecs()
  65. {
  66.  ExecBase = SysBase;
  67.  if(ExecBase->ColdCapture != NULL) return(Virus());
  68.  if(ExecBase->CoolCapture != NULL) return(Virus());
  69.  if(ExecBase->WarmCapture != NULL) return(Virus());
  70.  if(ExecBase->KickMemPtr  != NULL) return(Virus());
  71.  if(ExecBase->KickTagPtr  != NULL) return(Virus());
  72.  if(GetDoIO()        < 0x00f00000) return(Virus());
  73.  if(GetSendIO()      < 0x00f00000) return(Virus());
  74.  if(GetSumKick()     < 0x00f00000) return(Virus());
  75.  return(NOERROR);
  76. }
  77.  
  78. Virus()
  79. {
  80.  OpenAll();
  81.  SetUpWindow();
  82.  SetUpData();
  83.  FOREVER
  84.  {
  85.   Wait(1L<<MyWin->UserPort->mp_SigBit);
  86.   while(MyIMsg=(struct IntuiMessage *)GetMsg(MyWin->UserPort))
  87.   {
  88.    MyClass = MyIMsg->Class;
  89.    MyCode  = MyIMsg->Code;
  90.    MyAdr   = MyIMsg->IAddress;
  91.    ReplyMsg(MyIMsg);
  92.    switch(MyClass)
  93.    {
  94.     case GADGETUP:  switch((((struct Gadget *)MyAdr)->GadgetID))
  95.                     {
  96.                      case CLRVECS:      ExecBase->ColdCapture = NULL;
  97.                                         ExecBase->CoolCapture = NULL;
  98.                                         ExecBase->WarmCapture = NULL;
  99.                                         ExecBase->KickMemPtr  = NULL;
  100.                                         ExecBase->KickTagPtr  = NULL;
  101.                                         ExecBase->ChkSum      = CheckSum();
  102.                                         ExecBase->KickCheckSum= NULL;
  103.                                         CloseAll();
  104.                                         return(NOERROR);
  105.                                         break;
  106.                      case HARDRESET:    ColdReset();
  107.                                         CloseAll();
  108.                                         return(NOERROR);
  109.                                         break;
  110.                      case QUIT:         CloseAll();
  111.                                         return(NOERROR);
  112.                                         break;
  113.                      default:           CloseAll();
  114.                                         return(ILLEGALMSG);
  115.                                         break;
  116.                     }
  117.                     break;
  118.     default:        CloseAll();
  119.                     return(ILLEGALMSG);
  120.                     break;
  121.    }
  122.   }
  123.  }
  124. }
  125.  
  126. SetUpData()
  127. {
  128.  Check(ExecBase->ColdCapture,47);
  129.  Check(ExecBase->CoolCapture,57);
  130.  Check(ExecBase->WarmCapture,67);
  131.  Check(ExecBase->KickMemPtr,82);
  132.  Check(ExecBase->KickTagPtr,92);
  133.  CheckDoIO();
  134.  CheckSendIO();
  135.  CheckSumKick();
  136. }
  137.  
  138. CheckDoIO()
  139. {
  140.  ULONG Buffer;
  141.  UBYTE String[80];
  142.  Buffer = GetDoIO();
  143.  sprintf(String,"($ %08x)",Buffer);
  144.  Print(MyWin,String,325,107,0);
  145.  if(Buffer < 0x00f00000)
  146.   Print(MyWin,"** ALTERED **",189,107,0);
  147.  if(Buffer > 0x00f00000)
  148.   Print(MyWin,"unset",189,107,0);
  149. }
  150.  
  151. CheckSendIO()
  152. {
  153.  ULONG Buffer;
  154.  UBYTE String[80];
  155.  Buffer = GetSendIO();
  156.  sprintf(String,"($ %08x)",Buffer);
  157.  Print(MyWin,String,325,117,0);
  158.  if(Buffer < 0x00f00000)
  159.   Print(MyWin,"** ALTERED **",189,117,0);
  160.  if(Buffer > 0x00f00000)
  161.   Print(MyWin,"unset",189,117,0);
  162. }
  163.  
  164. CheckSumKick()
  165. {
  166.  ULONG Buffer;
  167.  UBYTE String[80];
  168.  Buffer = GetSumKick();
  169.  sprintf(String,"($ %08x)",Buffer);
  170.  Print(MyWin,String,325,127,0);
  171.  if(Buffer < 0x00f00000)
  172.   Print(MyWin,"** ALTERED **",189,127,0);
  173.  if(Buffer > 0x00f00000)
  174.   Print(MyWin,"unset",189,127,0);
  175. }
  176.  
  177. Check(Vec,Line)
  178. ULONG Vec;
  179. SHORT Line;
  180. {
  181.  UBYTE Buffer[80];
  182.  sprintf(Buffer,"($ %08x)",Vec);
  183.  Print(MyWin,Buffer,325,Line,0);
  184.  if(Vec == NULL)
  185.   Print(MyWin,"unset",189,Line,0);
  186.  if(Vec != NULL)
  187.   Print(MyWin,"** ALTERED **",189,Line,0);
  188. }
  189.  
  190. SetUpWindow()
  191. {
  192.  Box(MyWin,22,146,141,163);
  193.  Box(MyWin,159,146,278,163);
  194.  Box(MyWin,296,146,415,163);
  195.  Print(MyWin,"Some System Vectors are not default. Check if there",0,8,1);
  196.  Print(MyWin,"are running resident programs !",0,20,1);
  197.  Print(MyWin,"ColdCapture        :",21,47,0);
  198.  Print(MyWin,"CoolCapture        :",21,57,0);
  199.  Print(MyWin,"WarmCapture        :",21,67,0);
  200.  Print(MyWin,"KickMemPtr         :",21,82,0);
  201.  Print(MyWin,"KickTagPtr         :",21,92,0);
  202.  Print(MyWin,"DoIO               :",21,107,0);
  203.  Print(MyWin,"SendIO             :",21,117,0);
  204.  Print(MyWin,"SumKickData        :",21,127,0);
  205.  Print(MyWin,"CLR VECTORS",37,151,0);
  206.  Print(MyWin,"HARD RESET",181,151,0);
  207.  Print(MyWin,"It's OK",327,151,0);
  208. }
  209.  
  210. OpenAll()
  211. {
  212.  IntuitionBase          =   OpenLibrary("intuition.library",NULL);
  213.    if(IntuitionBase == NULL) { CloseAll(); return(NOINTUITION); }
  214.  GfxBase                =   OpenLibrary("graphics.library",NULL);
  215.    if(GfxBase       == NULL) { CloseAll(); return(NOGFX);       }
  216.  MyWin                  =   OpenWindow(&MyWinNW);
  217.    if(MyWin         == NULL) { CloseAll(); return(NOWINDOW);    }
  218.  MyFont                 =   OpenFont(&MyAttr);
  219.    if(MyFont        == NULL) { CloseAll(); return(NOFONT);      }
  220.  SetFont(MyWin->RPort,MyFont);
  221. }
  222.  
  223. CloseAll()
  224. {
  225.  if(MyWin)                  CloseWindow(MyWin);
  226.  if(MyFont)                 CloseFont(MyFont);
  227.  if(IntuitionBase)          CloseLibrary(IntuitionBase);
  228.  if(GfxBase)                CloseLibrary(GfxBase);
  229.  return();
  230. }
  231.  
  232. Box(Win,x1,y1,x2,y2)
  233. struct Window *Win;
  234. SHORT x1,y1,x2,y2;
  235. {
  236.  SetDrMd(Win->RPort,JAM1);
  237.  SetAPen(Win->RPort,1);
  238.  Move(Win->RPort,x1,y1);
  239.  Draw(Win->RPort,x2,y1);
  240.  Draw(Win->RPort,x2,y2);
  241.  Draw(Win->RPort,x1,y2);
  242.  Draw(Win->RPort,x1,y1);
  243.  Move(Win->RPort,x2+1,y1);
  244.  Draw(Win->RPort,x2+1,y2);
  245.  Move(Win->RPort,x1-1,y1);
  246.  Draw(Win->RPort,x1-1,y2);
  247.  SetAPen(Win->RPort,2);
  248.  Move(Win->RPort,x2+2,y1+1);
  249.  Draw(Win->RPort,x2+2,y2+1);
  250.  Move(Win->RPort,x2+3,y1+1);
  251.  Draw(Win->RPort,x2+3,y2+1);
  252.  Draw(Win->RPort,x1+2,y2+1);
  253. }
  254.  
  255. Print(Win,msg,x,y,c)
  256. struct Window *Win;
  257. STRPTR msg;
  258. SHORT  x,y;
  259. BOOL   c;
  260. {
  261.  SHORT SLen,Len;
  262.  SetDrMd(Win->RPort,JAM1);
  263.  SetAPen(Win->RPort,2);
  264.  SLen = strlen(msg);
  265.  Len  = ((Win->Width-TextLength(Win->RPort,msg,SLen))/2)-2;
  266.  if(c == 0)
  267.   Move(Win->RPort,x+2,y+Win->RPort->TxBaseline+1);
  268.  if(c == 1)
  269.   Move(Win->RPort,Len+2,y+Win->RPort->TxBaseline+1);
  270.  Text(Win->RPort,msg,strlen(msg));
  271.  SetAPen(Win->RPort,1);
  272.  if(c == 0)
  273.   Move(Win->RPort,x,y+Win->RPort->TxBaseline);
  274.  if(c == 1)
  275.   Move(Win->RPort,Len,y+Win->RPort->TxBaseline);
  276.  Text(Win->RPort,msg,strlen(msg));
  277. }
  278.  
  279. #asm
  280.             public  _GetDoIO
  281.             public  _GetSendIO
  282.             public  _GetSumKick
  283.             public  _CheckSum
  284.             public  _ColdReset
  285.  
  286.             public  _LVODoIO
  287.             public  _LVOSendIO
  288.             public  _LVOSumKick
  289.             public  _LVOSuperState
  290.  
  291. _GetDoIO:   movem.l a1-a6,-(a7)
  292.             move.l  _SysBase,a6
  293.             lea     _LVODoIO(a6),a1
  294.             lea     2(a1),a2
  295.             move.l  (a2),d0
  296.             movem.l (a7)+,a1-a6
  297.             rts
  298.  
  299. _GetSendIO: movem.l a1-a6,-(a7)
  300.             move.l  _SysBase,a6
  301.             lea     _LVOSendIO(a6),a1
  302.             lea     2(a1),a2
  303.             move.l  (a2),d0
  304.             movem.l (a7)+,a1-a6
  305.             rts
  306.  
  307. _GetSumKick:
  308.             movem.l a1-a6,-(a7)
  309.             movem.l _SysBase,a6
  310.             lea     _LVOSumKick(a6),a1
  311.             lea     2(a1),a2
  312.             move.l  (a2),d0
  313.             movem.l (a7)+,a1-a6
  314.             rts
  315.  
  316. _CheckSum:  movem.l a0-a6/d1-d7,-(a7)
  317.             move.l  _SysBase,a6
  318.             lea     34(a6),a1
  319.             move.l  #22,d0
  320.             move.l  #0,d1
  321. Chk:        add     (a1)+,d1
  322.             dbf     d0,Chk
  323.             not     d1
  324.             move.l  d1,d0
  325.             movem.l (a7)+,a0-a6/d1-d7
  326.             rts
  327.  
  328. _ColdReset: movem.l a0-a6,-(a7)
  329.             move.l  _SysBase,a6
  330.             jsr     _LVOSuperState(a6)
  331.             not.l   38(a6)
  332.             jmp     $FC0000
  333.             movem.l (a7)+,a0-a6
  334.             rts
  335.  
  336. #endasm
  337.