C++: Add il2cppi_is_initialized() API to scaffolding

This commit is contained in:
Katy Coe
2020-09-09 17:54:27 +02:00
parent 2c5e34c724
commit 605734a020
2 changed files with 15 additions and 1 deletions

View File

@@ -126,6 +126,8 @@ namespace Il2CppInspector.Properties {
///#include <sstream>
///#include <iomanip>
///
///#include "il2cpp-metadata-version.h"
///
///// Helper function to get the module base address
///uintptr_t il2cppi_get_base_address();
///
@@ -135,7 +137,7 @@ namespace Il2CppInspector.Properties {
///// Helper function to open a new console window and redirect stdout there
///void il2cppi_new_console();
///
///// Helper function to convert Il2CppString to st [rest of string was truncated]";.
///// Helper [rest of string was truncated]";.
/// </summary>
internal static string Cpp_HelpersH {
get {

View File

@@ -207,6 +207,8 @@ std::string il2cppi_to_string(app::String* str) {
#include &lt;sstream&gt;
#include &lt;iomanip&gt;
#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&lt;typename T&gt; bool il2cppi_is_initialized(T* metadataItem) {
#if __IL2CPP_METADATA_VERISON &lt; 270
return *metadataItem != 0;
#else
// Metadata &gt;=27 (Unity 2020.2)
return !((uintptr_t) *metadataItem &amp; 1);
#endif
}
// Helper function to convert a pointer to hex
template&lt;typename T&gt; std::string to_hex_string(T i) {
std::stringstream stream;