code: def install_hook(c_function, python_function):
      python_function_addr = ctypes.cast(
          ctypes.byref(python_function), ctypes.POINTER(ctypes.c_ulong)
      ).contents.value
      # AARCH64 trampoline to ioctl
      if processor == "aarch64":
          # 0x0000000000000000:  70 00 00 10    adr x16, #0xc
          # 0x0000000000000004:  10 02 40 F9    ldr x16, [x16]
          # 0x0000000000000008:  00 02 1F D6    br  x16
          tramp = b"\x70\x00\x00\x10\x10\x02\x40\xf9\x00\x02\x1f\xd6"
          tramp += struct.pack("Q", python_function_addr)
      elif processor == "x86_64":
          # 0x0000000000000000:  49 B8 aa aa aa aa aa aa aa aa    movabs r8, <address>
          # 0x000000000000000a:  41 FF E0                         jmp    r8
          tramp = (
              b"\x49\xB8"
              + struct.pack("Q", python_function_addr)
              + b"\x41\xFF\xE0"
          )
      else:
          raise Exception(f"processor {processor} not supported")
  
      # get real ioctl address
      ioctl_address = ctypes.cast(
          ctypes.byref(c_function), ctypes.POINTER(ctypes.c_ulong)
      )
  
      # hook ioctl
      ret = libc.mprotect(
          ctypes.c_ulong(
              (ioctl_address.contents.value // 0x1000) * 0x1000
          ),
          0x2000,
          7,
      )
      assert ret == 0
      libc.memcpy(
          ioctl_address.contents,
          ctypes.create_string_buffer(tramp),
          len(tramp),
      )
  
imports: import ctypes, ctypes.util, struct, platform, pathlib, re, time, os
  from extra.hip_gpu_driver import kfd_ioctl
label_desc: Use image node_id 3 for calling a global function with example usage: install_hook(c_function, python_function) without return types