title: How to patch a function in x64 assembly to always return true
body: <p>I'm trying to patch a function in CoreBrightness.framework of macOS to always return true. After hours of hopeless attempts, I really need some help.</p>
  
  <p>The function is as followed (from IDA 7):</p>
  
  <pre><code>__text:0000000000036CFA ; char __cdecl -[KeyboardBrightnessClient isKeyboardBuiltIn:](KeyboardBrightnessClient *self, SEL, unsigned __int64)
  __text:0000000000036CFA __KeyboardBrightnessClient_isKeyboardBuiltIn__ proc near
  __text:0000000000036CFA                                         ; DATA XREF: __objc_const:0000000000080BE8↓o
  // skipped
  __text:0000000000036D94
  __text:0000000000036D94 loc_36D94:                              ; CODE XREF: -[KeyboardBrightnessClient isKeyboardBuiltIn:]+81↑j
  __text:0000000000036D94                 xor     ebx, ebx
  __text:0000000000036D96
  __text:0000000000036D96 loc_36D96:                              ; CODE XREF: -[KeyboardBrightnessClient isKeyboardBuiltIn:]+98↑j
  __text:0000000000036D96                 mov     rdi, r14
  __text:0000000000036D99                 call    cs:_objc_release_ptr
  __text:0000000000036D9F                 movzx   eax, bl
  __text:0000000000036DA2                 pop     rbx
  __text:0000000000036DA3                 pop     r14
  __text:0000000000036DA5                 pop     rbp
  __text:0000000000036DA6                 retn
  __text:0000000000036DA7 ; ---------------------------------------------------------------------------
  __text:0000000000036DA7
  __text:0000000000036DA7 loc_36DA7:                              ; CODE XREF: -[KeyboardBrightnessClient isKeyboardBuiltIn:]+57↑j
  __text:0000000000036DA7                 mov     rdi, r14
  __text:0000000000036DAA                 mov     rsi, rbx
  __text:0000000000036DAD                 call    __KeyboardBrightnessClient_isKeyboardBuiltIn___cold_1 ; -[KeyboardBrightnessClient isKeyboardBuiltIn:].cold.1
  __text:0000000000036DB2                 jmp     short loc_36D53
  __text:0000000000036DB2 __KeyboardBrightnessClient_isKeyboardBuiltIn__ endp
  </code></pre>
  
  <p>The full version is at <a href="https://pastebin.com/UYG1sRx9" rel="nofollow noreferrer">https://pastebin.com/UYG1sRx9</a></p>