ReactOS 0.4.16-dev-306-g647d351
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}
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Status
Definition: gdiplustypes.h:25
#define PAGE_ROUND_UP(x)
Definition: mmtypes.h:38
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define MEM_RESERVE
Definition: nt_native.h:1314
#define MEM_RELEASE
Definition: nt_native.h:1316
#define MEM_COMMIT
Definition: nt_native.h:1313
#define PAGE_NOACCESS
Definition: nt_native.h:1302
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5230
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:4492
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG_PTR SIZE_T
Definition: typedefs.h:80
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

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()

◆ 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}

Referenced by START_TEST().