Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Documentation Fixes #166

Open
luke-croak opened this issue Feb 23, 2023 · 1 comment
Open

C++ Documentation Fixes #166

luke-croak opened this issue Feb 23, 2023 · 1 comment

Comments

@luke-croak
Copy link

As I was browsing the C++ documentation on the maat website, I noticed that there were some errors and missing parts to the documentation.

The "Get started" example has some errors; multiple missing ';', incorrect variable types and it uses constructors which don't seem to currently exist. The below compiled for me instead:

#include "maat/maat.hpp"
using namespace maat;
using namespace maat::loader;
using namespace maat::event;

// Set a callback displaying every memory read
Action show_mem_access(MaatEngine& engine, void* data)
{
    std::cout << *(engine.info.mem_access);
    return Action::CONTINUE;
}

int main(){
    // Create a symbolic engine for Linux X86-32bits
    MaatEngine engine(Arch::Type::X86, env::OS::LINUX);

    // Load a binary a offset 0x08001000 with a 20-chars symbolic command line argument
    std::vector<loader::CmdlineArg> args{
        CmdlineArg(engine.vars->new_symbolic_buffer("some_arg", 20))
    };
    std::unordered_map<std::string, std::string> env_vars;
    std::unordered_map<std::string, std::string> virtual_fs;
    std::list<std::string> libdirs;
    std::list<std::string> ignore_libs;

    libdirs.push_back(".");
    engine.load("some_binary", Format::ELF32, 0x08001000, args, env_vars,
                virtual_fs, libdirs, ignore_libs, true);

    // Get current eax value
    engine.cpu.ctx().get(X86::EAX);

    // Read 4 bytes at the top of the stack
    engine.mem->read(engine.cpu.ctx().get(X86::ESP), 4);

    engine.hooks.add(Event::MEM_R, When::BEFORE, EventCallback(show_mem_access));

    // Take and restore snapshots
    auto snap = engine.take_snapshot();
    engine.restore_snapshot(snap);

    // Run the binary
    engine.run();

    return 0;
}

Also, the C++ documentation seems out of date and is missing information. E.g., for the maat::MaatEngine class the documentation is missing the public member functions uid and resolve_addr_param etc., and missing the public attributes env etc..

@SheldonHolmgren
Copy link

I believe the python documentation might also need updating. I was casually browsing through https://github.com/crytic/optik source code and noticed that is creates a MaatEngine with ARCH.EVM which is not mentioned in the docs. I suspect plenty of evm-specific methods might be also missing from the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants