Advertisement
waliedassar

AllocAtHighestUserAddressBuffer

May 14th, 2021
1,046
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. ulonglong AllocAtHighestUserAddressBuffer()
  2. {
  3. #define HighestUserAddress          0x7FFFFFFF0000
  4. #define HighestUserAddressBuffer    0x7FFFFFFEF000
  5. #define PageSize                    0x1000
  6.  
  7.  
  8.     ulonglong Base = 0x7FFFFFFEF000;
  9.     ulonglong RegionSize = 0x1000;
  10.     int retV = ZwAllocateVirtualMemory(GetCurrentProcess(),&Base,0,&RegionSize,MEM_RESERVE,PAGE_READWRITE);
  11.     printf("ZwAllocateVirtualMemory, ret: %X, Base: %I64X Size: %I64X\r\n",retV,Base,RegionSize);
  12.     if(retV >= 0)
  13.     {
  14.         retV = ZwAllocateVirtualMemory(GetCurrentProcess(),&Base,0,&RegionSize,MEM_COMMIT,PAGE_READWRITE);
  15.         printf("ZwAllocateVirtualMemory, ret: %X, Base: %I64X Size: %I64X\r\n",retV,Base,RegionSize);
  16.  
  17.         *(uchar*)(HighestUserAddressBuffer+0xFFF) = 0;
  18.         return Base;
  19.     }
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement