Group Group Group Group Group Group Group Group Group

Chapter 16 custom disassembler

#1

Hello @lolgrep . First i want to say, that 16 chapter is a huge one! Thank you so for it!

But i’m having the issue with the custom disassembler (dd command). I’d use some from your git repo and synced it just this month (after the book update came).

So previously in that chapter i’d used dd and everything’s going well.
But on page 228, where you dump the [UIDebuggingInformationOverlay prepareDebuggingOverlay] assembly with dd, my copy of dd didn’t work.

Here’s what i’m doing here:
methods UIDebuggingInformationOverlay and i get follow output.

<UIDebuggingInformationOverlay: 0x10cf712a0>:
in UIDebuggingInformationOverlay:
	Class Methods:
		+ (void) prepareDebuggingOverlay; (0x10c58e036)
		+ (void) pushDisableApplyingConfigurations; (0x10c58e2e7)
		+ (void) popDisableApplyingConfigurations; (0x10c58e2f4)
		+ (id) overlay; (0x10c58e1a6)
	Properties:
		@property (retain, nonatomic) UIEvent* lastTouch;  (@synthesize lastTouch = _lastTouch;)
		@property (nonatomic) struct CGPoint drawingOrigin;  (@synthesize drawingOrigin = _drawingOrigin;)
		@property (readonly, nonatomic) UIDebuggingInformationOverlayViewController* overlayViewController;
		@property (retain, nonatomic) UIDebuggingInformationRootTableViewController* rootTableViewController;
		@property (nonatomic) BOOL checkingTouches;  (@synthesize checkingTouches = _checkingTouches;)
		@property (nonatomic) BOOL touchCaptureEnabled;  (@synthesize touchCaptureEnabled = _touchCaptureEnabled;)
		@property (retain, nonatomic) NSMutableArray* touchObservers;  (@synthesize touchObservers = _touchObservers;)
		@property (retain, nonatomic) UIWindow* inspectedWindow;  (@synthesize inspectedWindow = _inspectedWindow;)
	Instance Methods:
		- (id) hitTest:(struct CGPoint)arg1 withEvent:(id)arg2; (0x10c58e831)
		- (id) lastTouch; (0x10c58ef4c)
		- (id) inspectedWindow; (0x10c58ef27)
		- (void) setInspectedWindow:(id)arg1; (0x10c58ef38)
		- (void) setTouchCaptureEnabled:(BOOL)arg1; (0x10c58eef2)
		- (id) overlayViewController; (0x10c58e024)
		- (void) setCheckingTouches:(BOOL)arg1; (0x10c58eed2)
		- (void) toggleFullscreen; (0x10c58e7f4)
		- (void) toggleVisibility; (0x10c58e301)
		- (void) setRootTableViewController:(id)arg1; (0x10c58ed9a)
		- (id) rootTableViewController; (0x10c58ed4a)
		- (BOOL) checkingTouches; (0x10c58eec2)
		- (id) touchObservers; (0x10c58ef02)
		- (void) setLastTouch:(id)arg1; (0x10c58ef5d)
		- (BOOL) touchCaptureEnabled; (0x10c58eee2)
		- (void) setTouchObservers:(id)arg1; (0x10c58ef13)
		- (struct CGPoint) drawingOrigin; (0x10c58ef71)
		- (void) setDrawingOrigin:(struct CGPoint)arg1; (0x10c58ef89)
		- (void) .cxx_destruct; (0x10c58efa1)
		- (id) init; (0x10c58df62)
		- (id) initWithFrame:(struct CGRect)arg1; (0x10c58ec9a)
(UIWindow ...)

So as i’m interested in the + (void) prepareDebuggingOverlay; (0x10c58e036) class method, i’d copy its pointer address and try to paste it in dd, like:

dd 0x10c58e036, and get follow ouput:

Traceback (most recent call last):
  File "/Volumes/devel/apple/lldb_scripts/release/disassemble.py", line 42, in handle_command
    output += generateAssemblyFromSymbol(sym, options)
  File "/Volumes/devel/apple/lldb_scripts/release/disassemble.py", line 105, in generateAssemblyFromSymbol
    showComments, modName = generateDescriptionByAddress(addr)
  File "/Volumes/devel/apple/lldb_scripts/release/disassemble.py", line 186, in generateDescriptionByAddress
    idType = ds.getType('id')
AttributeError: 'module' object has no attribute 'getType'

In the same time disassemble -s 0x10c58e036 are working well, i mean it prints out the function of the interests:

UIKit`+[UIDebuggingInformationOverlay prepareDebuggingOverlay]:    0x10c58e036 <+0>: push   rbp
    0x10c58e037 <+1>:  mov    rbp, rsp
    0x10c58e03a <+4>:  push   r15
    0x10c58e03c <+6>:  push   r14
    0x10c58e03e <+8>:  push   r13
    0x10c58e040 <+10>: push   r12
    0x10c58e042 <+12>: push   rbx
    0x10c58e043 <+13>: push   rax
    0x10c58e044 <+14>: call   0x10c58efe3               ; _UIGetDebuggingOverlayEnabled
    0x10c58e049 <+19>: test   al, al
    0x10c58e04b <+21>: je     0x10c58e154               ; <+286>

Also in the same time dd 0x10c58df62 which is - (id) init; (0x10c58df62) method are doing well either and prints out the colored output in the same lldb session.

Also i mentioned, that problem occurs not only with the prepareDebuggingOverlay method. It also occurs with the - (id) initWithFrame:(struct CGRect)arg1; (0x10c58ec9a) method. Like:
dd 0x10c58ec9a gives the same input:

Traceback (most recent call last):
  File "/Volumes/devel/hack/apple/lldb_scripts/release/disassemble.py", line 42, in handle_command
    output += generateAssemblyFromSymbol(sym, options)
  File "/Volumes/devel/hack/apple/lldb_scripts/release/disassemble.py", line 105, in generateAssemblyFromSymbol
    showComments, modName = generateDescriptionByAddress(addr)
  File "/Volumes/devel/hack/apple/lldb_scripts/release/disassemble.py", line 186, in generateDescriptionByAddress
    idType = ds.getType('id')
AttributeError: 'module' object has no attribute 'getType'

Maybe do you have any idea how to fix it or any workaround that issue, or you’ve mentioned any mistake in my workflow which cause such behaviour?

#2

@lolgrep Can you please help with this when you get a chance? Thank you - much appreciated! :]

opened #4