Small fixes

This commit is contained in:
momo5502 2022-05-29 16:01:59 +02:00
parent e28c72e643
commit 5c2db6e8df
4 changed files with 21 additions and 35 deletions

View File

@ -378,38 +378,6 @@ namespace arxan
return og_data[0]; return og_data[0];
} }
void patch_check_type_1_xor()
{
const auto checks = "8B 00 33 45 ??"_sig;
for(size_t i = 0; i < checks.count(); ++i)
{
auto* addr = checks.get(i);
utils::hook::jump(addr, utils::hook::assemble([addr](utils::hook::assembler& a)
{
a.push(rax);
a.pushad64();
a.mov(rcx, rax);
a.call_aligned(get_integrity_data_dword);
a.mov(rcx, qword_ptr(rsp, 128));
a.movzx(ecx, eax);
a.mov(qword_ptr(rsp, 128), rcx);
a.popad64();
a.pop(rax);
// xor eax, [rbp+??h]
a.embedUInt8(addr[3]);
a.embedUInt8(addr[4]);
a.embedUInt8(addr[5]);
a.jmp(addr + 5);
}));
}
}
void patch_check_type_1_direct() void patch_check_type_1_direct()
{ {
auto patch_addr = [](uint8_t* addr) auto patch_addr = [](uint8_t* addr)

View File

@ -97,3 +97,15 @@ size_t operator"" _g(const size_t val)
assert(base && "Failed to resolve base"); assert(base && "Failed to resolve base");
return base + (val - 0x140000000); return base + (val - 0x140000000);
} }
size_t reverse_g(const size_t val)
{
static auto base = size_t(utils::nt::library{}.get_ptr());
assert(base && "Failed to resolve base");
return (val - base) + 0x140000000;
}
size_t reverse_g(const void* val)
{
return reverse_g(reinterpret_cast<size_t>(val));
}

View File

@ -57,4 +57,6 @@ namespace \
static component_loader::installer<name> __component; \ static component_loader::installer<name> __component; \
} }
size_t operator"" _g(const size_t val); size_t operator"" _g(size_t val);
size_t reverse_g(size_t val);
size_t reverse_g(const void* val);

View File

@ -126,7 +126,11 @@ namespace utils::hook
{ {
if(!is_relatively_far(address, memory.get_ptr())) if(!is_relatively_far(address, memory.get_ptr()))
{ {
return memory.allocate(size); const auto buffer = memory.allocate(size);
if(buffer)
{
return buffer;
}
} }
} }