xref: /aosp_15_r20/external/jazzer-api/src/main/native/com/code_intelligence/jazzer/android/dex_file_manager.h (revision 33edd6723662ea34453766bfdca85dbfdd5342b8)
1 /*
2  * Copyright 2023 Code Intelligence GmbH
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 
17 #include <vector>
18 
19 #include "jvmti.h"
20 #include "slicer/reader.h"
21 
22 // DexFileManager will contain the contents to multiple DEX files
23 class DexFileManager {
24  public:
DexFileManager()25   DexFileManager() {}
26 
27   void addDexFile(const unsigned char* bytes, int length);
28   unsigned char* getClassBytes(const char* className, int dexFileIndex,
29                                jvmtiEnv* jvmti, size_t* newSize);
30   uint32_t findDexFileForClass(const char* className);
31   bool structureMatches(dex::Reader* oldReader, dex::Reader* newReader,
32                         const char* className);
33 
34  private:
35   std::vector<unsigned char*> dexFiles;
36   std::vector<int> dexFilesSize;
37 };
38