#
dalvikvm_src_files := \
- Main.c
+ Main.cpp
dalvikvm_c_includes := \
$(JNI_H_INCLUDE) \
jobjectArray result = NULL;
int i;
- stringClass = (*env)->FindClass(env, "java/lang/String");
- if ((*env)->ExceptionCheck(env)) {
+ stringClass = env->FindClass("java/lang/String");
+ if (env->ExceptionCheck()) {
fprintf(stderr, "Got exception while finding class String\n");
goto bail;
}
assert(stringClass != NULL);
- strArray = (*env)->NewObjectArray(env, argc, stringClass, NULL);
- if ((*env)->ExceptionCheck(env)) {
+ strArray = env->NewObjectArray(argc, stringClass, NULL);
+ if (env->ExceptionCheck()) {
fprintf(stderr, "Got exception while creating String array\n");
goto bail;
}
for (i = 0; i < argc; i++) {
jstring argStr;
- argStr = (*env)->NewStringUTF(env, argv[i]);
- if ((*env)->ExceptionCheck(env)) {
+ argStr = env->NewStringUTF(argv[i]);
+ if (env->ExceptionCheck()) {
fprintf(stderr, "Got exception while allocating Strings\n");
goto bail;
}
assert(argStr != NULL);
- (*env)->SetObjectArrayElement(env, strArray, i, argStr);
- (*env)->DeleteLocalRef(env, argStr);
+ env->SetObjectArrayElement(strArray, i, argStr);
+ env->DeleteLocalRef(argStr);
}
/* return the array, and ensure we don't delete the local ref to it */
strArray = NULL;
bail:
- (*env)->DeleteLocalRef(env, stringClass);
- (*env)->DeleteLocalRef(env, strArray);
+ env->DeleteLocalRef(stringClass);
+ env->DeleteLocalRef(strArray);
return result;
}
int modifiers;
int result = JNI_FALSE;
- refMethod = (*env)->ToReflectedMethod(env, clazz, methodId, JNI_FALSE);
+ refMethod = env->ToReflectedMethod(clazz, methodId, JNI_FALSE);
if (refMethod == NULL) {
fprintf(stderr, "Dalvik VM unable to get reflected method\n");
goto bail;
* We now have a Method instance. We need to call
* its getModifiers() method.
*/
- methodClass = (*env)->FindClass(env, "java/lang/reflect/Method");
+ methodClass = env->FindClass("java/lang/reflect/Method");
if (methodClass == NULL) {
fprintf(stderr, "Dalvik VM unable to find class Method\n");
goto bail;
}
- getModifiersId = (*env)->GetMethodID(env, methodClass,
+ getModifiersId = env->GetMethodID(methodClass,
"getModifiers", "()I");
if (getModifiersId == NULL) {
fprintf(stderr, "Dalvik VM unable to find reflect.Method.getModifiers\n");
goto bail;
}
- modifiers = (*env)->CallIntMethod(env, refMethod, getModifiersId);
+ modifiers = env->CallIntMethod(refMethod, getModifiersId);
if ((modifiers & PUBLIC) == 0) {
fprintf(stderr, "Dalvik VM: main() is not public\n");
goto bail;
result = JNI_TRUE;
bail:
- (*env)->DeleteLocalRef(env, refMethod);
- (*env)->DeleteLocalRef(env, methodClass);
+ env->DeleteLocalRef(refMethod);
+ env->DeleteLocalRef(methodClass);
return result;
}
if (*cp == '.')
*cp = '/';
- startClass = (*env)->FindClass(env, slashClass);
+ startClass = env->FindClass(slashClass);
if (startClass == NULL) {
fprintf(stderr, "Dalvik VM unable to locate class '%s'\n", slashClass);
goto bail;
}
- startMeth = (*env)->GetStaticMethodID(env, startClass,
+ startMeth = env->GetStaticMethodID(startClass,
"main", "([Ljava/lang/String;)V");
if (startMeth == NULL) {
fprintf(stderr, "Dalvik VM unable to find static main(String[]) in '%s'\n",
/*
* Invoke main().
*/
- (*env)->CallStaticVoidMethod(env, startClass, startMeth, strArray);
+ env->CallStaticVoidMethod(startClass, startMeth, strArray);
- if (!(*env)->ExceptionCheck(env))
+ if (!env->ExceptionCheck())
result = 0;
bail:
* This allows join() and isAlive() on the main thread to work
* correctly, and also provides uncaught exception handling.
*/
- if ((*vm)->DetachCurrentThread(vm) != JNI_OK) {
+ if (vm->DetachCurrentThread() != JNI_OK) {
fprintf(stderr, "Warning: unable to detach main thread\n");
result = 1;
}
- if ((*vm)->DestroyJavaVM(vm) != 0)
+ if (vm->DestroyJavaVM() != 0)
fprintf(stderr, "Warning: Dalvik VM did not shut down cleanly\n");
/*printf("\nDalvik VM has exited\n");*/
}
LOCAL_PATH:= $(call my-dir)
dexdump_src_files := \
- DexDump.c
+ DexDump.cpp
dexdump_c_includes := \
dalvik \
static const char* gProgName = "dexdump";
-typedef enum OutputFormat {
+enum OutputFormat {
OUTPUT_PLAIN = 0, /* default */
OUTPUT_XML, /* fancy */
-} OutputFormat;
+};
/* command-line options */
-struct {
+struct Options {
bool checksumOnly;
bool disassemble;
bool showFileHeaders;
const char* tempFileName;
bool exportsOnly;
bool verbose;
-} gOptions;
+};
+
+struct Options gOptions;
/* basic info about a field or method */
-typedef struct FieldMethodInfo {
+struct FieldMethodInfo {
const char* classDescriptor;
const char* name;
const char* signature;
-} FieldMethodInfo;
+};
/*
* Get 2 little-endian bytes.
}
}
- newStr = malloc(targetLen + arrayDepth * 2 +1);
+ newStr = (char*)malloc(targetLen + arrayDepth * 2 +1);
/* copy class name over */
int i;
* size, so we add explicit space for it here.
*/
outSize++;
- buf = malloc(outSize);
+ buf = (char*)malloc(outSize);
if (buf == NULL) {
return NULL;
}
*/
void dumpRegisterMaps(DexFile* pDexFile)
{
- const u1* pClassPool = pDexFile->pRegisterMapPool;
+ const u1* pClassPool = (const u1*)pDexFile->pRegisterMapPool;
const u4* classOffsets;
const u1* ptr;
u4 numClasses;
if (gOptions.verbose)
printf("Processing '%s'...\n", fileName);
- if (dexOpenAndMap(fileName, gOptions.tempFileName, &map, false) != 0)
- goto bail;
+ if (dexOpenAndMap(fileName, gOptions.tempFileName, &map, false) != 0) {
+ return result;
+ }
mapped = true;
int flags = kDexParseVerifyChecksum;
if (gOptions.ignoreBadChecksum)
flags |= kDexParseContinueOnError;
- pDexFile = dexFileParse(map.addr, map.length, flags);
+ pDexFile = dexFileParse((u1*)map.addr, map.length, flags);
if (pDexFile == NULL) {
fprintf(stderr, "ERROR: DEX parse failed\n");
goto bail;
LOCAL_PATH:= $(call my-dir)
dexdump_src_files := \
- DexList.c
+ DexList.cpp
dexdump_c_includes := \
dalvik \
str++; /* Skip the 'L'. */
}
- newStr = malloc(at + 1); /* Add one for the '\0'. */
+ newStr = (char*)malloc(at + 1); /* Add one for the '\0'. */
newStr[at] = '\0';
while (at > 0) {
}
mapped = true;
- pDexFile = dexFileParse(map.addr, map.length, kDexParseDefault);
+ pDexFile = dexFileParse((u1*)map.addr, map.length, kDexParseDefault);
if (pDexFile == NULL) {
fprintf(stderr, "Warning: DEX parse failed for '%s'\n", fileName);
goto bail;
LOCAL_PATH:= $(call my-dir)
local_src_files := \
- OptMain.c
+ OptMain.cpp
local_c_includes := \
dalvik \
off_t dexOffset;
int err;
int result = -1;
+ int dexoptFlags = 0; /* bit flags, from enum DexoptFlags */
+ DexClassVerifyMode verifyMode = VERIFY_MODE_ALL;
+ DexOptimizerMode dexOptMode = OPTIMIZE_MODE_VERIFIED;
memset(&zippy, 0, sizeof(zippy));
}
/* Parse the options. */
-
- DexClassVerifyMode verifyMode = VERIFY_MODE_ALL;
- DexOptimizerMode dexOptMode = OPTIMIZE_MODE_VERIFIED;
- int dexoptFlags = 0; /* bit flags, from enum DexoptFlags */
-
if (dexoptFlagStr[0] != '\0') {
const char* opc;
const char* val;
static int processZipFile(int zipFd, int cacheFd, const char* zipName,
const char *dexoptFlags)
{
- int result = -1;
char* bcpCopy = NULL;
/*
const char* bcp = getenv("BOOTCLASSPATH");
if (bcp == NULL) {
LOGE("DexOptZ: BOOTCLASSPATH not set\n");
- goto bail;
+ return -1;
}
bool isBootstrap = false;
isBootstrap = true;
}
- result = extractAndProcessZip(zipFd, cacheFd, zipName, isBootstrap,
+ int result = extractAndProcessZip(zipFd, cacheFd, zipName, isBootstrap,
bcp, dexoptFlags);
-bail:
free(bcpCopy);
return result;
}
*/
fprintf(stderr, "Wrong number of args for --preopt (found %d)\n",
argc);
- goto bail;
+ return -1;
}
const char* zipName = argv[2];
strstr(dexoptFlags, "u=n") == NULL)
{
fprintf(stderr, "Either 'u=y' or 'u=n' must be specified\n");
- goto bail;
+ return -1;
}
zipFd = open(zipName, O_RDONLY);
if (zipFd < 0) {
perror(argv[0]);
- goto bail;
+ return -1;
}
outFd = open(outName, O_RDWR | O_EXCL | O_CREAT, 0666);
const char* debugFileName;
u4 crc, modWhen;
char* endp;
+ bool onlyOptVerifiedDex = false;
+ DexClassVerifyMode verifyMode;
+ DexOptimizerMode dexOptMode;
if (argc < 10) {
/* don't have all mandatory args */
LOGV(" bootclasspath is '%s'\n", bootClassPath);
/* start the VM partway */
- bool onlyOptVerifiedDex = false;
- DexClassVerifyMode verifyMode;
- DexOptimizerMode dexOptMode;
/* ugh -- upgrade these to a bit field if they get any more complex */
if ((flags & DEXOPT_VERIFY_ENABLED) != 0) {
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
- dvz.c
+ dvz.cpp
LOCAL_SHARED_LIBRARIES := \
libcutils
#ifndef _LIBDEX_CMDUTILS
#define _LIBDEX_CMDUTILS
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* encode the result of unzipping to a file */
-typedef enum UnzipToFileResult {
+enum UnzipToFileResult {
kUTFRSuccess = 0,
kUTFRGenericFailure,
kUTFRBadArgs,
kUTFRNoClassesDex,
kUTFROutputFileProblem,
kUTFRBadZip,
-} UnzipToFileResult;
+};
/*
* Map the specified DEX file read-only (possibly after expanding it into a
UnzipToFileResult dexUnzipToFile(const char* zipFileName,
const char* outFileName, bool quiet);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_LIBDEX_CMDUTILS*/
#include "DexFile.h"
#include "Leb128.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Catch handler entry, used while iterating over catch_handler_items.
*/
-typedef struct DexCatchHandler {
+struct DexCatchHandler {
u4 typeIdx; /* type index of the caught exception type */
u4 address; /* handler address */
-} DexCatchHandler;
+};
/* Get the first handler offset for the given DexCode.
* It's not 0 because the handlers list is prefixed with its size
* Iterator over catch handler data. This structure should be treated as
* opaque.
*/
-typedef struct DexCatchIterator {
+struct DexCatchIterator {
const u1* pEncodedData;
bool catchesAll;
u4 countRemaining;
DexCatchHandler handler;
-} DexCatchIterator;
+};
/* Initialize a DexCatchIterator to emptiness. This mostly exists to
* squelch innocuous warnings. */
}
}
-#ifdef __cplusplus
-}
-#endif
-
#endif
#include "DexFile.h"
#include "Leb128.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* expanded form of a class_data_item header */
-typedef struct DexClassDataHeader {
+struct DexClassDataHeader {
u4 staticFieldsSize;
u4 instanceFieldsSize;
u4 directMethodsSize;
u4 virtualMethodsSize;
-} DexClassDataHeader;
+};
/* expanded form of encoded_field */
-typedef struct DexField {
+struct DexField {
u4 fieldIdx; /* index to a field_id_item */
u4 accessFlags;
-} DexField;
+};
/* expanded form of encoded_method */
-typedef struct DexMethod {
+struct DexMethod {
u4 methodIdx; /* index to a method_id_item */
u4 accessFlags;
u4 codeOff; /* file offset to a code_item */
-} DexMethod;
+};
/* expanded form of class_data_item. Note: If a particular item is
* absent (e.g., no static fields), then the corresponding pointer
* is set to NULL. */
-typedef struct DexClassData {
+struct DexClassData {
DexClassDataHeader header;
DexField* staticFields;
DexField* instanceFields;
DexMethod* directMethods;
DexMethod* virtualMethods;
-} DexClassData;
+};
/* Read and verify the header of a class_data_item. This updates the
* given data pointer to point past the end of the read data and
*lastIndex = index;
}
-#ifdef __cplusplus
-}
-#endif
-
#endif
#include "DexFile.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct DexDataMap {
+struct DexDataMap {
u4 count; /* number of items currently in the map */
u4 max; /* maximum number of items that may be held */
u4* offsets; /* array of item offsets */
u2* types; /* corresponding array of item types */
-} DexDataMap;
+};
/*
* Allocate and initialize a DexDataMap. Returns NULL on failure.
return dexDataMapVerify(map, offset, type);
}
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_LIBDEX_DEXDATAMAP*/
}
}
-typedef struct LocalInfo {
+struct LocalInfo {
const char *name;
const char *descriptor;
const char *signature;
u2 startAddress;
bool live;
-} LocalInfo;
+};
static void emitLocalCbIfLive(void *cnxt, int reg, u4 endAddress,
LocalInfo *localInReg, DexDebugNewLocalCb localCb)
#include "DexFile.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Callback for "new position table entry".
* Returning non-0 causes the decoder to stop early.
DexDebugNewPositionCb posCb, DexDebugNewLocalCb localCb,
void* cnxt);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* def _LIBDEX_DEXDEBUGINFO */
#include "vm/Common.h" // basic type defs, e.g. u1/u2/u4/u8, and LOG
#include "libdex/SysUtil.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* gcc-style inline management -- ensures we have a copy of all functions
* in the library, so code that links against us will work whether or not
/*
* Enumeration of all the primitive types.
*/
-typedef enum PrimitiveType {
+enum PrimitiveType {
PRIM_NOT = 0, /* value is a reference type, not a primitive type */
PRIM_VOID = 1,
PRIM_BOOLEAN = 2,
PRIM_LONG = 7,
PRIM_FLOAT = 8,
PRIM_DOUBLE = 9,
-} PrimitiveType;
+};
/*
* access flags and masks; the "standard" ones are all <= 0x4000
/*
* Direct-mapped "header_item" struct.
*/
-typedef struct DexHeader {
+struct DexHeader {
u1 magic[8]; /* includes version number */
u4 checksum; /* adler32 checksum */
u1 signature[kSHA1DigestLen]; /* SHA-1 hash */
u4 classDefsOff;
u4 dataSize;
u4 dataOff;
-} DexHeader;
+};
/*
* Direct-mapped "map_item".
*/
-typedef struct DexMapItem {
- u2 type; /* type code (see kDexType* above) */
- u2 unused;
- u4 size; /* count of items of the indicated type */
- u4 offset; /* file offset to the start of data */
-} DexMapItem;
+struct DexMapItem {
+ u2 type; /* type code (see kDexType* above) */
+ u2 unused;
+ u4 size; /* count of items of the indicated type */
+ u4 offset; /* file offset to the start of data */
+};
/*
* Direct-mapped "map_list".
*/
-typedef struct DexMapList {
+struct DexMapList {
u4 size; /* #of entries in list */
DexMapItem list[1]; /* entries */
-} DexMapList;
+};
/*
* Direct-mapped "string_id_item".
*/
-typedef struct DexStringId {
- u4 stringDataOff; /* file offset to string_data_item */
-} DexStringId;
+struct DexStringId {
+ u4 stringDataOff; /* file offset to string_data_item */
+};
/*
* Direct-mapped "type_id_item".
*/
-typedef struct DexTypeId {
+struct DexTypeId {
u4 descriptorIdx; /* index into stringIds list for type descriptor */
-} DexTypeId;
+};
/*
* Direct-mapped "field_id_item".
*/
-typedef struct DexFieldId {
+struct DexFieldId {
u2 classIdx; /* index into typeIds list for defining class */
u2 typeIdx; /* index into typeIds for field type */
u4 nameIdx; /* index into stringIds for field name */
-} DexFieldId;
+};
/*
* Direct-mapped "method_id_item".
*/
-typedef struct DexMethodId {
+struct DexMethodId {
u2 classIdx; /* index into typeIds list for defining class */
u2 protoIdx; /* index into protoIds for method prototype */
u4 nameIdx; /* index into stringIds for method name */
-} DexMethodId;
+};
/*
* Direct-mapped "proto_id_item".
*/
-typedef struct DexProtoId {
+struct DexProtoId {
u4 shortyIdx; /* index into stringIds for shorty descriptor */
u4 returnTypeIdx; /* index into typeIds list for return type */
u4 parametersOff; /* file offset to type_list for parameter types */
-} DexProtoId;
+};
/*
* Direct-mapped "class_def_item".
*/
-typedef struct DexClassDef {
+struct DexClassDef {
u4 classIdx; /* index into typeIds for this class */
u4 accessFlags;
u4 superclassIdx; /* index into typeIds for superclass */
u4 annotationsOff; /* file offset to annotations_directory_item */
u4 classDataOff; /* file offset to class_data_item */
u4 staticValuesOff; /* file offset to DexEncodedArray */
-} DexClassDef;
+};
/*
* Direct-mapped "type_item".
*/
-typedef struct DexTypeItem {
+struct DexTypeItem {
u2 typeIdx; /* index into typeIds */
-} DexTypeItem;
+};
/*
* Direct-mapped "type_list".
*/
-typedef struct DexTypeList {
+struct DexTypeList {
u4 size; /* #of entries in list */
DexTypeItem list[1]; /* entries */
-} DexTypeList;
+};
/*
* Direct-mapped "code_item".
* "debugInfo" is used when displaying an exception stack trace or
* debugging. An offset of zero indicates that there are no entries.
*/
-typedef struct DexCode {
+struct DexCode {
u2 registersSize;
u2 insSize;
u2 outsSize;
/* followed by try_item[triesSize] */
/* followed by uleb128 handlersSize */
/* followed by catch_handler_item[handlersSize] */
-} DexCode;
+};
/*
* Direct-mapped "try_item".
*/
-typedef struct DexTry {
+struct DexTry {
u4 startAddr; /* start address, in 16-bit code units */
u2 insnCount; /* instruction count, in 16-bit code units */
u2 handlerOff; /* offset in encoded handler data to handlers */
-} DexTry;
+};
/*
* Link table. Currently undefined.
*/
-typedef struct DexLink {
+struct DexLink {
u1 bleargh;
-} DexLink;
+};
/*
* Direct-mapped "annotations_directory_item".
*/
-typedef struct DexAnnotationsDirectoryItem {
+struct DexAnnotationsDirectoryItem {
u4 classAnnotationsOff; /* offset to DexAnnotationSetItem */
u4 fieldsSize; /* count of DexFieldAnnotationsItem */
u4 methodsSize; /* count of DexMethodAnnotationsItem */
/* followed by DexFieldAnnotationsItem[fieldsSize] */
/* followed by DexMethodAnnotationsItem[methodsSize] */
/* followed by DexParameterAnnotationsItem[parametersSize] */
-} DexAnnotationsDirectoryItem;
+};
/*
* Direct-mapped "field_annotations_item".
*/
-typedef struct DexFieldAnnotationsItem {
+struct DexFieldAnnotationsItem {
u4 fieldIdx;
u4 annotationsOff; /* offset to DexAnnotationSetItem */
-} DexFieldAnnotationsItem;
+};
/*
* Direct-mapped "method_annotations_item".
*/
-typedef struct DexMethodAnnotationsItem {
+struct DexMethodAnnotationsItem {
u4 methodIdx;
u4 annotationsOff; /* offset to DexAnnotationSetItem */
-} DexMethodAnnotationsItem;
+};
/*
* Direct-mapped "parameter_annotations_item".
*/
-typedef struct DexParameterAnnotationsItem {
+struct DexParameterAnnotationsItem {
u4 methodIdx;
u4 annotationsOff; /* offset to DexAnotationSetRefList */
-} DexParameterAnnotationsItem;
+};
/*
* Direct-mapped "annotation_set_ref_item".
*/
-typedef struct DexAnnotationSetRefItem {
+struct DexAnnotationSetRefItem {
u4 annotationsOff; /* offset to DexAnnotationSetItem */
-} DexAnnotationSetRefItem;
+};
/*
* Direct-mapped "annotation_set_ref_list".
*/
-typedef struct DexAnnotationSetRefList {
+struct DexAnnotationSetRefList {
u4 size;
DexAnnotationSetRefItem list[1];
-} DexAnnotationSetRefList;
+};
/*
* Direct-mapped "annotation_set_item".
*/
-typedef struct DexAnnotationSetItem {
+struct DexAnnotationSetItem {
u4 size;
u4 entries[1]; /* offset to DexAnnotationItem */
-} DexAnnotationSetItem;
+};
/*
* Direct-mapped "annotation_item".
*
* NOTE: this structure is byte-aligned.
*/
-typedef struct DexAnnotationItem {
+struct DexAnnotationItem {
u1 visibility;
u1 annotation[1]; /* data in encoded_annotation format */
-} DexAnnotationItem;
+};
/*
* Direct-mapped "encoded_array".
*
* NOTE: this structure is byte-aligned.
*/
-typedef struct DexEncodedArray {
+struct DexEncodedArray {
u1 array[1]; /* data in encoded_array format */
-} DexEncodedArray;
+};
/*
* Lookup table for classes. It provides a mapping from class name to
* a hash table with direct pointers to the items, but because it's shared
* there's less of a penalty for using a fairly sparse table.
*/
-typedef struct DexClassLookup {
+struct DexClassLookup {
int size; // total size, including "size"
int numEntries; // size of table[]; always power of 2
struct {
int classDescriptorOffset; // in bytes, from start of DEX
int classDefOffset; // in bytes, from start of DEX
} table[1];
-} DexClassLookup;
+};
/*
* Header added by DEX optimization pass. Values are always written in
*
* Try to keep this simple and fixed-size.
*/
-typedef struct DexOptHeader {
+struct DexOptHeader {
u1 magic[8]; /* includes version number */
u4 dexOffset; /* file offset of DEX header */
u4 checksum; /* adler32 checksum covering deps/opt */
/* pad for 64-bit alignment if necessary */
-} DexOptHeader;
+};
#define DEX_OPT_FLAG_BIG (1<<1) /* swapped to big-endian */
* Code should regard DexFile as opaque, using the API calls provided here
* to access specific structures.
*/
-typedef struct DexFile {
+struct DexFile {
/* directly-mapped "opt" header */
const DexOptHeader* pOptHeader;
/* additional app-specific data structures associated with the DEX */
//void* auxData;
-} DexFile;
+};
/*
* Utility function -- rounds up to the nearest power of 2.
*/
PrimitiveType dexGetPrimitiveTypeFromDescriptorChar(char descriptorChar);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_LIBDEX_DEXFILE*/
#include "DexFile.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* kMaxOpcodeValue: the highest possible raw (unpacked) opcode value
*
* can find the next instruction" aren't possible. (This is
* correctable, but probably not useful.)
*/
-typedef enum Opcode {
+enum Opcode {
// BEGIN(libdex-opcode-enum); GENERATED AUTOMATICALLY BY opcode-gen
OP_NOP = 0x00,
OP_MOVE = 0x01,
OP_SPUT_OBJECT_VOLATILE_JUMBO = 0x1fe,
OP_THROW_VERIFICATION_ERROR_JUMBO = 0x1ff,
// END(libdex-opcode-enum)
-} Opcode;
+};
/*
* Macro used to generate a computed goto table for use in implementing
*/
const char* dexGetOpcodeName(Opcode op);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_LIBDEX_DEXOPCODES*/
#include "libdex/DexFile.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Parse the optimized data tables in the given dex file.
*
*/
u4 dexComputeOptChecksum(const DexOptHeader* pOptHeader);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* def _LIBDEX_DEXOPTDATA */
#include "DexFile.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Single-thread single-string cache. This structure holds a pointer to
* a string which is semi-automatically manipulated by some of the
* generally return a string that is valid until the next
* time the same DexStringCache is used.
*/
-typedef struct DexStringCache {
+struct DexStringCache {
char* value; /* the latest value */
size_t allocatedSize; /* size of the allocated buffer, if allocated */
char buffer[120]; /* buffer used to hold small-enough results */
-} DexStringCache;
+};
/*
* Make sure that the given cache can hold a string of the given length,
* Method prototype structure, which refers to a protoIdx in a
* particular DexFile.
*/
-typedef struct DexProto {
+struct DexProto {
const DexFile* dexFile; /* file the idx refers to */
u4 protoIdx; /* index into proto_ids table of dexFile */
-} DexProto;
+};
/*
* Set the given DexProto to refer to the prototype of the given MethodId.
* Single-thread prototype parameter iterator. This structure holds a
* pointer to a prototype and its parts, along with a cursor.
*/
-typedef struct DexParameterIterator {
+struct DexParameterIterator {
const DexProto* proto;
const DexTypeList* parameters;
int parameterCount;
int cursor;
-} DexParameterIterator;
+};
/*
* Initialize the given DexParameterIterator to be at the start of the
const char* dexParameterIteratorNextDescriptor(
DexParameterIterator* pIterator);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_LIBDEX_DEXPROTO*/
/*
* Some information we pass around to help verify values.
*/
-typedef struct CheckState {
+struct CheckState {
const DexHeader* pHeader;
const u1* fileStart;
const u1* fileEnd; // points to fileStart + fileLen
u4* pDefinedClassBits;
const void* previousItem; // set during section iteration
-} CheckState;
+};
/*
* Return the file offset of the given pointer.
#include "DexFile.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Retrieve the next UTF-16 character from a UTF-8 string.
*
* is for anything but "void". */
bool dexIsFieldDescriptor(const char* s);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* def _LIBDEX_DEXUTF */
#include "DexFile.h"
#include "DexOpcodes.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Possible instruction formats associated with Dalvik opcodes.
*
* See the file opcode-gen/README.txt for information about updating
* opcodes and instruction formats.
*/
-typedef enum {
+enum InstructionFormat {
kFmt00x = 0, // unknown format (also used for "breakpoint" opcode)
kFmt10x, // op
kFmt12x, // op vA, vB
kFmt41c, // exop vAAAA, thing@BBBBBBBB
kFmt52c, // exop vAAAA, vBBBB, thing@CCCCCCCC
kFmt5rc, // exop {vCCCC .. v(CCCC+AAAA-1)}, thing@BBBBBBBB
-} InstructionFormat;
+};
/*
* Types of indexed reference that are associated with opcodes whose
* formats include such an indexed reference (e.g., 21c and 35c).
*/
-typedef enum {
+enum InstructionIndexType {
kIndexUnknown = 0,
kIndexNone, // has no index
kIndexVaries, // "It depends." Used for throw-verification-error
kIndexInlineMethod, // inline method index (for inline linked methods)
kIndexVtableOffset, // vtable offset (for static linked methods)
kIndexFieldOffset // field offset (for static linked fields)
-} InstructionIndexType;
+};
/*
* Instruction width implied by an opcode's format; a value in the
* that works for both C and C++, but in the mean time, this will
* suffice.
*/
-typedef struct InstructionInfoTables {
+struct InstructionInfoTables {
u1* formats; /* InstructionFormat elements */
u1* indexTypes; /* InstructionIndexType elements */
OpcodeFlags* flags;
InstructionWidth* widths;
-} InstructionInfoTables;
+};
/*
* Global InstructionInfoTables struct.
/*
* Holds the contents of a decoded instruction.
*/
-typedef struct DecodedInstruction {
+struct DecodedInstruction {
u4 vA;
u4 vB;
u8 vB_wide; /* for kFmt51l */
u4 arg[5]; /* vC/D/E/F/G in invoke or filled-new-array */
Opcode opcode;
InstructionIndexType indexType;
-} DecodedInstruction;
+};
/*
* Return the instruction width of the specified opcode, or 0 if not defined.
*/
void dexDecodeInstruction(const u2* insns, DecodedInstruction* pDec);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_LIBDEX_INSTRUTILS*/
#include "DexFile.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Reads an unsigned LEB128 value, updating the given pointer to point
* just past the end of the read value. This function tolerates
return count;
}
-#ifdef __cplusplus
-}
-#endif
-
#endif
#ifndef _LIBDEX_OPTINVOCATION
#define _LIBDEX_OPTINVOCATION
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Utility routines, used by the VM.
*/
const char* subFileName);
int dexOptCreateEmptyHeader(int fd);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_LIBDEX_OPTINVOCATION*/
#include <sys/types.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* System page size. Normally you're expected to get this from
* sysconf(_SC_PAGESIZE) or some system-specific define (usually PAGESIZE
/*
* Use this to keep track of mapped segments.
*/
-typedef struct MemMapping {
+struct MemMapping {
void* addr; /* start of data */
size_t length; /* length of data */
void* baseAddr; /* page-aligned base address */
size_t baseLength; /* length of mapping */
-} MemMapping;
+};
/*
* Copy a map.
*/
int sysCopyFileToFile(int outFd, int inFd, size_t count);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_SYSUTIL*/
#include "SysUtil.h"
#include "DexFile.h" // need DEX_INLINE
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Trivial typedef to ensure that ZipEntry is not treated as a simple
* integer. We use NULL to indicate an invalid value.
/*
* One entry in the hash table.
*/
-typedef struct ZipHashEntry {
+struct ZipHashEntry {
const char* name;
unsigned short nameLen;
- //unsigned int hash;
-} ZipHashEntry;
+};
/*
* Read-only Zip archive.
* every page that the Central Directory touches. Easier to tuck a copy
* of the string length into the hash table entry.
*/
-typedef struct ZipArchive {
+struct ZipArchive {
/* open Zip archive */
int mFd;
*/
int mHashTableSize;
ZipHashEntry* mHashTable;
-} ZipArchive;
+};
/* Zip compression methods we support */
enum {
u4 dexInitCrc32(void);
u4 dexComputeCrc32(u4 crc, const void* buf, size_t len);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_LIBDEX_ZIPARCHIVE*/
const unsigned char buffer[64])
{
unsigned long a, b, c, d, e;
-typedef union {
+union CHAR64LONG16 {
unsigned char c[64];
unsigned long l[16];
-} CHAR64LONG16;
+};
CHAR64LONG16* block;
#ifdef SHA1HANDSOFF
static unsigned char workspace[64];
#ifndef _DALVIK_SHA1
#define _DALVIK_SHA1
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
+struct SHA1_CTX {
unsigned long state[5];
unsigned long count[2];
unsigned char buffer[64];
-} SHA1_CTX;
+};
#define HASHSIZE 20
unsigned long len);
void SHA1Final(unsigned char digest[HASHSIZE], SHA1_CTX* context);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_SHA1*/