blob: c34188865fe9bac663cf9ef574de692b69cb40b4 [file] [log] [blame]
[email protected]75739512014-05-13 00:40:581// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// This file is used to handle differences in Mach message IDs and structures
6// that occur between different OS versions. The Mach messages that the sandbox
7// is interested in are decoded using information derived from the open-source
8// libraries, i.e. <http://www.opensource.apple.com/source/launchd/>. While
9// these messages definitions are open source, they are not considered part of
10// the stable OS API, and so differences do exist between OS versions.
11
12#ifndef SANDBOX_MAC_OS_COMPATIBILITY_H_
13#define SANDBOX_MAC_OS_COMPATIBILITY_H_
14
15#include <mach/mach.h>
avi74a1875f2015-12-22 02:10:0316#include <stdint.h>
[email protected]75739512014-05-13 00:40:5817
mostynbd521b632016-04-06 13:22:0818#include <memory>
[email protected]75739512014-05-13 00:40:5819#include <string>
20
[email protected]168bdd4a2014-07-01 00:06:1121#include "sandbox/mac/message_server.h"
22
[email protected]75739512014-05-13 00:40:5823namespace sandbox {
24
rsesek05baf192015-07-22 16:13:4425class OSCompatibility {
26 public:
27 // Creates an OSCompatibility instance for the current OS X version.
mostynbd521b632016-04-06 13:22:0828 static std::unique_ptr<OSCompatibility> CreateForPlatform();
[email protected]75739512014-05-13 00:40:5829
rsesek05baf192015-07-22 16:13:4430 virtual ~OSCompatibility();
[email protected]168bdd4a2014-07-01 00:06:1131
rsesek7d60b3f2015-07-17 14:40:0432 // Gets the message and subsystem ID of an IPC message.
rsesek05baf192015-07-22 16:13:4433 virtual uint64_t GetMessageSubsystem(const IPCMessage message) = 0;
34 virtual uint64_t GetMessageID(const IPCMessage message) = 0;
[email protected]168bdd4a2014-07-01 00:06:1135
rsesek7d60b3f2015-07-17 14:40:0436 // Returns true if the message is a Launchd look up request.
rsesek05baf192015-07-22 16:13:4437 virtual bool IsServiceLookUpRequest(const IPCMessage message) = 0;
[email protected]75739512014-05-13 00:40:5838
rsesek7d60b3f2015-07-17 14:40:0439 // Returns true if the message is a Launchd vproc swap_integer request.
rsesek05baf192015-07-22 16:13:4440 virtual bool IsVprocSwapInteger(const IPCMessage message) = 0;
rsesek7d60b3f2015-07-17 14:40:0441
42 // Returns true if the message is an XPC domain management message.
rsesek05baf192015-07-22 16:13:4443 virtual bool IsXPCDomainManagement(const IPCMessage message) = 0;
[email protected]75739512014-05-13 00:40:5844
45 // A function to take a look_up2 message and return the string service name
46 // that was requested via the message.
rsesek05baf192015-07-22 16:13:4447 virtual std::string GetServiceLookupName(const IPCMessage message) = 0;
[email protected]75739512014-05-13 00:40:5848
49 // A function to formulate a reply to a look_up2 message, given the reply
50 // message and the port to return as the service.
rsesek05baf192015-07-22 16:13:4451 virtual void WriteServiceLookUpReply(IPCMessage reply,
52 mach_port_t service_port) = 0;
[email protected]795989f22014-05-16 02:05:4253
54 // A function to take a swap_integer message and return true if the message
55 // is only getting the value of a key, neither setting it directly, nor
56 // swapping two keys.
rsesek05baf192015-07-22 16:13:4457 virtual bool IsSwapIntegerReadOnly(const IPCMessage message) = 0;
[email protected]75739512014-05-13 00:40:5858};
59
[email protected]75739512014-05-13 00:40:5860} // namespace sandbox
61
62#endif // SANDBOX_MAC_OS_COMPATIBILITY_H_