rizin/shlr/java/code.c
Adam Pridgen 31e47f1c47 Squashed commit of the following:
commit 109915c7812305b9a442d3a0febd9bc43f7104b5
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Wed Sep 4 09:50:08 2013 -0500

    - Added author rewrite tag

commit 5fe0d07f3a318f871bc5d6a8499afd9ceab26e33
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Wed Sep 4 09:37:57 2013 -0500

    - Added a print statement for the number of attributes in the Code Attribute
    - Added a default stack frame creation

commit 4b1bca0d79c53421c1d7a9c59da070a5463ba05b
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Wed Sep 4 08:58:55 2013 -0500

    - Added the R_API prefix to all function declarations and definitions
    - Removed the offset<=size from loops.  Not sure why this check is failing, but it needs to be added in the future (probably add it to the list of defects.)
    - Code appears to parse the classfile correctly

commit 5f5a28302da8c605800946df739c67a0f4f80b0d
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Tue Sep 3 23:11:00 2013 -0500

    - still minor bug in the parsing code on the Type Verification
     or somewhere in the StackMapAttr.  The right number of bytes are
     being read, but not all the bytes are being consumed

commit 1c9d8b490c8d7d8592f898e019aed3b56f9406c8
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Tue Sep 3 20:59:08 2013 -0500

    - fixed some compiler warnings in class.c

commit c185248aa478c6c78f6dbe14cf65ee3396287302
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Tue Sep 3 20:58:21 2013 -0500

    - Propogated the change to code.c from changes from classes.

commit 927542a0672f37b41b23345533bc7e6f2d1a5369
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Tue Sep 3 17:10:40 2013 -0500

    Fixed some minor parsing bugs:

    code_attr offet was not updated correctly after reading the length of the attribute
    attr_buf was not initialized correctly before use

commit b43a7189e9934369d1fdbd96de020edcab907430
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Tue Sep 3 16:33:36 2013 -0500

    - Code compiles.  Time to test.

commit ea7b332d84b88baca1abc466d02b00b2b8739bca
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Mon Sep 2 23:55:44 2013 -0500

    - Added in size calculations for the CP Objects.
    - Need to add method or field references calculations for size after compiling

commit ba55375dc0e835fb46550d0063758e419ec0ed7b
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Mon Sep 2 22:56:56 2013 -0500

    - Revamped all of the attribute parsing.  The parsers will handle buffers rather than simply
      parsing straight from the file.

    - added a size calculator for each of the attributes, which opens up the way for creating
      writers for the attributes and such.

commit be6f2e038f01beeb56ace7d4daaf4d90ad3fdad7
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Sat Aug 31 12:19:18 2013 -0500

    - Cleaned up code and removed some of the compiler warnings.

commit 4c81812f2609e4a80c7036053d122306039dd6ef
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Fri Aug 30 15:24:15 2013 -0500

    - Compiler and linker errors have been resolved.
    - Need to work on testing

commit 429ed30621d9abff1eec99ef50a35c57bbed76ad
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Fri Aug 30 13:35:39 2013 -0500

    Added the RunTime Annotations and Parameter annotations.
    Time to start compiling and testing.

commit b6044e1c74cc10874902bd34da7c8fcbdb5713cc
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Fri Aug 30 12:34:14 2013 -0500

    Added BootstrapMethodsAttr Parsing code along with supporting stuff, like creating
      the method and argument structures and mapping the REF_types to strings

    More should be done to map the REF_types to specific resolutions.

    Added in the MethodType, MethodHandle, and InvokeDynamic ConstantPool Objects

commit 2c9317be5d2be0608131fb9aa10f713885c89471
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Fri Aug 30 00:21:34 2013 -0500

    Finished drafting the code for annotation, element values, element value pairs,
       and annotation default attribute.

    TODO: RTI, RTV, and then Bootstrap attributes.

commit cbee3a10c18342f6a8fb941245568de885fe5666
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Thu Aug 29 15:42:00 2013 -0500

    Fixed the r_bin_java_element_value_new function definition.

commit ab98a76fabf2bd7764a51f3363d821c5a4cf1200
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Thu Aug 29 15:39:28 2013 -0500

    - worked out some of the initial compile errors.
    - worked out an outline for parsing the element_values
    - need to work through parsing the element value, freeing the element value, and then printing a summary.

commit b543d904f2aebd0d1f9c0ac8ec8401b6ab698f36
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Thu Aug 29 08:21:33 2013 -0500

    Most of the heavy lifting is done for attributes.  Need to implement a few of the methods,
    and then compiling should be able to happen.

    Added in all attribute values to the enums, the function call tables, and then the Metas information.

    Need implement an ElementValue parser bleh.

    Need to implement RuntimeAnnotations, Annotations, ElementValue parsing and make sure that
    the attribute unions are all updated.

commit 81f9ca2da2ed7e007a97a20ecb8eb260dfd55e7e
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Wed Aug 28 22:33:43 2013 -0500

    Finished adding some logic to handle the StackMapFrame types.

commit 9a0965cc06021ad56d2127d279b918eef613bec9
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Wed Aug 28 17:54:52 2013 -0500

    Got some of the StackMapTable Atrribute parsing working.  Right now,
    only the FullStackFrame will correctly parse.

commit ea12bd6a8ae9969fa05cbcab622651c8b426917a
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Fri Aug 23 17:51:33 2013 -0500

    Added some debugging code while trying to figure out how to parse the StackMapTable.

commit 6141b57ee94c7bd0569d0ea76725fdce1ac50edf
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Fri Aug 23 17:00:12 2013 -0500

    Code compiles.

commit a7ad14050eb6184a1171620c4dcdba71b2f791aa
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Fri Aug 23 10:29:17 2013 -0500

    - Added a basic Signature element
    - Added declarations for the new functions to handle the parsing of the
      StackMapTable related structures.

commit 54cca3d9af60463dbfa77e23ef1d562ae82d6e5a
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Fri Aug 23 10:18:50 2013 -0500

    Finished an initial coding implementation of the StackMapTable.
    -- Will perform testing later in the day.
    -- Need to look-up the Signature Attribute

commit a14238eece865f4d1c5f2d6b1f482b000d10d94e
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Thu Aug 22 20:23:45 2013 -0500

    StackMap stuff is wip.

commit f011a5d948d31cc6197eed1bbea497a4dde362aa
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Thu Aug 22 18:44:23 2013 -0500

    Made the globals match the R_* standard.  Also tried to clean up naming stuff.

commit 6e61e15572744c2ed722ac3df8d988cc02f1316c
Author: Adam Pridgen <adam.pridgen@thecoverofnight.com>
Date:   Thu Aug 22 16:40:08 2013 -0500

    Plugging progress into the repo.  Adding fixes to handle the Java
    Class file appropriately.  This modification is mostly a re-write
    of the Class File parser, and it "tries" to do a better job of
    creating better objects for each of the Classfile elements.

    Currently this code is experimental, and current TODOs are:
    1) Testing
    2) StackMapTable
    3) LocalVariableTypeTable
2013-09-04 18:52:42 +02:00

478 lines
13 KiB
C

/* radare - LGPL - Copyright 2007-2013 - pancake */
#include <r_types.h>
#include <r_util.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <r_list.h>
#include "code.h"
#include "class.h"
#define V if(verbose)
static RList *cp_items = NULL;
static RBinJavaClass cf;
R_API void r_java_setcp(void *cp, int n) {
// eprintf ("SET CP (%p) %d\n", cp, n);
cp_items = (RList *) cp;
if(cp == NULL)
cp_items = r_list_new();
cf.cp_count = n;
}
static RBinJavaCPTypeObj* get_cp(int i) {
RBinJavaCPTypeObj *item = NULL;
if (i<0||i>cf.cp_count)
return r_bin_java_get_java_null_cp();
item = (RBinJavaCPTypeObj *) r_list_get_n(cp_items, i);
return item;
}
static int java_resolve(int idx, char *str) {
// TODO XXX FIXME add a size parameter to the str when it is passed in
RBinJavaCPTypeObj *item = NULL,
*class_cp_item = NULL,
*namet_cp_item = NULL;
char *class_str = NULL,
*namet_str = NULL,
*string_str = NULL,
*empty = "",
*cp_name = NULL;
int class_idx, namet_idx;
if (str == NULL)
return 0;
sprintf (str, "(%d)", idx);
if (cf.cp_count<1) {
/* load constant pool here */
}
if (idx<0||idx>cf.cp_count)
return 1;
// default case.
if (cp_items == NULL){
strcpy (str, "(null)");
return 0;
}
item = (RBinJavaCPTypeObj *) r_list_get_n(cp_items, idx);
if (!item){
sprintf (str, "(?): 0x%04x", item->tag);
return 0;
}
cp_name = ((RBinJavaCPTypeMetas *) item->metas->type_info)->name;
if ( !cp_name) {
sprintf (str, "0x%02x", item->tag);
return 0;
}
// Damn this is a long logic statement :-(
if ( strcmp (cp_name, "Class") == 0 ){
class_idx = item->info.cp_class.name_idx;
class_str = r_bin_java_get_utf8_from_cp_item_list(cp_items, class_idx);
if (class_str == NULL)
class_str = empty;
sprintf (str, "%s", class_str);
if (class_str != empty)
free(class_str);
}else if ( strcmp (cp_name, "MethodRef") == 0 ||
strcmp (cp_name, "FieldRef") == 0 ||
strcmp (cp_name, "InterfaceMethodRef") == 0) {
int class_idx = -1;
int namet_idx = -1;
if (strcmp (cp_name, "MethodRef") == 0){
class_idx = item->info.cp_method.class_idx;
namet_idx = item->info.cp_method.name_and_type_idx;
}else if(strcmp (cp_name, "FieldRef") == 0){
class_idx = item->info.cp_field.class_idx;
namet_idx = item->info.cp_field.name_and_type_idx;
}else if(strcmp (cp_name, "InterfaceMethodRef") == 0){
class_idx = item->info.cp_interface.class_idx;
namet_idx = item->info.cp_interface.name_and_type_idx;
}
class_str = r_bin_java_get_name_from_cp_item_list(cp_items, class_idx);
namet_str = r_bin_java_get_item_name_from_cp_item_list(cp_items, item);
if (class_str == NULL)
class_str = empty;
if (namet_str == NULL)
namet_str = empty;
sprintf (str, "%s %s", class_str, namet_str);
if (class_str != empty)
free(class_str);
if (namet_str != empty)
free(namet_str);
} else if (strcmp (cp_name, "String") == 0) {
string_str = r_bin_java_get_utf8_from_cp_item_list(cp_items, item->info.cp_string.string_idx);
if (string_str){
sprintf (str, "\"%s\"", string_str);
free(string_str);
}else
sprintf (str, "\"%s\"", empty);
} else if (strcmp (cp_name, "Utf8") == 0) {
sprintf (str, "\"%s\"", item->info.cp_utf8.bytes);
} else if (strcmp (cp_name, "Long") == 0) {
sprintf (str, "0x%llx", rbin_java_raw_to_long (item->info.cp_long.bytes.raw,0));
} else if (strcmp (cp_name, "Double") == 0) {
sprintf (str, "%f", rbin_java_raw_to_double (item->info.cp_double.bytes.raw,0));
} else if (strcmp (cp_name, "Integer") == 0) {
sprintf (str, "0x%08x", R_BIN_JAVA_UINT (item->info.cp_integer.bytes.raw,0));
} else if (strcmp (cp_name, "Float") == 0) {
sprintf (str, "%f", R_BIN_JAVA_FLOAT (item->info.cp_float.bytes.raw,0));
} else if (strcmp (cp_name, "NameAndType") == 0) {
sprintf (str, "Name: 0x%04x Type: 0x%04x", item->info.cp_name_and_type.name_idx, item->info.cp_name_and_type.descriptor_idx);
} else{
strcpy (str, "(null)");
}
return 0;
}
int java_print_opcode(ut64 addr, int idx, const ut8 *bytes, char *output, int outlen) {
char arg[1024];
switch (java_ops[idx].byte) {
case 0x12:
case 0x13:
case 0x14:
java_resolve (bytes[1]-1, arg);
snprintf (output, outlen, "%s %s", java_ops[idx].name, arg);
return java_ops[idx].size;
case 0x99: // ifeq
case 0x9a: // ifne
case 0x9b: // iflt
case 0x9c: // ifge
case 0x9d: // ifgt
case 0x9e: // ifle
case 0x9f: // if_icmpeq
case 0xa0: // if_icmpne
case 0xa1: // if_icmplt
case 0xa2: // if_icmpge
case 0xa3: // if_icmpgt
case 0xa4: // if_icmple
case 0xa5: // if_acmpne
case 0xa6: // if_acmpne
case 0xa7: // goto
case 0xa8: // jsr
snprintf (output, outlen, "%s 0x%08"PFMT64x, java_ops[idx].name,
addr+(int)(short)USHORT (bytes, 1));
return java_ops[idx].size;
case 0xb2: // getstatic
case 0xb6: // invokevirtual
case 0xb7: // invokespecial
case 0xb8: // invokestatic
case 0xb9: // invokeinterface
case 0xba: // invokedynamic
java_resolve ((int)USHORT (bytes, 1)-1, arg);
snprintf (output, outlen, "%s %s", java_ops[idx].name, arg);
return java_ops[idx].size;
}
/* process arguments */
switch (java_ops[idx].size) {
case 1: snprintf (output, outlen, "%s", java_ops[idx].name);
break;
case 2: snprintf (output, outlen, "%s %d", java_ops[idx].name, bytes[1]);
break;
case 3: snprintf (output, outlen, "%s 0x%x 0x%x", java_ops[idx].name, bytes[0], bytes[1]);
break;
case 5: snprintf (output, outlen, "%s %d", java_ops[idx].name, bytes[1]);
break;
}
return java_ops[idx].size;
}
R_API int r_java_disasm(ut64 addr, const ut8 *bytes, char *output, int outlen) {
int i;
// TODO: replace loop for direct array index
for (i = 0; java_ops[i].name != NULL; i++)
if (bytes[0] == java_ops[i].byte)
return java_print_opcode (addr, i, bytes, output, outlen);
return -1;
}
R_API int r_java_assemble(ut8 *bytes, const char *string) {
char name[128];
int a,b,c,d;
int i;
sscanf (string, "%s %d %d %d %d", name, &a, &b, &c, &d);
for (i = 0; java_ops[i].name != NULL; i++)
if (!strcmp (name, java_ops[i].name)) {
bytes[0] = java_ops[i].byte;
switch (java_ops[i].size) {
case 2: bytes[1] = a; break;
case 3: bytes[1] = a; bytes[2] = b; break;
case 5: bytes[1] = a;
bytes[2] = b;
bytes[3] = c;
bytes[4] = d;
break;
}
return java_ops[i].size;
}
return 0;
}
#if 0
unsigned short read_short(FILE *fd) {
unsigned short sh = 0;
fread (&sh, 2, 1, fd);
return r_num_ntohs (sh);
}
static int attributes_walk(FILE *fd, int sz2, int fields, int verbose) {
char *name, buf[99999];
int sz, k, j=0;
for (j=0;j<sz2;j++) {
fread(buf, 6, 1, fd);
name = (get_cp (USHORT(buf,0)-1))->value;
V printf(" %2d: Name Index: %d (%s)\n", j, USHORT(buf,0), name);
// TODO add comment with constant pool index
if (fields) {
V printf("FIELD\n");
} else {
V printf (" Length: %d\n", UINT (buf, 2));
if (!name) {
printf ("**ERROR ** Cannot identify attribute name into constant pool\n");
continue;
}
if (!strcmp (name, "Code")) {
fread(buf, 8, 1, fd);
V printf(" Max Stack: %d\n", USHORT(buf, 0));
V printf(" Max Locals: %d\n", USHORT(buf, 2));
V printf(" Code Length: %d\n", UINT(buf, 4));
V printf(" Code At Offset: 0x%08"PFMT64x"\n", (ut64)ftell(fd));
fread(buf, UINT(buf, 4), 1, fd); // READ CODE
sz = read_short(fd);
V printf(" Exception table length: %d\n", sz);
for (k=0;k<sz;k++) {
fread(buf, 8, 1, fd);
V printf(" start_pc: 0x%04x\n", USHORT(buf,0));
V printf(" end_pc: 0x%04x\n", USHORT(buf,2));
V printf(" handler_pc: 0x%04x\n", USHORT(buf,4));
V printf(" catch_type: %d\n", USHORT(buf,6));
}
sz = (int)read_short(fd);
V printf(" code Attributes_count: %d\n", sz);
if (sz>0)
attributes_walk(fd, sz, fields, verbose);
} else
if (!strcmp(name, "LineNumberTable")) {
sz = (int)read_short(fd);
V printf(" Table Length: %d\n", sz);
for(k=0;k<sz;k++) {
fread(buf, 4, 1, fd);
V printf(" %2d: start_pc: 0x%04x\n", k, USHORT(buf, 0));
V printf(" line_number: %d\n", USHORT(buf, 2));
}
} else
if (!strcmp(name, "StackMapTable")) {
fread (buf, 2, 1, fd);
V printf(" StackMapTable: %d\n", USHORT(buf, 0));
} else
if (!strcmp (name, "LocalVariableTable")) {
int i;
ut32 lvtl = (ut32)read_short (fd);
for (i=0; i<lvtl; i++) {
int start_pc = start_pc = read_short (fd);
int length = length = read_short (fd);
int name_idx = name_idx = read_short (fd);
int desc_idx = desc_idx = read_short (fd);
int index = index = read_short (fd);
}
} else
if (!strcmp(name, "ConstantValue")) {
fread(buf, 2, 1, fd);
#if 0
printf(" Name Index: %d\n", USHORT(buf, 0)); // %s\n", USHORT(buf, 0), cp_items[USHORT(buf,0)-1].value);
printf(" AttributeLength: %d\n", UINT(buf, 2));
#endif
V printf(" ConstValueIndex: %d\n", USHORT(buf, 0));
} else {
fprintf (stderr, "** ERROR ** Unknown section '%s'\n", name);
return 1;
}
}
}
return 0;
}
static void check_eof(FILE *fd) {
if (feof (fd)) {
fprintf(stderr, "Unexpected eof\n");
// XXX cannot exit on a library!!
exit(0);
}
}
int java_classdump(const char *file, int verbose) {
RBinJavaClass2 cf2;
unsigned short sz, sz2;
int this_class;
char buf[0x9999];
int i,j;
FILE *fd = fopen(file, "rb");
if (fd == NULL)
return -1;
/* start parsing */
fread (&cf, 10, 1, fd); //sizeof(struct classfile), 1, fd);
if (memcmp (cf.cafebabe, "\xCA\xFE\xBA\xBE", 4)) {
eprintf ("java_classdump: Invalid header\n");
return -1;
}
javasm_init ();
/* show class version information */
V printf ("Version: 0x%02x%02x 0x%02x%02x\n",
cf.major[1],cf.major[0], cf.minor[1],cf.minor[0]);
cf.cp_count = r_num_ntohs(cf.cp_count);
if (cf.major[0]==cf.major[1] && cf.major[0]==0) {
eprintf ("Oops. this is a Mach-O\n");
return 0;
}
cf.cp_count--;
V printf ("ConstantPoolCount %d\n", cf.cp_count);
cp_items = malloc (sizeof (struct cp_item)*(cf.cp_count+1));
for (i=0;i<cf.cp_count;i++) {
struct constant_t *c;
fread (buf, 1, 1, fd);
c = NULL;
for (j=0; r_bin_java_constants[j].name; j++) {
if (r_bin_java_constants[j].tag == buf[0]) {
c = &r_bin_java_constants[j];
break;
}
}
if (c == NULL) {
eprintf ("Invalid tag '%d'\n", buf[0]);
return 0;
}
V eprintf (" %3d %s: ", i+1, c->name);
/* store constant pool item */
strcpy (cp_items[i].name, c->name);
cp_items[i].tag = c->tag;
cp_items[i].value = NULL; // no string by default
cp_items[i].off = ftell(fd)-1;
/* read bytes */
switch (c->tag) {
case 1: // utf 8 string
fread (buf, 2, 1, fd);
sz = USHORT (buf,0);
//cp_items[i].len = sz;
fread(buf, sz, 1, fd);
buf[sz] = '\0';
break;
default:
fread(buf, c->len, 1, fd);
}
memcpy (cp_items[i].bytes, buf, 5);
/* parse value */
switch(c->tag) {
case 1:
V printf ("%s\n", buf);
cp_items[i].value = strdup(buf);
break;
case 7:
V printf ("%d\n", USHORT(buf,0));
break;
case 8:
V printf ("string ptr %d\n", USHORT(buf, 0));
break;
case 9:
case 11:
case 10: // METHOD REF
V printf("class = %d, ", USHORT(buf,0));
V printf("name_type = %d\n", USHORT(buf,2));
break;
case 12:
V printf("name = %d, ", USHORT(buf,0));
V printf("descriptor = %d\n", USHORT(buf,2));
break;
default:
V printf("%d\n", UINT(buf, 40));
}
}
fread (&cf2, sizeof (RBinJavaClass2), 1, fd);
check_eof(fd);
V printf("Access flags: 0x%04x\n", cf2.access_flags);
this_class = r_num_ntohs (cf2.this_class);
V printf ("This class: %d\n", this_class);
check_eof (fd);
//printf("This class: %d (%s)\n", ntohs(cf2.this_class), cp_items[ntohs(cf2.this_class)-1].value); // XXX this is a double pointer !!1
//printf("Super class: %d (%s)\n", ntohs(cf2.super_class), cp_items[ntohs(cf2.super_class)-1].value);
sz = read_short (fd);
V printf ("Interfaces count: %d\n", sz);
if (sz>0) {
fread (buf, sz*2, 1, fd);
sz = read_short (fd);
for (i=0; i<sz; i++) {
eprintf ("interfaces: TODO\n");
}
}
sz = read_short(fd);
V printf("Fields count: %d\n", sz);
if (sz>0) {
for (i=0;i<sz;i++) {
fread(buf, 8, 1, fd);
V printf("%2d: Access Flags: %d\n", i, USHORT(buf, 0));
V printf(" Name Index: %d (%s)\n", USHORT(buf, 2), get_cp(USHORT(buf,2)-1)->value);
V printf(" Descriptor Index: %d\n", USHORT(buf, 4)); //, cp_items[USHORT(buf, 4)-1].value);
sz2 = USHORT(buf, 6);
V printf(" field Attributes Count: %d\n", sz2);
attributes_walk(fd, sz2, 1, verbose);
}
}
sz = read_short(fd);
V printf("Methods count: %d\n", sz);
if (sz>0) {
for (i=0;i<sz;i++) {
fread(buf, 8, 1, fd);
check_eof(fd);
V printf("%2d: Access Flags: %d\n", i, USHORT(buf, 0));
V printf(" Name Index: %d (%s)\n", USHORT(buf, 2), get_cp(USHORT(buf, 2)-1)->value);
V printf(" Descriptor Index: %d (%s)\n", USHORT(buf, 4), get_cp(USHORT(buf, 4)-1)->value);
sz2 = USHORT(buf, 6);
V printf(" method Attributes Count: %d\n", sz2);
attributes_walk(fd, sz2, 0, verbose);
}
}
fclose(fd);
return 0;
}
#endif