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

ScanningComplexReg Class Reference

Inheritance diagram for ScanningComplexReg:

IScanning List of all members.

Public Methods

 ScanningComplexReg (vma_t _address, reg_t _reg)
bool GetResult () const
IMachineStatusCreateMachineStatus () const
bool ProcessInstruction (vma_t address, const Instruction &instr, IMachineStatus *status, CodeParser &codeInfo)

Private Methods

bool CheckLoop (vma_t address)
void AddLabel (vma_t address)

Private Attributes

reg_t reg
vma_t address
bool bResult
std::set< vma_t, std::less<
vma_t > > 
story

Constructor & Destructor Documentation

ScanningComplexReg::ScanningComplexReg vma_t    _address,
reg_t    _reg
[inline]
 

Definition at line 123 of file codescan.cpp.

References address, bResult, reg, reg_t, and vma_t.

00123                                                :
00124     reg(_reg),address(_address),bResult(true)
00125   {};
  bool GetResult() const;


Member Function Documentation

void ScanningComplexReg::AddLabel vma_t    address [inline, private]
 

Definition at line 137 of file codescan.cpp.

References address, story, and vma_t.

Referenced by ProcessInstruction().

00137 { story.insert(address); };

bool ScanningComplexReg::CheckLoop vma_t    address [inline, private]
 

Definition at line 136 of file codescan.cpp.

References address, IsPresent(), story, and vma_t.

Referenced by ProcessInstruction().

00136 { return IsPresent(story,address); };

IMachineStatus* ScanningComplexReg::CreateMachineStatus   const [inline, virtual]
 

Implements IScanning.

Definition at line 127 of file codescan.cpp.

00128   { return new MachineStatusReg(); };

bool ScanningComplexReg::GetResult   const
 

Definition at line 141 of file codescan.cpp.

References bResult.

Referenced by CodeParser::ExecuteComplexReferenceReg().

00142 {
00143   return bResult;
00144 }

bool ScanningComplexReg::ProcessInstruction vma_t    address,
const Instruction   instr,
IMachineStatus   status,
CodeParser   codeInfo
[virtual]
 

Implements IScanning.

Definition at line 149 of file codescan.cpp.

References _DEBUG_, _PRG_ASSERT, AddLabel(), address, CodeParser::AddTempFlow(), Instruction::Args, bResult, CodeInfo::byteInfo, CheckLoop(), esi, CodeParser::ExecuteComplexReferenceMemory(), FLOW_CALL, FLOW_JUMP, FlowTypes, Instruction::GetFlowType(), GetInstruction(), ObjectModule::GetSection(), Instruction::GetUseType(), IsNullAddress(), Param::literal, CodeInfo::module, Instruction::numArg, reg, REG, si, Param::t_literal, Param::t_memory, Param::type, Instruction::useMaskChange, Instruction::useModify, Instruction::useOverwrite, Instruction::UseType, and vma_t.

00151 {
00152   // segna che abbiamo attraversato questa etichetta
00153   if ( codeInfo.byteInfo[address].IsLabel() )
00154   {
00155     // !!! non ci sono problemi dato che nel loop
00156     // non ci possono essere modifiche
00157     if (CheckLoop(address))
00158       return false; // !!!
00159     AddLabel(address);
00160   }
00161 
00162   // !!! cosa succede se ci sono chiamate ???
00163   enum FlowTypes flow = instr.GetFlowType();
00164   _PRG_ASSERT( flow != FLOW_JUMP);
00165   if ( flow == FLOW_CALL )
00166   {
00167     // !!! assumi che tutte le chiamate lascino inalterate ESI, EDI, EBX e EBP
00168     // !!! codice non portatile
00169     if ( REG(esi)!=reg && REG(edi)!=reg && REG(ebx)!=reg && REG(ebp)!=reg)
00170       if ( REG(si)!=reg && REG(di)!=reg && REG(bx)!=reg && REG(bp)!=reg )
00171       {
00172         bResult = false;
00173         return false;
00174       }
00175   }
00176 
00177   // semplificazione quasi completa
00178   // ci devono essere solo istruzioni per sovrascrivere registro
00179   // se un'istruzione non e' supportata ritorna errore
00180   enum Instruction::UseType useType;
00181   try
00182   {
00183     useType = instr.GetUseType(reg);
00184   }
00185   catch (const Instruction::UseTypeUnimplemented&)
00186   {
00187     return (bResult = false);
00188   }
00189 #ifdef DEBUG
00190   // !!! corregge un errore del debugger di Borland C++ 5.01
00191   if (useType == 32) return (bResult = false);
00192 #endif
00193   _PRG_ASSERT(useType != 32);
00194 
00195   if ( (useType&Instruction::useMaskChange) == Instruction::useModify )
00196   {
00197     bResult = false;
00198     return false;
00199   }
00200 
00201   if ( (useType&Instruction::useMaskChange) == Instruction::useOverwrite )
00202   {
00203     Instruction currInstruction;
00204     _DEBUG_(int res =) GetInstruction(*codeInfo.module,this->address,currInstruction);
00205     _PRG_ASSERT(res != 0);
00206 
00207     // !!! modify instruction
00208     _PRG_ASSERT(currInstruction.numArg == 1);
00209     instr.GetUseType(reg,&currInstruction.Args[0]);
00210 
00211     // caso special: puntatore nullo
00212     if (currInstruction.Args[0].type == Param::t_literal)
00213     {
00214       if (IsNullAddress(currInstruction.Args[0].literal))
00215         return false;
00216       if (!codeInfo.module->GetSection(currInstruction.Args[0].literal)->IsCode())
00217       {
00218         // !!! segna da qualche parte
00219         return false;
00220       }
00221     }
00222 
00223     // se memoria esegui complesso memoria
00224     if (currInstruction.Args[0].type == Param::t_memory)
00225     {
00226       bResult = codeInfo.ExecuteComplexReferenceMemory(this->address,currInstruction);
00227       return false;
00228     }
00229 
00230     // se il reference e' ancora complesso non bisogna aggiungerlo
00231     if (!codeInfo.AddTempFlow(currInstruction.GetFlowType(),this->address,
00232            currInstruction,address,
00233            codeInfo.byteInfo[this->address].GetPriority(),false))
00234     {
00235       // sovrascrittura complessa
00236       // !!! finish (chiama ricorsivamente sccaner per funzioni complesse)
00237 #ifdef DEBUG
00238 //      fprintf(stderr,"Debug: unknow flow\n");
00239 #endif
00240       bResult = false;
00241     }
00242     return false;
00243   }
00244 
00245   return true;
00246 }


Member Data Documentation

vma_t ScanningComplexReg::address [private]
 

Definition at line 133 of file codescan.cpp.

Referenced by AddLabel(), CheckLoop(), ProcessInstruction(), and ScanningComplexReg().

bool ScanningComplexReg::bResult [private]
 

Definition at line 134 of file codescan.cpp.

Referenced by GetResult(), ProcessInstruction(), and ScanningComplexReg().

reg_t ScanningComplexReg::reg [private]
 

Definition at line 132 of file codescan.cpp.

Referenced by ProcessInstruction(), and ScanningComplexReg().

std::set<vma_t, std::less<vma_t> > ScanningComplexReg::story [private]
 

Definition at line 138 of file codescan.cpp.

Referenced by AddLabel(), and CheckLoop().


The documentation for this class was generated from the following file:
Generated on Mon Jan 13 22:20:37 2003 for perdr by doxygen1.2.15