objective c - How to get symbol address on iOS? -


i'm building library accessing objective-c python. i'm stuck on getting address of variables on ios.

let's want pointer address of cbcentralmanagerscanoptionallowduplicateskey:

nsstring *key = cbcentralmanagerscanoptionallowduplicateskey; nslog(@"address is: %p\n", key);  nsstring *key2 = dlsym(rtld_self, "cbcentralmanagerscanoptionallowduplicateskey"); nslog(@"address2 is: %p\n", key2); 

i got:

address is: 0x3a827fcc address2 is: 0x3a825514 

why different values? tried rtld_next, still same value. objective-c variables mangled somehow?

dlsym() gives address of cbcentralmanagerscanoptionallowduplicateskey variable, not contents, pointer objective-c string.

nslog(@"address  is: %p\n", & cbcentralmanagerscanoptionallowduplicateskey); nslog(@"key      is: %p\n", cbcentralmanagerscanoptionallowduplicateskey);  void *addr2 = dlsym(rtld_self, "cbcentralmanagerscanoptionallowduplicateskey"); nslog(@"address2 is: %p\n", addr2); // dereference pointer contents: nsstring *key2 = *(nsstring * __unsafe_unretained *)addr2; nslog(@"key2     is: %p\n", key2); 

output:

address  is: 0x7fff78950388 key      is: 0x7fff7894ec08 address2 is: 0x7fff78950388 key2     is: 0x7fff7894ec08 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -