Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

symbols.h

Go to the documentation of this file.
00001 /*
00002 PeRdr - PE file disassembler
00003 Copyright (C) 1999-2003 Frediano Ziglio
00004 -----
00005 
00006 This program is free software; you can redistribute it and/or modify
00007 it under the terms of the GNU General Public License as published by
00008 the Free Software Foundation; either version 2 of the License, or
00009 (at your option) any later version.
00010 
00011 This program is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with this program; if not, write to the Free Software
00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 -----
00020 
00021 INFORMATION
00022   www: https://freddy77.tripod.com/perdr/
00023   e-mail: freddy77@angelfire.com
00024 */
00025 #ifndef FILE_SYMBOLS_H
00026 #define FILE_SYMBOLS_H
00027 
00028 #include <string>
00029 #include <set>
00030 
00031 /**
00032  * Contain all info for API call (imports and exports)
00033  */
00034 class Symbols
00035 {
00036 private:
00037         /**
00038          * hold info (api name and address) on a single symbol
00039          */
00040   struct Symbol
00041   {
00042     vma_t address; /**< address of symbol */
00043     std::string name; /**< name of symbol */
00044     Symbol(vma_t _address,const std::string& _name):
00045       address(_address),name(_name)
00046     { }
00047     bool operator<(const Symbol& rhs) const
00048     { return address < rhs.address || (address == rhs.address && name < rhs.name); }
00049     bool operator==(const Symbol& rhs) const
00050     { return address == rhs.address && name == rhs.name; }
00051   };
00052         typedef std::set<Symbol,std::less<Symbol> > t_symbols;
00053         t_symbols symbols;
00054 public:
00055   typedef t_symbols::const_iterator iterator;
00056         Symbols();
00057   // "" if not found
00058         /** Return names at a given address
00059          * @param address address
00060          * @return a pair of iterator (begin, end) with all api infos
00061          */
00062         std::pair<iterator,iterator> operator[](vma_t address) const;
00063   // name compatible with STL std::map
00064         /**
00065          * Add an api entry
00066          */
00067   void insert(const std::string& name,vma_t address);
00068         /**
00069          * Return next valid address where an api is located
00070          * @param address address to start searching for api
00071          */
00072   vma_t GetNextValid(vma_t address) const;
00073         /**
00074          * Are there an api at given address
00075          * @param address address to query
00076          */
00077         bool IsValid(vma_t address) const;
00078 };
00079 
00080 struct SymbolsAddImportParam
00081 {
00082         Symbols* symbols;
00083   uint32_t imageBase;
00084 };
00085 
00086 // aggiungi una api eseguendo il parse
00087 // il parametro param punta a una struttura di tipo ApiAddImportParam
00088 void SymbolsAddImport(uint32_t address,uint32_t hint,const char* dll_name,const char* func_name,void* param);
00089 
00090 #endif //FILE_SYMBOLS_H

Generated on Mon Jan 13 22:20:34 2003 for perdr by doxygen1.2.15