10a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// Copyright 2013 Google Inc. All rights reserved.
20a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//
30a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// Redistribution and use in source and binary forms, with or without
40a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// modification, are permitted provided that the following conditions are
50a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// met:
60a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//
70a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//     * Redistributions of source code must retain the above copyright
80a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// notice, this list of conditions and the following disclaimer.
90a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//     * Redistributions in binary form must reproduce the above
100a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// copyright notice, this list of conditions and the following disclaimer
110a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// in the documentation and/or other materials provided with the
120a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// distribution.
130a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//     * Neither the name of Google Inc. nor the names of its
140a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// contributors may be used to endorse or promote products derived from
150a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// this software without specific prior written permission.
160a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//
170a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
180a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
190a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
200a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
210a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
220a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
230a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
240a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
250a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
260a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
270a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
280a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com
290a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// Provides an API for mapping symbols through OMAP information, if a PDB file
300a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// is augmented with it. This allows breakpad to work with addresses in
310a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// transformed images by transforming the symbols themselves, rather than
320a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// transforming addresses prior to querying symbols (the way it is typically
330a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// done by Windows-native tools, including the DIA).
340a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com
350a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com#ifndef COMMON_WINDOWS_OMAP_H_
360a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com#define COMMON_WINDOWS_OMAP_H_
370a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com
380a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com#include "common/windows/omap_internal.h"
390a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com
400a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.comnamespace google_breakpad {
410a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com
420a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// If the given session contains OMAP data this extracts it, populating
430a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// |omap_data|, and then disabling automatic translation for the session.
440a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// OMAP data is present in the PDB if |omap_data| is not empty. This returns
450a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// true on success, false otherwise.
460a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.combool GetOmapDataAndDisableTranslation(IDiaSession* dia_session,
470a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com                                      OmapData* omap_data);
480a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com
490a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// Given raw OMAP data builds an ImageMap. This can be used to query individual
500a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// image ranges using MapAddressRange.
510a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// |omap_data|| is the OMAP data extracted from the PDB.
520a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// |image_map| will be populated with a description of the image mapping. If
530a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//     |omap_data| is empty then this will also be empty.
540a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.comvoid BuildImageMap(const OmapData& omap_data, ImageMap* image_map);
550a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com
560a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// Given an address range in the original image space determines how exactly it
570a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// has been tranformed.
580a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// |omap_data| is the OMAP data extracted from the PDB, which must not be
590a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//     empty.
600a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// |original_range| is the address range in the original image being queried.
610a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com// |mapped_ranges| will be populated with a full description of the mapping.
620a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//     They may be disjoint in the transformed image so a vector is needed to
630a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//     fully represent the mapping. This will be appended to if it is not
640a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//     empty. If |omap_data| is empty then |mapped_ranges| will simply be
650a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com//     populated with a copy of |original_range| (the identity transform).
660a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.comvoid MapAddressRange(const ImageMap& image_map,
670a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com                     const AddressRange& original_range,
680a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com                     AddressRangeVector* mapped_ranges);
690a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com
700a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com}  // namespace google_breakpad
710a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com
720a35290a4ecafc23215c2df491f7093f18fcda97ivan.penkov@gmail.com#endif  // COMMON_WINDOWS_OMAP_H_
73