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