mirror of
https://github.com/67-6f-64/AntiOreans-CodeDevirtualizer
synced 2026-06-08 10:18:33 +00:00
57 lines
1.4 KiB
C++
57 lines
1.4 KiB
C++
#ifndef WILD_OPCODE_LABEL_MANAGER_HPP_
|
|
#define WILD_OPCODE_LABEL_MANAGER_HPP_
|
|
|
|
#include "wild_opcode_label.hpp"
|
|
|
|
#include <algorithm>
|
|
#include <iterator>
|
|
#include <vector>
|
|
|
|
class wild_opcode_label_manager
|
|
{
|
|
public:
|
|
void reset_labels()
|
|
{
|
|
this->virtual_opcode_labels.clear();
|
|
this->virtual_opcode_labels.reserve(0x1000);
|
|
}
|
|
|
|
public:
|
|
bool find_label_unread(std::vector<wild_opcode_label>::iterator& iter)
|
|
{
|
|
iter = std::find_if(this->virtual_opcode_labels.begin(), this->virtual_opcode_labels.end(), [&](wild_opcode_label const& label) -> bool
|
|
{
|
|
return (label.is_read == false);
|
|
});
|
|
|
|
return (iter != this->virtual_opcode_labels.end());
|
|
}
|
|
|
|
bool find_label_by_address(std::vector<wild_opcode_label>::iterator& iter, uint32_t address)
|
|
{
|
|
iter = std::find_if(this->virtual_opcode_labels.begin(), this->virtual_opcode_labels.end(), [&](wild_opcode_label const& label) -> bool
|
|
{
|
|
return (label.address == address);
|
|
});
|
|
|
|
return (iter != this->virtual_opcode_labels.end());
|
|
}
|
|
|
|
public:
|
|
bool exists_label(uint32_t address)
|
|
{
|
|
std::vector<wild_opcode_label>::iterator iter;
|
|
return this->find_label_by_address(iter, address);
|
|
}
|
|
|
|
void create_label(uint32_t address, uint32_t offset)
|
|
{
|
|
if (!this->exists_label(address))
|
|
this->virtual_opcode_labels.push_back(wild_opcode_label(address, offset));
|
|
}
|
|
|
|
protected:
|
|
std::vector<wild_opcode_label> virtual_opcode_labels;
|
|
};
|
|
|
|
#endif |