michael@0: // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: // Defines InterceptionManager, the class in charge of setting up interceptions michael@0: // for the sandboxed process. For more details see: michael@0: // http://dev.chromium.org/developers/design-documents/sandbox . michael@0: michael@0: #ifndef SANDBOX_SRC_INTERCEPTION_INTERNAL_H_ michael@0: #define SANDBOX_SRC_INTERCEPTION_INTERNAL_H_ michael@0: michael@0: #include "sandbox/win/src/sandbox_types.h" michael@0: michael@0: namespace sandbox { michael@0: michael@0: const int kMaxThunkDataBytes = 64; michael@0: michael@0: enum InterceptorId; michael@0: michael@0: // The following structures contain variable size fields at the end, and will be michael@0: // used to transfer information between two processes. In order to guarantee michael@0: // our ability to follow the chain of structures, the alignment should be fixed, michael@0: // hence this pragma. michael@0: #pragma pack(push, 4) michael@0: michael@0: // Structures for the shared memory that contains patching information michael@0: // for the InterceptionAgent. michael@0: // A single interception: michael@0: struct FunctionInfo { michael@0: size_t record_bytes; // rounded to sizeof(size_t) bytes michael@0: InterceptionType type; michael@0: InterceptorId id; michael@0: const void* interceptor_address; michael@0: char function[1]; // placeholder for null terminated name michael@0: // char interceptor[] // followed by the interceptor function michael@0: }; michael@0: michael@0: // A single dll: michael@0: struct DllPatchInfo { michael@0: size_t record_bytes; // rounded to sizeof(size_t) bytes michael@0: size_t offset_to_functions; michael@0: int num_functions; michael@0: bool unload_module; michael@0: wchar_t dll_name[1]; // placeholder for null terminated name michael@0: // FunctionInfo function_info[] // followed by the functions to intercept michael@0: }; michael@0: michael@0: // All interceptions: michael@0: struct SharedMemory { michael@0: int num_intercepted_dlls; michael@0: void* interceptor_base; michael@0: DllPatchInfo dll_list[1]; // placeholder for the list of dlls michael@0: }; michael@0: michael@0: // Dummy single thunk: michael@0: struct ThunkData { michael@0: char data[kMaxThunkDataBytes]; michael@0: }; michael@0: michael@0: // In-memory representation of the interceptions for a given dll: michael@0: struct DllInterceptionData { michael@0: size_t data_bytes; michael@0: size_t used_bytes; michael@0: void* base; michael@0: int num_thunks; michael@0: #if defined(_WIN64) michael@0: int dummy; // Improve alignment. michael@0: #endif michael@0: ThunkData thunks[1]; michael@0: }; michael@0: michael@0: #pragma pack(pop) michael@0: michael@0: } // namespace sandbox michael@0: michael@0: #endif // SANDBOX_SRC_INTERCEPTION_INTERNAL_H_