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

Side by Side Diff: courgette/disassembler_win32.h

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_elf_32_x86_unittest.cc ('k') | courgette/disassembler_win32.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef COURGETTE_DISASSEMBLER_WIN32_H_ 5 #ifndef COURGETTE_DISASSEMBLER_WIN32_H_
6 #define COURGETTE_DISASSEMBLER_WIN32_H_ 6 #define COURGETTE_DISASSEMBLER_WIN32_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Output is a vector of the RVAs corresponding to locations within executable 42 // Output is a vector of the RVAs corresponding to locations within executable
43 // that are listed in the base relocation table. 43 // that are listed in the base relocation table.
44 bool ParseRelocs(std::vector<RVA>* addresses); 44 bool ParseRelocs(std::vector<RVA>* addresses);
45 45
46 // Returns Section containing the relative virtual address, or null if none. 46 // Returns Section containing the relative virtual address, or null if none.
47 const Section* RVAToSection(RVA rva) const; 47 const Section* RVAToSection(RVA rva) const;
48 48
49 static std::string SectionName(const Section* section); 49 static std::string SectionName(const Section* section);
50 50
51 protected: 51 protected:
52 // Returns true if a valid executable is detected using only quick checks.
53 // Derived classes should inject |magic| corresponding to their architecture,
54 // which will be checked against the detected one.
55 static bool QuickDetect(const uint8_t* start, size_t length, uint16_t magic);
56
52 // Disassembler interfaces. 57 // Disassembler interfaces.
53 RvaVisitor* CreateAbs32TargetRvaVisitor() override; 58 RvaVisitor* CreateAbs32TargetRvaVisitor() override;
54 RvaVisitor* CreateRel32TargetRvaVisitor() override; 59 RvaVisitor* CreateRel32TargetRvaVisitor() override;
55 void RemoveUnusedRel32Locations(AssemblyProgram* program) override; 60 void RemoveUnusedRel32Locations(AssemblyProgram* program) override;
56 61
57 DisassemblerWin32(const void* start, size_t length); 62 DisassemblerWin32(const uint8_t* start, size_t length);
58 63
59 CheckBool ParseFile(AssemblyProgram* target) WARN_UNUSED_RESULT; 64 CheckBool ParseFile(AssemblyProgram* target) WARN_UNUSED_RESULT;
60 bool ParseAbs32Relocs(); 65 bool ParseAbs32Relocs();
61 void ParseRel32RelocsFromSections(); 66 void ParseRel32RelocsFromSections();
62 virtual void ParseRel32RelocsFromSection(const Section* section) = 0; 67 virtual void ParseRel32RelocsFromSection(const Section* section) = 0;
63 68
64 CheckBool ParseNonSectionFileRegion(FileOffset start_file_offset, 69 CheckBool ParseNonSectionFileRegion(FileOffset start_file_offset,
65 FileOffset end_file_offset, 70 FileOffset end_file_offset,
66 AssemblyProgram* program) 71 AssemblyProgram* program)
67 WARN_UNUSED_RESULT; 72 WARN_UNUSED_RESULT;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 std::map<RVA, int> rel32_target_rvas_; 144 std::map<RVA, int> rel32_target_rvas_;
140 #endif 145 #endif
141 146
142 private: 147 private:
143 DISALLOW_COPY_AND_ASSIGN(DisassemblerWin32); 148 DISALLOW_COPY_AND_ASSIGN(DisassemblerWin32);
144 }; 149 };
145 150
146 } // namespace courgette 151 } // namespace courgette
147 152
148 #endif // COURGETTE_DISASSEMBLER_WIN32_H_ 153 #endif // COURGETTE_DISASSEMBLER_WIN32_H_
OLDNEW
« no previous file with comments | « courgette/disassembler_elf_32_x86_unittest.cc ('k') | courgette/disassembler_win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698