Inheritance diagram for ScanningComplexReg:

Public Methods | |
| ScanningComplexReg (vma_t _address, reg_t _reg) | |
| bool | GetResult () const |
| IMachineStatus * | CreateMachineStatus () 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 |
|
||||||||||||
|
Definition at line 123 of file codescan.cpp. References address, bResult, reg, reg_t, and vma_t.
|
|
|
Definition at line 137 of file codescan.cpp. References address, story, and vma_t. Referenced by ProcessInstruction().
|
|
|
Definition at line 136 of file codescan.cpp. References address, IsPresent(), story, and vma_t. Referenced by ProcessInstruction().
|
|
|
Implements IScanning. Definition at line 127 of file codescan.cpp.
00128 { return new MachineStatusReg(); };
|
|
|
Definition at line 141 of file codescan.cpp. References bResult. Referenced by CodeParser::ExecuteComplexReferenceReg().
00142 {
00143 return bResult;
00144 }
|
|
||||||||||||||||||||
|
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 }
|
|
|
Definition at line 133 of file codescan.cpp. Referenced by AddLabel(), CheckLoop(), ProcessInstruction(), and ScanningComplexReg(). |
|
|
Definition at line 134 of file codescan.cpp. Referenced by GetResult(), ProcessInstruction(), and ScanningComplexReg(). |
|
|
Definition at line 132 of file codescan.cpp. Referenced by ProcessInstruction(), and ScanningComplexReg(). |
|
|
Definition at line 138 of file codescan.cpp. |
1.2.15