Rizin
unix-like reverse engineering framework and cli tools
class_bin.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 deroad <wargio@libero.it>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef RZ_BIN_JAVA_CLASS_H
5 #define RZ_BIN_JAVA_CLASS_H
6 #include <rz_types.h>
7 #include <rz_util.h>
8 #include <rz_bin.h>
9 #include <rz_demangler.h>
10 
11 #include "class_attribute.h"
12 #include "class_const_pool.h"
13 #include "class_field.h"
14 #include "class_interface.h"
15 #include "class_method.h"
16 
17 typedef enum {
18  ACCESS_FLAG_PUBLIC /* */ = 0x0001,
19  ACCESS_FLAG_PRIVATE /* */ = 0x0002,
20  ACCESS_FLAG_PROTECTED /* */ = 0x0004,
21  ACCESS_FLAG_STATIC /* */ = 0x0008,
22  ACCESS_FLAG_FINAL /* */ = 0x0010,
23  ACCESS_FLAG_SUPER /* */ = 0x0020,
24  ACCESS_FLAG_BRIDGE /* */ = 0x0040,
25  ACCESS_FLAG_VARARGS /* */ = 0x0080,
26  ACCESS_FLAG_NATIVE /* */ = 0x0100,
27  ACCESS_FLAG_INTERFACE /* */ = 0x0200,
28  ACCESS_FLAG_ABSTRACT /* */ = 0x0400,
29  ACCESS_FLAG_STRICT /* */ = 0x0800,
30  ACCESS_FLAG_SYNTHETIC /* */ = 0x1000,
32  ACCESS_FLAG_ENUM /* */ = 0x4000,
33  ACCESS_FLAG_MODULE /* */ = 0x8000
35 
36 #define ACCESS_FLAG_MASK_ALL (0xFFFF)
37 #define ACCESS_FLAG_MASK_ALL_NO_SUPER ((~ACCESS_FLAG_SUPER) & ACCESS_FLAG_MASK_ALL)
38 
39 typedef struct java_class_t {
56 
57  /* extra data not included in the real header */
65 
68 
79 
80 /* used in bin_java.c and core_java.c */
100 
101 #endif /* RZ_BIN_JAVA_CLASS_H */
#define mask()
static SblHeader sb
Definition: bin_mbn.c:26
RZ_API RZ_BORROW const char * rz_bin_java_class_language(RZ_NONNULL RzBinJavaClass *bin)
Definition: class_bin.c:378
RZ_API void rz_bin_java_class_const_pool_as_json(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL PJ *j)
Returns the class const pool in json format via PJ arg.
Definition: class_bin.c:1650
RZ_API RZ_OWN RzList * rz_bin_java_class_fields_as_symbols(RZ_NONNULL RzBinJavaClass *bin)
Returns a RzList<RzBinSymbol*> containing the class fields.
Definition: class_bin.c:1227
RZ_API RZ_OWN RzList * rz_bin_java_class_const_pool_as_symbols(RZ_NONNULL RzBinJavaClass *bin)
Returns a RzList<RzBinSymbol*> containing the class const pool.
Definition: class_bin.c:1435
RZ_API RZ_OWN RzList * rz_bin_java_class_methods_as_symbols(RZ_NONNULL RzBinJavaClass *bin)
Returns a RzList<RzBinSymbol*> containing the class methods.
Definition: class_bin.c:1052
RZ_API ut64 rz_bin_java_class_debug_info(RZ_NONNULL RzBinJavaClass *bin)
Definition: class_bin.c:351
RZ_API RZ_OWN RzList * rz_bin_java_class_as_libraries(RZ_NONNULL RzBinJavaClass *bin)
Returns a RzList<char*> containing the class libraries.
Definition: class_bin.c:1846
RZ_API void rz_bin_java_class_interfaces_as_text(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb)
Returns the class interfaces as text via RzStrBuf arg.
Definition: class_bin.c:1898
RZ_API RZ_OWN RzBinJavaClass * rz_bin_java_class_new(RZ_NONNULL RzBuffer *buf, ut64 offset, RZ_NONNULL Sdb *kv)
Parses the java class file and returns a RzBinJavaClass struct.
Definition: class_bin.c:289
RZ_API RZ_OWN RzList * rz_bin_java_class_strings(RZ_NONNULL RzBinJavaClass *bin)
Returns a RzList<RzBinString*> containing the strings.
Definition: class_bin.c:986
ClassAccessFlag
Definition: class_bin.h:17
@ ACCESS_FLAG_MODULE
Definition: class_bin.h:33
@ ACCESS_FLAG_SYNTHETIC
Definition: class_bin.h:30
@ ACCESS_FLAG_VARARGS
Definition: class_bin.h:25
@ ACCESS_FLAG_NATIVE
Definition: class_bin.h:26
@ ACCESS_FLAG_PRIVATE
Definition: class_bin.h:19
@ ACCESS_FLAG_SUPER
Definition: class_bin.h:23
@ ACCESS_FLAG_ENUM
Definition: class_bin.h:32
@ ACCESS_FLAG_PROTECTED
Definition: class_bin.h:20
@ ACCESS_FLAG_STATIC
Definition: class_bin.h:21
@ ACCESS_FLAG_ANNOTATION
Definition: class_bin.h:31
@ ACCESS_FLAG_BRIDGE
Definition: class_bin.h:24
@ ACCESS_FLAG_STRICT
Definition: class_bin.h:29
@ ACCESS_FLAG_ABSTRACT
Definition: class_bin.h:28
@ ACCESS_FLAG_FINAL
Definition: class_bin.h:22
@ ACCESS_FLAG_INTERFACE
Definition: class_bin.h:27
@ ACCESS_FLAG_PUBLIC
Definition: class_bin.h:18
RZ_API void rz_bin_java_class_as_json(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL PJ *j)
Returns the class info as json.
Definition: class_bin.c:521
RZ_API void rz_bin_java_class_fields_as_json(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL PJ *j)
Returns the fields in json format via PJ arg.
Definition: class_bin.c:1366
RZ_API RZ_OWN RzList * rz_bin_java_class_const_pool_as_imports(RZ_NONNULL RzBinJavaClass *bin)
Returns a RzList<RzBinImport*> containing the class const pool.
Definition: class_bin.c:1509
RZ_API RZ_OWN RzList * rz_bin_java_class_as_sections(RZ_NONNULL RzBinJavaClass *bin)
Returns a RzList<RzBinSection*> containing the class sections.
Definition: class_bin.c:1718
RZ_API RZ_OWN char * rz_bin_java_class_version(RZ_NONNULL RzBinJavaClass *bin)
Parses the java class file and returns a RzBinJavaClass struct.
Definition: class_bin.c:306
RZ_API RZ_OWN char * rz_bin_java_class_const_pool_resolve_index(RZ_NONNULL RzBinJavaClass *bin, st32 index)
Returns the string linked to the class const pool index.
Definition: class_bin.c:644
RZ_API void rz_bin_java_class_as_text(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb)
Returns the class info as text.
Definition: class_bin.c:591
RZ_API RZ_OWN char * rz_bin_java_class_access_flags_readable(RZ_NONNULL RzBinJavaClass *bin, ut16 mask)
Returns the readable class access flags.
Definition: class_bin.c:485
RZ_API RZ_OWN RzList * rz_bin_java_class_entrypoints(RZ_NONNULL RzBinJavaClass *bin)
Returns a RzList<RzBinAddr*> containing the entrypoints.
Definition: class_bin.c:927
RZ_API RZ_OWN char * rz_bin_java_class_name(RZ_NONNULL RzBinJavaClass *bin)
Returns the class name.
Definition: class_bin.c:447
RZ_API RZ_OWN RzList * rz_bin_java_class_fields_as_binfields(RZ_NONNULL RzBinJavaClass *bin)
Returns a RzList<RzBinField*> containing the class fields.
Definition: class_bin.c:1277
RZ_API RZ_OWN char * rz_bin_java_class_super(RZ_NONNULL RzBinJavaClass *bin)
Returns the class super name.
Definition: class_bin.c:466
RZ_API RZ_OWN RzBinAddr * rz_bin_java_class_resolve_symbol(RZ_NONNULL RzBinJavaClass *bin, RzBinSpecialSymbol resolve)
Resolves and returns the RzBinAddr struct linked to the input RzBinSpecialSymbol.
Definition: class_bin.c:870
RZ_API void rz_bin_java_class_as_source_code(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb)
Returns the class info as text source code.
Definition: class_bin.c:708
RZ_API void rz_bin_java_class_const_pool_as_text(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb)
Returns the class const pool in text format via RzStrBuf arg.
Definition: class_bin.c:1605
struct java_class_t RzBinJavaClass
RZ_API void rz_bin_java_class_free(RZ_NULLABLE RzBinJavaClass *bin)
Frees a RzBinJavaClass pointer.
Definition: class_bin.c:407
RZ_API void rz_bin_java_class_interfaces_as_json(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL PJ *j)
Returns the class interfaces as json via PJ arg.
Definition: class_bin.c:1928
RZ_API void rz_bin_java_class_methods_as_text(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb)
Returns the methods in text format via RzStrBuf arg.
Definition: class_bin.c:1121
RZ_API ut32 rz_bin_java_class_access_flags(RZ_NONNULL RzBinJavaClass *bin)
Definition: class_bin.c:477
RZ_API void rz_bin_java_class_fields_as_text(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb)
Returns the fields in text format via RzStrBuf arg.
Definition: class_bin.c:1318
RZ_API void rz_bin_java_class_methods_as_json(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL PJ *j)
Returns the methods in json format via PJ arg.
Definition: class_bin.c:1169
#define RZ_API
uint16_t ut16
uint32_t ut32
voidpf uLong offset
Definition: ioapi.h:144
voidpf void * buf
Definition: ioapi.h:138
RzBinSpecialSymbol
Definition: rz_bin.h:136
#define RZ_NULLABLE
Definition: rz_types.h:65
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NONNULL
Definition: rz_types.h:64
#define RZ_BORROW
Definition: rz_types.h:63
#define st32
Definition: rz_types_base.h:12
Definition: malloc.c:26
ut16 fields_count
Definition: class_bin.h:50
ut16 minor_version
Definition: class_bin.h:41
ut16 interfaces_count
Definition: class_bin.h:48
ut64 constant_pool_offset
Definition: class_bin.h:58
Attribute ** attributes
Definition: class_bin.h:55
ut16 methods_count
Definition: class_bin.h:52
Method ** methods
Definition: class_bin.h:53
ConstPool ** constant_pool
Definition: class_bin.h:44
ut16 constant_pool_count
Definition: class_bin.h:43
ut64 interfaces_offset
Definition: class_bin.h:59
ut16 access_flags
Definition: class_bin.h:45
ut16 attributes_count
Definition: class_bin.h:54
ut64 fields_offset
Definition: class_bin.h:60
Field ** fields
Definition: class_bin.h:51
ut16 this_class
Definition: class_bin.h:46
ut32 magic
Definition: class_bin.h:40
ut64 class_end_offset
Definition: class_bin.h:63
ut64 attributes_offset
Definition: class_bin.h:62
Interface ** interfaces
Definition: class_bin.h:49
ut64 methods_offset
Definition: class_bin.h:61
ut16 super_class
Definition: class_bin.h:47
ut16 major_version
Definition: class_bin.h:42
Definition: rz_pj.h:12
Definition: sdb.h:63
static const char * resolve(struct Type *t, const char *foo, const char **bar)
Definition: swift.c:91
ut64(WINAPI *w32_GetEnabledXStateFeatures)()