55
66from sys import version_info
77
8- FUNCS_SEGEND = ida_segment .get_segm_by_name (".text" ).end_ea
8+ FUNCS_SEGEND = idaapi .get_segm_by_name (".text" ).end_ea
99
1010def get_os ():
1111 # Lazy af lol
12- return "linux" if ida_nalt .get_root_filename ().endswith (".so" ) else "windows"
12+ return "linux" if idaapi .get_root_filename ().endswith (".so" ) else "windows"
1313
1414def checksig (sig ):
1515 if sig [0 ] == '@' :
@@ -19,10 +19,10 @@ def checksig(sig):
1919 sig = sig .replace (r"\x" , " " ).replace ("2A" , "?" ).replace ("2a" , "?" ).replace ("\\ " , "" ).strip ()
2020 count = 0
2121 addr = 0
22- addr = ida_search .find_binary (addr , FUNCS_SEGEND , sig , 0 , idc .SEARCH_DOWN | idc .SEARCH_NEXT )
22+ addr = idaapi .find_binary (addr , FUNCS_SEGEND , sig , 0 , idc .SEARCH_DOWN | idc .SEARCH_NEXT )
2323 while addr != idc .BADADDR :
2424 count = count + 1
25- addr = ida_search .find_binary (addr , FUNCS_SEGEND , sig , 0 , idc .SEARCH_DOWN | idc .SEARCH_NEXT )
25+ addr = idaapi .find_binary (addr , FUNCS_SEGEND , sig , 0 , idc .SEARCH_DOWN | idc .SEARCH_NEXT )
2626
2727 return count == 1
2828
@@ -36,7 +36,7 @@ def get_gamedir(kv):
3636 gamedir = ""
3737 # If we've got multiple games supported, so let's just ask
3838 if len (kv .items ()) > 1 :
39- gamedir = ida_kernwin .ask_str ("" , 0 , "There are multiple supported games with this file. Which game directory is this for?" )
39+ gamedir = idaapi .ask_str ("" , 0 , "There are multiple supported games with this file. Which game directory is this for?" )
4040 # Not in the basic game shit, check for support in default
4141 if gamedir not in kv .keys ():
4242 default = kv .get ("#default" )
@@ -58,7 +58,7 @@ def get_gamedir(kv):
5858 supported = kv .get ("#supported" )
5959 if supported :
6060 if len (supported .items ()) > 1 :
61- gamedir = ida_kernwin .ask_str ("" , 0 , "There are multiple supported games with this file. Which game directory is this for?" )
61+ gamedir = idaapi .ask_str ("" , 0 , "There are multiple supported games with this file. Which game directory is this for?" )
6262 if gamedir in default ["#supported" ].values ():
6363 return gamedir
6464 return ""
@@ -86,10 +86,10 @@ def read_vtable(funcname, ea):
8686 offset = 0
8787 while ea != idc .BADADDR :
8888 offs = idc .get_wide_dword (ea )
89- if not ida_bytes .is_code (ida_bytes .get_full_flags (offs )):
89+ if not idaapi .is_code (idaapi .get_full_flags (offs )):
9090 break
9191
92- name = idc .get_name (offs , ida_name .GN_VISIBLE )
92+ name = idc .get_name (offs , idaapi .GN_VISIBLE )
9393 demangled = idc .demangle_name (name , idc .get_inf_attr (idc .INF_SHORT_DN ))
9494 if demangled == None :
9595 demangled = name
@@ -99,7 +99,7 @@ def read_vtable(funcname, ea):
9999 funcs [demangled .lower ()] = offset
100100
101101 offset += 1
102- ea = ida_bytes .next_not_tail (ea )
102+ ea = idaapi .next_not_tail (ea )
103103
104104 # We've got a list of function names, let's do this really shittily because idk any other way
105105
@@ -152,7 +152,7 @@ def try_get_voffset(funcname):
152152
153153 # Let's chug along all of these functions, woohoo for option 2!
154154 for func in idautils .Functions ():
155- name = idc .get_name (func , ida_name .GN_VISIBLE )
155+ name = idc .get_name (func , idaapi .GN_VISIBLE )
156156 if not name or funcname not in name : # funcname should only be a plain function decl, so it would be unfettered in a mangled name
157157 continue
158158
@@ -181,18 +181,22 @@ def try_get_voffset(funcname):
181181
182182def main ():
183183 kv = None
184- with open (ida_kernwin .ask_file (0 , "*.txt" , "Select a gamedata file" )) as f :
184+ filereq = idaapi .ask_file (0 , "*.txt" , "Select a gamedata file" )
185+ if filereq == None :
186+ return
187+
188+ with open (filereq ) as f :
185189 kv = vdf .load (f )
186190
187191 if kv == None :
188- ida_kernwin .warning ("Could not load file!" )
192+ idaapi .warning ("Could not load file!" )
189193 return
190194
191195 kv = list (kv .values ())[0 ]
192196 os = get_os ()
193197 gamedir = get_gamedir (kv )
194198 if not gamedir :
195- ida_kernwin .warning ("Could not find game directory in file" )
199+ idaapi .warning ("Could not find game directory in file" )
196200 return
197201
198202 kv = kv [gamedir ]
@@ -238,7 +242,6 @@ def main():
238242# if os == "windows" and kv.get("Offsets"):
239243# print("Offset checking is not supported on Windows binaries")
240244
241- ida_kernwin . warning ( "Check console for output" )
245+ idaapi . ask_form ( "Validated \n Check console for output" )
242246
243- if __name__ == "__main__" :
244- main ()
247+ main ()
0 commit comments