/** * Sends a process closed debug event to BinNavi. * * @param dbg The debug event to be sent. * * @return A NaviError code that describes whether the operation was successful * or not. **/ NaviError BaseConnection::sendProcessClosedEvent(const DBGEVT *) const { const unsigned int NUMBER_OF_ARGUMENTS = 0; PacketBuffer buffer; buffer.add(createPacketHeader(resp_process_closed, 0, NUMBER_OF_ARGUMENTS)); NaviError sendResult = send(buffer.data(), buffer.size()); if (sendResult) { msglog->log(LOG_VERBOSE, "Error: Couldn't send debug event"); return sendResult; } return NaviErrors::SUCCESS; }
/** * Sends a simple reply to BinNavi. * * @param command The type of the reply. * * @return A NaviError code that describes whether the operation was successful * or not. **/ NaviError BaseConnection::sendSimpleReply(const commandtype_t command, unsigned int id) const { const unsigned int NUMBER_OF_ARGUMENTS = 0; PacketBuffer buffer; buffer.add(createPacketHeader(command, id, NUMBER_OF_ARGUMENTS)); NaviError sendResult = send(buffer.data(), buffer.size()); if (sendResult) { msglog->log(LOG_VERBOSE, "Error: Couldn't send simple reply message"); return sendResult; } return NaviErrors::SUCCESS; }
/** * Sends a reply to a register values request to BinNavi. * * @param id The message ID of the reply. * @param regString The register data string. * * @return A NaviError code that describes whether the operation was * successful or not. **/ NaviError BaseConnection::sendRegistersReply(commandtype_t type, unsigned int id, const std::string &str) const { const unsigned int NUMBER_OF_ARGUMENTS = 1; PacketBuffer buffer; buffer.add(createPacketHeader(type, id, NUMBER_OF_ARGUMENTS)); addStringArgument(buffer, str); NaviError sendResult = send(buffer.data(), buffer.size()); if (sendResult) { msglog->log(LOG_VERBOSE, "Error: Couldn't send registers reply message"); return sendResult; } return NaviErrors::SUCCESS; }
/** * Sends a reply to a memory data request to BinNavi. * * @param id The message ID of the reply. * @param address The address from the original memory request. * @param memrange The memory data. * * @return A NaviError code that describes whether the operation was * successful or not. **/ NaviError BaseConnection::sendMemoryReply(unsigned int id, CPUADDRESS address, const MemoryContainer &memrange) const { const unsigned int NUMBER_OF_ARGUMENTS = 2; PacketBuffer buffer; buffer.add(createPacketHeader(resp_read_memory, id, NUMBER_OF_ARGUMENTS)); addAddressArgument(buffer, address); addStringArgument(buffer, memrange); NaviError sendResult = send(buffer.data(), buffer.size()); if (sendResult) { msglog->log(LOG_VERBOSE, "Error: Couldn't send memory reply message"); return sendResult; } return NaviErrors::SUCCESS; }
/** * Sends a debug reply with a variable number of integer arguments and the * given command and packet ID to BinNavi. * * @param command The type of the reply. * @param id The message ID of the reply. * @param values The integer arguments to send to BinNavi. * @param nrvalues The number of integer arguments to send to BinNavi. * * @return A NaviError code that describes whether the operation was * successful or not. **/ NaviError BaseConnection::sendIntegersReply(const commandtype_t command, unsigned int id, unsigned int *values, unsigned int nrvalues) const { PacketBuffer buffer; buffer.add(createPacketHeader(command, id, nrvalues)); for (unsigned int i = 0; i < nrvalues; i++) { addIntegerArgument(buffer, values[i]); } NaviError sendResult = send(buffer.data(), buffer.size()); if (sendResult) { msglog->log(LOG_VERBOSE, "Error: Couldn't send integer reply message"); return sendResult; } return NaviErrors::SUCCESS; }
/** * Sends a debug reply with two integer arguments and one address argument and * the given command and packet ID * to BinNavi. * * @param command The type of the reply. * @param id The message ID of the reply. * @param value1 The first integer value to send. * @param value2 The second integer value to send. * @param address The address value to send. * * @return A NaviError code that describes whether the operation was * successful or not. **/ NaviError BaseConnection::sendIntegerIntegerAddressReply( const commandtype_t command, unsigned int id, unsigned int value1, unsigned int value2, CPUADDRESS address) const { const unsigned int NUMBER_OF_ARGUMENTS = 3; PacketBuffer buffer; buffer.add(createPacketHeader(command, id, NUMBER_OF_ARGUMENTS)); addIntegerArgument(buffer, value1); addIntegerArgument(buffer, value2); addAddressArgument(buffer, address); NaviError sendResult = send(buffer.data(), buffer.size()); if (sendResult) { msglog->log(LOG_VERBOSE, "Error: Couldn't send integer integer address reply message"); return sendResult; } return NaviErrors::SUCCESS; }
/** * Sends a debug reply with a variable number of address arguments and the * given command and packet ID to BinNavi. * * @param command The type of the reply. * @param id The message ID of the reply. * @param addresses The address arguments to send to BinNavi. * @param nraddresses The number of address arguments to send to BinNavi. * * @return A NaviError code that describes whether the operation was * successful or not. **/ NaviError BaseConnection::sendAddressesReply(const commandtype_t command, unsigned int id, const CPUADDRESS *addresses, unsigned int nraddresses) const { PacketBuffer buffer; buffer.add(createPacketHeader(command, id, nraddresses)); for (unsigned int i = 0; i < nraddresses; ++i) { addAddressArgument(buffer, addresses[i]); } msglog->log(LOG_ALL, "%d", nraddresses); NaviError sendResult = send(buffer.data(), buffer.size()); if (sendResult) { msglog->log(LOG_VERBOSE, "Error: Couldn't send address reply message"); return sendResult; } return NaviErrors::SUCCESS; }
/** * Sends a reply to an event that suspended the process to BinNavi. * * @param command The type of the reply. * @param id The message ID of the reply. * @param info Object that provides information about the event. * * @return A NaviError code that describes whether the operation was successful * or not. **/ NaviError BaseConnection::sendSuspendedReply(const commandtype_t command, unsigned int id, const InformationProvider &info) const { if (info.getRegisterString().size() == 0) { return NaviErrors::SUCCESS; } const unsigned int NUMBER_OF_ARGUMENTS = 3; PacketBuffer buffer; buffer.add(createPacketHeader(command, id, NUMBER_OF_ARGUMENTS)); addIntegerArgument(buffer, info.getTid()); addAddressArgument(buffer, info.getAddress(0)); addStringArgument(buffer, info.getRegisterString()); NaviError sendResult = send(buffer.data(), buffer.size()); if (sendResult) { msglog->log(LOG_VERBOSE, "Error: Couldn't send suspended reply message"); return sendResult; } return NaviErrors::SUCCESS; }
/** * Sends a debug reply that indicates what breakpoints were correctly set and * which ones were not. * * @param command The type of the reply. * @param id The message ID of the reply. * @param result Vector that contains the error codes for the individual * breakpoints. 0 = breakpoint was set. * * @return A NaviError code that describes whether the operation was * successful or not. **/ NaviError BaseConnection::sendBreakpointsReply( const commandtype_t command, unsigned int id, const std::vector<std::pair<CPUADDRESS, unsigned int>> &results) const { const unsigned int NUMBER_OF_ARGUMENTS = 1 + 2 * results.size(); PacketBuffer buffer; buffer.add(createPacketHeader(command, id, NUMBER_OF_ARGUMENTS)); addIntegerArgument(buffer, results.size()); for (const auto &breakpoint : results) { addAddressArgument(buffer, breakpoint.first); addIntegerArgument(buffer, breakpoint.second); } NaviError sendResult = send(buffer.data(), buffer.size()); if (sendResult) { msglog->log(LOG_VERBOSE, "Error: Couldn't send integer address reply message"); return sendResult; } return NaviErrors::SUCCESS; }