Advertisement
MagicAndre1981

new memory API for Windows 10

Apr 4th, 2015
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.09 KB | None | 0 0
  1. #define FILE_MAP_TARGETS_INVALID       0x40000000
  2.  
  3. WINBASEAPI
  4. BOOL
  5. WINAPI
  6. SetProcessValidCallTargets(
  7.     _In_ HANDLE hProcess,
  8.     _In_ PVOID VirtualAddress,
  9.     _In_ SIZE_T RegionSize,
  10.     _In_ ULONG NumberOfOffets,
  11.     _In_reads_(NumberOfOffets) PCFG_CALL_TARGET_INFO OffsetInformation
  12.     );
  13.  
  14.  
  15. WINBASEAPI
  16. _Ret_maybenull_ _Post_writable_byte_size_(Size)
  17. PVOID
  18. WINAPI
  19. VirtualAllocFromApp(
  20.     _In_opt_ PVOID BaseAddress,
  21.     _In_ SIZE_T Size,
  22.     _In_ ULONG AllocationType,
  23.     _In_ ULONG Protection
  24.     );
  25.  
  26.  
  27. WINBASEAPI
  28. _Success_(return != FALSE)
  29. BOOL
  30. WINAPI
  31. VirtualProtectFromApp(
  32.     _In_ PVOID Address,
  33.     _In_ SIZE_T Size,
  34.     _In_ ULONG NewProtection,
  35.     _Out_ PULONG OldProtection
  36.     );
  37.  
  38.  
  39. WINBASEAPI
  40. _Ret_maybenull_
  41. HANDLE
  42. WINAPI
  43. OpenFileMappingFromApp(
  44.     _In_ ULONG DesiredAccess,
  45.     _In_ BOOL InheritHandle,
  46.     _In_ PCWSTR Name
  47.     );
  48.  
  49.  
  50. the old APIs now internally call the new APP API calls:
  51.  
  52. #define CreateFileMapping  CreateFileMappingW
  53.  
  54. FORCEINLINE
  55. WINBASEAPI
  56. _Ret_maybenull_
  57. HANDLE
  58. WINAPI
  59. CreateFileMappingW(
  60.     _In_     HANDLE hFile,
  61.     _In_opt_ LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
  62.     _In_     DWORD flProtect,
  63.     _In_     DWORD dwMaximumSizeHigh,
  64.     _In_     DWORD dwMaximumSizeLow,
  65.     _In_opt_ LPCWSTR lpName
  66.     )
  67. {
  68.     return CreateFileMappingFromApp (hFile,
  69.                                      lpFileMappingAttributes,
  70.                                      flProtect,
  71.                                      (((ULONG64) dwMaximumSizeHigh) << 32) | dwMaximumSizeLow,
  72.                                      lpName);
  73. }
  74.  
  75. FORCEINLINE
  76. WINBASEAPI
  77. _Ret_maybenull_  __out_data_source(FILE)
  78. LPVOID
  79. WINAPI
  80. MapViewOfFile(
  81.     _In_ HANDLE hFileMappingObject,
  82.     _In_ DWORD dwDesiredAccess,
  83.     _In_ DWORD dwFileOffsetHigh,
  84.     _In_ DWORD dwFileOffsetLow,
  85.     _In_ SIZE_T dwNumberOfBytesToMap
  86.     )
  87. {
  88.     return MapViewOfFileFromApp (hFileMappingObject,
  89.                                  dwDesiredAccess,
  90.                                  (((ULONG64) dwFileOffsetHigh) << 32) | dwFileOffsetLow,
  91.                                  dwNumberOfBytesToMap);
  92. }
  93.  
  94. #endif
  95.  
  96.  
  97. #if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
  98.  
  99. FORCEINLINE
  100. WINBASEAPI
  101. _Ret_maybenull_ _Post_writable_byte_size_(dwSize)
  102. LPVOID
  103. WINAPI
  104. VirtualAlloc(
  105.     _In_opt_ LPVOID lpAddress,
  106.     _In_     SIZE_T dwSize,
  107.     _In_     DWORD flAllocationType,
  108.     _In_     DWORD flProtect
  109.     )
  110. {
  111.     return VirtualAllocFromApp (lpAddress, dwSize, flAllocationType, flProtect);
  112. }
  113.  
  114. FORCEINLINE
  115. WINBASEAPI
  116. _Success_(return != FALSE)
  117. BOOL
  118. WINAPI
  119. VirtualProtect(
  120.     _In_  LPVOID lpAddress,
  121.     _In_  SIZE_T dwSize,
  122.     _In_  DWORD flNewProtect,
  123.     _Out_ PDWORD lpflOldProtect
  124.     )
  125. {
  126.     return VirtualProtectFromApp (lpAddress, dwSize, flNewProtect, lpflOldProtect);
  127. }
  128.  
  129. #define OpenFileMapping  OpenFileMappingW
  130.  
  131. FORCEINLINE
  132. WINBASEAPI
  133. _Ret_maybenull_
  134. HANDLE
  135. WINAPI
  136. OpenFileMappingW(
  137.     _In_ DWORD dwDesiredAccess,
  138.     _In_ BOOL bInheritHandle,
  139.     _In_ LPCWSTR lpName
  140.     )
  141. {
  142.     return OpenFileMappingFromApp (dwDesiredAccess, bInheritHandle, lpName);
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement