Skip to content

Commit

Permalink
Make AppEntitlements() work in the simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Mar 9, 2020
1 parent fa03338 commit 670dfec
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/AppGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#import <Foundation/Foundation.h>
#include <mach-o/loader.h>
#include <mach-o/getsect.h>
#include <dlfcn.h>

struct cs_blob_index {
Expand Down Expand Up @@ -45,6 +46,19 @@
if (header->magic != MH_MAGIC_64)
return nil;

// Simulator executables have fake entitlements in the code signature. The real entitlements can be found in an __entitlements section.
size_t entitlements_size;
uint8_t *entitlements_data = getsectiondata(header, "__TEXT", "__entitlements", &entitlements_size);
if (entitlements_data != NULL) {
NSData *data = [NSData dataWithBytesNoCopy:entitlements_data
length:entitlements_size
freeWhenDone:NO];
return entitlements = [NSPropertyListSerialization propertyListWithData:data
options:NSPropertyListImmutable
format:nil
error:nil];
}

// Find the LC_CODE_SIGNATURE
struct load_command *lc = (void *) (base + sizeof(*header));
struct linkedit_data_command *cs_lc = NULL;
Expand Down

0 comments on commit 670dfec

Please sign in to comment.