Last active
May 23, 2024 02:58
-
-
Save omarzl/f5ebfb31d4bdf5e247559434fbc84be9 to your computer and use it in GitHub Desktop.
Modifying Settings app with LLDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Launch the simulator | |
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app | |
# Get the identifier of the running simulator | |
sim_id=$(xcrun simctl list | grep Booted | cut -d ' ' -f7 | sed -e 's/(//' -e 's/)//') | |
# Launch the Preferences app | |
xcrun simctl launch $sim_id com.apple.Preferences | |
# Attach LLDB to the process | |
lldb -n Preferences | |
# Set a breakpoint | |
br set -n "-[UILabel setText:]" -C 'po $rdx = (unsigned long)[NSString stringWithFormat: @"%@ - %@", (NSString *)$rdx, @"Omar"]' -G1 | |
# How it works: | |
# -n "-[UILabel setText:]" -> Sets the symbol name that will trigger the breakpoint. | |
# -C 'po $rdx = (unsigned long)[NSString stringWithFormat: @"%@ - %@", (NSString *)$rdx, @"Omar"]' -> When the breakpoint is triggered, | |
# it will modify the rdx register (which corresponds to the argument that is received in the function) to the address of the new string. | |
# -G1 -> Tells the breakpoint to auto continue. | |
# Continue the process | |
continue | |
# When you're done, detach from the process and exit LLDB ;) | |
detach | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment