diff --git a/src/common-opencl.c b/src/common-opencl.c index 68ab955..0caa067 100644 --- a/src/common-opencl.c +++ b/src/common-opencl.c @@ -320,7 +320,7 @@ static void build_device_list(char * device_list[MAXGPUS]) } } -void init_opencl_devices(void) +int init_opencl_devices(void) { char * device_list[MAXGPUS], string[10]; int n = 0; @@ -333,7 +333,7 @@ void init_opencl_devices(void) /* This is an OpenCL build on a host without *any* working OpenCL device or platform. */ if (get_number_of_available_devices() == 0) { ocl_gpu_id = 0; - return; + return 0; } if (options.ocl_platform) { @@ -427,6 +427,8 @@ void init_opencl_devices(void) } ocl_gpu_id = ocl_device_list[0]; platform_id = get_platform_id(ocl_gpu_id); + + return get_number_of_available_devices(); } void clean_opencl_environment() diff --git a/src/common-opencl.h b/src/common-opencl.h index 42450c6..1d947c1 100644 --- a/src/common-opencl.h +++ b/src/common-opencl.h @@ -82,7 +82,7 @@ int cores_per_MP[MAXGPUS]; cl_int oclGetDevCap(cl_device_id device, cl_int *iComputeCapMajor, cl_int *iComputeCapMinor); -void init_opencl_devices(); +int init_opencl_devices(); void clean_opencl_environment(); int get_number_of_available_devices(); int get_devices_being_used(); diff --git a/src/john.c b/src/john.c index a8c31eb..c3b3dd7 100644 --- a/src/john.c +++ b/src/john.c @@ -225,7 +225,7 @@ static void john_register_one(struct fmt_main *format) fmt_register(format); } -static void john_register_all(void) +static void john_register_all(int show_usage) { int i, cnt; struct fmt_main *selfs; @@ -291,43 +291,46 @@ static void john_register_all(void) john_register_one(&fmt_dummy); #ifdef HAVE_OPENCL - john_register_one(&fmt_opencl_NSLDAPS); - john_register_one(&fmt_opencl_rawMD4); - john_register_one(&fmt_opencl_rawMD5); - john_register_one(&fmt_opencl_NT); - john_register_one(&fmt_opencl_rawSHA1); - john_register_one(&fmt_opencl_cryptMD5); - john_register_one(&fmt_opencl_phpass); - john_register_one(&fmt_opencl_mysqlsha1); - john_register_one(&fmt_opencl_cryptsha256); - john_register_one(&fmt_opencl_cryptsha256_ng); - john_register_one(&fmt_opencl_cryptsha512); - john_register_one(&fmt_opencl_mscash2); - john_register_one(&fmt_opencl_wpapsk); - john_register_one(&fmt_opencl_keychain); - john_register_one(&fmt_opencl_agilekeychain); - john_register_one(&fmt_opencl_strip); - john_register_one(&fmt_opencl_zip); - john_register_one(&fmt_opencl_encfs); - john_register_one(&fmt_opencl_odf); - john_register_one(&fmt_opencl_odf_aes); - john_register_one(&fmt_opencl_sxc); - john_register_one(&fmt_opencl_gpg); - john_register_one(&fmt_opencl_dmg); - john_register_one(&fmt_opencl_xsha512); - john_register_one(&fmt_opencl_xsha512_ng); - john_register_one(&fmt_opencl_rawsha512); - john_register_one(&fmt_opencl_rawsha512_ng); - john_register_one(&fmt_opencl_rawsha256); - john_register_one(&fmt_opencl_bf); - john_register_one(&fmt_opencl_pwsafe); - john_register_one(&fmt_opencl_DES); - john_register_one(&fmt_opencl_office2007); - john_register_one(&fmt_opencl_office2010); - john_register_one(&fmt_opencl_office2013); - john_register_one(&fmt_opencl_NTLMv2); - john_register_one(&fmt_opencl_krb5pa_sha1); - john_register_one(&fmt_opencl_rar); + + if (!show_usage && init_opencl_devices()) { + john_register_one(&fmt_opencl_NSLDAPS); + john_register_one(&fmt_opencl_rawMD4); + john_register_one(&fmt_opencl_rawMD5); + john_register_one(&fmt_opencl_NT); + john_register_one(&fmt_opencl_rawSHA1); + john_register_one(&fmt_opencl_cryptMD5); + john_register_one(&fmt_opencl_phpass); + john_register_one(&fmt_opencl_mysqlsha1); + john_register_one(&fmt_opencl_cryptsha256); + john_register_one(&fmt_opencl_cryptsha256_ng); + john_register_one(&fmt_opencl_cryptsha512); + john_register_one(&fmt_opencl_mscash2); + john_register_one(&fmt_opencl_wpapsk); + john_register_one(&fmt_opencl_keychain); + john_register_one(&fmt_opencl_agilekeychain); + john_register_one(&fmt_opencl_strip); + john_register_one(&fmt_opencl_zip); + john_register_one(&fmt_opencl_encfs); + john_register_one(&fmt_opencl_odf); + john_register_one(&fmt_opencl_odf_aes); + john_register_one(&fmt_opencl_sxc); + john_register_one(&fmt_opencl_gpg); + john_register_one(&fmt_opencl_dmg); + john_register_one(&fmt_opencl_xsha512); + john_register_one(&fmt_opencl_xsha512_ng); + john_register_one(&fmt_opencl_rawsha512); + john_register_one(&fmt_opencl_rawsha512_ng); + john_register_one(&fmt_opencl_rawsha256); + john_register_one(&fmt_opencl_bf); + john_register_one(&fmt_opencl_pwsafe); + john_register_one(&fmt_opencl_DES); + john_register_one(&fmt_opencl_office2007); + john_register_one(&fmt_opencl_office2010); + john_register_one(&fmt_opencl_office2013); + john_register_one(&fmt_opencl_NTLMv2); + john_register_one(&fmt_opencl_krb5pa_sha1); + john_register_one(&fmt_opencl_rar); + } #endif #ifdef HAVE_CUDA @@ -614,8 +617,8 @@ static void john_init(char *name, int argc, char **argv) !strcasecmp(argv[1], "-h") || !strcasecmp(argv[1], "-help")))) { - john_register_all(); /* for printing by opt_init() */ show_usage = 1; + john_register_all(show_usage); /* for printing by opt_init() */ } opt_init(name, argc, argv, show_usage); @@ -648,16 +651,12 @@ static void john_init(char *name, int argc, char **argv) initUnicode(UNICODE_UNICODE); /* Init the unicode system */ - john_register_all(); /* maybe restricted to one format by options */ + john_register_all(show_usage); /* maybe restricted to one format by options */ if ((options.subformat && !strcasecmp(options.subformat, "list")) || options.listconf) listconf_parse_late(); -#ifdef HAVE_OPENCL - init_opencl_devices(); -#endif - common_init(); sig_init();