Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cbxp/control_block_explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "control_blocks/cvt.hpp"
#include "control_blocks/ecvt.hpp"
#include "control_blocks/psa.hpp"
#include "control_blocks/asxb.hpp"
#include "logger.hpp"

namespace CBXP {
Expand Down Expand Up @@ -86,7 +87,10 @@ void ControlBlockExplorer::exploreControlBlock(
control_block_json = ASVT(includes).get();
} else if (control_block_name == "assb") {
control_block_json = ASSB(includes).get();
} else {
} else if (control_block_name == "asxb") {
control_block_json = ASXB(includes).get();
}
else {
throw ControlBlockError();
}
} catch (const CBXPError& e) {
Expand Down
5 changes: 5 additions & 0 deletions cbxp/control_blocks/ascb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "assb.hpp"
#include "asvt.hpp"
#include "asxb.hpp"
#include "logger.hpp"

namespace CBXP {
Expand Down Expand Up @@ -58,6 +59,10 @@ nlohmann::json ASCB::get(void* __ptr32 p_control_block) {
ascb_json["ascbassb"] =
CBXP::ASSB(include_includes).get(p_ascb->ascbassb);
}
else if (include == "asxb") {
ascb_json["ascbasxb"] =
CBXP::ASXB(include_includes).get(p_ascb->ascbasxb);
}
}

Logger::getInstance().debug("ASCB hex dump:");
Expand Down
2 changes: 1 addition & 1 deletion cbxp/control_blocks/ascb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ASCB : public ControlBlock {
public:
nlohmann::json get(void* __ptr32 p_control_block = nullptr) override;
explicit ASCB(const std::vector<std::string>& includes)
: ControlBlock("ascb", {"assb"}, includes) {}
: ControlBlock("ascb", {"assb", "asxb"}, includes) {}
};

} // namespace CBXP
Expand Down
75 changes: 75 additions & 0 deletions cbxp/control_blocks/asxb.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <cvt.h>
#include <ihaascb.h>
#include <ihaasxb.h>
#include <ihapsa.h>

#include <asxb.hpp>
#include <cstdint>
#include <nlohmann/json.hpp>
#include <string>
#include <vector>
#include "ascb.hpp"
#include "asvt.hpp"
#include "logger.hpp"

namespace CBXP {
nlohmann::json ASXB::get(void* __ptr32 p_control_block) {
const asxb* __ptr32 p_asxb;
nlohmann::json asxb_json = {};
if (p_control_block == nullptr) {
// PSA starts at address 0
const struct psa* __ptr32 p_psa = 0;

const struct cvtmap* __ptr32 p_cvtmap =
// 'nullPointer' is a false positive because the PSA starts at address 0
// cppcheck-suppress nullPointer
static_cast<struct cvtmap* __ptr32>(p_psa->flccvt);
const asvt_t* __ptr32 p_asvt =
static_cast<asvt_t* __ptr32>(p_cvtmap->cvtasvt);

asxb_json["asxbs"] = std::vector<nlohmann::json>();
std::vector<nlohmann::json>& asxbs =
asxb_json["asxbs"].get_ref<std::vector<nlohmann::json>&>();
asxbs.reserve(p_asvt->asvtmaxu);

const uint32_t* __ptr32 p_ascb_addr =
reinterpret_cast<const uint32_t* __ptr32>(&p_asvt->asvtenty);
for (int i = 0; i < p_asvt->asvtmaxu; i++) {
if (0x80000000 & *p_ascb_addr) {
Logger::getInstance().debug(formatter_.getHex<uint32_t>(p_ascb_addr) +
" is not a valid ASCB address");
p_ascb_addr++;
continue;
}
// cast ascb addr into ascb pointer a
//
const struct ascb* __ptr32 p_ascb =
reinterpret_cast<struct ascb* __ptr32>(*p_ascb_addr);
asxbs.push_back(
ASXB::get(reinterpret_cast<void* __ptr32>(p_ascb->ascbasxb)));
p_ascb_addr++; // This SHOULD increment the pointer by 4 bytes.
}
return asxbs;
} else {
p_asxb = static_cast<asxb* __ptr32>(p_control_block);
}

Logger::getInstance().debug("asxb hex dump:");
Logger::getInstance().hexDump(reinterpret_cast<const char*>(p_asxb),
sizeof(struct asxb));


asxb_json["asxb_noabdump"] = p_asxb->asxb_noabdump;
asxb_json["asxbftcb"] = formatter_.getHex<uint32_t>(&(p_asxb->asxbftcb));
asxb_json["asxbitcb"] = formatter_.getHex<uint32_t>(&(p_asxb->asxbitcb));
asxb_json["asxbltcb"] = formatter_.getHex<uint32_t>(&(p_asxb->asxbltcb));
asxb_json["asxblwa"] = formatter_.getHex<uint32_t>(&(p_asxb->asxblwa));
asxb_json["asxbsenv"] = formatter_.getHex<uint32_t>(&(p_asxb->asxbsenv));
asxb_json["asxbusr8"] = formatter_.getHex<uint32_t>(&(p_asxb->asxbusr8));
asxb_json["asxbuser"] = formatter_.getString(p_asxb->asxbuser, 7);



return asxb_json;
}
} // namespace CBXP
17 changes: 17 additions & 0 deletions cbxp/control_blocks/asxb.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef __ASXB_H_
#define __ASXB_H_

#include "control_block.hpp"

namespace CBXP {

class ASXB : public ControlBlock {
public:
nlohmann::json get(void* __ptr32 p_control_block = nullptr) override;
explicit ASXB(const std::vector<std::string>& includes)
: ControlBlock("asxb", {}, includes) {}
};

} // namespace CBXP

#endif
Loading