forked from eeveelo/PapyrusUtil
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsm.cpp
More file actions
21 lines (18 loc) · 696 Bytes
/
Asm.cpp
File metadata and controls
21 lines (18 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "Asm.h"
namespace Asm{
bool WriteJump(int addressFrom1, int addressFrom2, int addressTo){
DWORD oldProtect = 0;
int len1 = addressFrom2 - addressFrom1;
if (VirtualProtect((void *)addressFrom1, len1, PAGE_EXECUTE_READWRITE, &oldProtect))
{
*((unsigned char *)addressFrom1) = (unsigned char)0xE9;
*((int *)(addressFrom1 + 1)) = (int)addressTo - addressFrom1 - 5;
for (int i = 5; i < len1; i++)
*((unsigned char *)(i + addressFrom1)) = (unsigned char)0x90;
if (VirtualProtect((void *)addressFrom1, len1, oldProtect, &oldProtect))
return true;
}
_MESSAGE("WriteJump(0x%X, 0x%X, 0x%X) failed!", addressFrom1, addressFrom2, addressTo);
return false;
}
}