Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- class Memory
- {
- public:
- Memory(const std::string &ClassName);
- bool Read(unsigned int Address, std::string& Buffer);
- virtual ~Memory(void);
- private:
- HANDLE h_Process;
- DWORD h_PID;
- HWND h_HWND;
- };
- Memory::Memory(const std::string &ClassName)
- {
- this->h_HWND = FindWindow(ClassName.c_str(), NULL);
- GetWindowThreadProcessId(this->h_HWND, &this->h_PID);
- this->h_Process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, this->h_PID);
- }
- bool Memory::Read(unsigned int Address, std::string& Buffer)
- {
- SIZE_T ByteOfRead;
- if(Address == NULL)
- return false;
- if (!ReadProcessMemory(this->h_Process, (LPCVOID)Address, (LPVOID)&Buffer, sizeof(std::string), &ByteOfRead))
- return false;
- if ( ByteOfRead != sizeof(Buffer) )
- return false;
- return true;
- }
- Memory::~Memory(void)
- {
- this->h_HWND = NULL;
- this->h_PID = NULL;
- if(this->h_Process != NULL)
- CloseHandle(this->h_Process);
- this->h_Process = NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement