blob: 7b04c548ccbb653399edf2c45c75da19dbe728d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*============================================================
**
** Source: test3.c
**
** Purpose:
** Check that IsBadWritePtr returns non-zero on Read-only memory.
**
**
**=========================================================*/
#include <palsuite.h>
int __cdecl main(int argc, char *argv[]) {
LPVOID PageOne;
if(0 != (PAL_Initialize(argc, argv)))
{
return FAIL;
}
/* Reserve enough space for four pages. We'll commit this memory
and set the correct access for each page below.
*/
PageOne = VirtualAlloc(NULL,
GetOsPageSize(),
MEM_COMMIT,
PAGE_READONLY);
if(PageOne == NULL)
{
Fail("ERROR: VirtualAlloc failed to commit the required memory.\n");
}
if(IsBadWritePtr(PageOne,GetOsPageSize()) == 0)
{
VirtualFree(PageOne,0,MEM_RELEASE);
Fail("ERROR: IsBadWritePtr returned 0 when checking a section of "
"read-only memory. It should be non-zero.\n");
}
VirtualFree(PageOne,0,MEM_RELEASE);
PAL_Terminate();
return PASS;
}
|