Merge PR #5087: FIX(client): Use ReadProcessMemory() instead of Toolhelp32ReadProcessMemory()

This commit is contained in:
Davide Beatrici 2021-06-02 19:22:59 +02:00 committed by GitHub
commit 9d5feb54e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -11,14 +11,18 @@
#include <tlhelp32.h>
HostWindows::HostWindows(const procid_t pid) : m_pid(pid) {
m_handle = OpenProcess(PROCESS_VM_READ, false, m_pid);
}
HostWindows::~HostWindows() {
if (m_handle) {
CloseHandle(m_handle);
}
}
bool HostWindows::peek(const procptr_t address, void *dst, const size_t size) const {
SIZE_T read;
const auto ok = Toolhelp32ReadProcessMemory(m_pid, reinterpret_cast< void * >(address), dst, size, &read);
const auto ok = ReadProcessMemory(m_handle, reinterpret_cast< void * >(address), dst, size, &read);
return (ok && read == size);
}

View File

@ -13,6 +13,7 @@ typedef uint32_t procid_t;
class HostWindows {
protected:
procid_t m_pid;
void *m_handle;
public:
bool peek(const procptr_t address, void *dst, const size_t size) const;