Skip to content

Commit 0d49e45

Browse files
committed
Add wrapper for LoadFromMemoryAsync_Internal
1 parent dd365ed commit 0d49e45

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/ext.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,14 @@ mod asset_bundle_ext {
13861386
use crate::unity_engine::assetbundlecreaterequest::AssetBundleCreateRequest;
13871387
use unity2::{Array, OptionalMethod};
13881388

1389+
#[skyline::from_offset(0x491ff0)]
1390+
unsafe fn engage_method_from_full_name(name: *const u8) -> *const u8;
1391+
1392+
fn lookup_method_by_signature(full_signature: &str) -> *const u8 {
1393+
let c = std::ffi::CString::new(full_signature).unwrap();
1394+
unsafe { engage_method_from_full_name(c.as_ptr() as *const u8) }
1395+
}
1396+
13891397
pub trait AssetBundleExt {
13901398
fn load_from_memory_async_internal(binary: Array<u8>, crc: u32) -> AssetBundleCreateRequest;
13911399
}
@@ -1394,15 +1402,14 @@ mod asset_bundle_ext {
13941402
fn load_from_memory_async_internal(binary: Array<u8>, crc: u32) -> AssetBundleCreateRequest {
13951403
static METHOD_PTR: ::std::sync::OnceLock<usize> = ::std::sync::OnceLock::new();
13961404
let ptr = *METHOD_PTR.get_or_init(|| {
1397-
let mi = ::unity2::lookup::method_info_on_class(
1398-
<AssetBundle as ::unity2::ClassIdentity>::class(),
1399-
"LoadFromMemoryAsync_Internal",
1400-
2,
1401-
)
1402-
.expect(
1403-
"UnityEngine.AssetBundle.LoadFromMemoryAsync_Internal not found in metadata",
1405+
let p = lookup_method_by_signature(
1406+
"UnityEngine.AssetBundle::LoadFromMemoryAsync_Internal(System.Byte[],System.UInt32)",
1407+
);
1408+
assert!(
1409+
!p.is_null(),
1410+
"UnityEngine.AssetBundle.LoadFromMemoryAsync_Internal not found via runtime full-signature lookup"
14041411
);
1405-
mi.method_ptr as usize
1412+
p as usize
14061413
});
14071414

14081415
type RawFn = extern "C" fn(Array<u8>, u32, OptionalMethod) -> AssetBundleCreateRequest;

0 commit comments

Comments
 (0)