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

relocationinfo.cpp

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 #include "global.h"
00026 #ifdef HAVE_HDRSTOP
00027 #pragma hdrstop
00028 #endif
00029 
00030 #include "relocationinfo.h"
00031 
00032 void RelocationInfos::AddRelocation(const Relocation& rel,vma_t address)
00033 {
00034   _PRG_ASSERT(rel.GetType() == Relocation::relNone ||
00035     rel.GetType() == Relocation::relRelative);
00036   if ( rel.GetType() != Relocation::relNone )
00037     relocations.insert(address);
00038 }
00039 
00040 static const Relocation relRelative(Relocation::relRelative);
00041 
00042 const Relocation* RelocationInfos::GetRelocation(vma_t address,unsigned bytes) const
00043 {
00044   t_relocations::const_iterator i = relocations.lower_bound(address);
00045   if ( i == relocations.end() )
00046     return NULL;
00047 
00048   if ( *i == address && bytes == 4 ) // !!! constants !!!
00049     // la rilocazione e' ok!
00050                 return &relRelative;
00051   else if ( address+bytes > *i )
00052                 return &relError;
00053         return NULL;
00054 }
00055 
00056 const Relocation* RelocationInfos::GetRelocation(vma_t address) const
00057 {
00058   // !!! memoriazzre ultimo byte per rilocazioni ?
00059   t_relocations::const_iterator i = relocations.lower_bound(address-3);
00060   if ( i == relocations.end() )
00061     return NULL;
00062   if ( *i == address)
00063     return &relRelative;
00064   if ( (address - *i) < 4 ) // !!! constants !!!
00065     return &relError;
00066   return NULL;
00067 }
00068 
00069 const Relocation RelocationInfos::relError(Relocation::relNone);
00070 

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