#ifndef useregcheck
  #print "regcheck.hmm: [1;36;44myou can use #define useregcheck[1;37;40m\n"
#endif

#define CHECKREGSEBX 1
#define CHECKREGSESI 2
#define CHECKREGSEDI 4
#define CHECKREGSEBP 8
#define CHECKREGSESP 16

#ifdef useregcheck
  #include "myprintf.h--"

  struct CheckRegistersClass
  {
    dword regsptr_;
    dword regsstr;
    dword oldEBX;
    dword oldESI;
    dword oldEDI;
    dword oldESP;
    CheckRegistersClass(dword str,regsptr,regs);
    ~CheckRegistersClass();
  };

  :CheckRegistersClass::CheckRegistersClass(dword str,regsptr,regs)inline
  uses EAX ECX EDX
  {
    EAX=SSDWORD[ESP+0x10];//str

    $push SSDWORD[ESP+0x14];
    $pop  EAX.CheckRegistersClass.regsstr;

    EDX=SSDWORD[ESP+0x18];//regsptr
    EAX.CheckRegistersClass.regsptr_=EDX;

    CL=SSBYTE[ESP+0x1C];//regs
    DSBYTE[EDX]|=CL;

    EAX.CheckRegistersClass.oldEBX=EBX;
    EAX.CheckRegistersClass.oldESI=ESI;
    EAX.CheckRegistersClass.oldEDI=EDI;
    ECX=ESP+0x20;
    EAX.CheckRegistersClass.oldESP=ECX;
    return;
  }

  :CheckRegistersClass::~CheckRegistersClass()inline
  uses EAX ECX EDX
  {
    EAX=SSDWORD[ESP+0x10];
    EDX=EAX.CheckRegistersClass.regsptr_;
    ECX=ESP+0x18;

    IF(!$test DSBYTE[EDX],CHECKREGSEBX )&&(EAX.CheckRegistersClass.oldEBX!=EBX)
    {
      $pushad
      DSBYTE[EDX]|=CHECKREGSEBX;
      myprintf("EBX is damaged in \"%s\"\n",EAX.CheckRegistersClass.regsstr);
      $popad
    }
    IF(!$test DSBYTE[EDX],CHECKREGSESI )&&(EAX.CheckRegistersClass.oldESI!=ESI)
    {
      $pushad
      DSBYTE[EDX]|=CHECKREGSESI;
      myprintf("ESI is damaged in \"%s\"\n",EAX.CheckRegistersClass.regsstr);
      $popad
    }
    IF(!$test DSBYTE[EDX],CHECKREGSEDI )&&(EAX.CheckRegistersClass.oldEDI!=EDI)
    {
      $pushad
      DSBYTE[EDX]|=CHECKREGSEDI;
      myprintf("EDI is damaged in \"%s\"\n",EAX.CheckRegistersClass.regsstr);
      $popad
    }
    IF(!$test DSBYTE[EDX],CHECKREGSESP )&&(EAX.CheckRegistersClass.oldESP!=ECX)
    {
      ECX-=EAX.CheckRegistersClass.oldESP;
      $pushad
      DSBYTE[EDX]|=CHECKREGSESP;
      myprintf("ESP is damaged in \"%s\", deltaESP= %d\n",EAX.CheckRegistersClass.regsstr,ECX);
      $popad
    }

    return;
  }

  #define CHECKREGSINIT(str,reg) static dword checkregistersclassregs;CheckRegistersClass checkregistersclass;checkregistersclass.CheckRegistersClass(str,#checkregistersclassregs,reg);
#else
  #define CHECKREGSINIT(str,reg)
#endif
