Initial commit

This commit is contained in:
drof
2026-11-05 02:19:09 +01:00
commit 13f8503697
125 changed files with 17029 additions and 0 deletions
+334
View File
@@ -0,0 +1,334 @@
#include <include.h>
unsigned int hde64_disasm(const void* code, hde64s* hs)
{
uint8_t x, c, * p = (uint8_t*)code, cflags, opcode, pref = 0;
uint8_t* ht = hde64_table, m_mod, m_reg, m_rm, disp_size = 0;
uint8_t op64 = 0;
memset(hs, 0, sizeof(hde64s));
for (x = 16; x; x--)
switch (c = *p++) {
case 0xf3:
hs->p_rep = c;
pref |= PRE_F3;
break;
case 0xf2:
hs->p_rep = c;
pref |= PRE_F2;
break;
case 0xf0:
hs->p_lock = c;
pref |= PRE_LOCK;
break;
case 0x26: case 0x2e: case 0x36:
case 0x3e: case 0x64: case 0x65:
hs->p_seg = c;
pref |= PRE_SEG;
break;
case 0x66:
hs->p_66 = c;
pref |= PRE_66;
break;
case 0x67:
hs->p_67 = c;
pref |= PRE_67;
break;
default:
goto pref_done;
}
pref_done:
hs->flags = (uint32_t)pref << 23;
if (!pref)
pref |= PRE_NONE;
if ((c & 0xf0) == 0x40) {
hs->flags |= F_PREFIX_REX;
if ((hs->rex_w = (c & 0xf) >> 3) && (*p & 0xf8) == 0xb8)
op64++;
hs->rex_r = (c & 7) >> 2;
hs->rex_x = (c & 3) >> 1;
hs->rex_b = c & 1;
if (((c = *p++) & 0xf0) == 0x40) {
opcode = c;
goto error_opcode;
}
}
if ((hs->opcode = c) == 0x0f) {
hs->opcode2 = c = *p++;
ht += DELTA_OPCODES;
}
else if (c >= 0xa0 && c <= 0xa3) {
op64++;
if (pref & PRE_67)
pref |= PRE_66;
else
pref &= ~PRE_66;
}
opcode = c;
cflags = ht[ht[opcode / 4] + (opcode % 4)];
if (cflags == C_ERROR) {
error_opcode:
hs->flags |= F_ERROR | F_ERROR_OPCODE;
cflags = 0;
if ((opcode & -3) == 0x24)
cflags++;
}
x = 0;
if (cflags & C_GROUP) {
uint16_t t;
t = *(uint16_t*)(ht + (cflags & 0x7f));
cflags = (uint8_t)t;
x = (uint8_t)(t >> 8);
}
if (hs->opcode2) {
ht = hde64_table + DELTA_PREFIXES;
if (ht[ht[opcode / 4] + (opcode % 4)] & pref)
hs->flags |= F_ERROR | F_ERROR_OPCODE;
}
if (cflags & C_MODRM) {
hs->flags |= F_MODRM;
hs->modrm = c = *p++;
hs->modrm_mod = m_mod = c >> 6;
hs->modrm_rm = m_rm = c & 7;
hs->modrm_reg = m_reg = (c & 0x3f) >> 3;
if (x && ((x << m_reg) & 0x80))
hs->flags |= F_ERROR | F_ERROR_OPCODE;
if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) {
uint8_t t = opcode - 0xd9;
if (m_mod == 3) {
ht = hde64_table + DELTA_FPU_MODRM + t * 8;
t = ht[m_reg] << m_rm;
}
else {
ht = hde64_table + DELTA_FPU_REG;
t = ht[t] << m_reg;
}
if (t & 0x80)
hs->flags |= F_ERROR | F_ERROR_OPCODE;
}
if (pref & PRE_LOCK) {
if (m_mod == 3) {
hs->flags |= F_ERROR | F_ERROR_LOCK;
}
else {
uint8_t* table_end, op = opcode;
if (hs->opcode2) {
ht = hde64_table + DELTA_OP2_LOCK_OK;
table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK;
}
else {
ht = hde64_table + DELTA_OP_LOCK_OK;
table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK;
op &= -2;
}
for (; ht != table_end; ht++)
if (*ht++ == op) {
if (!((*ht << m_reg) & 0x80))
goto no_lock_error;
else
break;
}
hs->flags |= F_ERROR | F_ERROR_LOCK;
no_lock_error:
;
}
}
if (hs->opcode2) {
switch (opcode) {
case 0x20: case 0x22:
m_mod = 3;
if (m_reg > 4 || m_reg == 1)
goto error_operand;
else
goto no_error_operand;
case 0x21: case 0x23:
m_mod = 3;
if (m_reg == 4 || m_reg == 5)
goto error_operand;
else
goto no_error_operand;
}
}
else {
switch (opcode) {
case 0x8c:
if (m_reg > 5)
goto error_operand;
else
goto no_error_operand;
case 0x8e:
if (m_reg == 1 || m_reg > 5)
goto error_operand;
else
goto no_error_operand;
}
}
if (m_mod == 3) {
uint8_t* table_end;
if (hs->opcode2) {
ht = hde64_table + DELTA_OP2_ONLY_MEM;
table_end = ht + sizeof(hde64_table) - DELTA_OP2_ONLY_MEM;
}
else {
ht = hde64_table + DELTA_OP_ONLY_MEM;
table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM;
}
for (; ht != table_end; ht += 2)
if (*ht++ == opcode) {
if (*ht++ & pref && !((*ht << m_reg) & 0x80))
goto error_operand;
else
break;
}
goto no_error_operand;
}
else if (hs->opcode2) {
switch (opcode) {
case 0x50: case 0xd7: case 0xf7:
if (pref & (PRE_NONE | PRE_66))
goto error_operand;
break;
case 0xd6:
if (pref & (PRE_F2 | PRE_F3))
goto error_operand;
break;
case 0xc5:
goto error_operand;
}
goto no_error_operand;
}
else
goto no_error_operand;
error_operand:
hs->flags |= F_ERROR | F_ERROR_OPERAND;
no_error_operand:
c = *p++;
if (m_reg <= 1) {
if (opcode == 0xf6)
cflags |= C_IMM8;
else if (opcode == 0xf7)
cflags |= C_IMM_P66;
}
switch (m_mod) {
case 0:
if (pref & PRE_67) {
if (m_rm == 6)
disp_size = 2;
}
else
if (m_rm == 5)
disp_size = 4;
break;
case 1:
disp_size = 1;
break;
case 2:
disp_size = 2;
if (!(pref & PRE_67))
disp_size <<= 1;
}
if (m_mod != 3 && m_rm == 4) {
hs->flags |= F_SIB;
p++;
hs->sib = c;
hs->sib_scale = c >> 6;
hs->sib_index = (c & 0x3f) >> 3;
if ((hs->sib_base = c & 7) == 5 && !(m_mod & 1))
disp_size = 4;
}
p--;
switch (disp_size) {
case 1:
hs->flags |= F_DISP8;
hs->disp.disp8 = *p;
break;
case 2:
hs->flags |= F_DISP16;
hs->disp.disp16 = *(uint16_t*)p;
break;
case 4:
hs->flags |= F_DISP32;
hs->disp.disp32 = *(uint32_t*)p;
}
p += disp_size;
}
else if (pref & PRE_LOCK)
hs->flags |= F_ERROR | F_ERROR_LOCK;
if (cflags & C_IMM_P66) {
if (cflags & C_REL32) {
if (pref & PRE_66) {
hs->flags |= F_IMM16 | F_RELATIVE;
hs->imm.imm16 = *(uint16_t*)p;
p += 2;
goto disasm_done;
}
goto rel32_ok;
}
if (op64) {
hs->flags |= F_IMM64;
hs->imm.imm64 = *(uint64_t*)p;
p += 8;
}
else if (!(pref & PRE_66)) {
hs->flags |= F_IMM32;
hs->imm.imm32 = *(uint32_t*)p;
p += 4;
}
else
goto imm16_ok;
}
if (cflags & C_IMM16) {
imm16_ok:
hs->flags |= F_IMM16;
hs->imm.imm16 = *(uint16_t*)p;
p += 2;
}
if (cflags & C_IMM8) {
hs->flags |= F_IMM8;
hs->imm.imm8 = *p++;
}
if (cflags & C_REL32) {
rel32_ok:
hs->flags |= F_IMM32 | F_RELATIVE;
hs->imm.imm32 = *(uint32_t*)p;
p += 4;
}
else if (cflags & C_REL8) {
hs->flags |= F_IMM8 | F_RELATIVE;
hs->imm.imm8 = *p++;
}
disasm_done:
if ((hs->len = (uint8_t)(p - (uint8_t*)code)) > 15) {
hs->flags |= F_ERROR | F_ERROR_LENGTH;
hs->len = 15;
}
return (unsigned int)hs->len;
}
+132
View File
@@ -0,0 +1,132 @@
#include <include.h>
void c_synced_input::sync(std::array<button_t, 255>& buttons)
{
m_buttons_prev = m_buttons;
m_buttons = buttons;
}
bool c_synced_input::is_button_down(uintptr_t key_code) noexcept
{
return (m_buttons[key_code].m_state == button_state_busy);
}
bool c_synced_input::was_button_down(uintptr_t key_code) noexcept
{
return (m_buttons_prev[key_code].m_state != button_state_busy && m_buttons[key_code].m_state ==
button_state_busy);
}
void c_input_manager::update()
{
ix::input_system->get_cursor_pos( &m_cursor_pos.x, &m_cursor_pos.y );
}
void c_input_manager::window_proc(UINT msg, WPARAM w_param, LPARAM l_param)
{
m_buttons_prev = m_buttons;
switch (msg)
{
case WM_KEYDOWN:
{
if (!(HIWORD(l_param) & KF_REPEAT))
internal_handler_key_down(w_param);
break;
}
case WM_LBUTTONDOWN:
{
if (!(HIWORD(l_param) & KF_REPEAT))
internal_handler_key_down(VK_LBUTTON);
break;
}
case WM_RBUTTONDOWN:
{
if (!(HIWORD(l_param) & KF_REPEAT))
internal_handler_key_down(VK_RBUTTON);
break;
}
case WM_MBUTTONDOWN:
{
if (!(HIWORD(l_param) & KF_REPEAT))
internal_handler_key_down(VK_MBUTTON);
break;
}
case WM_XBUTTONDOWN:
{
if (!(HIWORD(l_param) & KF_REPEAT))
{
auto xb_index = GET_XBUTTON_WPARAM(w_param);
internal_handler_key_down(((xb_index == 2) ? VK_XBUTTON2 : VK_XBUTTON1));
}
break;
}
case WM_KEYUP:
{
internal_handler_key_up(w_param);
break;
}
case WM_LBUTTONUP:
{
internal_handler_key_up(VK_LBUTTON);
break;
}
case WM_RBUTTONUP:
{
internal_handler_key_up(VK_RBUTTON);
break;
}
case WM_MBUTTONUP:
{
internal_handler_key_up(VK_MBUTTON);
break;
}
case WM_XBUTTONUP:
{
auto xb_index = GET_XBUTTON_WPARAM(w_param);
internal_handler_key_up(((xb_index == 2) ? VK_XBUTTON2 : VK_XBUTTON1));
break;
}
default:
break;
}
}
void c_input_manager::sync(c_synced_input* si)
{
si->sync(m_buttons);
}
void c_input_manager::internal_handler_key_down(uintptr_t key_code)
{
m_buttons[key_code].m_state = button_state_busy;
m_buttons[key_code].m_pressed = true;
}
void c_input_manager::internal_handler_key_up(uintptr_t key_code)
{
m_buttons[key_code].m_state = button_state_released;
m_buttons[key_code].m_pressed = false;
}
bool c_input_manager::is_button_down(uintptr_t key_code) noexcept
{
return (m_buttons[key_code].m_state == button_state_busy);
}
math::position_t<int> c_input_manager::get_cursor_pos() noexcept
{
return m_cursor_pos;
}
+15
View File
@@ -0,0 +1,15 @@
#include <include.h>
void* instr::system_call_t::stub() noexcept
{
auto length = sizeof(*this);
auto* result = win_api::rebuilt::virtual_alloc(nullptr, length, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if (result)
{
memset(result, 0, length);
memcpy(result, this, length);
}
return result;
}
+138
View File
@@ -0,0 +1,138 @@
#include <include.h>
void c_json::reset() noexcept
{
m_count = { };
if (m_json)
stl::mem_free(m_json);
memset(m_tok, 0, sizeof(m_tok));
}
bool c_json::parse(const char* data) noexcept
{
size_t length = strlen(data);
jsmn_init(&m_parser);
m_count = jsmn_parse(
&m_parser, data, length, m_tok,
sizeof(m_tok) / sizeof(m_tok[0])
);
bool succeeded = (m_count > 0);
if (succeeded)
{
//
// Create a cached version of the specified raw JSON text.
//
m_json = stl::mem_alloc<char*>(length + 1);
if (m_json == nullptr)
return false;
memset(m_json, 0, length + 1);
memcpy(m_json, data, length);
}
return succeeded;
}
bool c_json::is_equal(int index, const char* text)
{
auto jsoneq = [](const char* json, jsmntok_t* tok, const char* s) {
if (tok->type == JSMN_STRING && (int)stl::strlen(s) == tok->end - tok->start &&
stl::strncmp(json + tok->start, s, static_cast<size_t>(tok->end - tok->start)) == 0) {
return 0;
}
return -1;
};
return (jsoneq(m_json, &m_tok[index], text) == 0);
}
void c_json::get_value_internal(int index, char* buffer, size_t length)
{
auto dup = stl::strndup(
m_json + m_tok[index + 1].start,
static_cast<size_t>(m_tok[index + 1].end) -
m_tok[index + 1].start
);
stl::strcpy(buffer, dup);
stl::mem_free(dup);
}
int c_json::get_value_integer(const char* name)
{
int result{ };
char buffer[16];
memset(buffer, 0, sizeof(buffer));
for (auto i = 1; i < count(); i++)
{
if (is_equal(i, name))
{
get_value_internal(i, buffer, sizeof(buffer));
result = stl::strtol(buffer, nullptr, 0);
break;
}
}
return result;
}
bool c_json::get_value_boolean(const char* name)
{
bool result{ };
char buffer[16];
memset(buffer, 0, sizeof(buffer));
for (auto i = 1; i < count(); i++)
{
if (is_equal(i, name))
{
get_value_internal(i, buffer, sizeof(buffer));
result = (buffer[0] == 't') ? true : false;
break;
}
}
return result;
}
double c_json::get_value_double(const char* name)
{
double result{ };
char buffer[32];
memset(buffer, 0, sizeof(buffer));
for (auto i = 1; i < count(); i++)
{
if (is_equal(i, name))
{
get_value_internal(i, buffer, sizeof(buffer));
result = stl::strtod(buffer, nullptr);
break;
}
}
return result;
}
c_json::~c_json()
{
if (m_count && m_json)
{
stl::mem_free(m_json);
}
}
+1
View File
@@ -0,0 +1 @@
#include <include.h>
+87
View File
@@ -0,0 +1,87 @@
#include <include.h>
bool pe::get_headers(void* image, _pimage_dos_header* out_dh, _pimage_nt_header* out_nh)
{
auto* const dos_header =
mem::addr(image)
.As<PIMAGE_DOS_HEADER>();
if (dos_header == nullptr || dos_header->e_magic != IMAGE_DOS_SIGNATURE)
return false;
auto* const nt_header =
mem::addr(image)
.Add(dos_header->e_lfanew)
.As<PIMAGE_NT_HEADERS>();
if (nt_header == nullptr || nt_header->Signature != IMAGE_NT_SIGNATURE)
return false;
if (out_dh)
*out_dh = dos_header;
if (out_nh)
*out_nh = nt_header;
return true;
}
uintptr_t pe::find_export_address(uintptr_t base, _pimage_dos_header dos_hdr, _pimage_nt_header nt_hdr, const char* exp_name)
{
auto* const export_descriptor =
get_data_directory_ptr<_image_export_directory>(base, nt_hdr,
IMAGE_DIRECTORY_ENTRY_EXPORT);
IMAGE_DATA_DIRECTORY export_descriptor_info{};
if (export_descriptor == nullptr)
return 0;
if (!get_data_directory_info(base, nt_hdr,
IMAGE_DIRECTORY_ENTRY_EXPORT, export_descriptor_info))
return 0;
const auto export_descriptor_rva =
(reinterpret_cast<uintptr_t>(export_descriptor) - base);
const uintptr_t names_rva = export_descriptor->AddressOfNames;
const uintptr_t addresses_rva = export_descriptor->AddressOfFunctions;
const uintptr_t ordinals_rva = export_descriptor->AddressOfNameOrdinals;
const auto names_address = static_cast<uintptr_t>(base + names_rva);
const auto addresses_address = static_cast<uintptr_t>(base + addresses_rva);
const auto ordinals_address = static_cast<uintptr_t>(base + ordinals_rva);
auto* const names_array = reinterpret_cast<std::uint32_t*>(names_address);
auto* const addresses_array = reinterpret_cast<std::uint32_t*>(addresses_address);
auto* const ordinals_array = reinterpret_cast<std::uint16_t*>(ordinals_address);
const auto export_descriptor_rva_begin = export_descriptor_rva;
const auto export_descriptor_rva_end = (export_descriptor_rva + export_descriptor_info.Size);
for (size_t i = 0; i < export_descriptor->NumberOfFunctions; i++)
{
const auto ordinal_rva = ordinals_array[i];
if (!ordinal_rva)
continue;
const auto ordinal = ordinals_array[i];
const auto name_rva = names_array[i];
const auto address_rva = addresses_array[ordinal > 1000 ? i : ordinal];
const auto address = static_cast<std::uintptr_t>(base + address_rva);
auto* const name = reinterpret_cast<char*>(base + name_rva);
if (name_rva >= export_descriptor_rva_begin &&
name_rva <= export_descriptor_rva_end)
{
if (!stl::strcmp(name, exp_name))
return mem::addr(base).Add(address_rva).Base();
}
}
return 0;
}
+91
View File
@@ -0,0 +1,91 @@
#include <include.h>
DWORD_PTR shared::sig::FindPattern(const DWORD_PTR baseAddress, const DWORD_PTR length, const PCWSTR pattern)
{
PCWSTR pat = pattern;
DWORD_PTR firstMatch = 0x0, numSkippedBytes = 0x0;
for (DWORD_PTR pCur = baseAddress; pCur < baseAddress + length; pCur++)
{
numSkippedBytes += 1;
if (*(BYTE*)pat == '\?' || *(BYTE*)pCur == GetByte(pat)) {
if (!*pat) {
return firstMatch;
}
if (!firstMatch) {
firstMatch = pCur;
}
if (!pat[2]) {
return firstMatch;
}
if (*(WORD*)pat == '\?\?' || *(BYTE*)pat != '\?') {
pat += 3;
}
else {
pat += 2;
}
}
else {
pCur -= numSkippedBytes - 0x1;
numSkippedBytes = 0;
pat = pattern;
firstMatch = 0;
}
}
return 0;
}
uintptr_t shared::sig::find_offset(uintptr_t start_addr, const uint8_t* pattern_buf, size_t pattern_len, size_t offset, size_t opcode_len) noexcept
{
size_t max_steps = 32;
uintptr_t end_addr = (start_addr + max_steps * sizeof(uintptr_t));
hde64s instr[1];
for (auto current = (uint8_t*)start_addr; (uintptr_t)current < end_addr; current = (uint8_t*)((uintptr_t)current + instr[0].len))
{
if (!hde::disasm_buffer(reinterpret_cast<void*>(current), 32, instr, 1))
break;
if (stl::memeq(current, pattern_buf, pattern_len))
{
auto dst = ((uintptr_t)current + offset);
return *(u_long*)(dst + opcode_len);
}
}
return 0;
}
DWORD_PTR shared::sig::FindPatternSafe(const DWORD_PTR baseAddress, const DWORD_PTR length, const PCWSTR pattern)
{
if (!baseAddress || !length || !pattern)
return 0;
const auto buffer = stl::mem_alloc<void*>( length );
const auto buffer_base = mem::addr(buffer).Base();
if (!buffer || !buffer_base)
return 0;
memset(buffer, 0, length);
if (!util::read_memory(buffer, baseAddress, length))
return 0;
const auto result = FindPattern(buffer_base, length, pattern);
if (!result)
return 0;
const auto result_rva = mem::addr(result).Sub(buffer_base).Base();
const auto result_actual = mem::addr(baseAddress).Add(result_rva).Base();
return result_actual;
}
+59
View File
@@ -0,0 +1,59 @@
#include <include.h>
extern "C"
{
int _fltused = 0;
}
void* operator new(size_t size)
{
return stl::mem_alloc<void*>(size);
}
void* operator new[](size_t size)
{
return stl::mem_alloc<void*>(size);
}
void operator delete(void* ptr)
{
stl::mem_free(ptr);
}
void operator delete[](void* ptr)
{
stl::mem_free(ptr);
}
extern "C"
{
void* memset(void* str, int c, size_t n)
{
return stl::preserved::memset2(str, c, n);
}
void* memcpy(void* dest, const void* src, size_t len)
{
return stl::preserved::memcpy(dest, src, len);
}
int memcmp(const void* s1, const void* s2, size_t n)
{
unsigned char const* t1;
unsigned char const* t2;
t1 = (unsigned char const*)s1;
t2 = (unsigned char const*)s2;
while (n-- != 0) {
if (*t1 != *t2) {
return (int)*t1 - (int)*t2;
}
t1++;
t2++;
}
return 0;
}
}
+66
View File
@@ -0,0 +1,66 @@
#include <include.h>
BOOL util::read_file_ex(LPCWSTR pszPath, PVOID pBuffer, DWORD uLength)
{
NTSTATUS status{ };
HANDLE handle{ };
OBJECT_ATTRIBUTES attribs{ };
UNICODE_STRING unicode_path{ };
IO_STATUS_BLOCK iosb{ };
LARGE_INTEGER byte_offs{ };
stl::init_unicode_string(&unicode_path, pszPath);
attribs.Length = sizeof(OBJECT_ATTRIBUTES);
attribs.RootDirectory = NULL;
attribs.ObjectName = &unicode_path;
attribs.Attributes = 0;
attribs.SecurityDescriptor = NULL;
attribs.SecurityQualityOfService = NULL;
status = sc_asm_open_file(
&handle, FILE_READ_ACCESS | FILE_WRITE_ACCESS | SYNCHRONIZE,
&attribs, &iosb, 0,
FILE_SYNCHRONOUS_IO_NONALERT
);
if (!NT_SUCCESS(status))
return false;
stl::c_handle_guard _(handle);
status = sc_asm_read_file(
handle, nullptr, nullptr,
nullptr, &iosb, pBuffer,
uLength, &byte_offs, nullptr
);
if (!NT_SUCCESS(status))
return false;
return true;
}
PVOID util::get_file_ptr(LPCWSTR pszPath)
{
if (pszPath && file_exists_wide(pszPath))
{
SIZE_T uLength = get_file_size_wide(pszPath);
PVOID pBuffer{ };
if (uLength)
{
pBuffer = stl::mem_alloc<void*>(uLength + 1);
if (pBuffer == nullptr)
return nullptr;
ZERO_MEM(pBuffer, uLength + 1);
if (read_file_ex(pszPath, pBuffer, uLength))
return pBuffer;
}
}
return nullptr;
}
+45
View File
@@ -0,0 +1,45 @@
#include <include.h>
size_t c_vfunc_hook::estimate_vftbl_length(std::uintptr_t* vftbl_start)
{
MEMORY_BASIC_INFORMATION memInfo = {};
int m_nSize = -1;
do {
m_nSize++;
win_api::rebuilt::virtual_query(reinterpret_cast<LPCVOID>(vftbl_start[m_nSize]), &memInfo, sizeof(memInfo));
} while (memInfo.Protect == PAGE_EXECUTE_READ || memInfo.Protect == PAGE_EXECUTE_READWRITE);
return m_nSize;
}
bool c_vfunc_hook::setup(void* base)
{
if (base != nullptr)
class_base = base;
if (class_base == nullptr)
return false;
old_vftbl = *static_cast<std::uintptr_t**>(class_base);
vftbl_len = estimate_vftbl_length(old_vftbl) * sizeof(std::uintptr_t);
if (vftbl_len == 0)
return false;
new_vftb1 = stl::mem_alloc<uintptr_t*>((sizeof(uintptr_t) * (vftbl_len + 1)));
if (new_vftb1 == nullptr)
return false;
memcpy(&new_vftb1[1], old_vftbl, vftbl_len);
auto guard = detail::protect_guard{ class_base, sizeof(std::uintptr_t), PAGE_READWRITE };
new_vftb1[0] = old_vftbl[-1];
*static_cast<std::uintptr_t**>(class_base) = &new_vftb1[1];
wasAllocated = true;
return true;
}
+9
View File
@@ -0,0 +1,9 @@
#include <include.h>
bool win_api::virtual_protect(void* address, size_t size, u_long new_protect, u_long* old_protect)
{
return hvi::protect_virt_memory(
get_current_process_id(), mem::addr(address).Base(),
size, new_protect, old_protect
);
}
+1
View File
@@ -0,0 +1 @@
#include <include.h>