summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect')
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/CMakeLists.txt9
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/VirtualProtect.c69
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/VirtualProtect.c69
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/VirtualProtect.c69
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/VirtualProtect.c68
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/VirtualProtect.c68
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/VirtualProtect.c69
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/testinfo.dat13
19 files changed, 613 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/CMakeLists.txt
new file mode 100644
index 0000000000..cac5452ec9
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+add_subdirectory(test3)
+add_subdirectory(test4)
+add_subdirectory(test6)
+add_subdirectory(test7)
+
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/CMakeLists.txt
new file mode 100644
index 0000000000..214cf460ae
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ VirtualProtect.c
+)
+
+add_executable(paltest_virtualprotect_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_virtualprotect_test1 coreclrpal)
+
+target_link_libraries(paltest_virtualprotect_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/VirtualProtect.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/VirtualProtect.c
new file mode 100644
index 0000000000..1a28bd156d
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/VirtualProtect.c
@@ -0,0 +1,69 @@
+// 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: virtualprotect.c
+**
+** Purpose: Positive test the VirtualProtect API.
+** Call VirtualProtect to set new protect as
+** PAGE_READWRITE
+**
+**
+**============================================================*/
+#include <palsuite.h>
+
+#define REGIONSIZE 1024
+
+int __cdecl main(int argc, char *argv[])
+{
+ int err;
+ LPVOID lpVirtualAddress;
+ DWORD OldProtect;
+
+ //Initialize the PAL environment
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ ExitProcess(FAIL);
+ }
+
+ //Allocate the physical storage in memory or in the paging file on disk
+ lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region
+ REGIONSIZE, //specify the size
+ MEM_COMMIT, //allocation type
+ PAGE_READONLY); //access protection
+ if(NULL == lpVirtualAddress)
+ {
+ Fail("\nFailed to call VirtualAlloc API!\n");
+ }
+
+ OldProtect = PAGE_READONLY;
+ //Set new access protection
+ err = VirtualProtect(lpVirtualAddress,
+ REGIONSIZE, //specify the region size
+ PAGE_READWRITE,//desied access protection
+ &OldProtect);//old access protection
+ if(0 == err)
+ {
+ Trace("\nFailed to call VirtualProtect API!\n");
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+ Fail("");
+ }
+
+
+ //decommit the specified region
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/testinfo.dat
new file mode 100644
index 0000000000..6b78c079e7
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/testinfo.dat
@@ -0,0 +1,13 @@
+# 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.
+
+Version = 1.0
+Section = Filemapping_memmgt
+Function = VirtualProtect
+Name = Positive test for VirtualProtect - with PAGE_READWRITE
+TYPE = DEFAULT
+EXE1 = virtualprotect
+Description
+=Test the VirtualProtect to set new access protection
+=as PAGE_READWRITE
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/CMakeLists.txt
new file mode 100644
index 0000000000..27f43477ea
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ VirtualProtect.c
+)
+
+add_executable(paltest_virtualprotect_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_virtualprotect_test2 coreclrpal)
+
+target_link_libraries(paltest_virtualprotect_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/VirtualProtect.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/VirtualProtect.c
new file mode 100644
index 0000000000..64a08d7885
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/VirtualProtect.c
@@ -0,0 +1,69 @@
+// 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: virtualprotect.c
+**
+** Purpose: Positive test the VirtualProtect API.
+** Call VirtualProtect to set new protect as
+** PAGE_EXECUTE
+**
+**
+**============================================================*/
+#include <palsuite.h>
+
+#define REGIONSIZE 1024
+
+int __cdecl main(int argc, char *argv[])
+{
+ int err;
+ LPVOID lpVirtualAddress;
+ DWORD OldProtect;
+
+ //Initialize the PAL environment
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ ExitProcess(FAIL);
+ }
+
+ //Allocate the physical storage in memory or in the paging file on disk
+ lpVirtualAddress = VirtualAlloc(NULL,//determine where to allocate the region
+ REGIONSIZE, //specify the size
+ MEM_COMMIT, //allocation type
+ PAGE_READONLY); //access protection
+ if(NULL == lpVirtualAddress)
+ {
+ Fail("\nFailed to call VirtualAlloc API!\n");
+ }
+
+ OldProtect = PAGE_READONLY;
+ //Set new access protection
+ err = VirtualProtect(lpVirtualAddress,
+ REGIONSIZE, //specify the region size
+ PAGE_EXECUTE,//desied access protection
+ &OldProtect);//old access protection
+ if(0 == err)
+ {
+ Trace("\nFailed to call VirtualProtect API!\n");
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+ Fail("");
+ }
+
+
+ //decommit the specified region
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/testinfo.dat
new file mode 100644
index 0000000000..d5fa0cfbc2
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/testinfo.dat
@@ -0,0 +1,13 @@
+# 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.
+
+Version = 1.0
+Section = Filemapping_memmgt
+Function = VirtualProtect
+Name = Positive test for VirtualProtect - with PAGE_EXECUTE
+TYPE = DEFAULT
+EXE1 = virtualprotect
+Description
+=Test the VirtualProtect to set new access protection
+=as PAGE_EXECUTE
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/CMakeLists.txt
new file mode 100644
index 0000000000..994d4e2f41
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ VirtualProtect.c
+)
+
+add_executable(paltest_virtualprotect_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_virtualprotect_test3 coreclrpal)
+
+target_link_libraries(paltest_virtualprotect_test3
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/VirtualProtect.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/VirtualProtect.c
new file mode 100644
index 0000000000..0f738630ee
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/VirtualProtect.c
@@ -0,0 +1,69 @@
+// 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: virtualprotect.c
+**
+** Purpose: Positive test the VirtualProtect API.
+** Call VirtualProtect to set new protect as
+** PAGE_EXECUTE_READ
+**
+**
+**============================================================*/
+#include <palsuite.h>
+
+#define REGIONSIZE 1024
+
+int __cdecl main(int argc, char *argv[])
+{
+ int err;
+ LPVOID lpVirtualAddress;
+ DWORD OldProtect;
+
+ //Initialize the PAL environment
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ ExitProcess(FAIL);
+ }
+
+ //Allocate the physical storage in memory or in the paging file on disk
+ lpVirtualAddress = VirtualAlloc(NULL,//determine where to allocate the region
+ REGIONSIZE, //specify the size
+ MEM_COMMIT, //allocation type
+ PAGE_READONLY); //access protection
+ if(NULL == lpVirtualAddress)
+ {
+ Fail("\nFailed to call VirtualAlloc API!\n");
+ }
+
+ OldProtect = PAGE_READONLY;
+ //Set new access protection
+ err = VirtualProtect(lpVirtualAddress,
+ REGIONSIZE, //specify the region size
+ PAGE_EXECUTE_READ,//desied access protection
+ &OldProtect);//old access protection
+ if(0 == err)
+ {
+ Trace("\nFailed to call VirtualProtect API!\n");
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+ Fail("");
+ }
+
+
+ //decommit the specified region
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/testinfo.dat
new file mode 100644
index 0000000000..7c64c3092e
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/testinfo.dat
@@ -0,0 +1,13 @@
+# 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.
+
+Version = 1.0
+Section = Filemapping_memmgt
+Function = VirtualProtect
+Name = Positive test for VirtualProtect - with PAGE_EXECUTE_READ
+TYPE = DEFAULT
+EXE1 = virtualprotect
+Description
+=Test the VirtualProtect to set new access protection
+=as PAGE_EXECUTE_READ
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/CMakeLists.txt
new file mode 100644
index 0000000000..2e0fba50bb
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ VirtualProtect.c
+)
+
+add_executable(paltest_virtualprotect_test4
+ ${SOURCES}
+)
+
+add_dependencies(paltest_virtualprotect_test4 coreclrpal)
+
+target_link_libraries(paltest_virtualprotect_test4
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/VirtualProtect.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/VirtualProtect.c
new file mode 100644
index 0000000000..926d501d0d
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/VirtualProtect.c
@@ -0,0 +1,68 @@
+// 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: virtualprotect.c
+**
+** Purpose: Positive test the VirtualProtect API.
+** Call VirtualProtect to set new protect as
+** PAGE_EXECUTE_READWRITE
+**
+**
+**============================================================*/
+#include <palsuite.h>
+
+#define REGIONSIZE 1024
+
+int __cdecl main(int argc, char *argv[])
+{
+ int err;
+ LPVOID lpVirtualAddress;
+ DWORD OldProtect;
+
+ //Initialize the PAL environment
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ ExitProcess(FAIL);
+ }
+
+ //Allocate the physical storage in memory or in the paging file on disk
+ lpVirtualAddress = VirtualAlloc(NULL,//determine where to allocate the region
+ REGIONSIZE, //specify the size
+ MEM_COMMIT, //allocation type
+ PAGE_READONLY); //access protection
+ if(NULL == lpVirtualAddress)
+ {
+ Fail("\nFailed to call VirtualAlloc API!\n");
+ }
+
+ OldProtect = PAGE_READONLY;
+ //Set new access protection
+ err = VirtualProtect(lpVirtualAddress,
+ REGIONSIZE, //specify the region size
+ PAGE_EXECUTE_READWRITE,//desied access protection
+ &OldProtect);//old access protection
+ if(0 == err)
+ {
+ Trace("\nFailed to call VirtualProtect API!\n");
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+ Fail("");
+ }
+
+ //decommit the specified region
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/testinfo.dat
new file mode 100644
index 0000000000..c344073113
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/testinfo.dat
@@ -0,0 +1,13 @@
+# 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.
+
+Version = 1.0
+Section = Filemapping_memmgt
+Function = VirtualProtect
+Name = Positive test for VirtualProtect - with PAGE_EXECUTE_READWRITE
+TYPE = DEFAULT
+EXE1 = virtualprotect
+Description
+=Test the VirtualProtect to set new access protection
+=as PAGE_EXECUTE_READWRITE
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/CMakeLists.txt
new file mode 100644
index 0000000000..6d6fd07df8
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ VirtualProtect.c
+)
+
+add_executable(paltest_virtualprotect_test6
+ ${SOURCES}
+)
+
+add_dependencies(paltest_virtualprotect_test6 coreclrpal)
+
+target_link_libraries(paltest_virtualprotect_test6
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/VirtualProtect.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/VirtualProtect.c
new file mode 100644
index 0000000000..d60b323ec6
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/VirtualProtect.c
@@ -0,0 +1,68 @@
+// 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: virtualprotect.c
+**
+** Purpose: Positive test the VirtualProtect API.
+** Call VirtualProtect to set new protect as
+** PAGE_NOACCESS
+**
+**
+**============================================================*/
+#include <palsuite.h>
+
+#define REGIONSIZE 1024
+
+int __cdecl main(int argc, char *argv[])
+{
+ int err;
+ LPVOID lpVirtualAddress;
+ DWORD OldProtect;
+
+ //Initialize the PAL environment
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ ExitProcess(FAIL);
+ }
+ //Allocate the physical storage in memory or in the paging file on disk
+ lpVirtualAddress = VirtualAlloc(NULL,//determine where to allocate the region
+ REGIONSIZE, //specify the size
+ MEM_COMMIT, //allocation type
+ PAGE_READONLY); //access protection
+ if(NULL == lpVirtualAddress)
+ {
+ Fail("\nFailed to call VirtualAlloc API!\n");
+ }
+
+ OldProtect = PAGE_READONLY;
+ //Set new access protection
+ err = VirtualProtect(lpVirtualAddress,
+ REGIONSIZE, //specify the region size
+ PAGE_NOACCESS,//desied access protection
+ &OldProtect);//old access protection
+ if(0 == err)
+ {
+ Trace("\nFailed to call VirtualProtect API!\n");
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+ Fail("");
+ }
+
+
+ //decommit the specified region
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/testinfo.dat
new file mode 100644
index 0000000000..71ccad5639
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/testinfo.dat
@@ -0,0 +1,13 @@
+# 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.
+
+Version = 1.0
+Section = Filemapping_memmgt
+Function = VirtualProtect
+Name = Positive test for VirtualProtect - with PAGE_NOACCESS
+TYPE = DEFAULT
+EXE1 = virtualprotect
+Description
+=Test the VirtualProtect to set new access protection
+=as PAGE_NOACCESS
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/CMakeLists.txt
new file mode 100644
index 0000000000..06af860559
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ VirtualProtect.c
+)
+
+add_executable(paltest_virtualprotect_test7
+ ${SOURCES}
+)
+
+add_dependencies(paltest_virtualprotect_test7 coreclrpal)
+
+target_link_libraries(paltest_virtualprotect_test7
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/VirtualProtect.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/VirtualProtect.c
new file mode 100644
index 0000000000..edc37711f4
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/VirtualProtect.c
@@ -0,0 +1,69 @@
+// 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: virtualprotect.c
+**
+** Purpose: Positive test the VirtualProtect API.
+** Call VirtualProtect to set new protect as
+** PAGE_READONLY
+**
+**
+**============================================================*/
+#include <palsuite.h>
+
+#define REGIONSIZE 1024
+
+int __cdecl main(int argc, char *argv[])
+{
+ int err;
+ LPVOID lpVirtualAddress;
+ DWORD OldProtect;
+
+ //Initialize the PAL environment
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ ExitProcess(FAIL);
+ }
+
+ //Allocate the physical storage in memory or in the paging file on disk
+ lpVirtualAddress = VirtualAlloc(NULL,//determine where to allocate the region
+ REGIONSIZE, //specify the size
+ MEM_COMMIT, //allocation type
+ PAGE_READWRITE); //access protection
+ if(NULL == lpVirtualAddress)
+ {
+ Fail("\nFailed to call VirtualAlloc API!\n");
+ }
+
+ OldProtect = PAGE_READONLY;
+ //Set new access protection
+ err = VirtualProtect(lpVirtualAddress,
+ REGIONSIZE, //specify the region size
+ PAGE_READONLY,//desied access protection
+ &OldProtect);//old access protection
+ if(0 == err)
+ {
+ Trace("\nFailed to call VirtualProtect API!\n");
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+ Fail("");
+ }
+
+
+ //decommit the specified region
+ err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/testinfo.dat
new file mode 100644
index 0000000000..6b6eb58b34
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/testinfo.dat
@@ -0,0 +1,13 @@
+# 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.
+
+Version = 1.0
+Section = Filemapping_memmgt
+Function = VirtualProtect
+Name = Positive test for VirtualProtect - with PAGE_READONLY
+TYPE = DEFAULT
+EXE1 = virtualprotect
+Description
+=Test the VirtualProtect to set new access protection
+=as PAGE_READONLY