Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- extern char *key;
- #define START_ENCRYPTION(num) \
- static DWORD pointer##num; \
- static DWORD endpointer##num; \
- static bool encrypted##num; \
- if(encrypted##num) XOR(pointer##num, endpointer##num, key); \
- else \
- { \
- SuperCoolLabel##num: \
- __asm { PUSH ESI } \
- __asm { MOV ESI, SuperCoolLabel##num } \
- __asm { MOV pointer##num, ESI } \
- __asm { POP ESI } \
- }
- #define END_ENCRYPTION(num) \
- if(!encrypted##num) \
- { \
- SuperCoolEndLabel##num: \
- __asm { PUSH ESI } \
- __asm { MOV ESI, SuperCoolEndLabel##num } \
- __asm { MOV endpointer##num, ESI } \
- __asm { POP ESI } \
- } \
- encrypted##num = true; \
- XOR(pointer##num, endpointer##num, key);
- void XOR(DWORD start, DWORD end, char *theKey);
- #define KEY_LENGTH 11
- char key[KEY_LENGTH] = "thisisakey";
- void XOR(DWORD start, DWORD end, char *theKey)
- {
- for(DWORD i = start; i <= end; i++)
- {
- DWORD dwOldProtect;
- VirtualProtect((void*)i, 0x1, PAGE_READWRITE, &dwOldProtect);
- *(byte*)i ^= theKey[i % (KEY_LENGTH - 1)];
- VirtualProtect((void*)i, 0x1, dwOldProtect, &dwOldProtect);
- }
- }
Add Comment
Please, Sign In to add comment