ReactOS  0.4.15-dev-499-g1f31905
apitest_guard.h File Reference
#include <ndk/mmfuncs.h>
#include <ndk/psfuncs.h>
Include dependency graph for apitest_guard.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static PVOID AllocateGuarded (_In_ SIZE_T SizeRequested)
 
static VOID FreeGuarded (_In_ PVOID Pointer)
 
static VOID MakeReadOnly (PVOID Pointer, SIZE_T SizeRequested)
 

Function Documentation

◆ AllocateGuarded()

static PVOID AllocateGuarded ( _In_ SIZE_T  SizeRequested)
inlinestatic

Definition at line 10 of file apitest_guard.h.

12 {
14  SIZE_T Size = PAGE_ROUND_UP(SizeRequested + PAGE_SIZE);
15  PVOID VirtualMemory = NULL;
16  PCHAR StartOfBuffer;
17 
19 
20  if (!NT_SUCCESS(Status))
21  return NULL;
22 
23  Size -= PAGE_SIZE;
24  if (Size)
25  {
27  if (!NT_SUCCESS(Status))
28  {
29  Size = 0;
31  ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
32  return NULL;
33  }
34  }
35 
36  StartOfBuffer = VirtualMemory;
37  StartOfBuffer += Size - SizeRequested;
38 
39  return StartOfBuffer;
40 }
signed char * PCHAR
Definition: retypes.h:7
LONG NTSTATUS
Definition: precomp.h:26
#define MEM_COMMIT
Definition: nt_native.h:1313
#define PAGE_ROUND_UP(x)
Definition: scsiport_int.h:13
#define MEM_RESERVE
Definition: nt_native.h:1314
#define PAGE_NOACCESS
Definition: nt_native.h:1302
smooth NULL
Definition: ftsmooth.c:416
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PAGE_SIZE
Definition: env_spec_w32.h:49
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:79
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
Definition: virtual.c:4367
#define ok(value,...)
Definition: atltest.h:57
#define MEM_RELEASE
Definition: nt_native.h:1316
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define PAGE_READWRITE
Definition: nt_native.h:1304
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5090

Referenced by MakeAcl(), START_TEST(), Test_RtlAreBitsClear(), Test_RtlAreBitsSet(), Test_RtlClearAllBits(), Test_RtlClearBits(), Test_RtlFindClearBits(), Test_RtlFindClearBitsAndSet(), Test_RtlFindNextForwardRunClear(), Test_RtlFindSetBits(), Test_RtlFindSetBitsAndClear(), Test_RtlNumberOfClearBits(), Test_RtlNumberOfSetBits(), Test_RtlSetAllBits(), Test_RtlSetBits(), TestGetUserObjectInfoA(), and TestGetUserObjectInfoW().

◆ FreeGuarded()

static VOID FreeGuarded ( _In_ PVOID  Pointer)
inlinestatic

Definition at line 45 of file apitest_guard.h.

47 {
49  PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer);
50  SIZE_T Size = 0;
51 
53  ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
54 }
LONG NTSTATUS
Definition: precomp.h:26
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
void * PVOID
Definition: retypes.h:9
#define NtCurrentProcess()
Definition: nt_native.h:1657
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define ok(value,...)
Definition: atltest.h:57
#define MEM_RELEASE
Definition: nt_native.h:1316
return STATUS_SUCCESS
Definition: btrfs.c:3014
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5090

Referenced by START_TEST(), Test_RtlAreBitsClear(), Test_RtlAreBitsSet(), Test_RtlClearAllBits(), Test_RtlClearBits(), Test_RtlFindClearBits(), Test_RtlFindClearBitsAndSet(), Test_RtlFindNextForwardRunClear(), Test_RtlFindSetBits(), Test_RtlFindSetBitsAndClear(), Test_RtlNumberOfClearBits(), Test_RtlNumberOfSetBits(), Test_RtlSetAllBits(), Test_RtlSetBits(), TestGetUserObjectInfoA(), and TestGetUserObjectInfoW().

◆ MakeReadOnly()

static VOID MakeReadOnly ( PVOID  Pointer,
SIZE_T  SizeRequested 
)
inlinestatic

Definition at line 59 of file apitest_guard.h.

62 {
64  SIZE_T Size = PAGE_ROUND_UP(SizeRequested);
65  PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer);
66 
67  if (Size)
68  {
70  if (!NT_SUCCESS(Status))
71  {
72  Size = 0;
74  ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
75  }
76  }
77 }
LONG NTSTATUS
Definition: precomp.h:26
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
#define MEM_COMMIT
Definition: nt_native.h:1313
#define PAGE_ROUND_UP(x)
Definition: scsiport_int.h:13
void * PVOID
Definition: retypes.h:9
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:79
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
Definition: virtual.c:4367
#define ok(value,...)
Definition: atltest.h:57
#define MEM_RELEASE
Definition: nt_native.h:1316
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define PAGE_READWRITE
Definition: nt_native.h:1304
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5090

Referenced by START_TEST().