Guest User

Untitled

a guest
May 22nd, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <Windows.h>
  2.  
  3. extern char *key;
  4.  
  5. #define START_ENCRYPTION(num) \
  6.     static DWORD pointer##num; \
  7.     static DWORD endpointer##num; \
  8.     static bool encrypted##num; \
  9.     if(encrypted##num) XOR(pointer##num, endpointer##num, key); \
  10.     else \
  11.     { \
  12. SuperCoolLabel##num: \
  13.         __asm { PUSH ESI } \
  14.         __asm { MOV ESI, SuperCoolLabel##num } \
  15.         __asm { MOV pointer##num, ESI } \
  16.         __asm { POP ESI } \
  17.     }
  18.  
  19.  
  20. #define END_ENCRYPTION(num) \
  21.     if(!encrypted##num) \
  22.     { \
  23. SuperCoolEndLabel##num: \
  24.         __asm { PUSH ESI } \
  25.         __asm { MOV ESI, SuperCoolEndLabel##num } \
  26.         __asm { MOV endpointer##num, ESI } \
  27.         __asm { POP ESI } \
  28.     } \
  29.     encrypted##num = true; \
  30.     XOR(pointer##num, endpointer##num, key);
  31.  
  32.  
  33. void XOR(DWORD start, DWORD end, char *theKey);
  34.  
  35. #define KEY_LENGTH 11
  36. char key[KEY_LENGTH] = "thisisakey";
  37.  
  38. void XOR(DWORD start, DWORD end, char *theKey)
  39. {
  40.     for(DWORD i = start; i <= end; i++)
  41.     {
  42.         DWORD dwOldProtect;
  43.  
  44.         VirtualProtect((void*)i, 0x1, PAGE_READWRITE, &dwOldProtect);
  45.         *(byte*)i ^= theKey[i % (KEY_LENGTH - 1)];
  46.         VirtualProtect((void*)i, 0x1, dwOldProtect, &dwOldProtect);
  47.     }
  48. }
Add Comment
Please, Sign In to add comment