-def GetKmodAddrIntAsString(kgm_pc):
- global kgm_pkmod
- global kgm_pkmodst
- global kgm_pkmoden
-
- out_string = ""
- mh_execute_addr = int(lldb_run_command('p/x (uintptr_t *)&_mh_execute_header').split('=')[-1].strip(), 16)
-
- out_string += GetPointerAsString(kgm_pc)
- if ((unsigned(kgm_pc) >= unsigned(kgm_pkmodst)) and (unsigned(kgm_pc) < unsigned(kgm_pkmoden))):
- kgm_off = kgm_pc - kgm_pkmodst
- out_string += "<" + str(Cast(kgm_pkmod, 'kmod_info_t *').name) + " + 0x" + str(kgm_off) + ">"
- else:
- kgm_kmodp = kern.globals.kmod
- if ((kern.arch == 'x86_64') and (long(kgm_pc) >= long(mh_execute_addr))):
- kgm_kmodp = 0
-
- while kgm_kmodp:
- kgm_off = unsigned((kgm_pc - kgm_kmodp.address) & 0x00000000ffffffff)
- if ((long(kgm_kmodp.address) <= long(kgm_pc)) and (kgm_off) < unsigned(kgm_kmodp.size)):
- kgm_pkmod = kgm_kmodp
- kgm_pkmodst = unsigned(kgm_kmodp.address)
- kgm_pkmoden = unsigned(kgm_pkmodst + kgm_kmodp.size)
- kgm_kmodp = 0
- else:
- kgm_kmodp = kgm_kmodp.next
- return out_string
-