def get_kdbg(addr_space):
 if obj.VolMagic(addr_space).KPCR.value:
  kpcr = obj.Object('_KPCR', offset=obj.VolMagic(addr_space).KPCR.value, vm=addr_space)
  kdbg = kpcr.get_kdbg()
  if kdbg.is_valid():
   return kdbg
 kdbg_magic = obj.VolMagic(addr_space).KDBG
 for kdbg in kdbg_magic.get_suggestions():
  if kdbg.is_valid():
   return kdbg
 memmode = addr_space.profile.metadata.get('memory_model', '32bit')
 version = (addr_space.profile.metadata.get('major', 0), addr_space.profile.metadata.get('minor', 0))
 if ((memmode == '32bit') or (version <= (6, 1))):
  for kpcr_off in obj.VolMagic(addr_space).KPCR.get_suggestions():
   kpcr = obj.Object('_KPCR', offset=kpcr_off, vm=addr_space)
   kdbg = kpcr.get_kdbg()
   if kdbg.is_valid():
    return kdbg
 return obj.NoneObject('KDDEBUGGER structure not found using either KDBG signature or KPCR pointer')

def get_kdbg ( addr_space ) : if obj . VolMagic ( addr_space ) . KPCR . value : kpcr = obj . Object ( '_KPCR' , offset = obj . VolMagic ( addr_space ) . KPCR . value , vm = addr_space ) kdbg = kpcr . get_kdbg ( ) if kdbg . is_valid ( ) : return kdbg kdbg_magic = obj . VolMagic ( addr_space ) . KDBG for kdbg in kdbg_magic . get_suggestions ( ) : if kdbg . is_valid ( ) : return kdbg memmode = addr_space . profile . metadata . get ( 'memory_model' , '32bit' ) version = ( addr_space . profile . metadata . get ( 'major' , 0 ) , addr_space . profile . metadata . get ( 'minor' , 0 ) ) if ( ( memmode == '32bit' ) or ( version <= ( 6 , 1 ) ) ) : for kpcr_off in obj . VolMagic ( addr_space ) . KPCR . get_suggestions ( ) : kpcr = obj . Object ( '_KPCR' , offset = kpcr_off , vm = addr_space ) kdbg = kpcr . get_kdbg ( ) if kdbg . is_valid ( ) : return kdbg return obj . NoneObject ( 'KDDEBUGGER structure not found using either KDBG signature or KPCR pointer' )
a function designed to return the kdbg structure from an address space .