forked from difcareer/010templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CLASSTemplate2.bt
executable file
·121 lines (115 loc) · 2.54 KB
/
CLASSTemplate2.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
BigEndian();
typedef struct {
enum <ubyte> {
CONSTANT_Class = 7,
CONSTANT_Fieldref = 9,
CONSTANT_Methodref = 10,
CONSTANT_InterfaceMethodref = 11,
CONSTANT_String = 8,
CONSTANT_Integer = 3,
CONSTANT_Float = 4,
CONSTANT_Long = 5,
CONSTANT_Double = 6,
CONSTANT_NameAndType = 12,
CONSTANT_Utf8 = 1
} tag;
switch (tag) {
case 7:
uint16 name_index;
break;
case 9:
uint16 class_index;
uint16 name_and_type_index;
break;
case 10:
uint16 class_index;
uint16 name_and_type_index;
break;
case 11:
uint16 class_index;
uint16 name_and_type_index;
break;
case 8:
uint16 string_index;
break;
case 3:
int32 int_value;
break;
case 4:
float float_value;
break;
case 5:
int64 long_value;
break;
case 6:
double double_value;
break;
case 12:
uint16 name_index;
uint16 descriptor_index;
break;
case 1:
uint16 length;
char utf8_value[length];
break;
}
} cp_info;
typedef struct {
uint16 attribute_name_index;
uint32 attribute_length;
char info[attribute_length];
} attribute_info;
typedef struct {
uint16 access_flags <format = binary>;
uint16 name_index;
uint16 descriptor_index;
uint16 attributes_count;
local int i_att2 = 0;
for ( i_att2 = 0; i_att2 < attributes_count; i_att2++) {
attribute_info attributes;
};
} field_info, method_info;
typedef struct {
uint32 magic <format = hex>;
if (magic != 0xCAFEBABE) {
Warning ("Invalid Class File.");
return -1;
}
uint16 minor_version;
uint16 major_version;
uint16 constant_pool_count;
local int i_cp = 0;
for ( i_cp = 1; i_cp < constant_pool_count; i_cp++) {
cp_info constant_pool;
if ( constant_pool.tag == 5 || constant_pool.tag == 6 ){
i_cp++;
}
};
uint16 access_flags <format = binary>;
uint16 this_class;
uint16 super_class;
uint16 interfaces_count;
local int i_if = 0;
for ( i_if = 0; i_if < interfaces_count; i_if++) {
uint16 interfaces;
};
uint16 fields_count;
local int i_fld = 0;
for ( i_fld = 0; i_fld < fields_count; i_fld++) {
field_info fields;
};
uint16 methods_count;
local int i_m = 0;
for ( i_m = 0; i_m < methods_count; i_m++) {
method_info methods;
};
uint16 attributes_count;
local int i_att = 0;
for ( i_att = 0; i_att < attributes_count; i_att++) {
attribute_info attributes;
};
} class_file;
class_file file;
if (!FEof()) {
Warning("File is not properly ended.");
};