Untitled
unknown
plain_text
8 months ago
3.3 kB
5
Indexable
#pragma once
#include <cstdint>
#include <memory>
#include <string_view>
#include <windows.h>
#include <TlHelp32.h>
#include <mutex>
#include <iostream>
#include <vector>
typedef struct _COPY_MEMORY {
void* buffer;
ULONG64 address;
ULONG size;
HANDLE pid;
bool get_pid;
bool base;
bool peb;
bool read;
bool write;
const char* module_name;
const char* process_name;
}COPY_MEMORY;
namespace sdk {
static HANDLE process_id;
static uintptr_t peb_1;
static uintptr_t base_address;
}
namespace driver {
static std::once_flag flag;
template<typename ... A>
uint64_t call_hook(const A ... arguments)
{
std::call_once(flag, [] { LoadLibrary("user32.dll"); });
void* control_function = GetProcAddress(LoadLibrary("win32u.dll"), "NtOpenCompositionSurfaceSectionInfo");
const auto control = static_cast<uint64_t(__stdcall*)(A...)>(control_function);
return control(arguments ...);
}
static HANDLE get_process_id(const char* process_name) {
COPY_MEMORY m{};
m.get_pid = true;
m.process_name = process_name;
call_hook(&m);
return m.pid;
}
static uintptr_t get_module_base_address(const char* module_name) {
COPY_MEMORY m{};
m.base = true;
m.pid = sdk::process_id;
m.module_name = module_name;
call_hook(&m);
return (uintptr_t)m.buffer;
}
static uintptr_t get_peb() {
COPY_MEMORY m{};
m.peb = true;
m.pid = sdk::process_id;
call_hook(&m);
return (uintptr_t)m.buffer;
}
template <typename type>
type read(ULONG64 address) {
type buffer{};
COPY_MEMORY m{};
m.read = true;
m.pid = sdk::process_id;
m.address = address;
m.buffer = &buffer;
m.size = sizeof(type);
call_hook(&m);
return buffer;
}
template <typename type>
void write(ULONG64 address, const type& value, ULONG size = sizeof(type))
{
COPY_MEMORY m{};
m.write = true;
m.pid = sdk::process_id;
m.address = address;
m.buffer = (void*)&value;
m.size = size;
call_hook(&m);
}
}
DWORD GetProcessId(const char* processName) {
PROCESSENTRY32 processInfo;
processInfo.dwSize = sizeof(processInfo);
HANDLE processesSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (processesSnapshot == INVALID_HANDLE_VALUE) {
std::cerr << "Error: Unable to create toolhelp snapshot." << std::endl;
return 0;
}
if (Process32First(processesSnapshot, &processInfo)) {
do {
if (strcmp(processInfo.szExeFile, processName) == 0) {
CloseHandle(processesSnapshot);
return processInfo.th32ProcessID;
}
} while (Process32Next(processesSnapshot, &processInfo));
}
CloseHandle(processesSnapshot);
return 0;
}
bool IsProcessRunning(DWORD processId) {
HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processId);
if (processHandle) {
DWORD exitCode;
if (GetExitCodeProcess(processHandle, &exitCode) && exitCode == STILL_ACTIVE) {
CloseHandle(processHandle);
return true;
}
CloseHandle(processHandle);
}
return false;
}
void launch() {
DWORD Game = GetProcessId("cod.exe");
while (true) {
Game = GetProcessId("cod.exe");
if (Game != 0 && IsProcessRunning(Game)) {
if (GetAsyncKeyState(0x38) & 1) {
break;
}
}
Sleep(1000);
}
}
Editor is loading...
Leave a Comment