interception_internal.h 2.2 KB

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