@@ -180,6 +180,12 @@ G_DEFINE_TYPE_EXTENDED(LoaderInvocationListener,
180
180
#define READ_ASSET_FILE_ADDRESS (minecraftpeBaseAddr + 0xC8E3CC4)
181
181
#define RESOURCE_LOCATION_ADDRESS (gum_module_find_export_by_name("libminecraftpe.so", "_ZN16ResourceLocationC2ERKN4Core4PathE"))
182
182
#endif
183
+ #ifdef V1_20_50_21
184
+ #define RESOURCE_PACK_MANAGER_ADDRESS (minecraftpeBaseAddr + 0x9929E20)
185
+ #define READ_ASSET_FILE_ADDRESS (minecraftpeBaseAddr + 0x6ABDC6C)
186
+ #define RESOURCE_LOCATION_ADDRESS (gum_module_find_export_by_name("libminecraftpe.so", "_ZN16ResourceLocationC2ERKN4Core4PathE"))
187
+ #endif
188
+
183
189
typedef enum _HookId HookId ;
184
190
enum _HookId {
185
191
RESOURCE_PACK_MANAGER ,
@@ -247,6 +253,12 @@ void __attribute__((destructor)) dispose() {
247
253
gum_deinit ();
248
254
}
249
255
256
+ typedef struct _std_string {
257
+ size_t cap ;
258
+ size_t size ;
259
+ char * data ;
260
+ } std_string ;
261
+
250
262
bool std_string_is_short (void * str ) {
251
263
return (* (char * )str & 1 ) == 0 ;
252
264
}
@@ -271,6 +283,30 @@ bool std_string_is_empty(void* str) {
271
283
return std_string_size (str ) == 0 ;
272
284
}
273
285
286
+ void std_string_constructor (std_string * str , const char * data ) {
287
+ size_t dataLen = strlen (data );
288
+ str -> cap = dataLen + 1 ;
289
+ if ((str -> cap & 1 ) == 0 ) {
290
+ str -> cap ++ ;
291
+ }
292
+ str -> size = dataLen ;
293
+ str -> data = (char * )malloc (str -> cap );
294
+ strcpy (str -> data , data );
295
+ }
296
+
297
+ void std_string_destructor (void * str ) {
298
+ if (!std_string_is_short (str ) && std_string_data (str ) != NULL ) {
299
+ free (std_string_data (str ));
300
+ }
301
+ }
302
+
303
+ typedef struct _ResourceLocation {
304
+ int32_t mFileSystem ;
305
+ std_string mPath ;
306
+ uint64_t mPathHash ;
307
+ uint64_t mFullHash ;
308
+ } ResourceLocation ;
309
+
274
310
//==========================================================================================================================================
275
311
276
312
static void loader_invocation_listener_class_init (LoaderInvocationListenerClass * klass ) {
@@ -293,6 +329,7 @@ static void loader_invocation_listener_on_enter(GumInvocationListener* listener,
293
329
HookId hookId = GUM_IC_GET_FUNC_DATA (ic , HookId );
294
330
295
331
switch (hookId ) {
332
+ //ResourcePackManager::ResourcePackManager
296
333
case RESOURCE_PACK_MANAGER : {
297
334
gpointer needsToInitialize = gum_invocation_context_get_nth_argument (ic , 3 );
298
335
@@ -316,7 +353,7 @@ static void loader_invocation_listener_on_enter(GumInvocationListener* listener,
316
353
return ;
317
354
}
318
355
319
- if (strncmp (data , "renderer/materials/" , 19 ) == 0 && strncmp (data + size - 13 , ".material.bin" , 13 ) == 0 ) {
356
+ if (( strncmp (data , "renderer/materials/" , 19 ) == 0 || strncmp ( data , "assets/renderer/materials/" , 26 ) == 0 ) && strncmp (data + size - 13 , ".material.bin" , 13 ) == 0 ) {
320
357
#ifdef DEBUG
321
358
printf ("filename=%s\n" , data );
322
359
#endif
@@ -355,26 +392,31 @@ static void loader_invocation_listener_on_leave(GumInvocationListener* listener,
355
392
bool (* load )(void * , void * , void * ) = (bool (* )(void * , void * , void * ))* (vptr + 2 );
356
393
357
394
//void ResourceLocation::ResourceLocation(ResourceLocation* this, Core::Path* path)
358
- void (* ResourceLocation )(void * , void * ) = (void (* )(void * , void * ))ResourceLocation_ResourceLocation ;
395
+ void (* ResourceLocationConstructor )(void * , void * ) = (void (* )(void * , void * ))ResourceLocation_ResourceLocation ;
396
+
397
+ ResourceLocation location = {0 };
398
+ const char * data = std_string_data (state -> filename );
399
+ if (strncmp (data , "assets/" , 7 ) != 0 ) {
400
+ ResourceLocationConstructor (& location , state -> filename );
401
+ } else {
402
+ std_string fileName = {0 };
403
+ std_string_constructor (& fileName , data + 7 );
404
+ ResourceLocationConstructor (& location , & fileName );
405
+ std_string_destructor (& fileName );
406
+ }
359
407
360
- void * location = malloc (0x50 );
361
- memset (location , 0 , 0x50 );
362
- ResourceLocation (location , state -> filename );
408
+ std_string resourceStream = {0 };
409
+ bool result = load (resourcePackManager , & location , & resourceStream );
363
410
364
- void * resourceStream = malloc (3 * sizeof (size_t ));
365
- memset (resourceStream , 0 , 3 * sizeof (size_t ));
366
- bool result = load (resourcePackManager , location , resourceStream );
411
+ std_string_destructor (& location .mPath );
367
412
368
413
if (result ) {
369
414
#ifdef DEBUG
370
415
printf ("ResourcePackManager::load returned true\n" );
371
416
#endif
372
- if (!std_string_is_empty (resourceStream )) {
373
- if (!std_string_is_short (state -> retstr ) && std_string_data (state -> retstr ) != NULL ) {
374
- free (std_string_data (state -> retstr ));
375
- }
376
-
377
- memcpy (state -> retstr , resourceStream , 3 * sizeof (size_t ));
417
+ if (!std_string_is_empty (& resourceStream )) {
418
+ std_string_destructor (state -> retstr );
419
+ memcpy (state -> retstr , & resourceStream , sizeof (resourceStream ));
378
420
}
379
421
} else {
380
422
#ifdef DEBUG
@@ -385,9 +427,6 @@ static void loader_invocation_listener_on_leave(GumInvocationListener* listener,
385
427
#ifdef DEBUG
386
428
printf ("\n" );
387
429
#endif
388
-
389
- free (resourceStream );
390
- free (location );
391
430
}
392
431
}
393
432
break ;
0 commit comments