TypeTreeDumper icon indicating copy to clipboard operation
TypeTreeDumper copied to clipboard

Some questions.

Open 0x900x90 opened this issue 4 years ago • 13 comments

I tried to build this project. Got some errors. I removed 2019 TypeTree's because i got CS0208 errors on them.

CS0208 - "Cannot take the address of, get the size of, or declare a pointer to a managed type.

When i tried to start an exe with Unity 5.4.5 and 5.6.7 and got different unresolved symbol errors. BTW i can't redirect stdout to file...

OK. Then i decided to give a chance to this old injector. It works with unity player exe's. https://gist.github.com/mafaca/ec867e9dc30a8e092302dfda120c42ba

Everything works perfect except MonoBehaviour case.

GetTypeTree fails only in MonoBehaviour case.

Here is some code

Object *obj = Object__Produce(rtti, rtti, 0, *kMemBaseObject, 0); TypeTree *typeTree = (TypeTree *)malloc(sizeof(TypeTree));

[code] if(!TypeTreeCache__GetTypeTree(obj, 0x100, typeTree)) { fprintf(dumpFile, "Can't get TypeTree for %s...\n", rtti->ClassName); fflush(dumpFile); free(typeTree);

return false;

} [/code]

Maybe you have any clues why this happens?

0x900x90 avatar Jan 26 '21 12:01 0x900x90

Sorry. I can't edit my message. GitHub don't want to work properly with my browser...

0x900x90 avatar Jan 26 '21 12:01 0x900x90

@0x900x90

I tried to build this project. Got some errors. I removed 2019 TypeTree's because i got CS0208 errors on them.

CS0208 - "Cannot take the address of, get the size of, or declare a pointer to a managed type.

Your tools (Visual Studio, .NET SDK, etc) are outdated if you get this error, the project requires at least C# 8.

When i tried to start an exe with Unity 5.4.5 and 5.6.7 and got different unresolved symbol errors. BTW i can't redirect stdout to file...

Could you post the errors that you received?

Everything works perfect except MonoBehaviour case.

GetTypeTree fails only in MonoBehaviour case.

Maybe you have any clues why this happens?

At the moment, the return value of TypeTreeCache::GetTypeTree isn't completely understood. At first I thought it was just a success value, but it still produces a valid type tree even when it returns false. So you should be able to just ignore the return value.

DaZombieKiller avatar Jan 26 '21 14:01 DaZombieKiller

Compilation error CS0208 happens in TypeTree.V2019_1.cs

internal struct TypeTree { public TypeTreeShareableData* Data; <-- This string public TypeTreeShareableData PrivateData; }

This happens with Unity 5.4.5 https://i.imgur.com/YAgeCby.png This happens with Unity 5.6.7 https://i.imgur.com/erEO56j.png

Both x86.

0x900x90 avatar Jan 26 '21 14:01 0x900x90

Compilation error CS0208 happens in TypeTree.V2019_1.cs

internal struct TypeTree { public TypeTreeShareableData* Data; <-- This string public TypeTreeShareableData PrivateData; }

Yeah, this is because the code needs to be compiled with C# 8. TypeTreeShareableData contains generic types, so on C# 7 and older you can't use it with pointers.

This happens with Unity 5.4.5 https://i.imgur.com/YAgeCby.png This happens with Unity 5.6.7 https://i.imgur.com/erEO56j.png

Both x86.

The tool has currently only been tested on 64-bit versions of Unity (except for Unity 4.x). I assume those symbols have minor naming differences on x86, which should be simple to fix.

DaZombieKiller avatar Jan 26 '21 14:01 DaZombieKiller

I got an idea with ignoring return value of GetTypeTree right after i created my post with question about it. It works!

Thank you for your answer. Maybe i intercepted your thoughts somehow :o).

0x900x90 avatar Jan 26 '21 14:01 0x900x90

Understood. Thanks.

0x900x90 avatar Jan 26 '21 15:01 0x900x90

If you change this line: https://github.com/DaZombieKiller/TypeTreeDumper/blob/f9d75f3ecdc0adf502ea3b45f9e8c92c468c2b6d/Unity/RuntimeTypes.cs#L56 to this:

ClassIDToRTTI = resolver.ResolveFunction<ClassIDToRTTI>(
    "?ClassIDToRTTI@Object@@SAPEAURTTI@@H@Z",
    "?ClassIDToRTTI@Object@@SAPAURTTI@@H@Z"
);

Does it work?

DaZombieKiller avatar Jan 26 '21 15:01 DaZombieKiller

I receive the same errors as with Unity 5.6.7. I understood what i should do with this errors. Thank you.

0x900x90 avatar Jan 26 '21 15:01 0x900x90

The unresolved symbol errors should now be fixed in https://github.com/DaZombieKiller/TypeTreeDumper/commit/7996e0af87c44f20d8d4b1791db6074fb76a6f3d.

DaZombieKiller avatar Jan 26 '21 15:01 DaZombieKiller

I fixed this function name ??0UnityVersion@@QAA@PBD@Z

Program starts and i don't see any error messages. But i don't see any output. Output files should be in the same directory with main exe?

I checked Unity folder and found crash report folder in it.

I think not so many people using x86 programs this days. So, there is no reason for all this work with x86 Unity.

0x900x90 avatar Jan 26 '21 18:01 0x900x90

I fixed this function name ??0UnityVersion@@QAA@PBD@Z

In the most recent commit (https://github.com/DaZombieKiller/TypeTreeDumper/commit/7996e0af87c44f20d8d4b1791db6074fb76a6f3d) I introduced NameMangling.Ptr64 to fix cases like this, which changes the symbol string to $"??0UnityVersion@@Q{NameMangling.Ptr64}AA@P{NameMangling.Ptr64}BD@Z" instead of "??0UnityVersion@@QEAA@PEBD@Z".

Program starts and i don't see any error messages. But i don't see any output. [...] I checked Unity folder and found crash report folder in it.

I've had this happen on my end with Unity 5 when the licensing information is missing, but the crash report seems strange.

Program starts and i don't see any error messages. But i don't see any output. Output files should be in the same directory with main exe?

Yeah. It creates a folder called Output for all of the files.

I think not so many people using x86 programs this days. So, there is no reason for all this work with x86 Unity.

I agree. The only reason x86 support is even considered in this project is because old versions of Unity are 32-bit only.

DaZombieKiller avatar Jan 26 '21 19:01 DaZombieKiller

In 5.4.5 this function has a name ??0UnityVersion@@QAE@PEBD@Z That's why i fixed it manually.

Thank you for spending your time to answer my questions.

0x900x90 avatar Jan 26 '21 19:01 0x900x90

I see, so there's a __thiscall variant of it. It might be worth changing it to $"??0UnityVersion@@QAE@P{NameMangling.Ptr64}BD@Z" to support both x86 and x64 at the same time then. I'll do a new commit for that now. EDIT: Done https://github.com/DaZombieKiller/TypeTreeDumper/commit/e27c74c85490fa9fc2e08eae291bc335a61e4e86.

Thank you for spending your time to answer my questions.

No problem! I appreciate the bug reports

DaZombieKiller avatar Jan 26 '21 19:01 DaZombieKiller