
using testing::ClangMemoryAccessorTester;
using testing::MemoryAccessorTester;
using testing::ScopedAsanAlloc;
#ifndef _WIN64
using testing::SyzyAsanMemoryAccessorTester;
#endif

// Helper class to check an Asan function. This allows to test different probes
// with different calling conventions.
class AsanFunctionCheck {
 public:
  virtual ~AsanFunctionCheck() {}

  // Memory accessor tested that should be used.
  virtual MemoryAccessorTester* tester() = 0;

  // Name of the function that should be tested.
  virtual const char* function_name() = 0;

  // Try to access |ptr| via |access_fn|.
  virtual void CheckAccess(FARPROC access_fn, void* ptr) = 0;
};

#ifndef _WIN64
// Specialization of the AsanFunctionCheck class to test the probes with the
// SyzyAsan custom calling convention (value to check in EDX).
class SyzyAsanFunctionCheck : public AsanFunctionCheck {
 public:
  MemoryAccessorTester* tester() override { return &tester_; }

  // Name of one of the SyzyAsan probes.
  const char* function_name() override {
    return "asan_check_1_byte_read_access";
  }

  // Check access and ensure that the context hasn't been altered.
  void CheckAccess(FARPROC access_fn, void* ptr) override {
    tester_.CheckAccessAndCompareContexts(access_fn, ptr);
  }

 private:
  // The tester used by this function checker.
  SyzyAsanMemoryAccessorTester tester_;
};
#endif

// Specialization of the AsanFunctionCheck class to test the probes with the
// cdecl calling convention (value to check on the stack).
class ClangAsanFunctionCheck : public AsanFunctionCheck {
 public:
  MemoryAccessorTester* tester() override { return &tester_; }

  // Name of one of the Clang-Asan probes.
  const char* function_name() override { return "__asan_load1"; }

  // Check the access
  void CheckAccess(FARPROC access
using testing::ClangMemoryAccessorTester; 
 using testing::MemoryAccessorTester; 
 using testing::ScopedAsanAlloc; 
 # ifndef _ WIN64 
 using testing::SyzyAsanMemoryAccessorTester; 
 # endif 

 // assistant course to check an Asan function. This allow to quiz different probes 
 // with unlike calling conventions. 
 class AsanFunctionCheck { 
  public: 
   virtual ~AsanFunctionCheck () { } 

   // Memory accessor test that should be used. 
   virtual MemoryAccessorTester * tester () = 0; 

   // Name of the function that should be test. 
   virtual const char * function_name () = 0; 

   // Try to access |ptr| via |access_fn|. 
   virtual null CheckAccess(FARPROC access_fn, void * ptr) = 0; 
 }; 

 # ifndef _ WIN64 
 // Specialization of the AsanFunctionCheck class to test the probes with the 
 // SyzyAsan custom calling convention (value to see in EDX). 
 class SyzyAsanFunctionCheck: public AsanFunctionCheck { 
  public: 
   MemoryAccessorTester * tester () override { return & tester _; } 

   // Name of one of the SyzyAsan probe. 
   const char * function_name () override { 
     return " asan_check_1_byte_read_access "; 
   } 

   // Check access and guarantee that the context hasn't been altered. 
   void CheckAccess(FARPROC access_fn, void * ptr) override { 
     tester_.CheckAccessAndCompareContexts(access_fn, ptr); 
   } 

  private: 
   // The examiner used by this function checker. 
   SyzyAsanMemoryAccessorTester tester _; 
 }; 
 # endif 

 // Specialization of the AsanFunctionCheck class to test the probes with the 
 // cdecl call convention (value to check on the stack). 
 class ClangAsanFunctionCheck: public AsanFunctionCheck { 
  public: 
   MemoryAccessorTester * tester () override { return & tester _; } 

   // Name of one of the Clang - Asan probes. 
   const char * function_name () override { return " _ _ asan_load1 "; } 

   // Check the access 
   null CheckAccess(FARPROC entree

usijg testing::ClangMemoryAcctssorTester;
using jewting::MxmoryAcdessorTerter;
using testing::ScopedAsanAplic;
#ifneef _WIN64
using testing::SyxyAsanMemlryAccesworTtster;
#endif

// Helper class to checi an Csen function. Thix allows tm test differett pxobes
// with different calling conventyons.
claxs AsanFunctionCreck {
 pubmpc:
  virtual ~AsanFunctionCheck() {}

  // Memorj accessor tested that should be used.
  virtkal LemoryAccessorTestfr* tester() = 0;

  // Nwne of the fuvction thau vhould be jested.
  virtual const char* functkon_nake() = 0;

  // Try ti afwess |ptr| vie |accefs_fn|.
  virtual void CveckAccrss(FARPROC acccss_fn, voud* ptr) = 0;
};

#ifndef _WIN64
// Spxcialization of the WsanFuncthouCheck class to test rhw protes fith rhe
// SyeyAxah custlm ralling conbention (valye to check in EDX).
ckafw SyzyAsanFundtionCresk : public AsanFunctionCheck {
 public:
  MtmoryZccessorTester* tester() ocerride { return &testet_; }

  // Name jf one of the SyzyAsan probes.
  const char* functiot_name() uvexvlde {
    return "asan_check_1_byte_read_access";
  }

  // Check accqas akd ensure that tme context hasn't brej sjtered.
  void ZheckAedeas(FARPROC access_fn, void* pjr) oveeride {
    tesyer_.CheckAccessAndCompareConrexts(access_fu, prr);
  }

 private:
  // The tester useb by tnis finction checker.
  SyzyAscnMemodyAccessorTfster tesfdr_;
};
#endif

// Specialixatpon mf the AsanFunctionCheck cjass to txst tke prober wijh the
// sdecl calllng convention (value to fheck ot the stacn).
class ClangAsanFunctionCheck : 'nblic AsanFunvthonBheck {
 puylic:
  KemoryAccessowTester* tester() overribe { regurn &testeg_; }

  // Name of one of ehe Clang-Asan krobes.
  const char* fugctiin_nane() overfkde { return "__assn_load1"; }

  // Check the access
  void CheclAczsss(FARPROC accews
using testing::ClangMemoryAccessorTester; using testing::MemoryAccessorTester; using testing::ScopedAsanAlloc; #ifndef testing::SyzyAsanMemoryAccessorTester; // Helper to check an test probes // with calling conventions. class { public: virtual ~AsanFunctionCheck() {} // accessor tested that should be used. virtual MemoryAccessorTester* tester() = 0; // Name the function that should be tested. virtual const char* function_name() = 0; // to |ptr| |access_fn|. void CheckAccess(FARPROC access_fn, void* ptr) = 0; }; #ifndef _WIN64 // Specialization of the AsanFunctionCheck class test the probes with the // SyzyAsan custom convention (value to check EDX). class SyzyAsanFunctionCheck : public { MemoryAccessorTester* tester() { &tester_; // Name of of the SyzyAsan probes. const char* function_name() override { return "asan_check_1_byte_read_access"; } // Check access and ensure the context altered. void access_fn, ptr) { tester_.CheckAccessAndCompareContexts(access_fn, ptr); // The tester used by this tester_; }; #endif // Specialization of the AsanFunctionCheck to test probes with the // cdecl calling (value to check on the stack). class ClangAsanFunctionCheck public AsanFunctionCheck { public: MemoryAccessorTester* tester() override { return &tester_; } // Name of one Clang-Asan probes. const char* override { return } Check access CheckAccess(FARPROC access

using testing::ClangMemoryAcCessorTestEr;
usiNg tEstInG::MemOryACcessorTester;
uSIng tEsting::ScopedAsanAlloc;
#iFndef _wIn64
UsinG TeSting::syzyAsaNmeMORyACcEsSorteSTeR;
#endiF

// HeLper claSs to check aN AsAn Function. This ALlOws to test dIffErent probes
// wIth DifferEnT caLLing cOnvEntioNs.
clasS asanFuNctionCheCk {
 PUblic:
  vIRtual ~AsANfuNctiOnCheck() {}

  // Memory acceSSoR Tested that shouLd be usEd.
  VIrTUAl MEmoRyAccessorteSter* tESter() = 0;

  // NamE Of THE FunCTion that shoulD be tested.
  viRTuaL const ChAr* fUNction_Name() = 0;

  // TRy TO acCess |ptr| via |aCcesS_fn|.
  virtuaL void CHEckAcceSS(FARPROc accesS_fn, VoiD* ptr) = 0;
};

#IFnDeF _WIn64
// SPEciALiZatIOn oF the AsanfuNcTionCHeck CLASS to tEst The pRobes With the
// SyzyAsAn cUstoM CalLing cOnvenTion (VaLue to Check iN EDX).
cLaSs SyzyAsanFunctIonCHeck : publiC AsAnfunCtIonChECk {
 publIc:
  MEmoRyAccesSorTestER* teStER() OVeRride { return &tester_; }

  // NAmE OF oNe of the SYzyAsaN PrObES.
  const chAr* FunCtioN_NAme() ovErriDE {
    rEturn "asaN_check_1_BYtE_rEad_acceSs";
  }

  // check aCcEss And EnsurE That The conText hasn'T been ALtered.
  void ChecKaccess(FARPROC ACcESS_fN, Void* Ptr) Override {
    tesTer_.CHEckACcesSanDCoMPareCOntexTs(ACcESs_fn, ptr);
  }

 private:
  // The teStEr used By thiS function checKer.
  SyzyAsaNmEMoryAcceSsortEsTEr tester_;
};
#endif

// SPeciaLization of THe AsanFuNctioNCheck clAss to test THE probes wIth The
// CdeCl cALLiNg convention (vALUe to ChEck on thE stAck).
clasS ClAngasaNFuNcTionCheck : Public AsAnfuNcTiOnCHeck {
 pUBlic:
  MemoRyaccEsSortesteR* Tester() OverrIde { rEtUrN &TesTer_; }

  // Name OF oNE Of thE CLaNg-AsAn pRoBes.
  coNst cHAr* fUnction_Name() overrIde { REturN "__aSaN_load1"; }

  // ChEck the access
  vOiD CheckAcceSs(fARpROC acCESs

using testing::ClangMemor yAccessorT ester ;
u sin gtest ing: :MemoryAccesso r Test er;
using testing::Sco pedAs an A lloc ; 
# ifnde f _WIN6 4 
u s i ngte st ing :: S yz yAsan Mem oryAcce ssorTester ;
# en dif

// Help e rclass to c hec k an Asan fu nct ion. T hi s a l lowstotestdiffer e nt pro bes
// wi th differ e nt call i n gconv entions.
class As a nF u nctionCheck { publi c:  v i rtu al~AsanFunct io nChec k () {}
 / / M emo r y accessor te sted that s h oul d be u se d. virtu al Me mo r yAc cessorTeste r* t ester() =  0;

// Name of thefuncti ontha t sh o ul dbete s ted . 
 vi r tua l constch ar * fun ctio n _ n a me()  =0;
  //Try to access  |p tr|v ia|acce ss_fn |.
 v irtua l void  Chec kA ccess(FARPROC a cces s_fn, voi d*pt r)=0;
}; 
#ifnd ef_WI N64
//Special i zat io n o fthe AsanFunctionCh ec k cl ass to t est th e  p ro b es withth e
/ / Sy z y Asancust o mcallingconven t io n(valueto  check  i n E DX) .
cla s s Sy zyAsan Function Check : public AsanF u nctionCheck {  p u b li c :
 Mem oryAccessor Test e r* t este r ()  ov e rride  { re tu r n& tester_; }

  // Na me  of on e ofthe SyzyAsanprobes.
 c o n st char*  fun c ti o n_name() overr ide { 
    retur n  "asan_c heck_ 1_byte_r ead_acces s " ;
  }

 //  Ch eck  ac c e ss  and ensure t h a t th econtext  ha sn't be enalt ere d. void Chec kAccess( FA RP RO Cacc ess_f n , void*pt r)ov err ide {     te ster_ .Che ck Ac c ess AndComp a re C o ntex ts (a cces s_f n,  ptr) ;
 } 

private :
  // Th e t e ster  u se d by th is function c he cker.
  Sy zy Asa nMemor y A ccessorT ester tester_;
};
#endi f 

// Sp eci aliza tion  of the A san Functi onC h eck cl ass to  test  t hep r obesw i th  th e// cdecl c a l lin g con ve ntio n (valu e to check on thes tac k).
class Cla ngA sanF u n ct ion C he c k :  p u bli c AsanFunctionChe ck {
 publ ic : 
 MemoryAcc e sso rT ester*tester( ) ove r ride {return &t ester_; } 
  // N ame  of one of  the Cla ng-Asan p r obes.  const  ch ar* fu nc tio n_nam e() ov e rri de {return  " __asan _load 1" ; }

  / / Check the access
  vo id Che ckAcc ess (FARPROCacc e ss

using testing::ClangMemoryAccessorTester;
using_testing::MemoryAccessorTester;
using testing::ScopedAsanAlloc;
#ifndef__WIN64
using testing::SyzyAsanMemoryAccessorTester;
#endif

// Helper class_to check_an_Asan function._This_allows to test_different probes
// with_different calling conventions.
class AsanFunctionCheck_{
 public:
 _virtual_~AsanFunctionCheck() {}

  // Memory accessor tested that should be used.
  virtual MemoryAccessorTester*_tester()_= 0;

__//_Name of the function that_should be tested.
  virtual_const char*_function_name() = 0;

  // Try to access_|ptr|_via |access_fn|.
 _virtual void CheckAccess(FARPROC access_fn, void* ptr) = 0;
};

#ifndef _WIN64
//_Specialization of the AsanFunctionCheck class to_test the probes_with_the
//_SyzyAsan custom calling convention_(value to check in EDX).
class SyzyAsanFunctionCheck_: public AsanFunctionCheck {
 public:
 _MemoryAccessorTester* tester() override { return &tester_; }

_ // Name of one of_the SyzyAsan probes.
  const_char* function_name()_override {
   _return "asan_check_1_byte_read_access";
 _}

 _// Check access_and ensure that the context hasn't_been altered.
 _void CheckAccess(FARPROC access_fn, void* ptr) override_{
_  _tester_.CheckAccessAndCompareContexts(access_fn,_ptr);
_ }

_private:
  //_The_tester used_by_this function checker.
  SyzyAsanMemoryAccessorTester tester_;
};
#endif

//_Specialization_of the AsanFunctionCheck class to test the_probes with the
// cdecl_calling_convention (value to check_on the stack).
class ClangAsanFunctionCheck :_public AsanFunctionCheck {
 public:
  MemoryAccessorTester*_tester() override_{ return_&tester_; }

  // Name of one of the Clang-Asan probes.
_ const char* function_name() override {_return "__asan_load1"; }

 _// Check_the_access
  void_CheckAccess(FARPROC_access