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