// a should be the address of a UserProc void FrontEnd::decodeOnly(Prog *prog, ADDRESS a) { UserProc* p = (UserProc*)prog->setNewProc(a); assert(!p->isLib()); std::ofstream os; if (processProc(p->getNativeAddress(), p, os)) p->setDecoded(); prog->wellForm(); }
// Somehow, a == NO_ADDRESS has come to mean decode anything not already decoded void FrontEnd::decode(Prog *prog, ADDRESS a) { if (a != NO_ADDRESS) { std::cout<<"decode main at a!= NOADDRESS\n"; prog->setNewProc(a); if (VERBOSE) LOG << "starting decode at address " << a << "\n"; UserProc* p = (UserProc*)prog->findProc(a); if (p == NULL) { if (VERBOSE) LOG << "no proc found at address " << a << "\n"; return; } if (p->isLib()) { LOG << "NOT decoding library proc at address 0x" << a << "\n"; return; } std::ofstream os; PROGMAP::const_iterator it; for (Proc *pProc = prog->getFirstProc(it); pProc != NULL; pProc = prog->getNextProc(it)) { std::cout<<"Proc name Before main "<<pProc->getName()<<"\n"; } processProc(a, p, os); for (Proc *pProc = prog->getFirstProc(it); pProc != NULL; pProc = prog->getNextProc(it)) { std::cout<<"Proc name After decode main "<<pProc->getName()<<"\n"; } p->setDecoded(); } else { // a == NO_ADDRESS std::cout<<"decode child proc\n"; bool change = true; while (change) { change = false; PROGMAP::const_iterator it; for (Proc *pProc = prog->getFirstProc(it); pProc != NULL; pProc = prog->getNextProc(it)) { if (pProc->isLib()) continue; UserProc *p = (UserProc*)pProc; if (p->isDecoded()) continue; // undecoded userproc.. decode it change = true; std::ofstream os; std::cout<<"Signature Before :"<<p->getSignature()->prints()<<"\n"; int res = processProc(p->getNativeAddress(), p, os); std::cout<<"Signature After :"<<p->getSignature()->prints()<<"\n"; //std::cout<<"Sig type:"<<p->getSignature()->prints()<<"\n"; std::cout<<"process Proc finish< res:"<<res<<"\n"; if (res == 1) p->setDecoded(); else break; // Break out of the loops if not decoding children if (Boomerang::get()->noDecodeChildren) break; } if (Boomerang::get()->noDecodeChildren) break; } } prog->wellForm(); }