Skip to content

An error occurred while running the StartCoroutine function #46

@solomode0001

Description

@solomode0001

Logs:

MethodAccessException: Attempt to access method 'System.Collections.IEnumerator.MoveNext' on type 'IEnumerator.BNM.Coroutine' failed.

Code:

BNM::Method<void*> StartCoroutine;

BNM::Coroutine::IEnumerator MyEnumerator() {
    LOGI("MyEnumerator Started");
    co_yield BNM::Coroutine::WaitForSeconds(5.0f);
    LOGI("MyEnumerator Finished");
   co_return;
}

void (*_PlayerScript_Start)(void*);
void PlayerScript_Start(BNM::UnityEngine::MonoBehaviour *ins) {
    _PlayerScript_Start(ins);

    auto enumerator = MyEnumerator().get();
    auto r = StartCoroutine[ins](enumerator);
    LOGI("Invoked: %p", r);
}

void OnLoad() {
    StartCoroutine = BNM::Class(OBFUSCATE_BNM("UnityEngine"), OBFUSCATE_BNM("MonoBehaviour")).GetMethod(OBFUSCATE_BNM("StartCoroutine"), {OBFUSCATE_BNM("routine")});

    auto playerScript = BNM::Class("", "PlayerScript");
    BNM::InvokeHook(playerScript.GetMethod("Start"), PlayerScript_Start, _PlayerScript_Start);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions