security/sandbox/win/src/interception_internal.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 // Defines InterceptionManager, the class in charge of setting up interceptions
michael@0 6 // for the sandboxed process. For more details see:
michael@0 7 // http://dev.chromium.org/developers/design-documents/sandbox .
michael@0 8
michael@0 9 #ifndef SANDBOX_SRC_INTERCEPTION_INTERNAL_H_
michael@0 10 #define SANDBOX_SRC_INTERCEPTION_INTERNAL_H_
michael@0 11
michael@0 12 #include "sandbox/win/src/sandbox_types.h"
michael@0 13
michael@0 14 namespace sandbox {
michael@0 15
michael@0 16 const int kMaxThunkDataBytes = 64;
michael@0 17
michael@0 18 enum InterceptorId;
michael@0 19
michael@0 20 // The following structures contain variable size fields at the end, and will be
michael@0 21 // used to transfer information between two processes. In order to guarantee
michael@0 22 // our ability to follow the chain of structures, the alignment should be fixed,
michael@0 23 // hence this pragma.
michael@0 24 #pragma pack(push, 4)
michael@0 25
michael@0 26 // Structures for the shared memory that contains patching information
michael@0 27 // for the InterceptionAgent.
michael@0 28 // A single interception:
michael@0 29 struct FunctionInfo {
michael@0 30 size_t record_bytes; // rounded to sizeof(size_t) bytes
michael@0 31 InterceptionType type;
michael@0 32 InterceptorId id;
michael@0 33 const void* interceptor_address;
michael@0 34 char function[1]; // placeholder for null terminated name
michael@0 35 // char interceptor[] // followed by the interceptor function
michael@0 36 };
michael@0 37
michael@0 38 // A single dll:
michael@0 39 struct DllPatchInfo {
michael@0 40 size_t record_bytes; // rounded to sizeof(size_t) bytes
michael@0 41 size_t offset_to_functions;
michael@0 42 int num_functions;
michael@0 43 bool unload_module;
michael@0 44 wchar_t dll_name[1]; // placeholder for null terminated name
michael@0 45 // FunctionInfo function_info[] // followed by the functions to intercept
michael@0 46 };
michael@0 47
michael@0 48 // All interceptions:
michael@0 49 struct SharedMemory {
michael@0 50 int num_intercepted_dlls;
michael@0 51 void* interceptor_base;
michael@0 52 DllPatchInfo dll_list[1]; // placeholder for the list of dlls
michael@0 53 };
michael@0 54
michael@0 55 // Dummy single thunk:
michael@0 56 struct ThunkData {
michael@0 57 char data[kMaxThunkDataBytes];
michael@0 58 };
michael@0 59
michael@0 60 // In-memory representation of the interceptions for a given dll:
michael@0 61 struct DllInterceptionData {
michael@0 62 size_t data_bytes;
michael@0 63 size_t used_bytes;
michael@0 64 void* base;
michael@0 65 int num_thunks;
michael@0 66 #if defined(_WIN64)
michael@0 67 int dummy; // Improve alignment.
michael@0 68 #endif
michael@0 69 ThunkData thunks[1];
michael@0 70 };
michael@0 71
michael@0 72 #pragma pack(pop)
michael@0 73
michael@0 74 } // namespace sandbox
michael@0 75
michael@0 76 #endif // SANDBOX_SRC_INTERCEPTION_INTERNAL_H_

mercurial