Skip to content

Commit

Permalink
Add API to attach native threads to the il2cpp domain
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschwarzer committed Sep 3, 2024
1 parent e516377 commit f8cb6da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions projects/Modloader/il2cpp_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,10 @@ namespace il2cpp {

std::string get_class_namespace(Il2CppClass* klass) { return {il2cpp_class_get_namespace(klass)}; }

void attach_thread() {
il2cpp_thread_attach(il2cpp_domain_get());
}

/**
* Converts a C# string to std::string by truncating characters.
* May lose special characters.
Expand Down
2 changes: 2 additions & 0 deletions projects/Modloader/il2cpp_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ namespace il2cpp {

IL2CPP_MODLOADER_DLLEXPORT std::string get_class_namespace(Il2CppClass* klass);

IL2CPP_MODLOADER_DLLEXPORT void attach_thread();

template<typename Return = Il2CppClass>
Return* get_class(std::string_view namezpace, std::string_view name) {
return reinterpret_cast<Return*>(untyped::get_class(namezpace, name));
Expand Down

0 comments on commit f8cb6da

Please sign in to comment.