Git Product home page Git Product logo

Comments (14)

sneakyevil avatar sneakyevil commented on May 24, 2024

You could wrap the string in u8"..." if that doesn't work maybe best way would be to use get all fields and cache the offset and read it directly.

from il2cpp_resolver.

Patrick-van-Halm avatar Patrick-van-Halm commented on May 24, 2024

So I tried both, the u8 method throws the same error and getting all fields causes also a access violation writing location.

Within the GetFields method

return reinterpret_cast<Unity::il2cppFieldInfo * (IL2CPP_CALLING_CONVENTION)(void*, void**)>(Functions.m_ClassGetFields)(m_pClass, m_pIterator);
std::vector<Unity::il2cppFieldInfo*> fields;
playerInstance->FetchFields(&fields);

for (Unity::il2cppFieldInfo* field : fields) {
      std::cout << field->m_pName << std::endl; // Just so I can add a breakpoint
}

Am I possibly accessing a class wrong? I am going to try and run it within a different application to see if it works there.

from il2cpp_resolver.

Patrick-van-Halm avatar Patrick-van-Halm commented on May 24, 2024

Alright with a quick test on a different game I found the issue. It seems like

Unity::CComponent* playerInstance = Unity::Object::FindObjectOfType<Unity::CComponent>("Player");

returns an incorrect pointer. If I look at the debug information the m_pName is not equal to "Player" but rather equal to "ðžê—z�".

from il2cpp_resolver.

Patrick-van-Halm avatar Patrick-van-Halm commented on May 24, 2024

And when I change the type to Unity::il2cppClass it does contain the correct name. So I assume the definition of the Unity components are changed so I will look into that

from il2cpp_resolver.

Patrick-van-Halm avatar Patrick-van-Halm commented on May 24, 2024

It also seems like the flag "UNITY_VERSION_2022_3_8F1" is an incorrect version I currently have traced it back to Unity 2021.3.27f1

from il2cpp_resolver.

extremeblackliu avatar extremeblackliu commented on May 24, 2024

It also seems like the flag "UNITY_VERSION_2022_3_8F1" is an incorrect version I currently have traced it back to Unity 2021.3.27f1

this flag is used for unity version that higher than 2022.3.8, your problem can be solve by using field offset from target class.
seems you are trying to add a light component to camera, if the camera is the eye camera, you can try get the camera from static class Camera by calling Camera.get_current() or Camera.get_main()

from il2cpp_resolver.

karaok1 avatar karaok1 commented on May 24, 2024

Alright with a quick test on a different game I found the issue. It seems like

Unity::CComponent* playerInstance = Unity::Object::FindObjectOfType<Unity::CComponent>("Player");

returns an incorrect pointer. If I look at the debug information the m_pName is not equal to "Player" but rather equal to "ðžê—z�".

The problem might be that you are searching for the player, but the player is probably a GameObject rather than being a Component. They are different things in Unity. The former one has an instance and is an object in the hierarchy but a component is not.

from il2cpp_resolver.

Patrick-van-Halm avatar Patrick-van-Halm commented on May 24, 2024

Alright with a quick test on a different game I found the issue. It seems like

Unity::CComponent* playerInstance = Unity::Object::FindObjectOfType<Unity::CComponent>("Player");

returns an incorrect pointer. If I look at the debug information the m_pName is not equal to "Player" but rather equal to "ðžê—z�".

The problem might be that you are searching for the player, but the player is probably a GameObject rather than being a Component. They are different things in Unity. The former one has an instance and is an object in the hierarchy but a component is not.

I know the difference however in using Il2CppDumper it specifically mentions Player in the root namespace. The class also returns correctly with the corresponding class so yes it's a component.

from il2cpp_resolver.

Patrick-van-Halm avatar Patrick-van-Halm commented on May 24, 2024

It also seems like the flag "UNITY_VERSION_2022_3_8F1" is an incorrect version I currently have traced it back to Unity 2021.3.27f1

this flag is used for unity version that higher than 2022.3.8, your problem can be solve by using field offset from target class. seems you are trying to add a light component to camera, if the camera is the eye camera, you can try get the camera from static class Camera by calling Camera.get_current() or Camera.get_main()

I know its just accessing other classes causes the same error...

from il2cpp_resolver.

extremeblackliu avatar extremeblackliu commented on May 24, 2024

I know the difference however in using Il2CppDumper it specifically mentions Player in the root namespace. The class also returns correctly with the corresponding class so yes it's a component.

see

The problem might be that you are searching for the player, but the player is probably a GameObject rather than being a Component. They are different things in Unity. The former one has an instance and is an object in the hierarchy but a component is not.

game obfuscate doesn't affects system classes like gameobject, transform, camera ... etc, so when you get their classname, you should have non-obfuscate name or you messed up.
try get it as gameobject then get the component which is you need from the gameobject.
this step is literally same as you writing c# script for unity, just think it.

from il2cpp_resolver.

extremeblackliu avatar extremeblackliu commented on May 24, 2024

also, own thread is not recommended, its very unstable and randomly crashes.
use https://sneakyevil.gitbook.io/il2cpp-resolver/callback/onupdate for instead

from il2cpp_resolver.

karaok1 avatar karaok1 commented on May 24, 2024

May I ask, which game is this?

from il2cpp_resolver.

Patrick-van-Halm avatar Patrick-van-Halm commented on May 24, 2024

also, own thread is not recommended, its very unstable and randomly crashes. use https://sneakyevil.gitbook.io/il2cpp-resolver/callback/onupdate for instead

Also tried this without any luck

from il2cpp_resolver.

Patrick-van-Halm avatar Patrick-van-Halm commented on May 24, 2024

May I ask, which game is this?

Phasmophobia

from il2cpp_resolver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.