It shows how to work with generic classes and methods.
#include <BNM/Class.hpp>
#include <BNM/Method.hpp>
void OnLoaded_Example_03() {
auto gameObject =
Class(BNM_OBFUSCATE(
"UnityEngine"), BNM_OBFUSCATE(
"GameObject"),
Image(BNM_OBFUSCATE(
"UnityEngine.CoreModule")));
auto GetComponent = gameObject.GetMethod(BNM_OBFUSCATE("GetComponent"), 0);
BNM_LOG_INFO("GameObject::GetComponent<T>: 0x%lX", (BNM_PTR)BNM::Utils::OffsetInLib((void *)GetComponent.GetOffset()));
BNM_LOG_INFO(
"GameObject::GetComponent<object>: 0x%lX", (BNM_PTR)BNM::Utils::OffsetInLib((
void *)GetComponentObject.
GetOffset()));
auto dictionaryClass =
BNM::Class(BNM_OBFUSCATE(
"System.Collections.Generic"), BNM_OBFUSCATE(
"Dictionary`2"),
BNM::Image(BNM_OBFUSCATE(
"mscorlib.dll")));
BNM_LOG_INFO("Dictionary<TKey, TValue>::Add: 0x%lX", (BNM_PTR)BNM::Utils::OffsetInLib((void *)dictionaryClass.GetMethod("Add", 2).GetOffset()));
BNM_LOG_INFO("Dictionary<int, int>::Add: 0x%lX", (BNM_PTR)BNM::Utils::OffsetInLib((void *)dictionary_int_int_Class.GetMethod("Add", 2).GetOffset()));
}
constexpr DefaultTypeRef Get()
Method that helps to get il2cpp class type from C++ and BNM types.
Definition Defaults.hpp:132
Main BNM namespace.
Definition BasicMonoStructures.hpp:16
Class for working with il2cpp classes.
Definition Class.hpp:29
Class for working with il2cpp images.
Definition Image.hpp:19
MethodBase GetGeneric(const std::initializer_list< CompileTimeClass > &templateTypes) const
Get typed version of current generic method.
BNM_PTR GetOffset() const
Get method offset.
Definition MethodBase.hpp:60
Typed class for working with il2cpp methods.
Definition Method.hpp:20