Advertisement
Guest User

Untitled

a guest
Aug 8th, 2019
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. diff --git a/fbobjc/VendorLib/FBRetainCycleDetector/src/rcd_fishhook/rcd_fishhook.c b/fbobjc/VendorLib/FBRetainCycleDetector/src/rcd_fishhook/rcd_fishhook.c
  2. --- a/fbobjc/VendorLib/FBRetainCycleDetector/src/rcd_fishhook/rcd_fishhook.c
  3. +++ b/fbobjc/VendorLib/FBRetainCycleDetector/src/rcd_fishhook/rcd_fishhook.c
  4. @@ -24,8 +24,10 @@
  5. #include "rcd_fishhook.h"
  6.  
  7. #include <dlfcn.h>
  8. +#include <stdbool.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. +#include <sys/mman.h>
  12. #include <sys/types.h>
  13. #include <mach-o/dyld.h>
  14. #include <mach-o/loader.h>
  15. @@ -82,8 +84,12 @@
  16. nlist_t *symtab,
  17. char *strtab,
  18. uint32_t *indirect_symtab) {
  19. + const bool isDataConst = strcmp(section->segname, "__DATA_CONST") == 0;
  20. uint32_t *indirect_symbol_indices = indirect_symtab + section->reserved1;
  21. void **indirect_symbol_bindings = (void **)((uintptr_t)slide + section->addr);
  22. + if (isDataConst) {
  23. + mprotect(indirect_symbol_bindings, section->size, PROT_READ | PROT_WRITE);
  24. + }
  25. for (uint i = 0; i < section->size / sizeof(void *); i++) {
  26. uint32_t symtab_index = indirect_symbol_indices[i];
  27. if (symtab_index == INDIRECT_SYMBOL_ABS || symtab_index == INDIRECT_SYMBOL_LOCAL ||
  28. @@ -110,6 +116,9 @@
  29. }
  30. symbol_loop:;
  31. }
  32. + if (isDataConst) {
  33. + mprotect(indirect_symbol_bindings, section->size, PROT_READ);
  34. + }
  35. }
  36.  
  37. static void rebind_symbols_for_image(struct rcd_rebindings_entry *rebindings,
  38. diff --git a/fbobjc/VendorLib/fishhook/src/fishhook.c b/fbobjc/VendorLib/fishhook/src/fishhook.c
  39. --- a/fbobjc/VendorLib/fishhook/src/fishhook.c
  40. +++ b/fbobjc/VendorLib/fishhook/src/fishhook.c
  41. @@ -24,8 +24,10 @@
  42. #include "fishhook.h"
  43.  
  44. #include <dlfcn.h>
  45. +#include <stdbool.h>
  46. #include <stdlib.h>
  47. #include <string.h>
  48. +#include <sys/mman.h>
  49. #include <sys/types.h>
  50. #include <mach-o/dyld.h>
  51. #include <mach-o/loader.h>
  52. @@ -82,8 +84,12 @@
  53. nlist_t *symtab,
  54. char *strtab,
  55. uint32_t *indirect_symtab) {
  56. + const bool isDataConst = strcmp(section->segname, "__DATA_CONST") == 0;
  57. uint32_t *indirect_symbol_indices = indirect_symtab + section->reserved1;
  58. void **indirect_symbol_bindings = (void **)((uintptr_t)slide + section->addr);
  59. + if (isDataConst) {
  60. + mprotect(indirect_symbol_bindings, section->size, PROT_READ | PROT_WRITE);
  61. + }
  62. for (uint i = 0; i < section->size / sizeof(void *); i++) {
  63. uint32_t symtab_index = indirect_symbol_indices[i];
  64. if (symtab_index == INDIRECT_SYMBOL_ABS || symtab_index == INDIRECT_SYMBOL_LOCAL ||
  65. @@ -110,6 +116,9 @@
  66. }
  67. symbol_loop:;
  68. }
  69. + if (isDataConst) {
  70. + mprotect(indirect_symbol_bindings, section->size, PROT_READ);
  71. + }
  72. }
  73.  
  74. static void rebind_symbols_for_image(struct rebindings_entry *rebindings,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement