OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "courgette/disassembler_win32_x86.h" | 5 #include "courgette/disassembler_win32_x86.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "courgette/assembly_program.h" | 10 #include "courgette/assembly_program.h" |
11 #include "courgette/courgette.h" | 11 #include "courgette/courgette.h" |
12 #include "courgette/rel32_finder_x86.h" | 12 #include "courgette/rel32_finder_x86.h" |
13 | 13 |
14 #if COURGETTE_HISTOGRAM_TARGETS | 14 #if COURGETTE_HISTOGRAM_TARGETS |
15 #include <iostream> | 15 #include <iostream> |
16 #endif | 16 #endif |
17 | 17 |
18 namespace courgette { | 18 namespace courgette { |
19 | 19 |
20 DisassemblerWin32X86::DisassemblerWin32X86(const void* start, size_t length) | 20 DisassemblerWin32X86::DisassemblerWin32X86(const uint8_t* start, size_t length) |
21 : DisassemblerWin32(start, length) {} | 21 : DisassemblerWin32(start, length) {} |
22 | 22 |
23 RVA DisassemblerWin32X86::PointerToTargetRVA(const uint8_t* p) const { | 23 RVA DisassemblerWin32X86::PointerToTargetRVA(const uint8_t* p) const { |
24 return Address32ToRVA(Read32LittleEndian(p)); | 24 return Address32ToRVA(Read32LittleEndian(p)); |
25 } | 25 } |
26 | 26 |
27 RVA DisassemblerWin32X86::Address32ToRVA(uint32_t address) const { | 27 RVA DisassemblerWin32X86::Address32ToRVA(uint32_t address) const { |
28 if (address < image_base() || address >= image_base() + size_of_image_) | 28 if (address < image_base() || address >= image_base() + size_of_image_) |
29 return kNoRVA; | 29 return kNoRVA; |
30 return static_cast<RVA>(address - image_base()); | 30 return static_cast<RVA>(address - image_base()); |
(...skipping 25 matching lines...) Expand all Loading... |
56 finder.Find(start_pointer, end_pointer, start_rva, end_rva, abs32_locations_); | 56 finder.Find(start_pointer, end_pointer, start_rva, end_rva, abs32_locations_); |
57 finder.SwapRel32Locations(&rel32_locations_); | 57 finder.SwapRel32Locations(&rel32_locations_); |
58 | 58 |
59 #if COURGETTE_HISTOGRAM_TARGETS | 59 #if COURGETTE_HISTOGRAM_TARGETS |
60 DCHECK(rel32_target_rvas_.empty()); | 60 DCHECK(rel32_target_rvas_.empty()); |
61 finder.SwapRel32TargetRVAs(&rel32_target_rvas_); | 61 finder.SwapRel32TargetRVAs(&rel32_target_rvas_); |
62 #endif | 62 #endif |
63 } | 63 } |
64 | 64 |
65 } // namespace courgette | 65 } // namespace courgette |
OLD | NEW |