def test_calls(): if not os.environ.get("GEN_DATA", None): for val, ret in data.api_name_ntcreatesection_arg_name_desiredaccess_data( ): assert pp_fn.api_name_ntcreatesection_arg_name_desiredaccess( val) == ret for val, ret in data.api_name_shgetfolderpathw_arg_name_folder_data(): assert pp_fn.api_name_shgetfolderpathw_arg_name_folder(val) == ret for val, ret in data.api_name_createtoolhelp32snapshot_arg_name_flags_data( ): assert pp_fn.api_name_createtoolhelp32snapshot_arg_name_flags( val) == ret for val, ret in data.blobtype_data(): assert pp_fn.blobtype(val) == ret for val, ret in data.algid_data(): assert pp_fn.algid(val) == ret for val, ret in data.hookidentifer_data(): assert pp_fn.hookidentifer(val) == ret for val, ret in data.infolevel_data(): assert pp_fn.infolevel(val) == ret for val, ret in data.disposition_data(): assert pp_fn.disposition(val) == ret for val, ret in data.createdisposition_data(): assert pp_fn.createdisposition(val) == ret for val, ret in data.shareaccess_data(): assert pp_fn.shareaccess(val) == ret for val, ret in data.systeminformationclass_data(): assert pp_fn.systeminformationclass(val) == ret for val, ret in data.category_registry_arg_name_type_data(): assert pp_fn.category_registry_arg_name_type(val) == ret for val, ret in data.api_name_opensc_arg_name_desiredaccess_data(): assert pp_fn.api_name_opensc_arg_name_desiredaccess(val) == ret for val, ret in data.category_services_arg_name_controlcode_data(): assert pp_fn.category_services_arg_name_controlcode(val) == ret for val, ret in data.category_services_arg_name_errorcontrol_data(): assert pp_fn.category_services_arg_name_errorcontrol(val) == ret for val, ret in data.category_services_arg_name_starttype_data(): assert pp_fn.category_services_arg_name_starttype(val) == ret for val, ret in data.category_services_arg_name_servicetype_data(): assert pp_fn.category_services_arg_name_servicetype(val) == ret for val, ret in data.category_services_arg_name_desiredaccess_data(): assert pp_fn.category_services_arg_name_desiredaccess(val) == ret for val, ret in data.category_registry_arg_name_access_desired_access_data( ): assert pp_fn.category_registry_arg_name_access_desired_access( val) == ret for val, ret in data.arg_name_protection_and_others_data(): assert pp_fn.arg_name_protection_and_others(val) == ret for val, ret in data.arg_name_iocontrolcode_data(): assert pp_fn.arg_name_iocontrolcode(val) == ret for val, ret in data.api_name_in_creation_data(): assert pp_fn.api_name_in_creation(val) == ret for val, ret in data.api_name_move_arg_name_flags_data(): assert pp_fn.api_name_move_arg_name_flags(val) == ret for val, ret in data.arg_name_fileattributes_data(): assert pp_fn.arg_name_fileattributes(val) == ret for val, ret in data.api_name_nt_arg_name_desiredaccess_data(): assert pp_fn.api_name_nt_arg_name_desiredaccess(val) == ret for val, ret in data.api_name_ntopenprocess_arg_name_desiredaccess_data( ): assert pp_fn.api_name_ntopenprocess_arg_name_desiredaccess( val) == ret for val, ret in data.api_name_ntopenthread_arg_name_desiredaccess_data( ): assert pp_fn.api_name_ntopenthread_arg_name_desiredaccess( val) == ret for val, ret in data.api_name_cointernet_arg_name_featureentry_data(): assert pp_fn.api_name_cointernet_arg_name_featureentry(val) == ret for val, ret in data.api_name_cointernet_arg_name_flags_data(): assert pp_fn.api_name_cointernet_arg_name_flags(val) == ret # for val, ret in data.api_name_socket_data(): # assert pp_fn.api_name_socket(arg_val=val, arg_name="process") == ret for val, ret in data.api_name_internetsetoptiona_arg_name_option_data( ): assert pp_fn.api_name_internetsetoptiona_arg_name_option( val) == ret for val, ret in data.arg_name_fileinformationclass_data(): assert pp_fn.arg_name_fileinformationclass(val) == ret for val, ret in data.arg_name_processinformationclass_data(): assert pp_fn.arg_name_processinformationclass(val) == ret for val, ret in data.arg_name_threadinformationclass_data(): assert pp_fn.arg_name_threadinformationclass(val) == ret for val, ret in data.arg_name_memtype_data(): assert pp_fn.arg_name_memtype(val) == ret for val, ret in data.arg_name_show_data(): assert pp_fn.arg_name_show(val) == ret for val, ret in data.arg_name_registry_data(): assert pp_fn.arg_name_registry(val) == ret
def pretty_print_arg(category, api_name, arg_name, arg_val): """Creates pretty-printed versions of API arguments that convert raw values in common APIs to their named-enumeration forms @return: pretty-printed version of the argument value provided, or None if no conversion exists """ if api_name == "NtCreateSection" and arg_name == "DesiredAccess": return pp_funcs.api_name_ntcreatesection_arg_name_desiredaccess( arg_val) elif api_name == "CreateToolhelp32Snapshot" and arg_name == "Flags": return pp_funcs.api_name_createtoolhelp32snapshot_arg_name_flags( arg_val) elif arg_name == "ClsContext": return arg_name_clscontext(arg_val) elif arg_name == "BlobType": return pp_funcs.blobtype(arg_val) elif arg_name == "Algid": return pp_funcs.algid(arg_val) elif api_name == "SHGetFolderPathW" and arg_name == "Folder": return pp_funcs.api_name_shgetfolderpathw_arg_name_folder(arg_val) elif arg_name == "HookIdentifier": return pp_funcs.hookidentifer(arg_val) elif arg_name == "InfoLevel": return pp_funcs.infolevel(arg_val) elif arg_name == "Disposition": return pp_funcs.disposition(arg_val) elif arg_name == "CreateDisposition": return pp_funcs.createdisposition(arg_val) elif arg_name == "ShareAccess": return pp_funcs.shareaccess(arg_val) elif arg_name == "SystemInformationClass": return pp_funcs.systeminformationclass(arg_val) elif category == "registry" and arg_name == "Type": return pp_funcs.category_registry_arg_name_type(arg_val) elif (api_name == "OpenSCManagerA" or api_name == "OpenSCManagerW") and arg_name == "DesiredAccess": return pp_funcs.api_name_opensc_arg_name_desiredaccess(arg_val) elif category == "services" and arg_name == "ControlCode": return pp_funcs.category_services_arg_name_controlcode(arg_val) elif category == "services" and arg_name == "ErrorControl": return pp_funcs.category_services_arg_name_errorcontrol(arg_val) elif category == "services" and arg_name == "StartType": return pp_funcs.category_services_arg_name_starttype(arg_val) elif category == "services" and arg_name == "ServiceType": return pp_funcs.category_services_arg_name_servicetype(arg_val) elif category == "services" and arg_name == "DesiredAccess": return pp_funcs.category_services_arg_name_desiredaccess(arg_val) elif category == "registry" and (arg_name == "Access" or arg_name == "DesiredAccess"): return pp_funcs.category_registry_arg_name_access_desired_access( arg_val) elif arg_name == "IoControlCode": return pp_funcs.arg_name_iocontrolcode(arg_val) elif (arg_name == "Protection" or arg_name == "Win32Protect" or arg_name == "NewAccessProtection" or arg_name == "OldAccessProtection" or arg_name == "OldProtection"): return pp_funcs.arg_name_protection_and_others(arg_val) elif (api_name in [ "CreateProcessInternalW", "CreateProcessWithTokenW", "CreateProcessWithLogonW" ] and arg_name == "CreationFlags"): return pp_funcs.api_name_in_creation(arg_val) elif (api_name == "MoveFileWithProgressW" or api_name == "MoveFileWithProgressTransactedW") and arg_name == "Flags": return pp_funcs.api_name_move_arg_name_flags(arg_val) elif arg_name == "FileAttributes": return pp_funcs.arg_name_fileattributes(arg_val) elif (api_name == "NtCreateFile" or api_name == "NtOpenFile" or api_name == "NtCreateDirectoryObject" or api_name == "NtOpenDirectoryObject") and arg_name == "DesiredAccess": return pp_funcs.api_name_nt_arg_name_desiredaccess(arg_val) elif api_name == "NtOpenProcess" and arg_name == "DesiredAccess": return pp_funcs.api_name_ntopenprocess_arg_name_desiredaccess(arg_val) elif api_name == "NtOpenThread" and arg_name == "DesiredAccess": return pp_funcs.api_name_ntopenthread_arg_name_desiredaccess(arg_val) elif api_name == "CoInternetSetFeatureEnabled" and arg_name == "FeatureEntry": return pp_funcs.api_name_cointernet_arg_name_featureentry(arg_val) elif api_name == "CoInternetSetFeatureEnabled" and arg_name == "Flags": return pp_funcs.api_name_cointernet_arg_name_flags(arg_val) elif api_name == "InternetSetOptionA" and arg_name == "Option": return pp_funcs.api_name_internetsetoptiona_arg_name_option(arg_val) elif api_name in ["socket", "WSASocketA", "WSASocketW"]: return pp_funcs.api_name_socket(arg_val, arg_name) elif arg_name == "FileInformationClass": return pp_funcs.arg_name_fileinformationclass(arg_val) elif arg_name == "ProcessInformationClass": return pp_funcs.arg_name_processinformationclass(arg_val) elif arg_name == "ThreadInformationClass": return pp_funcs.arg_name_threadinformationclass(arg_val) elif arg_name == "MemType": return pp_funcs.arg_name_memtype(arg_val) elif arg_name == "Show": return pp_funcs.arg_name_show(arg_val) elif arg_name == "Registry": return pp_funcs.arg_name_registry(arg_val) return None