home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / pedasm.zip / Symbol.h < prev   
C/C++ Source or Header  |  1998-10-23  |  4KB  |  129 lines

  1. /*        fichier Symbol.h : fichier header
  2.  *
  3.  *    descr : herarchie de classe qui represente les differents types de symbols
  4.  *
  5.  *    projet : PEDasm
  6.  *    
  7.  *    rq:
  8.  *    Ce programme est libre de droits. Il peut etre distribue et/ou modifie
  9.  *  selon les termes de la licence 'GNU General Public License version 2'.
  10.  *    
  11.  *    Ce programme est distribue sans aucunes garanties, y compris d'utilite 
  12.  *    ni de risques encouru, quelle que soit son utilisation.
  13.  *
  14.  *    lire le fichier licence.txt fourni ou bien ecrire a :
  15.  *    the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  *    pour recevoir une copie de la licence.
  17.  *
  18.  *    Copyright (C) 1997 - 1998 Nicolas Witczak <witczak@geocities.com>
  19.  */
  20.  
  21. #ifndef SYMBOLS
  22.     #define SYMBOLS
  23.  
  24. #include <cstdlib>
  25. #include <cstdio>
  26. #include <vector>
  27. #include <set>
  28. #include <string>
  29.  
  30. #include "Globals.h"
  31.  
  32.  
  33. //////////////////////////////////////////////////////////////////
  34. // structure d'aide
  35. class CExeRep ;
  36. class CSection ;
  37.  
  38.  
  39. #pragma pack( 4 )
  40.  
  41. ///////////////////////////////////////////////////////////////
  42. // drapeaux et categories de la class CSymbol 
  43.     // categorie
  44. const unsigned int fSymKnown    = 1     ;    
  45. const unsigned int fSymData        = 2     ;    // code sinon 
  46. const unsigned int fSymCode        = 4     ;    // donnee sinon 
  47. const unsigned int fSymPointer    = 8     ;    // tjs a 0 ci c'est du code, ou inconnu
  48. const unsigned int fSymFunc        = 16 ;    // jmp sinon , tjs a 0 ci c'est des donnees 
  49.  
  50.     // qualificatifs
  51. const unsigned int fSymExtern    = 32 ;    // tjs a 0 ci c'est du code
  52. const unsigned int fSymHidden    = 64 ;     // ne doit pas apparaitre ds le code
  53. const unsigned int fSymPublic    = 128 ; // le symbol est a exporter    
  54. const unsigned int fComment        = 256 ; // commentaire de source
  55. const unsigned int fCallBack    = 512 ; // fonction appelee en call back
  56. const unsigned int fSymUser        = 1024; // symbol rajoute manuellement par l'utilisateur
  57.  
  58. const unsigned int cSymUnknown    = 0    ;    
  59. const unsigned int cSymData        = fSymKnown | fSymData     ;    
  60. const unsigned int cSymUser        = fSymKnown | fSymUser     ;    
  61. const unsigned int cSymDataPtr    = fSymKnown | fSymData | fSymPointer ;    
  62. const unsigned int cSymFunc        = fSymKnown | fSymCode | fSymFunc ;    
  63. const unsigned int cSymCallBack    = cSymFunc  | fCallBack ;    
  64. const unsigned int cSymJmp        = fSymKnown | fSymCode ;    
  65. const unsigned int cSymDllImp    = fSymKnown | fSymData | fSymPointer | fSymExtern  ;
  66. const unsigned int cSymUnused    = fSymKnown | fSymData | fSymHidden    ;    
  67.  
  68. ///////////////////////////////////////////////////////////////
  69. /** class CSymbol : represente un symbol : variable , fonction , jmp ...
  70.  *        classe de base
  71.  */
  72. class CSymbol 
  73. {
  74. public:
  75. // construction
  76.     CSymbol( unsigned int VirtAdress = 0 , unsigned int attrib = 0 , const char* pName = 0 ); 
  77.     virtual ~CSymbol() ;
  78.  
  79. // atributs
  80.     /** var m_VirtAdress: adresse abs de debut du symbole */
  81.     unsigned int    m_VirtAdress ;
  82.  
  83.     /** attributs */
  84.     unsigned int    m_Attrib ;
  85.     
  86.     /** nom opt ( ou 0 ) */
  87.     const char*        m_pszName ;
  88.  
  89. // interface virtuelle
  90.     /** accede a la section qui contient ce symbol*/
  91.     CSection* GetSection() const;
  92.  
  93.     /** accede au nom : retourne une chaine temporaire */
  94.     const char* GetName() const ;
  95.  
  96.     /** fct GetDeclaration : retourne une chaine contenant la
  97.      *        declaration imprimable du symbol
  98.      */
  99.     const char* GetDeclaration() const ;
  100.  
  101.     /** taille du symbol ou -1 si inconnu */
  102.     unsigned int GetSize() const ;
  103.  
  104.     /** retourne le symbol pointe par ce symbol ou 0 si aucun */
  105.     CSymbol* GetSource() const ;
  106.  
  107.     /** dump le contenu de ce symbole sur une ligne texte
  108.      *        retourne le stream passe en entree 
  109.      */
  110.     void Dump( FILE* pFile ) const ;
  111. };
  112.  
  113. #pragma pack()
  114.  
  115.  
  116. //////////////////////////////////////////////////////////////////
  117. // fonctions globales
  118.  
  119.     //////////////////////////////////////////////////////////////
  120.     // obj fonctionnel de comparaison de symbol (par adresse)
  121. struct symb_less : public binary_function< CSymbol* , CSymbol* , bool>
  122. {
  123.     bool operator()(const CSymbol* x, const CSymbol* y) const
  124.     {    return x->m_VirtAdress < y->m_VirtAdress ; } ;
  125. };
  126.  
  127.  
  128. #endif //SYMBOLS
  129.