Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: courgette/disassembler_win32_x64.cc

Issue 2055343002: Courgette: Add static method QuickDetect() to optimize program detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « courgette/disassembler_win32_x64.h ('k') | courgette/disassembler_win32_x64_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_x64.h" 5 #include "courgette/disassembler_win32_x64.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
11 #include "courgette/assembly_program.h" 11 #include "courgette/assembly_program.h"
12 #include "courgette/courgette.h" 12 #include "courgette/courgette.h"
13 #include "courgette/rel32_finder_x64.h" 13 #include "courgette/rel32_finder_x64.h"
14 14
15 #if COURGETTE_HISTOGRAM_TARGETS 15 #if COURGETTE_HISTOGRAM_TARGETS
16 #include <iostream> 16 #include <iostream>
17 #endif 17 #endif
18 18
19 namespace courgette { 19 namespace courgette {
20 20
21 DisassemblerWin32X64::DisassemblerWin32X64(const void* start, size_t length) 21 DisassemblerWin32X64::DisassemblerWin32X64(const uint8_t* start, size_t length)
22 : DisassemblerWin32(start, length) {} 22 : DisassemblerWin32(start, length) {}
23 23
24 RVA DisassemblerWin32X64::PointerToTargetRVA(const uint8_t* p) const { 24 RVA DisassemblerWin32X64::PointerToTargetRVA(const uint8_t* p) const {
25 return Address64ToRVA(Read64LittleEndian(p)); 25 return Address64ToRVA(Read64LittleEndian(p));
26 } 26 }
27 27
28 RVA DisassemblerWin32X64::Address64ToRVA(uint64_t address) const { 28 RVA DisassemblerWin32X64::Address64ToRVA(uint64_t address) const {
29 if (address < image_base() || address >= image_base() + size_of_image_) 29 if (address < image_base() || address >= image_base() + size_of_image_)
30 return kNoRVA; 30 return kNoRVA;
31 return base::checked_cast<RVA>(address - image_base()); 31 return base::checked_cast<RVA>(address - image_base());
(...skipping 26 matching lines...) Expand all
58 finder.Find(start_pointer, end_pointer, start_rva, end_rva, abs32_locations_); 58 finder.Find(start_pointer, end_pointer, start_rva, end_rva, abs32_locations_);
59 finder.SwapRel32Locations(&rel32_locations_); 59 finder.SwapRel32Locations(&rel32_locations_);
60 60
61 #if COURGETTE_HISTOGRAM_TARGETS 61 #if COURGETTE_HISTOGRAM_TARGETS
62 DCHECK(rel32_target_rvas_.empty()); 62 DCHECK(rel32_target_rvas_.empty());
63 finder.SwapRel32TargetRVAs(&rel32_target_rvas_); 63 finder.SwapRel32TargetRVAs(&rel32_target_rvas_);
64 #endif 64 #endif
65 } 65 }
66 66
67 } // namespace courgette 67 } // namespace courgette
OLDNEW
« no previous file with comments | « courgette/disassembler_win32_x64.h ('k') | courgette/disassembler_win32_x64_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698