Skip to content

en_write_memory

伏秋洛 edited this page Jun 17, 2023 · 1 revision

Example

Using Writer

#include "process.h"
#include "proc.h"
#include "writer.h"

using namespace hak;

std::string packageName = "bin.mt.plus";
try {
    auto pid = hak::find_process(packageName);
    std::cout << "pid: " << pid << "\n";
    auto process = std::make_shared<hak::process>(pid);
    process->set_memory_mode(memory_mode::SYSCALL);
    auto writer = hak::memory_writer(process);

    pointer address = 0x1234567;
    writer.write_i32(address, 777);
} catch (std::exception& e) {
    std::cout << "error: " << e.what() << "\n";
}

Please note that you have certain permissions when performing read/write memory operations.

Simple method

#include "process.h"
#include "proc.h"

using namespace hak;

std::string packageName = "bin.mt.plus";
try {
    auto pid = hak::find_process(packageName);
    std::cout << "pid: " << pid << "\n";
    auto process = std::make_shared<hak::process>(pid);
    process->set_memory_mode(memory_mode::SYSCALL);

    pointer address = 0x1234567;
    i32 data = 777;
    process->write(address, &data, sizeof(data));
} catch (std::exception& e) {
    std::cout << "error: " << e.what() << "\n";
}