From 2c9afc07fe5cc53fefb90540d5db2ca424c71a51 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Sat, 27 Oct 2018 23:28:42 -0700 Subject: Major restructuring -- also set up for UI work tomorrow --- WitnessRandomizer/Memory.h | 51 ---------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 WitnessRandomizer/Memory.h (limited to 'WitnessRandomizer/Memory.h') diff --git a/WitnessRandomizer/Memory.h b/WitnessRandomizer/Memory.h deleted file mode 100644 index 8e8bbc3..0000000 --- a/WitnessRandomizer/Memory.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once -#include -#include -#include - -// https://github.com/erayarslan/WriteProcessMemory-Example -// http://stackoverflow.com/q/32798185 -// http://stackoverflow.com/q/36018838 -// http://stackoverflow.com/q/1387064 -class Memory -{ -public: - Memory(const std::string& processName); - ~Memory(); - - Memory(const Memory& memory) = delete; - Memory& operator=(const Memory& other) = delete; - - template - std::vector ReadData(const std::vector& offsets, size_t numItems) { - std::vector data; - data.resize(numItems); - for (int i=0; i<5; i++) { - if (ReadProcessMemory(_handle, ComputeOffset(offsets), &data[0], sizeof(T) * numItems, nullptr)) - { - return data; - } - } - ThrowError(); - return {}; - } - - template - void WriteData(const std::vector& offsets, const std::vector& data) { - for (int i=0; i<5; i++) { - if (WriteProcessMemory(_handle, ComputeOffset(offsets), &data[0], sizeof(T) * data.size(), nullptr)) { - return; - } - } - ThrowError(); - } - -private: - void ThrowError(); - - void* ComputeOffset(std::vector offsets); - - std::map _computedAddresses; - uintptr_t _baseAddress = 0; - HANDLE _handle = nullptr; -}; \ No newline at end of file -- cgit 1.4.1