1010#include <android/log.h>
1111#include "zygisk.h"
1212
13- // --- KONFIGURASI ---
13+ // --- CONFIGURATION ---
1414#define LOG_TAG "Zygisk_Loader"
1515#define LOGD (...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
1616#define LOGI (...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
@@ -28,14 +28,13 @@ static bool g_target_app_detected = false;
2828
2929// --- UTILITY FUNCTIONS ---
3030
31- // Pengganti rand_int()
3231static uint32_t rand_int () {
3332 struct timespec ts ;
3433 clock_gettime (CLOCK_MONOTONIC , & ts );
3534 return (uint32_t )(ts .tv_nsec ^ ts .tv_sec );
3635}
3736
38- // Menulis buffer ke file
37+ // Write buffer to file
3938static bool write_file (const char * path , const uint8_t * data , size_t size ) {
4039 FILE * f = fopen (path , "wb" );
4140 if (!f ) return false;
@@ -46,7 +45,7 @@ static bool write_file(const char *path, const uint8_t *data, size_t size) {
4645 return written == size ;
4746}
4847
49- // Membaca file utuh ke memori (RAM Buffer)
48+ // Reading the entire file into memory (RAM Buffer)
5049static bool read_file_to_memory (const char * path , uint8_t * * out_buffer , size_t * out_size ) {
5150 FILE * f = fopen (path , "rb" );
5251 if (!f ) return false;
@@ -79,19 +78,18 @@ static bool read_file_to_memory(const char *path, uint8_t **out_buffer, size_t *
7978 return true;
8079}
8180
82- // Membaca file konfigurasi (Mendapatkan Target)
81+ // Reading configuration file (Get Target)
8382static void read_target_config () {
8483 FILE * f = fopen (CONFIG_PATH , "r" );
8584 if (f ) {
8685 if (fgets (g_target_package , sizeof (g_target_package ), f )) {
87- // Hilangkan karakter newline / spasi di akhir
8886 g_target_package [strcspn (g_target_package , "\r\n" )] = 0 ;
8987 }
9088 fclose (f );
9189 }
9290}
9391
94- // Helper untuk membaca jstring ke buffer C yang aman
92+ // Helper for reading jstrings into a safe C buffer
9593static void get_jstring_utf (JNIEnv * env , jstring * jstr_ptr , char * out_buf , size_t buf_size ) {
9694 out_buf [0 ] = '\0' ;
9795 if (jstr_ptr && * jstr_ptr ) {
@@ -117,7 +115,7 @@ static void onLoad(struct zygisk_api *api, JNIEnv *env) {
117115static void preAppSpecialize (void * impl , struct zygisk_app_specialize_args * args ) {
118116 (void )impl ;
119117
120- // 1. Baca Konfigurasi Target (Sebagai Root/Zygote)
118+ // 1. Read Target Configuration (As Root/Zygote)
121119 read_target_config ();
122120
123121 if (strlen (g_target_package ) == 0 ) return ;
@@ -126,10 +124,10 @@ static void preAppSpecialize(void *impl, struct zygisk_app_specialize_args *args
126124 if (g_jvm && (* g_jvm )-> GetEnv (g_jvm , (void * * )& env , JNI_VERSION_1_6 ) == JNI_OK ) {
127125 char process_name [256 ] = {0 };
128126
129- // Coba dapatkan dari nice_name (Fast-path)
127+ // Try getting from nice_name (Fast-path)
130128 get_jstring_utf (env , args -> nice_name , process_name , sizeof (process_name ));
131129
132- // Jika kosong, ekstrak dari app_data_dir (Fallback untuk isolated process )
130+ // If empty, extract from app_data_dir (Fallback for isolated processes )
133131 if (strlen (process_name ) == 0 ) {
134132 char app_data_dir [256 ] = {0 };
135133 get_jstring_utf (env , args -> app_data_dir , app_data_dir , sizeof (app_data_dir ));
@@ -139,12 +137,12 @@ static void preAppSpecialize(void *impl, struct zygisk_app_specialize_args *args
139137 }
140138 }
141139
142- // Cek apakah target sesuai dengan konfigurasi
140+ // Check if the target matches the configuration
143141 if (strstr (process_name , g_target_package ) != NULL ) {
144142 LOGI ("Target Detected: %s" , process_name );
145143 g_target_app_detected = true;
146144
147- // 2. Baca file Payload .so ke dalam RAM
145+ // 2. Read the .so Payload file into RAM
148146 if (read_file_to_memory (SOURCE_PAYLOAD_PATH , & g_payload_buffer , & g_payload_size )) {
149147 LOGI ("Payload buffered to RAM: %zu bytes" , g_payload_size );
150148 } else {
@@ -157,7 +155,7 @@ static void preAppSpecialize(void *impl, struct zygisk_app_specialize_args *args
157155static void postAppSpecialize (void * impl , const struct zygisk_app_specialize_args * args ) {
158156 (void )impl ;
159157
160- // Cegah eksekusi di aplikasi yang bukan target atau jika gagal load buffer
158+ // Prevent execution in non- target applications or if buffer load fails
161159 if (!g_target_app_detected || !g_payload_buffer ) return ;
162160
163161 JNIEnv * env = NULL ;
@@ -171,18 +169,18 @@ static void postAppSpecialize(void *impl, const struct zygisk_app_specialize_arg
171169 goto cleanup ;
172170 }
173171
174- // Generate nama file random /cache/.res_[rand].so
172+ // Generate random file name /cache/.res_[rand].so
175173 char file_name [1024 ];
176174 snprintf (file_name , sizeof (file_name ), "%s/cache/.res_%u.so" , app_data_dir , rand_int ());
177175
178176 LOGI ("Attempting injection to: %s" , file_name );
179177
180- // Tulis buffer ke Cache -> Dlopen -> Unlink
178+ // Write buffer to Cache -> Dlopen -> Unlink
181179 if (write_file (file_name , g_payload_buffer , g_payload_size )) {
182180
183181 void * handle = dlopen (file_name , RTLD_NOW );
184182
185- // Hapus file secara instan untuk stealth
183+ // Delete files instantly for stealth
186184 unlink (file_name );
187185
188186 if (!handle ) {
@@ -196,15 +194,15 @@ static void postAppSpecialize(void *impl, const struct zygisk_app_specialize_arg
196194 }
197195
198196cleanup :
199- // Hapus memori buffer agar tidak menjadi memory leak di sisi target aplikasi
197+ // Clear the buffer memory so that it does not become a memory leak on the target application side.
200198 if (g_payload_buffer ) {
201199 free (g_payload_buffer );
202200 g_payload_buffer = NULL ;
203201 g_payload_size = 0 ;
204202 }
205203}
206204
207- // Kita tidak membutuhkan method server
205+ // We don't need server method
208206static void preServerSpecialize (void * impl , struct zygisk_server_specialize_args * args ) { (void )impl ; (void )args ; }
209207static void postServerSpecialize (void * impl , const struct zygisk_server_specialize_args * args ) { (void )impl ; (void )args ; }
210208
@@ -226,6 +224,6 @@ void zygisk_module_entry(struct zygisk_api *api, JNIEnv *env) {
226224
227225__attribute__((visibility ("default" )))
228226void zygisk_companion_entry (int client ) {
229- // Companion tidak digunakan, cukup di- close
227+ // Companion is not used, just close it
230228 close (client );
231229}
0 commit comments