1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | /*============================================================= |
6 | ** |
7 | ** Source: virtualalloc.c |
8 | ** |
9 | ** Purpose: Negative test the VirtualAlloc API. |
10 | ** Call VirtualAlloc with MEM_COMMIT allocation type |
11 | ** and PAGE_READWRITE access protection |
12 | |
13 | ** |
14 | **============================================================*/ |
15 | #include <palsuite.h> |
16 | |
17 | int __cdecl main(int argc, char *argv[]) |
18 | { |
19 | int err; |
20 | LPVOID lpVirtualAddress; |
21 | |
22 | |
23 | //Initialize the PAL environment |
24 | err = PAL_Initialize(argc, argv); |
25 | if(0 != err) |
26 | { |
27 | ExitProcess(FAIL); |
28 | } |
29 | |
30 | //Allocate the physical storage in memory or in the paging file on disk |
31 | lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region |
32 | (SIZE_T)(2147483647000000), //specify the size to be int32.maxvalue mega bytes |
33 | MEM_COMMIT, //allocation type |
34 | PAGE_READWRITE); //access protection |
35 | if(NULL != lpVirtualAddress) |
36 | { |
37 | Fail("\nWelcome to the Future, where Unlimited Memory is Available, disregard this test!\n" ); |
38 | } |
39 | |
40 | |
41 | |
42 | PAL_Terminate(); |
43 | return PASS; |
44 | } |
45 | |