Skip to content

zh_write_memory

伏秋洛 edited this page Jun 14, 2023 · 2 revisions

前言

直接梭哈,没什么说的。

例子

通过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";
}

朴实无华的写内存

#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";
}