When using the AssetsTools backend in TypeTreeGeneratorAPI, the behavior of load_il2cpp() is different from that of load_local_dll_folder(). load_local_dll_folder() will include a ".dll" at the end of each loaded assembly name, while load_il2cpp() will not. Example script and output showcasing this:
from UnityPy.helpers.TypeTreeGenerator import TypeTreeGenerator
generator_mono = TypeTreeGenerator('2020.3.32f1', generator="AssetsTools")
# Loading DummyDLLs dumped from LukeFZ's il2cppInsector
generator_mono.load_local_dll_folder("./test/v0.11/inspectordll/")
mono_dlls = generator_mono.get_loaded_dll_names()
generator_il2cpp = TypeTreeGenerator('2020.3.32f1', generator="AssetsTools")
bin = open("./test/v0.11/UnityFramework", "rb").read()
metadata = open("./test/v0.11/global-metadata.dat", "rb").read()
generator_il2cpp.load_il2cpp(bin,metadata)
il2cpp_dlls = generator_il2cpp.get_loaded_dll_names()
# Sort lists to make names lineup
mono_dlls.sort()
il2cpp_dlls.sort()
print(f"Mono DLLs: {mono_dlls[0]}, {mono_dlls[1]}, {mono_dlls[2]}")
print(f"IL2CPP DLLs: {il2cpp_dlls[0]}, {il2cpp_dlls[1]}, {il2cpp_dlls[2]}")
Output:
Mono DLLs: ACTk.Runtime.dll, AddressablesPlayAssetDelivery.dll, AppsFlyer.dll
IL2CPP DLLs: ACTk.Runtime, AddressablesPlayAssetDelivery, AppsFlyer
This causes issues when UnityPy tries to get the type trees from TypeTreeGeneratorAPI as it will always pass in the assembly name with a ".dll" at the end, and TypeTreeGeneratorAPI will simply return a "Sequence contains no matching element" exception when it can't find the assembly name with the extension.
Error generating tree nodes:
Sequence contains no matching element
Note that in my testing this only happens with the AssetsTools backend. The other two backends seem to have consistent behavior between the loading methods, but since the type trees from those don't seem to be correct for the game I'm working with, I have to stick with AssetsTools.
AssetStudio backend output:
Mono DLLs: ACTk.Runtime.dll, AddressablesPlayAssetDelivery.dll, AppsFlyer.dll
IL2CPP DLLs: ACTk.Runtime.dll, AddressablesPlayAssetDelivery.dll, AppsFlyer.dll
AssetRipper backend output:
Mono DLLs: ACTk.Runtime, AddressablesPlayAssetDelivery, AppsFlyer
IL2CPP DLLs: ACTk.Runtime, AddressablesPlayAssetDelivery, AppsFlyer
The quickest solution I have found is to strip out the ".dll" extension when before it gets passed to monoTemplateGenerator.GetTemplateFieldPatch() function in the AssetsTools backend file. I haven't extensively tested this yet, but for the game I'm working with this seems fine.
--- a/TypeTreeGeneratorAPI/TypeTreeGenerator/AssetsTools/AssetsToolsGenerator.cs
+++ b/TypeTreeGeneratorAPI/TypeTreeGenerator/AssetsTools/AssetsToolsGenerator.cs
@@ -68,6 +68,7 @@ namespace TypeTreeGeneratorAPI.TypeTreeGenerator.AssetsTools
} else {
#if ENABLE_IL2CPP
monoTemplateGenerator = cpp2IlGenerator;
+ assemblyName = assemblyName[..assemblyName.LastIndexOf('.')];
#else
monoTemplateGenerator = monoCecilGenerator;
#endif
I haven't looked too deep into the C# code, so there might be better solutions like making the two loaders have consistent assembly naming. But if this solution seems fine, then it could be added for the next release.
When using the AssetsTools backend in TypeTreeGeneratorAPI, the behavior of
load_il2cpp()is different from that ofload_local_dll_folder().load_local_dll_folder()will include a ".dll" at the end of each loaded assembly name, whileload_il2cpp()will not. Example script and output showcasing this:Output:
This causes issues when UnityPy tries to get the type trees from TypeTreeGeneratorAPI as it will always pass in the assembly name with a ".dll" at the end, and TypeTreeGeneratorAPI will simply return a "Sequence contains no matching element" exception when it can't find the assembly name with the extension.
Note that in my testing this only happens with the AssetsTools backend. The other two backends seem to have consistent behavior between the loading methods, but since the type trees from those don't seem to be correct for the game I'm working with, I have to stick with AssetsTools.
AssetStudio backend output:
AssetRipper backend output:
The quickest solution I have found is to strip out the ".dll" extension when before it gets passed to
monoTemplateGenerator.GetTemplateFieldPatch()function in the AssetsTools backend file. I haven't extensively tested this yet, but for the game I'm working with this seems fine.I haven't looked too deep into the C# code, so there might be better solutions like making the two loaders have consistent assembly naming. But if this solution seems fine, then it could be added for the next release.