Guest User

Untitled

a guest
Jan 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. unsigned char testf[] = {
  6. 0x8b, 0x44, 0x24, 0x04, // mov eax, [esp+4]
  7. 0x03, 0x44, 0x24, 0x08, // add eax, [esp+8]
  8. 0xc3 // ret
  9. };
  10.  
  11. int main() {
  12. auto page = VirtualAlloc(nullptr, sizeof(testf), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
  13. memcpy(page, testf, sizeof(testf));
  14. auto test = reinterpret_cast<int(*)(int, int)>(page);
  15. printf("test(2, 3): %d\n", test(2, 3));
  16. VirtualFree(page, 0, MEM_RELEASE);
  17. }
Add Comment
Please, Sign In to add comment