Get a basic modification of dex file working

This allows the modification of a single classes methods through
transformation. One must ensure that the provided dex file only
contains one function and does not add or remove any methods or fields
and does not change the inheritance hierarchy in any way. The provided
dex file must verify and there must be no frames of the old code
present on any thread. These constraints are not checked or verified.
Breaking them might cause undefined behavior in all parts of the
runtime. Code that has been inlined in any way might not be replaced.
This feature is extremely experimental.

Bug: 31455788
Test: ./test/run-test --host 902-hello-transformation

Change-Id: I35133d24f6cdafdd2af9dc9863e15ba8493fc50e
diff --git a/runtime/dex_file.h b/runtime/dex_file.h
index 14bde09..28aeb1e 100644
--- a/runtime/dex_file.h
+++ b/runtime/dex_file.h
@@ -590,6 +590,9 @@
                              const DexFile::StringId& name,
                              const DexFile::TypeId& type) const;
 
+  uint32_t FindCodeItemOffset(const DexFile::ClassDef& class_def,
+                              uint32_t dex_method_idx) const;
+
   // Returns the declaring class descriptor string of a field id.
   const char* GetFieldDeclaringClassDescriptor(const FieldId& field_id) const {
     const DexFile::TypeId& type_id = GetTypeId(field_id.class_idx_);
@@ -1060,6 +1063,16 @@
                                              std::string* error_msg,
                                              VerifyResult* verify_result = nullptr);
 
+
+  // Opens a .dex file at the given address, optionally backed by a MemMap
+  static std::unique_ptr<const DexFile> OpenMemory(const uint8_t* dex_file,
+                                                   size_t size,
+                                                   const std::string& location,
+                                                   uint32_t location_checksum,
+                                                   std::unique_ptr<MemMap> mem_map,
+                                                   const OatDexFile* oat_dex_file,
+                                                   std::string* error_msg);
+
   DexFile(const uint8_t* base,
           size_t size,
           const std::string& location,