@yanfox777

Почему FindLibrary выдает 0x0?

Пытаюсь собрать лаунчер для SAMP Android. Все шло успешно, до момента интеграции самого SAMP (build69). libsamp.so Не может найти адрес соседней библиотеки libGTASA.so.

Инициализация всех библиотек
static {
        vmVersion = null;
        System.out.println("**** Loading SO's");
        try
        {
            vmVersion = System.getProperty("java.vm.version");
            System.out.println("vmVersion " + vmVersion);
            System.out.println("**** Loading libImmEmulatorJ.so");
            System.loadLibrary("ImmEmulatorJ");
        } catch (ExceptionInInitializerError | UnsatisfiedLinkError e) {
        }
        System.out.println("**** Loading libGTASA.so");
        System.loadLibrary("GTASA");
        System.out.println("**** Loading libsamp.so");
        System.loadLibrary("samp");
    }


Поиск библиотеки в libsamp.so
jint JNI_OnLoad(JavaVM *vm, void *reserved)
{
	Log("SAMP library loaded! Build time: " __DATE__ " " __TIME__);

	g_libGTASA = FindLibrary("libGTASA.so");
	if(g_libGTASA == 0)
	{
		Log("ERROR: libGTASA.so address not found!");
		return 0;
	}

	Log("libGTASA.so image base address: 0x%X", g_libGTASA);

	srand(time(0));

	InitHookStuff();
	InitRenderWareFunctions();
	InstallSpecialHooks();

	pthread_t thread;
	pthread_create(&thread, 0, Init, 0);

	struct sigaction act;
	act.sa_sigaction = handler;
	sigemptyset(&act.sa_mask);
	act.sa_flags = SA_SIGINFO;
	sigaction(SIGSEGV, &act, 0);

	return JNI_VERSION_1_4;
}


FindLibrary:

uintptr_t FindLibrary(const char* library)
{
    char filename[0xFF] = {0},
    buffer[2048] = {0};
    FILE *fp = 0;
    uintptr_t address = 0;

    sprintf( filename, "/proc/%d/maps", getpid() );

    fp = fopen( filename, "rt" );
    if(fp == 0)
    {
        Log("ERROR: can't open file %s", filename);
        goto done;
    }

    while(fgets(buffer, sizeof(buffer), fp))
    {
        if( strstr( buffer, library ) )
        {
            address = (uintptr_t)strtoul( buffer, 0, 16 );
            break;
        }
    }

    done:

    if(fp)
      fclose(fp);

    return address;
}


Лог приложения:
2023-10-28 14:57:32.800 29054-29054 System.out              com.kalinovka.game                   I  **** Loading SO's
2023-10-28 14:57:32.800 29054-29054 System.out              com.kalinovka.game                   I  vmVersion 2.1.0
2023-10-28 14:57:32.800 29054-29054 System.out              com.kalinovka.game                   I  **** Loading libImmEmulatorJ.so
2023-10-28 14:57:32.804 29054-29054 System.out              com.kalinovka.game                   I  **** Loading libGTASA.so
2023-10-28 14:57:32.813 29054-29054 NVEvent                 com.kalinovka.game                   D  JNI_OnLoad called
2023-10-28 14:57:32.813 29054-29054 NVEvent                 com.kalinovka.game                   D  RegisterNatives 12
2023-10-28 14:57:32.813 29054-29054 System.out              com.kalinovka.game                   I  **** Loading libsamp.so
2023-10-28 14:57:32.815 29054-29054 AXL                     com.kalinovka.game                   I  SAMP library loaded! Build time: Oct 28 2023 14:47:20
2023-10-28 14:57:32.819 29054-29054 AXL                     com.kalinovka.game                   I  ERROR: libGTASA.so address not found!
2023-10-28 14:57:32.820 29054-29054 AndroidRuntime          com.kalinovka.game                   D  Shutting down VM
2023-10-28 14:57:32.823 29054-29054 AndroidRuntime          com.kalinovka.game                   E  FATAL EXCEPTION: main
                                                                                                    Process: com.kalinovka.game, PID: 29054
                                                                                                    java.lang.UnsatisfiedLinkError: Bad JNI version returned from JNI_OnLoad in "/data/app/~~AIt22YvJlsdkRyH_N_WAEw==/com.kalinovka.game-G93aBwDihlPGnVBadiHFkQ==/base.apk!/lib/armeabi-v7a/libsamp.so": 0
                                                                                                    	at java.lang.Runtime.loadLibrary0(Runtime.java:1082)
                                                                                                    	at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
                                                                                                    	at java.lang.System.loadLibrary(System.java:1661)
                                                                                                    	at com.kalinovka.game.core.GTASA.<clinit>(GTASA.java:28)
                                                                                                    	at java.lang.Class.newInstance(Native Method)
                                                                                                    	at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
                                                                                                    	at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
                                                                                                    	at android.app.Instrumentation.newActivity(Instrumentation.java:1287)
                                                                                                    	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3701)
                                                                                                    	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3977)
                                                                                                    	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:109)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2374)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:233)
                                                                                                    	at android.os.Looper.loop(Looper.java:344)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8249)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:589)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1071)
2023-10-28 14:57:32.894 29054-29054 Process                 com.kalinovka.game                   I  Sending signal. PID: 29054 SIG: 9


Ошибка Bad JNI version returned from JNI_OnLoad - потому что libsamp.so отправил 0, на это можно не обращать внимания
  • Вопрос задан
  • 145 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы