@@ -298,13 +298,22 @@ def expand_ppp_def(line):
298298
299299 # MANUAL curated list of PPP headers
300300 define_clean_header (ffi , include_dir + "/syscalls_ext_typedefs.h" )
301-
302301 define_clean_header (ffi , include_dir + "/callstack_instr.h" )
303302
304- define_clean_header (ffi , include_dir + "/hooks2_ppp.h" )
305- define_clean_header (ffi , include_dir + "/proc_start_linux_ppp.h" )
306- define_clean_header (ffi , include_dir + "/forcedexec_ppp.h" )
307- define_clean_header (ffi , include_dir + "/stringsearch_ppp.h" )
303+ #define clean header for files ending in "_ppp.h"
304+
305+ import os
306+ plugin_dirs = [os .path .join (PLUGINS_DIR , f ) for f in os .listdir (PLUGINS_DIR ) if os .path .isdir (os .path .join (PLUGINS_DIR , f ))]
307+
308+ pattern = re .compile (r"_ppp\.h$" )
309+ for plugin_dir in plugin_dirs :
310+ plugin_files = os .listdir (plugin_dir )
311+
312+ for plugin_file in plugin_files :
313+ if pattern .search (plugin_file ):
314+ define_clean_header (ffi , f"{ include_dir } /{ os .path .basename (plugin_file )} " )
315+
316+
308317 # END PPP headers
309318
310319 define_clean_header (ffi , include_dir + "/breakpoints.h" )
@@ -376,17 +385,29 @@ def main(install=False,recompile=True):
376385 copy_ppp_header ("%s/%s" % (PLUGINS_DIR + "/osi" , "os_intro.h" ))
377386 pypanda_headers .append (os .path .join (INCLUDE_DIR_PYP , "os_intro.h" ))
378387
379- copy_ppp_header ("%s/%s" % (PLUGINS_DIR + "/hooks2" , "hooks2_ppp.h" ))
380- # TODO: programtically copy anything that ends with _ppp.h
381- copy_ppp_header ("%s/%s" % (PLUGINS_DIR + "/forcedexec" , "forcedexec_ppp.h" ))
382- copy_ppp_header ("%s/%s" % (PLUGINS_DIR + "/stringsearch" , "stringsearch_ppp.h" ))
383- create_pypanda_header ("%s/%s" % (PLUGINS_DIR + "/hooks2" , "hooks2.h" ))
384-
385- copy_ppp_header ("%s/%s" % (PLUGINS_DIR + "/proc_start_linux" , "proc_start_linux_ppp.h" ))
386- create_pypanda_header ("%s/%s" % (PLUGINS_DIR + "/proc_start_linux" , "proc_start_linux.h" ))
387388 create_pypanda_header ("%s/%s" % (PLUGINS_DIR + "/cosi" , "cosi.h" ))
389+
388390 copy_ppp_header ("%s/taint2/taint2.h" % PLUGINS_DIR )
389391
392+
393+ #programtically copy anything that ends with _ppp.h
394+
395+ #for each subdirectory under PLUGINS_DIR
396+ plugin_dirs = [os .path .join (PLUGINS_DIR , f ) for f in os .listdir (PLUGINS_DIR ) if os .path .isdir (os .path .join (PLUGINS_DIR , f ))]
397+
398+ pattern = re .compile (r"_ppp\.h$" ) #matches strings ending with _ppp.h
399+ for plugin_dir in plugin_dirs :
400+ plugin_files = os .listdir (plugin_dir )
401+
402+ for plugin_file in plugin_files :
403+ if pattern .search (plugin_file ):
404+ copy_ppp_header (f"{ plugin_dir } /{ plugin_file } " )
405+
406+ #if the directory with the _ppp.h file also has a [plugin_name].h file, include it
407+ header_filepath = f"{ plugin_dir } /{ os .path .basename (plugin_dir ) + '.h' } "
408+ if os .path .isfile (header_filepath ):
409+ create_pypanda_header (header_filepath )
410+
390411 with open (os .path .join (OUTPUT_DIR , "panda_datatypes.py" ), "w" ) as pdty :
391412 pdty .write ("""from __future__ import print_function
392413\" \" \"
0 commit comments