2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * Access .dex (Dalvik Executable Format) files. The code here assumes that
18 * the DEX file has been rewritten (byte-swapped, word-aligned) and that
19 * the contents can be directly accessed as a collection of C arrays. Please
20 * see docs/dalvik/dex-format.html for a detailed description.
22 * The structure and field names were chosen to match those in the DEX spec.
24 * It's generally assumed that the DEX file will be stored in shared memory,
25 * obviating the need to copy code and constant pool entries into newly
26 * allocated storage. Maintaining local pointers to items in the shared area
27 * is valid and encouraged.
29 * All memory-mapped structures are 32-bit aligned unless otherwise noted.
31 #ifndef _LIBDEX_CMDUTILS
32 #define _LIBDEX_CMDUTILS
34 /* encode the result of unzipping to a file */
35 typedef enum UnzipToFileResult {
41 kUTFROutputFileProblem,
46 * Map the specified DEX file, possibly after expanding it into a temp file
47 * from a Jar. Pass in a MemMapping struct to hold the info.
49 * This is intended for use by tools (e.g. dexdump) that need to get a
50 * read-only copy of a DEX file that could be in a number of different states.
52 * If "tempFileName" is NULL, a default value is used. The temp file is
53 * deleted after the map succeeds.
55 * Returns 0 on success.
57 UnzipToFileResult dexOpenAndMap(const char* fileName, const char* tempFileName,
58 MemMapping* pMap, bool quiet);
61 * Utility function to open a Zip archive, find "classes.dex", and extract
64 UnzipToFileResult dexUnzipToFile(const char* zipFileName,
65 const char* outFileName, bool quiet);
67 #endif /*_LIBDEX_CMDUTILS*/