diff options
author | segfault <toni@impl.cc> | 2020-12-15 18:49:34 +0100 |
---|---|---|
committer | segfault <toni@impl.cc> | 2020-12-15 18:49:34 +0100 |
commit | 0d68295e7697cad2ec0d39251213f143b199673d (patch) | |
tree | fb1d980b8eb6bb7104589d7ccd0dc1979dd05e1d /include | |
parent | d9fa838219ba5e3bb0b0612e78afc2eb21154621 (diff) |
CheattEngineServer: CMD_OPENPROCESS, CMD_PROCESS32FIRST, CMD_PROCESS32NEXT, CMD_CLOSEHANDLE
* KMemDriver integration
* generic MT-Support achieved by synchronized wrapper functions
* ability to spawn a Ping-Only Thread
Diffstat (limited to 'include')
-rw-r--r-- | include/KInterface.h | 66 | ||||
-rw-r--r-- | include/KMemDriver.h | 2 |
2 files changed, 64 insertions, 4 deletions
diff --git a/include/KInterface.h b/include/KInterface.h index 3fee236..981ae35 100644 --- a/include/KInterface.h +++ b/include/KInterface.h @@ -2,11 +2,13 @@ #include "KMemDriver.h" +#include <Windows.h> + +#include <mutex> #include <stdexcept> #include <vector> -#include <Windows.h> -#define DEFAULT_TIMEOUT 2500 +#define DEFAULT_TIMEOUT_MS ((KRNL_WAIT_TIME_US / 1000) * (KRNL_MAX_WAITS - 1)) #define INVALID_NTSTATUS (UINT32)-1 typedef enum SendRecvReturn { @@ -43,21 +45,77 @@ public: bool VFree(HANDLE targetPID, PVOID address, SIZE_T size); bool VUnlink(HANDLE targetPID, PVOID address); + bool MtInit() { + std::unique_lock<std::mutex> lck(m_jobLock); + return Init(); + } + bool MtHandshake() { + std::unique_lock<std::mutex> lck(m_jobLock); + return Handshake(); + } + bool MtPing() { + std::unique_lock<std::mutex> lck(m_jobLock); + return Ping(); + } + bool MtProcesses(std::vector<PROCESS_DATA>& dest) { + std::unique_lock<std::mutex> lck(m_jobLock); + return Processes(dest); + } + bool MtPages(HANDLE targetPID, std::vector<MEMORY_BASIC_INFORMATION>& dest, PVOID start_address = NULL) { + std::unique_lock<std::mutex> lck(m_jobLock); + return Pages(targetPID, dest, start_address); + } + bool MtModules(HANDLE targetPID, std::vector<MODULE_DATA>& dest) { + std::unique_lock<std::mutex> lck(m_jobLock); + return Modules(targetPID, dest); + } + bool MtExit() { + std::unique_lock<std::mutex> lck(m_jobLock); + return Exit(); + } + bool MtRPM(HANDLE targetPID, PVOID address, BYTE* buf, SIZE_T size, PKERNEL_READ_REQUEST result) { + std::unique_lock<std::mutex> lck(m_jobLock); + return RPM(targetPID, address, buf, size, result); + } + bool MtWPM(HANDLE targetPID, PVOID address, BYTE* buf, SIZE_T size, PKERNEL_WRITE_REQUEST result) { + std::unique_lock<std::mutex> lck(m_jobLock); + return WPM(targetPID, address, buf, size, result); + } + bool MtVAlloc(HANDLE targetPID, PVOID* address, SIZE_T* size, ULONG protection) { + std::unique_lock<std::mutex> lck(m_jobLock); + return VAlloc(targetPID, address, size, protection); + } + bool MtVFree(HANDLE targetPID, PVOID address, SIZE_T size) { + std::unique_lock<std::mutex> lck(m_jobLock); + return VFree(targetPID, address, size); + } + bool MtVUnlink(HANDLE targetPID, PVOID address) { + std::unique_lock<std::mutex> lck(m_jobLock); + return VUnlink(targetPID, address); + } + PVOID getBuffer(); HANDLE getKHandle(); HANDLE getUHandle(); UINT32 getLastPingValue(); UINT32 getLastNtStatus(); - SendRecvReturn RecvWait(DWORD timeout = DEFAULT_TIMEOUT); + + SendRecvReturn RecvWait(DWORD timeout = DEFAULT_TIMEOUT_MS); + void StartPingThread(void); private: - SendRecvReturn SendRecvWait(UINT32 type, DWORD timeout = DEFAULT_TIMEOUT); + SendRecvReturn SendRecvWait(UINT32 type, DWORD timeout = DEFAULT_TIMEOUT_MS); + void PingThread(void); PVOID m_shmem = NULL; HANDLE m_kevent = NULL, m_uevent = NULL; UINT32 m_last_ping_value = 0; UINT32 m_last_ntstatus = INVALID_NTSTATUS; + + bool m_pingThreadStarted = false; + std::thread m_pingThread; + std::mutex m_jobLock; }; class KMemory diff --git a/include/KMemDriver.h b/include/KMemDriver.h index bc50d61..778006c 100644 --- a/include/KMemDriver.h +++ b/include/KMemDriver.h @@ -18,6 +18,8 @@ typedef _Return_type_success_(return >= 0) LONG NTSTATUS; #define SHMEM_ADDR 0x60000000 #define SHMEM_SIZE 8192*8*2 #define INVALID_REQUEST (UINT32)-1 +#define KRNL_MAX_WAITS 20 +#define KRNL_WAIT_TIME_US 1000000 #define MEM_HANDSHAKE 0x800 #define MEM_PING 0x801 |