1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
4 /*=============================================================
6 ** Source: createfilemapping.c (test 8)
8 ** Purpose: Positive test the CreateFileMapping API.
9 ** Test the un-verifiable parameter combinations.
12 **============================================================*/
15 const int MAPPINGSIZE = 2048;
16 HANDLE SWAP_HANDLE = ((VOID *)(-1));
18 int __cdecl main(int argc, char *argv[])
22 /* Initialize the PAL environment.
24 if(0 != PAL_Initialize(argc, argv))
29 /* Create a READONLY, "swap", un-named file mapping.
30 * This test is unverifiable since there is no hook back to the file map
31 * because it is un-named. As well, since it resides in "swap", and is
32 * initialized to zero, there is nothing to read.
34 hFileMap = CreateFileMapping(
36 NULL, /*not inherited*/
37 PAGE_READONLY, /*read only*/
38 0, /*high-order size*/
39 MAPPINGSIZE, /*low-order size*/
40 NULL); /*un-named object*/
44 Fail("ERROR:%u: Failed to create File Mapping.\n",
49 /* Create a COPYWRITE, "swap", un-named file mapping.
50 * This test is unverifiable, here is a quote from MSDN:
52 * Copy on write access. If you create the map with PAGE_WRITECOPY and
53 * the view with FILE_MAP_COPY, you will receive a view to file. If you
54 * write to it, the pages are automatically swappable and the modifications
55 * you make will not go to the original data file.
58 hFileMap = CreateFileMapping(
60 NULL, /*not inherited*/
61 PAGE_WRITECOPY, /*read only*/
62 0, /*high-order size*/
63 MAPPINGSIZE, /*low-order size*/
64 NULL); /*unnamed object*/
68 Fail("ERROR:%u: Failed to create File Mapping.\n",