summaryrefslogtreecommitdiff
path: root/inject.m
diff options
context:
space:
mode:
Diffstat (limited to 'inject.m')
-rw-r--r--inject.m10
1 files changed, 5 insertions, 5 deletions
diff --git a/inject.m b/inject.m
index 64eacd2..5f39e2b 100644
--- a/inject.m
+++ b/inject.m
@@ -150,15 +150,15 @@ NSArray *filteredHashes(uint64_t trust_chain, NSDictionary *hashes) {
#endif
}
-int injectTrustCache(NSArray <NSString*> *files, uint64_t trust_chain) {
+int injectTrustCache(NSArray <NSString*> *files, uint64_t trust_chain, int (*pmap_load_trust_cache)(uint64_t, size_t))
+{
@autoreleasepool {
struct trust_mem mem;
uint64_t kernel_trust = 0;
mem.next = rk64(trust_chain);
mem.count = 0;
- *(uint64_t *)&mem.uuid[0] = 0xabadbabeabadbabe;
- *(uint64_t *)&mem.uuid[8] = 0xabadbabeabadbabe;
+ arc4random_buf(&mem.uuid, 16);
NSMutableDictionary *hashes = [NSMutableDictionary new];
int errors=0;
@@ -190,7 +190,7 @@ int injectTrustCache(NSArray <NSString*> *files, uint64_t trust_chain) {
return errors;
}
- size_t length = (sizeof(mem) + hashesToInject * TRUST_CDHASH_LEN + 0xFFFF) & ~0xFFFF;
+ size_t length = (sizeof(mem) + hashesToInject * TRUST_CDHASH_LEN + 0x3FFF) & ~0x3FFF;
char *buffer = malloc(hashesToInject * TRUST_CDHASH_LEN);
if (buffer == NULL) {
fprintf(stderr, "Unable to allocate memory for cdhashes: %s\n", strerror(errno));
@@ -206,7 +206,7 @@ int injectTrustCache(NSArray <NSString*> *files, uint64_t trust_chain) {
mem.count = hashesToInject;
kwrite(kernel_trust, &mem, sizeof(mem));
kwrite(kernel_trust + sizeof(mem), buffer, mem.count * TRUST_CDHASH_LEN);
- wk64(trust_chain, kernel_trust);
+ pmap_load_trust_cache(kernel_trust, length);
return (int)errors;
}