1 // Copyright (c) 2010 Google Inc. 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions are 6 // met: 7 // 8 // * Redistributions of source code must retain the above copyright 9 // notice, this list of conditions and the following disclaimer. 10 // * Redistributions in binary form must reproduce the above 11 // copyright notice, this list of conditions and the following disclaimer 12 // in the documentation and/or other materials provided with the 13 // distribution. 14 // * Neither the name of Google Inc. nor the names of its 15 // contributors may be used to endorse or promote products derived from 16 // this software without specific prior written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30 // memory_region.h: Access to memory regions. 31 // 32 // A MemoryRegion provides virtual access to a range of memory. It is an 33 // abstraction allowing the actual source of memory to be independent of 34 // methods which need to access a virtual memory space. 35 // 36 // Author: Mark Mentovai 37 38 #ifndef GOOGLE_BREAKPAD_PROCESSOR_MEMORY_REGION_H__ 39 #define GOOGLE_BREAKPAD_PROCESSOR_MEMORY_REGION_H__ 40 41 42 #include "google_breakpad/common/breakpad_types.h" 43 44 45 namespace google_breakpad { 46 47 48 class MemoryRegion { 49 public: ~MemoryRegion()50 virtual ~MemoryRegion() {} 51 52 // The base address of this memory region. 53 virtual uint64_t GetBase() const = 0; 54 55 // The size of this memory region. 56 virtual uint32_t GetSize() const = 0; 57 58 // Access to data of various sizes within the memory region. address 59 // is a pointer to read, and it must lie within the memory region as 60 // defined by its base address and size. The location pointed to by 61 // value is set to the value at address. Byte-swapping is performed 62 // if necessary so that the value is appropriate for the running 63 // program. Returns true on success. Fails and returns false if address 64 // is out of the region's bounds (after considering the width of value), 65 // or for other types of errors. 66 virtual bool GetMemoryAtAddress(uint64_t address, uint8_t* value) const = 0; 67 virtual bool GetMemoryAtAddress(uint64_t address, uint16_t* value) const = 0; 68 virtual bool GetMemoryAtAddress(uint64_t address, uint32_t* value) const = 0; 69 virtual bool GetMemoryAtAddress(uint64_t address, uint64_t* value) const = 0; 70 71 // Print a human-readable representation of the object to stdout. 72 virtual void Print() const = 0; 73 }; 74 75 76 } // namespace google_breakpad 77 78 79 #endif // GOOGLE_BREAKPAD_PROCESSOR_MEMORY_REGION_H__ 80