1
0
mirror of https://github.com/phra/PEzor synced 2026-06-08 16:45:36 +00:00

refactor: small fixes

This commit is contained in:
phra
2021-10-27 00:37:08 +02:00
parent f594d313af
commit 8c977059ba
2 changed files with 11 additions and 8 deletions
+8 -8
View File
@@ -4,11 +4,6 @@ unsigned char originalBytes[16] = { 0 };
unsigned int originalProtection = 0;
unsigned int XOR_KEY = 0;
unsigned int generate_random_int() {
std::srand(std::time(nullptr));
return std::rand() | std::rand() << 16;
}
#ifdef _DEBUG_
// https://gist.github.com/ccbrown/9722406
void DumpHex(const void* data, size_t size) {
@@ -73,6 +68,11 @@ void print_type(DWORD type) {
}
#endif
unsigned int generate_random_int() {
std::srand(std::time(nullptr));
return std::rand() | std::rand() << 16;
}
void xor32(void* address, unsigned int size, unsigned int key) {
#ifdef _DEBUG_
wprintf(L"xor32: before xor 0x%p:\n", address);
@@ -173,7 +173,7 @@ void xor_region_and_change_protection(void* address, unsigned int key, DWORD new
}
}
FlushInstructionCache(GetCurrentProcess(), allocation_base, region_size);
FlushInstructionCache((HANDLE)-1, allocation_base, region_size);
xor32(allocation_base, region_size, key);
if (!VirtualProtect(allocation_base, region_size, newProtection, &oldProt)) {
@@ -184,7 +184,7 @@ void xor_region_and_change_protection(void* address, unsigned int key, DWORD new
ExitProcess(-1);
}
FlushInstructionCache(GetCurrentProcess(), allocation_base, region_size);
FlushInstructionCache((HANDLE)-1, allocation_base, region_size);
}
void inline_hook_function(BOOL enable, char* addressToHook, void* jumpAddress) {
@@ -222,7 +222,7 @@ void inline_hook_function(BOOL enable, char* addressToHook, void* jumpAddress) {
ExitProcess(-1);
}
FlushInstructionCache(GetCurrentProcess(), addressToHook, trampolineLength);
FlushInstructionCache((HANDLE)-1, addressToHook, trampolineLength);
if (!VirtualProtect(addressToHook, trampolineLength, oldProt, &oldProt)) {
#ifdef _DEBUG_
+3
View File
@@ -5,6 +5,9 @@
#include <memoryapi.h>
#include <cstdlib>
#include <ctime>
#ifdef _DEBUG_
#include <iostream>
#endif
void fluctuate();