C++: Add il2cppi_is_initialized() API to scaffolding
This commit is contained in:
@@ -207,6 +207,8 @@ std::string il2cppi_to_string(app::String* str) {
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "il2cpp-metadata-version.h"
|
||||
|
||||
// Helper function to get the module base address
|
||||
uintptr_t il2cppi_get_base_address();
|
||||
|
||||
@@ -222,6 +224,16 @@ std::string il2cppi_to_string(Il2CppString* str);
|
||||
// Helper function to convert System.String to std::string
|
||||
std::string il2cppi_to_string(app::String* str);
|
||||
|
||||
// Helper function to check if a metadata usage pointer is initialized
|
||||
template<typename T> bool il2cppi_is_initialized(T* metadataItem) {
|
||||
#if __IL2CPP_METADATA_VERISON < 270
|
||||
return *metadataItem != 0;
|
||||
#else
|
||||
// Metadata >=27 (Unity 2020.2)
|
||||
return !((uintptr_t) *metadataItem & 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Helper function to convert a pointer to hex
|
||||
template<typename T> std::string to_hex_string(T i) {
|
||||
std::stringstream stream;
|
||||
|
||||
Reference in New Issue
Block a user