offsetdump.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // offsetdump.m
  3. // Meridian
  4. //
  5. // Created by Ben Sparkes on 30/03/2018.
  6. // Copyright © 2018 Ben Sparkes. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #include "v0rtex.h"
  10. void dumpOffsetsToFile(offsets_t *offsets, uint64_t kernel_base, uint64_t kernel_slide) {
  11. NSData *blob = [NSData dataWithContentsOfFile:@"/meridian/offsets.plist"];
  12. NSMutableDictionary *off_file = [NSPropertyListSerialization propertyListWithData:blob
  13. options:NSPropertyListMutableContainers
  14. format:nil
  15. error:nil];
  16. // There is probably a better way than doing this all manually, but ¯\_(ツ)_/¯
  17. // We don't really need to log *all* of these, but better safe than PR'ing, right?
  18. // See the amfid patch for an example of using this (amfid/main.m)
  19. off_file[@"Base"] = [NSString stringWithFormat:@"0x%016llx", offsets->base];
  20. off_file[@"KernelBase"] = [NSString stringWithFormat:@"0x%016llx", kernel_base];
  21. off_file[@"KernelSlide"] = [NSString stringWithFormat:@"0x%016llx", kernel_slide];
  22. off_file[@"SizeOfTask"] = [NSString stringWithFormat:@"0x%016llx", offsets->sizeof_task];
  23. off_file[@"TaskItkSelf"] = [NSString stringWithFormat:@"0x%016llx", offsets->task_itk_self];
  24. off_file[@"TaskItkRegistered"] = [NSString stringWithFormat:@"0x%016llx", offsets->task_itk_registered];
  25. off_file[@"TaskBsdInfo"] = [NSString stringWithFormat:@"0x%016llx", offsets->task_bsd_info];
  26. off_file[@"ProcUcred"] = [NSString stringWithFormat:@"0x%016llx", offsets->proc_ucred];
  27. off_file[@"VmMapHdr"] = [NSString stringWithFormat:@"0x%016llx", offsets->vm_map_hdr];
  28. off_file[@"IpcSpaceIsTask"] = [NSString stringWithFormat:@"0x%016llx", offsets->ipc_space_is_task];
  29. off_file[@"RealhostSpecial"] = [NSString stringWithFormat:@"0x%016llx", offsets->realhost_special];
  30. off_file[@"IOUserClientIPC"] = [NSString stringWithFormat:@"0x%016llx", offsets->iouserclient_ipc];
  31. off_file[@"VtabGetRetainCount"] = [NSString stringWithFormat:@"0x%016llx", offsets->vtab_get_retain_count];
  32. off_file[@"VtabGetExternalTrapForIndex"] = [NSString stringWithFormat:@"0x%016llx", offsets->vtab_get_external_trap_for_index];
  33. off_file[@"ZoneMap"] = [NSString stringWithFormat:@"0x%016llx", offsets->zone_map];
  34. off_file[@"KernelMap"] = [NSString stringWithFormat:@"0x%016llx", offsets->kernel_map];
  35. off_file[@"KernelTask"] = [NSString stringWithFormat:@"0x%016llx", offsets->kernel_task];
  36. off_file[@"RealHost"] = [NSString stringWithFormat:@"0x%016llx", offsets->realhost];
  37. off_file[@"CopyIn"] = [NSString stringWithFormat:@"0x%016llx", offsets->copyin];
  38. off_file[@"CopyOut"] = [NSString stringWithFormat:@"0x%016llx", offsets->copyout];
  39. off_file[@"Chgproccnt"] = [NSString stringWithFormat:@"0x%016llx", offsets->chgproccnt];
  40. off_file[@"KauthCredRef"] = [NSString stringWithFormat:@"0x%016llx", offsets->kauth_cred_ref];
  41. off_file[@"IpcPortAllocSpecial"] = [NSString stringWithFormat:@"0x%016llx", offsets->ipc_port_alloc_special];
  42. off_file[@"IpcKobjectSet"] = [NSString stringWithFormat:@"0x%016llx", offsets->ipc_kobject_set];
  43. off_file[@"IpcPortMakeSend"] = [NSString stringWithFormat:@"0x%016llx", offsets->ipc_port_make_send];
  44. off_file[@"OSSerializerSerialize"] = [NSString stringWithFormat:@"0x%016llx", offsets->osserializer_serialize];
  45. off_file[@"RopLDR"] = [NSString stringWithFormat:@"0x%016llx", offsets->rop_ldr_x0_x0_0x10];
  46. off_file[@"RootVnode"] = [NSString stringWithFormat:@"0x%016llx", offsets->root_vnode];
  47. off_file[@"VfsContextCurrent"] = [NSString stringWithFormat:@"0x%016llx", offsets->vfs_context_current];
  48. off_file[@"VnodeGetFromFD"] = [NSString stringWithFormat:@"0x%016llx", offsets->vnode_getfromfd];
  49. off_file[@"VnodeGetAttr"] = [NSString stringWithFormat:@"0x%016llx", offsets->vnode_getattr];
  50. off_file[@"CSBlobEntDictSet"] = [NSString stringWithFormat:@"0x%016llx", offsets->csblob_ent_dict_set];
  51. off_file[@"SHA1Init"] = [NSString stringWithFormat:@"0x%016llx", offsets->sha1_init];
  52. off_file[@"SHA1Update"] = [NSString stringWithFormat:@"0x%016llx", offsets->sha1_update];
  53. off_file[@"SHA1Final"] = [NSString stringWithFormat:@"0x%016llx", offsets->sha1_final];
  54. [off_file writeToFile:@"/meridian/offsets.plist" atomically:YES];
  55. }