Guest User

Untitled

a guest
Mar 11th, 2014
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <windows.h>
  2. #include <stdio.h>
  3. int main()
  4. {
  5. SYSTEM_INFO sSysInfo;
  6.  
  7. GetSystemInfo(&sSysInfo);
  8.  
  9. DWORD dwPageSize = sSysInfo.dwPageSize;
  10.  
  11.  
  12. LPVOID lpvBase = VirtualAlloc(
  13. NULL,
  14. dwPageSize,
  15. MEM_RESERVE|MEM_COMMIT,
  16. PAGE_EXECUTE_READWRITE);
  17. if (lpvBase == NULL )
  18. printf("VirtualAlloc reserve failed.");
  19.  
  20.  
  21. BYTE *endExec = (BYTE*)lpvBase;
  22. memset(lpvBase,0x90,dwPageSize);
  23. endExec[1024] = 0xC3;
  24.  
  25. INT64 t0 = 0;
  26. INT64 t1 = 0;
  27. _asm
  28. {
  29. rdtsc
  30. mov DWORD PTR [t0],eax
  31. mov DWORD PTR [t0+4],edx
  32. call endExec
  33. rdtsc
  34. mov DWORD PTR [t1],eax
  35. mov DWORD PTR [t1+4],edx
  36. }
  37.  
  38. printf("%d",t1-t0);
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment