#include "IdlInterface.h" #include "internalRpcDecompiler.h" // ====================================================================== // CONSTRUCTOR // ====================================================================== IdlInterface::IdlInterface(std::string strIfName, RPC_IF_ID& RpcIfId, size_t szNbFunctions): m_strIfName(strIfName), m_szNbFunctions(szNbFunctions), m_vectFunctions(szNbFunctions), m_RpcIfId(RpcIfId) { } IdlInterface::~IdlInterface() { for(size_t i=0; i IdlInterface::getIntefaceFunctions() { return m_vectFunctions; } // ====================================================================== // DECODING METHODS // ====================================================================== DECOMP_STATUS IdlInterface::decode(void* pCtx) { DECOMP_STATUS dStatus = DS_ERR; DECOMP_STATUS dStatusRet = DS_SUCCESS; // check param if(pCtx == NULL) { RPC_ERROR_FN("pCtx NULL pointer\n"); return DS_ERR_INVALID_PARAM; } // decode every functions for(UINT i=0; idecodeFunction(i, pCtx); if(dStatus != DS_SUCCESS) { RPC_ERROR_FN("decodeFunction failed\n"); printf("Idx %u\n", i); std::ostringstream ossIf; this->dumpIfInfo(ossIf); printf("%s", ossIf.str().c_str()); //DEBUG_BREAK(); // don't stop at first failure in order to decompile every possible functions dStatusRet = dStatus; } } if(dStatusRet == DS_SUCCESS) { // once every functions is decoded dStatusRet = decodeInterfaceComplexTypes(pCtx); } return dStatusRet; } DECOMP_STATUS IdlInterface::decodeFunction(UINT uFunctionIdx, void* pCtx) { // check param if(pCtx == NULL) { return DS_ERR_INVALID_PARAM; } if(uFunctionIdx > m_szNbFunctions) { return DS_ERR_INVALID_INDEX; } // has function already been decoded if(m_vectFunctions[uFunctionIdx] == NULL) { m_vectFunctions[uFunctionIdx] = new IdlFunction(uFunctionIdx, this); return (m_vectFunctions[uFunctionIdx])->decode(pCtx); } else { return DS_SUCCESS; } } DECOMP_STATUS IdlInterface::decodeInterfaceComplexTypes(void* pCtx) { std::list listAllTypesSorted; std::ostringstream ossUseless; // check param if(pCtx == NULL) { return DS_ERR_INVALID_PARAM; } // clear string stream content m_ossComplexTypes.flush(); // recursively explore all list in order to get a complete list of types if (getAllTypesSortedInAList(pCtx, m_listProcTypes, listAllTypesSorted, ossUseless) == FALSE) { m_ossComplexTypes<<"[ERROR] unable to get list of all types sorted" << std::endl; return DS_ERR_UNABLE_TO_DECODE_COMPLEX_TYPE; } if( dumpTypeList(pCtx, listAllTypesSorted, m_ossComplexTypes) == FALSE) { m_ossComplexTypes<<"[ERROR] unable to dump type list" << std::endl; return DS_ERR_UNABLE_TO_DECODE_COMPLEX_TYPE; } return DS_SUCCESS; } std::ostream& IdlInterface::dump(std::ostream& o) const { dumpIfInfo(o); o << std::endl; o << "interface "<< m_strIfName << std::endl; o << "{" << std::endl; // display complex type o << m_ossComplexTypes.str(); // display functions for(size_t i=0; i< m_szNbFunctions; i++) { o << std::endl; if(m_vectFunctions[i] == NULL) { o << "void Opnum"<