summaryrefslogtreecommitdiffstats
path: root/courgette/disassembler_win32_x86.h
diff options
context:
space:
mode:
authordgarrett@chromium.org <dgarrett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-21 22:24:19 +0000
committerdgarrett@chromium.org <dgarrett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-21 22:24:19 +0000
commit93d529cafc6423e431a88612dff69d06d4f0759f (patch)
tree46e73fe8ddd2806e23a1309b92cd9ffca33c9ccb /courgette/disassembler_win32_x86.h
parentad2e64c7fae41d9b8053e040fd282b1cf0f8b610 (diff)
downloadchromium_src-93d529cafc6423e431a88612dff69d06d4f0759f.zip
chromium_src-93d529cafc6423e431a88612dff69d06d4f0759f.tar.gz
chromium_src-93d529cafc6423e431a88612dff69d06d4f0759f.tar.bz2
Start refactoring to reduce executable type knowledge.
This creates executable detection functions, a globally shared enum for describing an executable type, and reduces the number of classes and locations with executable specific knowledge. These changes, along with moving architecture specific classes into their own files should make it easier to produce special purpose clients that only contain the code required to apply their own form of patch. DisassemblerWin32EXE, ImagePE, CourgetteWin32X86PatchGenerator, and CourgetteWin32X86Patcher, and ensemble handling are all heavily affected here. This should have no effect on the behavior of the system yet, and is instead all prep-work. This is the same as an earlier CL, except that ParseHeader will now return an error for 64 bit PE executables, and resource only DLLs. This is because the detection factories depend on ParseHeader to decide if a given file is supported. BUG=None TEST=Unittests Review URL: http://codereview.chromium.org/7920004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103879 0039d316-1c4b-4281-b951-d872f2087c98 Review URL: http://codereview.chromium.org/8344037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106793 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'courgette/disassembler_win32_x86.h')
-rw-r--r--courgette/disassembler_win32_x86.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/courgette/disassembler_win32_x86.h b/courgette/disassembler_win32_x86.h
new file mode 100644
index 0000000..fe00b6d
--- /dev/null
+++ b/courgette/disassembler_win32_x86.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COURGETTE_DISASSEMBLER_WIN32_X86_H_
+#define COURGETTE_DISASSEMBLER_WIN32_X86_H_
+
+#include "base/basictypes.h"
+#include "courgette/disassembler.h"
+#include "courgette/image_info.h"
+#include "courgette/memory_allocator.h"
+
+namespace courgette {
+
+class AssemblyProgram;
+
+class DisassemblerWin32X86 : public Disassembler {
+ public:
+ explicit DisassemblerWin32X86(PEInfo* pe_info);
+
+ virtual bool Disassemble(AssemblyProgram* target);
+
+ 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
+
+ DISALLOW_COPY_AND_ASSIGN(DisassemblerWin32X86);
+};
+
+} // namespace courgette
+#endif // COURGETTE_DISASSEMBLER_WIN32_X86_H_