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

Unified Diff: courgette/disassembler_win32_x86.cc

Issue 8344037: Start refactoring to reduce executable type knowledge. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix comment. Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « courgette/disassembler_win32_x86.h ('k') | courgette/encode_decode_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/disassembler_win32_x86.cc
diff --git a/courgette/disassembler.cc b/courgette/disassembler_win32_x86.cc
similarity index 84%
copy from courgette/disassembler.cc
copy to courgette/disassembler_win32_x86.cc
index e3dd71af2d6a53ded9c2c92b1862b9716cf74516..fb12c226cc0c1da0554b589014f0f6ee0ba3e718 100644
--- a/courgette/disassembler.cc
+++ b/courgette/disassembler_win32_x86.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "courgette/disassembler.h"
+#include "courgette/disassembler_win32_x86.h"
#include <algorithm>
#include <string>
@@ -22,46 +22,10 @@
namespace courgette {
-class DisassemblerWin32X86 : public Disassembler {
- public:
- explicit DisassemblerWin32X86(PEInfo* pe_info)
- : pe_info_(pe_info),
- incomplete_disassembly_(false) {
- }
-
- virtual bool Disassemble(AssemblyProgram* target);
-
- virtual void Destroy() { delete this; }
-
- protected:
- PEInfo& pe_info() { return *pe_info_; }
-
- CheckBool ParseFile(AssemblyProgram* target) WARN_UNUSED_RESULT;
- bool ParseAbs32Relocs();
- void ParseRel32RelocsFromSections();
- void ParseRel32RelocsFromSection(const Section* section);
-
- CheckBool ParseNonSectionFileRegion(uint32 start_file_offset,
- uint32 end_file_offset, AssemblyProgram* program) WARN_UNUSED_RESULT;
- CheckBool ParseFileRegion(const Section* section,
- uint32 start_file_offset, uint32 end_file_offset,
- AssemblyProgram* program) WARN_UNUSED_RESULT;
-
-#if COURGETTE_HISTOGRAM_TARGETS
- void HistogramTargets(const char* kind, const std::map<RVA, int>& map);
-#endif
-
- PEInfo* pe_info_;
- bool incomplete_disassembly_; // 'true' if can leave out 'uninteresting' bits
-
- std::vector<RVA> abs32_locations_;
- std::vector<RVA> rel32_locations_;
-
-#if COURGETTE_HISTOGRAM_TARGETS
- std::map<RVA, int> abs32_target_rvas_;
- std::map<RVA, int> rel32_target_rvas_;
-#endif
-};
+DisassemblerWin32X86::DisassemblerWin32X86(PEInfo* pe_info)
+ : pe_info_(pe_info),
+ incomplete_disassembly_(false) {
+}
bool DisassemblerWin32X86::Disassemble(AssemblyProgram* target) {
if (!pe_info().ok())
@@ -410,42 +374,4 @@ void DisassemblerWin32X86::HistogramTargets(const char* kind,
}
#endif // COURGETTE_HISTOGRAM_TARGETS
-Disassembler* Disassembler::MakeDisassemberWin32X86(PEInfo* pe_info) {
- return new DisassemblerWin32X86(pe_info);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-Status ParseWin32X86PE(const void* buffer, size_t length,
- AssemblyProgram** output) {
- *output = NULL;
-
- PEInfo* pe_info = new PEInfo();
- pe_info->Init(buffer, length);
-
- if (!pe_info->ParseHeader()) {
- delete pe_info;
- return C_INPUT_NOT_RECOGNIZED;
- }
-
- Disassembler* disassembler = Disassembler::MakeDisassemberWin32X86(pe_info);
- AssemblyProgram* program = new AssemblyProgram();
-
- if (!disassembler->Disassemble(program)) {
- delete program;
- disassembler->Destroy();
- delete pe_info;
- return C_DISASSEMBLY_FAILED;
- }
-
- disassembler->Destroy();
- delete pe_info;
- *output = program;
- return C_OK;
-}
-
-void DeleteAssemblyProgram(AssemblyProgram* program) {
- delete program;
-}
-
} // namespace courgette
« no previous file with comments | « courgette/disassembler_win32_x86.h ('k') | courgette/encode_decode_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698