An SDK generator for BNM (ByNameModding) that creates C++ headers from Unity IL2CPP assemblies.
- Compile SDKGeneratorBNM (or use release version)
- Get your DummyDll from using Il2CppDumper
- Drag Assembly-CSharp.dll (from DummyDll folder) to SDKGeneratorBNM.exe
- Wait for your SDK to be generated
- Copy the SDK folder to your project
- Copy BNM headers to your project (And include it to your Android.mk or CMakeList.txt)
- Download BNMIncludes.hpp and place it in your
Includefolder - If using the
-bor--bnm-resolveflag, also download BNMResolve.hpp and place it in yourIncludefolder
Add the following to your CMakeLists.txt:
# Add BNM include directory
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/extern/BNM-Android/include)
# Add BNMIncludes.hpp (required)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Include)
# Add BNMResolve.hpp (optional, only if you generated SDK with -b flag)
# Uncomment the line below if you used the -b or --bnm-resolve flag
# include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Include)Or for Android.mk:
# Add BNM include directory
LOCAL_C_INCLUDES += $(LOCAL_PATH)/extern/BNM-Android/include
# Add BNMIncludes.hpp (required)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/Include
# Add BNMResolve.hpp (optional, only if you generated SDK with -b flag)
# LOCAL_C_INCLUDES += $(LOCAL_PATH)/IncludePlease read how to Initialize BNM Functions first before using any of the SDK/BNM Functions.
Example:
#include "SDK/GlobalNamespace/PlayerController.hpp"
#include "SDK/GlobalNamespace/GameManager.hpp"
using namespace GlobalNamespace;
using namespace BNM::UnityEngine;
void ModifyPlayer() {
auto gameManager = GameManager::get_Instance();
if (gameManager) {
auto player = gameManager->GetCurrentPlayer();
if(player) {
auto transform = ((Component *)player)->get_transform();
auto position = transform->get_position();
LOGD("Player Position: %f %f %f", position.x, position.y, position.z);
player->SetHealth(9999.0f);
}
}
}- Use
-sor--single-fileto generate everything in one file - Use
-gor--getter-setterto use getter_setter naming style instead of GetSet - Use
-aor--accessorto use accessor style (field()->Get(), method()->Call()) - Use
-bor--bnm-resolveto use BNMResolve types (GameObject, Transform, Camera, etc.) - Use
-hor--helpto display help message
Uses generic Il2CppObject pointers for all BNMResolve types:
UnityEngine.GameObject→BNM::IL2CPP::Il2CppObject*UnityEngine.Transform→BNM::IL2CPP::Il2CppObject*UnityEngine.Camera→BNM::IL2CPP::Il2CppObject*- etc.
Does not require: BNMResolve.hpp include
Uses typed BNMResolve objects for better type safety:
UnityEngine.GameObject→GameObject*UnityEngine.Transform→Transform*UnityEngine.Camera→Camera*- etc.
Requires: BNMResolve.hpp in your CMake/Android.mk