unityhook: check for new entrypoint

The new entrypoint has been introduced in UnityDoorstop 4.1.0,
which is used by BepInEx 5.4.23.

This commit check for new entrypoint to support new version
of BepInEx.
This commit is contained in:
arcfox 2024-05-09 23:37:20 +08:00
parent 25e954fb55
commit 00b3d5b7bb
Signed by untrusted user: Yusen0727
GPG Key ID: D330D33893DB5212

View File

@ -118,9 +118,19 @@ void doorstop_invoke(void* domain) {
return;
}
void *desc = mono_method_desc_new("*:Main", FALSE);
// BepInEx 5.4.23 has upgrade its doorstop version,
// which forces entrypoint to Doorstop.Entrypoint:Start
void *desc = mono_method_desc_new("Doorstop.Entrypoint:Start", TRUE);
void *method = mono_method_desc_search_in_image(desc, image);
if (!method) {
// Fallback to old entrypoint definition.
desc = mono_method_desc_new("*:Main", FALSE);
method = mono_method_desc_search_in_image(desc, image);
}
if (!method) {
dprintf("Unity: Assembly does not have a valid entrypoint.\n");
free(dll_path);