@@ -27,7 +27,7 @@ __BEGIN_DECLS
2727
2828#define FAKELINKER_LIB_INIT_NAME "fakelinker_module_init"
2929
30- enum FakeLinkerError {
30+ typedef enum {
3131 kErrorNo = 0 , /**< No error */
3232 kHJErrorNO = kErrorNo , /**< No error */
3333 kErrorNpNull = 1 , /**< android namespace empty errors */
@@ -41,25 +41,26 @@ enum FakeLinkerError {
4141 kErrorParameter = 1 << 9 , /**< Parameter type error */
4242 kErrorParameterNull = 1 << 10 , /**< Parameter is empty error */
4343 kErrorMemoryError = 1 << 11 , /**< Internal memory request error */
44- kErrorUnavailable = 1 << 12 , /**< The feature is not available, and it may be fixed in the future */
44+ kErrorUnavailable = 1 << 12 , /**< The feature is not available, and it may be
45+ fixed in the future */
4546 kErrorExec = 1 << 13 , /**< Internal execution error */
4647 kHJErrorOffset = 1 << 14 , /**< Method index error, out of range or illegal */
4748 kHJErrorMethodNull = 1 << 15 , /**< Method pointer is null error */
4849 kHJErrorRepeatOperation = 1 << 16 , /**< Repeated operation error */
4950 kHJErrorExec = 1 << 17 , /**< Inside execute error */
50- };
51+ } FakeLinkerError ;
5152
52- struct HookJniUnit {
53+ typedef struct {
5354 int offset ;
5455 void * hook_method ;
5556 void * * backup_method ;
56- };
57+ } HookJniUnit ;
5758
58- struct HookRegisterNativeUnit {
59+ typedef struct {
5960 JNINativeMethod hook_method ;
6061 bool is_static ;
6162 void * * backup_method ;
62- };
63+ } HookRegisterNativeUnit ;
6364
6465#define FunPtr (Ret , Name , ...) Ret (*Name)(__VA_ARGS__)
6566
@@ -70,7 +71,7 @@ typedef void *AndroidDlextinfoPtr; // android_dlextinfo *
7071typedef void * AndroidNamespacePtr ;
7172typedef void * AndroidLinkNamespacePtr ;
7273
73- struct SoinfoAttributes {
74+ typedef struct {
7475 SoinfoPtr soinfo_ptr ;
7576 const char * so_name ;
7677 const char * real_path ;
@@ -86,27 +87,27 @@ struct SoinfoAttributes {
8687 size_t size ;
8788 uint32_t flags ;
8889 ANDROID_GE_N SoinfoHandle handle ;
89- };
90+ } SoinfoAttributes ;
9091
91- enum SoinfoFindType {
92+ typedef enum {
9293 kSTAddress , /**< Find the soinfo data by the address, if it is null, take the
9394 address of the caller */
9495 kSTHandle , /**< Android 7.0+, find soinfo by handle */
9596 kSTName , /**< Find soinfo by library name */
9697 kSTOrig , /**< It is already soinfo, no query operation */
97- };
98+ } SoinfoFindType ;
9899
99- enum FindSymbolType {
100+ typedef enum {
100101 kImported , /**< find import symbol address*/
101102 kExported , /**< find export symbol address*/
102103 kInternal /**< find internal symbol addresses, need to load library file from
103104 disk*/
104- };
105+ } FindSymbolType ;
105106
106- struct FindSymbolUnit {
107+ typedef struct {
107108 const char * symbol_name ;
108109 FindSymbolType symbol_type ;
109- };
110+ } FindSymbolUnit ;
110111
111112/**
112113 * @brief dlopen function signature inside FakeLinker
@@ -134,11 +135,11 @@ typedef void *(*DlopenFun)(const char *filename, int flags, void *caller_addr, c
134135 */
135136typedef void * (* DlsymFun )(void * handle , const char * symbol_name , void * caller_addr );
136137
137- ANDROID_GE_N enum NamespaceFindType {
138+ ANDROID_GE_N typedef enum {
138139 kNPOriginal , /**< It is already a namespace, do not query */
139140 kNPSoinfo , /**< Specify the namespace in which soinfo looks for it */
140141 kNPNamespaceName , /**< Find the namespace with the specified name */
141- };
142+ } NamespaceFindType ;
142143
143144/**
144145 * @brief FakeLinker exports multiple function pointers, which are passed as
@@ -172,8 +173,8 @@ typedef struct {
172173 FunPtr (SoinfoPtr , soinfo_find , SoinfoFindType find_type , const void * param , int * out_error );
173174
174175 /**
175- * @brief Android 7.0+ finds soinfo, restricts the namespace, and returns the first matching item when the namespace
176- * is empty
176+ * @brief Android 7.0+ finds soinfo, restricts the namespace, and returns the
177+ * first matching item when the namespace is empty
177178 *
178179 * @note Required Android 7.0+
179180 *
@@ -415,8 +416,8 @@ typedef struct {
415416 FunPtr (bool , call_manual_relocation_by_names , SoinfoPtr global_lib , int len , const char * target_names []);
416417
417418 /**
418- * @brief Specify the soinfo pointer to get the first export symbol address of the
419- * specified name prefix
419+ * @brief Specify the soinfo pointer to get the first export symbol address of
420+ * the specified name prefix
420421 *
421422 * @param soinfo_ptr Specify the soinfo pointer
422423 * @param name Export symbol name
@@ -503,7 +504,8 @@ typedef struct {
503504 MEMORY_FREE SoinfoPtr * * out_soinfo_ptr_array , int * out_error );
504505
505506 /**
506- * @brief Get the address contained in the namespace, often used in the dlopen function to pass the caller address.
507+ * @brief Get the address contained in the namespace, often used in the dlopen
508+ * function to pass the caller address.
507509 * @note that the namespace must contain at least one soinfo
508510 *
509511 * @param android_namespace_ptrDoc
@@ -856,7 +858,7 @@ typedef struct {
856858 */
857859extern void fakelinker_module_init (JNIEnv * env , SoinfoPtr fake_soinfo , const FakeLinker * fake_linker );
858860
859- enum FakeLinkerMode {
861+ typedef enum {
860862 /**
861863 * Initialize soinfo, initialize all linker functions by default,
862864 * if only some functions are needed, please add kInitLinkerXXXX flag
@@ -868,12 +870,14 @@ enum FakeLinkerMode {
868870 kFMNativeHook = 1 << 1 ,
869871
870872 /**
871- * Register the Java functions, by default, the FakeLinker class will return success even if the registration fails,
872- * whereas non-default classes will only return success if the registration is successful.
873+ * Register the Java functions, by default, the FakeLinker class will return
874+ * success even if the registration fails, whereas non-default classes will
875+ * only return success if the registration is successful.
873876 */
874877 kFMJavaRegister = 1 << 2 ,
875878 /**
876- * The default FakeLinker class or non-default classes must return success only if the registration is successful.
879+ * The default FakeLinker class or non-default classes must return success
880+ * only if the registration is successful.
877881 */
878882 kFMForceJavaRegister = 1 << 3 ,
879883 /**
@@ -902,19 +906,20 @@ enum FakeLinkerMode {
902906 */
903907 kInitLinkerMemory = 1 << 8 ,
904908
905- };
909+ } FakeLinkerMode ;
906910
907911/**
908- * @brief Fakelinker has been changed to static library mode to facilitate integration and reuse of APIs,
909- * so the initialization function needs to be called manually.
910- * It can be initialized multiple times, for example, it can be used before there is no jni environment
911- * and it can be used after there is a jni environment.
912+ * @brief Fakelinker has been changed to static library mode to facilitate
913+ * integration and reuse of APIs, so the initialization function needs to be
914+ * called manually. It can be initialized multiple times, for example, it can be
915+ * used before there is no jni environment and it can be used after there is a
916+ * jni environment.
912917 *
913918 *
914919 * @param env jni environment or nullptr
915920 * @param mode initialization mode
916- * @param java_class_name Register the class name of the Java interface. If empty, use the default
917- * com/sanfengandroid/fakelinker/FakeLinker
921+ * @param java_class_name Register the class name of the Java interface. If
922+ * empty, use the default com/sanfengandroid/fakelinker/FakeLinker
918923 * @return return 0 on success
919924 */
920925int init_fakelinker (JNIEnv * env , FakeLinkerMode mode , const char * java_class_name );
0 commit comments