Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I obtain the attribute values in Level #566

Open
Fuduji95 opened this issue Nov 5, 2024 · 2 comments
Open

How can I obtain the attribute values in Level #566

Fuduji95 opened this issue Nov 5, 2024 · 2 comments

Comments

@Fuduji95
Copy link

Fuduji95 commented Nov 5, 2024

This is part of the content of the level class

public class Level : ZeroFormattableBase<Level, string, int, List<Bubble>, BoardCondition, int, bool, int> // TypeDefIndex: 13106
{
	// Properties
	public string author { get; set; }

	// Methods
	// RVA: 0x21692A8 Offset: 0x21682A8 VA: 0x21692A8
	public string get_author() { }


}

This is the function being called and the return value

[AsyncStateMachine(typeof(LevelDataManager.<LoadLevel>d__9))]  
// RVA: 0x21615D0 Offset: 0x21605D0 VA: 0x21615D0
public UniTask<Level> LoadLevel(int levelNumber) { }

This is my code

 const levelItem=LevelDataManager.field<Il2Cpp.Object>("Instance").value.method("LoadLevel").invoke(2);
    console.log(levelItem)
    console.log(levelItem.handle);
    console.log(levelItem.type)
    console.log(levelItem.type.handle)
    console.log(levelItem.method("ToString").invoke())

This is the output result

console------>Data.Level
console------>0x74c3fe1fa0
console------>Cysharp.Threading.Tasks.UniTask<Data.Level>
console------>0x74bc75bdf0
console------>"Data.Level"

The help needed

I cannot get what I want through field and method, new Il2Cpp.Object(levelItem.handle) also doesn't work
The problem seems to be with the return value UniTask, which I cannot handle

@UnknownAPI
Copy link

UnknownAPI commented Nov 7, 2024

Hello, you first need to retrieve the UniTask result.
Here's a function to do so

import "frida-il2cpp-bridge";

function getUniTaskResult(uniTaskObj: Il2Cpp.Object): any {
    const awaiter = uniTaskObj.method("GetAwaiter").invoke() as Il2Cpp.Object;
    while (!(awaiter.method("get_IsCompleted").invoke() as boolean)) {}
    return awaiter.method("GetResult").invoke();
}

Here's how you can use it

Il2Cpp.perform(() => {
    const AsemblyCSharp = Il2Cpp.domain.assembly("Assembly-CSharp").image;
    const ExampleClass = AsemblyCSharp.class("LevelDataManager");
    const loadLevelMethod = ExampleClass.method("LoadLevel");
    const uniTaskObj = loadLevelMethod.invoke(2) as Il2Cpp.Object;
    const result = getUniTaskResult(uniTaskObj) as Il2Cpp.Object;
    console.log(result)
});

You can tweak the code as needed but this should help you fix your issue ! (this code assumes that LoadLevel is static but it's not)

@Fuduji95
Copy link
Author

Fuduji95 commented Nov 8, 2024

Hello, you first need to retrieve the UniTask result. Here's a function to do so

import "frida-il2cpp-bridge";

function getUniTaskResult(uniTaskObj: Il2Cpp.Object): any {
    const awaiter = uniTaskObj.method("GetAwaiter").invoke() as Il2Cpp.Object;
    while (!(awaiter.method("get_IsCompleted").invoke() as boolean)) {}
    return awaiter.method("GetResult").invoke();
}

Here's how you can use it

Il2Cpp.perform(() => {
    const AsemblyCSharp = Il2Cpp.domain.assembly("Assembly-CSharp").image;
    const ExampleClass = AsemblyCSharp.class("LevelDataManager");
    const loadLevelMethod = ExampleClass.method("LoadLevel");
    const uniTaskObj = loadLevelMethod.invoke(2) as Il2Cpp.Object;
    const result = getUniTaskResult(uniTaskObj) as Il2Cpp.Object;
    console.log(result)
});

You can tweak the code as needed but this should help you fix your issue ! (this code assumes that LoadLevel is static but it's not)

Thank you for answering the question I raised due to my insufficient development skills. I can now use the Level object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants