BNM 2.4.0
 
Loading...
Searching...
No Matches
BNM::Loading Namespace Reference

Namespace with all methods for loading BNM. More...

Typedefs

typedef void *(* MethodFinder) (const char *name, void *userData)
 

Functions

void AllowLateInitHook ()
 Allow BNM to load at any game state.
 
bool TryLoadByJNI (JNIEnv *env, jobject context=nullptr)
 Try load BNM using JNI.
 
bool TryLoadByDlfcnHandle (void *handle)
 Try load BNM using dlfcn handle.
 
void SetMethodFinder (MethodFinder finderMethod, void *userData)
 Set custom method finder.
 
bool TryLoadByUsersFinder ()
 Try load BNM using custom method finder.
 
void TrySetupByUsersFinder ()
 Try setup BNM using custom method finder.
 
void AddOnLoadedEvent (void(*event)())
 Add event that will be called from il2cpp thread when il2cpp and BNM will be fully loaded.
 
void ClearOnLoadedEvents ()
 Remove all events.
 

Detailed Description

Namespace with all methods for loading BNM.

Function Documentation

◆ AllowLateInitHook()

void BNM::Loading::AllowLateInitHook ( )

Allow BNM to load at any game state.

Allow BNM to hook il2cpp::vm::Class::FromIl2CppType to load itself if loading starts too late. Should be called before attempting to load BNM. (Before TryLoadByJNI, TryLoadByDlfcnHandle, TryLoadByUsersFinder and TrySetupByUsersFinder).

Warning
For this loading method Unhook is required. Otherwise, the game will be slowed down.
Examples
KittyMemoryFinder.cpp.

◆ SetMethodFinder()

void BNM::Loading::SetMethodFinder ( MethodFinder finderMethod,
void * userData )

Set custom method finder.

You can use it for setting custom method finder if dlfcn or JNI don't work in current context.

Parameters
finderMethodPointer to custom method finder
userDataData that will be passed with every custom method finder call
Examples
KittyMemoryFinder.cpp.

◆ TryLoadByDlfcnHandle()

bool BNM::Loading::TryLoadByDlfcnHandle ( void * handle)

Try load BNM using dlfcn handle.

Uses the library handle to hook methods for loading BNM from the il2cpp thread.

Returns
True if hooks are setup.

Example usage:

void method() {
// ...
auto handle = BNM_dlopen(path_to_libil2cpp, RTLD_LAZY);
// ...
// ...
}
bool TryLoadByDlfcnHandle(void *handle)
Try load BNM using dlfcn handle.

◆ TryLoadByJNI()

bool BNM::Loading::TryLoadByJNI ( JNIEnv * env,
jobject context = nullptr )

Try load BNM using JNI.

Uses JNI and Context to find the full path to libil2cpp.so and then hook methods for loading BNM from the il2cpp thread.

Parameters
envValid in current thread JNIEnv
contextTarget app's android.content.Context
Returns
True if library is found and hooks are setup.

Example usage:

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
// ...
JNIEnv *env;
vm->GetEnv((void **) &env, JNI_VERSION_1_6);
// ...
// ...
}
bool TryLoadByJNI(JNIEnv *env, jobject context=nullptr)
Try load BNM using JNI.

◆ TryLoadByUsersFinder()

bool BNM::Loading::TryLoadByUsersFinder ( )

Try load BNM using custom method finder.

Uses custom method finder to hook methods for loading BNM from the il2cpp thread.

Returns
True if hooks are setup.
Examples
KittyMemoryFinder.cpp.

◆ TrySetupByUsersFinder()

void BNM::Loading::TrySetupByUsersFinder ( )

Try setup BNM using custom method finder.

Uses custom method finder to load BNM from the current thread.

Warning
You cannot call the method until il2cpp is fully loaded. It will cause crash.
Highly recommended not to call it from thread other than il2cpp's, it can cause a lot of problems and crashes, especially if classes management is enabled.