Bug 1758813 [wpt PR 33142] - Implement RP sign out, a=testonly
[gecko.git] / ipc / glue / SharedMemory_windows.cpp
blob1cc93687af38687aca5ef5ca3b191ee951f8859f
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include <windows.h>
9 #include "mozilla/ipc/SharedMemory.h"
11 namespace mozilla {
12 namespace ipc {
14 void SharedMemory::SystemProtect(char* aAddr, size_t aSize, int aRights) {
15 if (!SystemProtectFallible(aAddr, aSize, aRights)) {
16 MOZ_CRASH("can't VirtualProtect()");
20 bool SharedMemory::SystemProtectFallible(char* aAddr, size_t aSize,
21 int aRights) {
22 DWORD flags;
23 if ((aRights & RightsRead) && (aRights & RightsWrite))
24 flags = PAGE_READWRITE;
25 else if (aRights & RightsRead)
26 flags = PAGE_READONLY;
27 else
28 flags = PAGE_NOACCESS;
30 DWORD oldflags;
31 return VirtualProtect(aAddr, aSize, flags, &oldflags);
34 size_t SharedMemory::SystemPageSize() {
35 SYSTEM_INFO si;
36 GetSystemInfo(&si);
37 return si.dwPageSize;
40 } // namespace ipc
41 } // namespace mozilla