Mathieu Chartier | 7b074bf | 2017-09-25 16:22:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Mathieu Chartier | 292567e | 2017-10-12 13:24:38 -0700 | [diff] [blame^] | 17 | #ifndef ART_RUNTIME_STANDARD_DEX_FILE_H_ |
| 18 | #define ART_RUNTIME_STANDARD_DEX_FILE_H_ |
Mathieu Chartier | 7b074bf | 2017-09-25 16:22:36 -0700 | [diff] [blame] | 19 | |
| 20 | #include <iosfwd> |
| 21 | |
| 22 | #include "dex_file.h" |
| 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | class OatDexFile; |
| 27 | |
Mathieu Chartier | 292567e | 2017-10-12 13:24:38 -0700 | [diff] [blame^] | 28 | // Standard dex file. This is the format that is packaged in APKs and produced by tools. |
| 29 | class StandardDexFile : public DexFile { |
Mathieu Chartier | 7b074bf | 2017-09-25 16:22:36 -0700 | [diff] [blame] | 30 | public: |
| 31 | static const uint8_t kDexMagic[kDexMagicSize]; |
| 32 | static constexpr size_t kNumDexVersions = 4; |
| 33 | static const uint8_t kDexMagicVersions[kNumDexVersions][kDexVersionLen]; |
| 34 | |
| 35 | // Returns true if the byte string points to the magic value. |
| 36 | static bool IsMagicValid(const uint8_t* magic); |
| 37 | virtual bool IsMagicValid() const OVERRIDE; |
| 38 | |
| 39 | // Returns true if the byte string after the magic is the correct value. |
| 40 | static bool IsVersionValid(const uint8_t* magic); |
| 41 | virtual bool IsVersionValid() const OVERRIDE; |
| 42 | |
| 43 | private: |
Mathieu Chartier | 292567e | 2017-10-12 13:24:38 -0700 | [diff] [blame^] | 44 | StandardDexFile(const uint8_t* base, |
| 45 | size_t size, |
| 46 | const std::string& location, |
| 47 | uint32_t location_checksum, |
| 48 | const OatDexFile* oat_dex_file) |
Mathieu Chartier | 7b074bf | 2017-09-25 16:22:36 -0700 | [diff] [blame] | 49 | : DexFile(base, size, location, location_checksum, oat_dex_file) {} |
| 50 | |
Mathieu Chartier | 79c87da | 2017-10-10 11:54:29 -0700 | [diff] [blame] | 51 | friend class DexFileLoader; |
Mathieu Chartier | 7b074bf | 2017-09-25 16:22:36 -0700 | [diff] [blame] | 52 | friend class DexFileVerifierTest; |
| 53 | |
| 54 | ART_FRIEND_TEST(ClassLinkerTest, RegisterDexFileName); // for constructor |
| 55 | |
Mathieu Chartier | 292567e | 2017-10-12 13:24:38 -0700 | [diff] [blame^] | 56 | DISALLOW_COPY_AND_ASSIGN(StandardDexFile); |
Mathieu Chartier | 7b074bf | 2017-09-25 16:22:36 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | } // namespace art |
| 60 | |
Mathieu Chartier | 292567e | 2017-10-12 13:24:38 -0700 | [diff] [blame^] | 61 | #endif // ART_RUNTIME_STANDARD_DEX_FILE_H_ |