mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-22 16:29:29 +08:00
add: migrate source code of luahook
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#include "dobby/dobby_internal.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
using namespace zz;
|
||||
|
||||
PUBLIC int DobbyCodePatch(void *address, uint8_t *buffer, uint32_t buffer_size) {
|
||||
DWORD oldProtect;
|
||||
int page_size;
|
||||
|
||||
// Get page size
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
page_size = si.dwPageSize;
|
||||
|
||||
void *addressPageAlign = (void *)ALIGN(address, page_size);
|
||||
|
||||
if (!VirtualProtect(addressPageAlign, page_size, PAGE_EXECUTE_READWRITE, &oldProtect))
|
||||
return kMemoryOperationError;
|
||||
|
||||
memcpy(address, buffer, buffer_size);
|
||||
|
||||
if (!VirtualProtect(addressPageAlign, page_size, oldProtect, &oldProtect))
|
||||
return kMemoryOperationError;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user