From a97e31881cdb45c5693bf01482348c4587a1beeb Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 6 Oct 2016 15:49:07 +0200 Subject: [PATCH] Update interface.c function parameters --- include/interface.h | 14 +++++++------- src/hashcat.c | 6 +++--- src/hashes.c | 4 ++-- src/interface.c | 32 +++++++++++++++++++++++++------- src/mpsp.c | 2 +- src/opencl.c | 4 ++-- 6 files changed, 40 insertions(+), 22 deletions(-) diff --git a/include/interface.h b/include/interface.h index 24a994622..39d7d1e91 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1509,12 +1509,12 @@ void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, const void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, const hashconfig_t *hashconfig, const hashes_t *hashes); -int hashconfig_init (hashconfig_t *hashconfig, const user_options_t *user_options); -void hashconfig_destroy (hashconfig_t *hashconfig); -u32 hashconfig_enforce_kernel_threads (const hashconfig_t *hashconfig, const hc_device_param_t *device_param); -u32 hashconfig_enforce_kernel_loops (const hashconfig_t *hashconfig, const user_options_t *user_options); -void hashconfig_general_defaults (hashconfig_t *hashconfig, hashes_t *hashes, const user_options_t *user_options); -void hashconfig_benchmark_defaults (const hashconfig_t *hashconfig, salt_t *salt, void *esalt); -char *hashconfig_benchmark_mask (const hashconfig_t *hashconfig); +int hashconfig_init (hashcat_ctx_t *hashcat_ctx); +void hashconfig_destroy (hashcat_ctx_t *hashcat_ctx); +u32 hashconfig_enforce_kernel_threads (hashcat_ctx_t *hashcat_ctx, const hc_device_param_t *device_param); +u32 hashconfig_enforce_kernel_loops (hashcat_ctx_t *hashcat_ctx); +void hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx); +void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, void *esalt); +char *hashconfig_benchmark_mask (hashcat_ctx_t *hashcat_ctx); #endif // _INTERFACE_H diff --git a/src/hashcat.c b/src/hashcat.c index b44029a64..965126da6 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -787,7 +787,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * setup variables and buffers depending on hash_mode */ - const int rc_hashconfig = hashconfig_init (hashconfig, user_options); + const int rc_hashconfig = hashconfig_init (hashcat_ctx); if (rc_hashconfig == -1) return -1; @@ -874,7 +874,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) hashes_destroy (hashcat_ctx); - hashconfig_destroy (hashconfig); + hashconfig_destroy (hashcat_ctx); potfile_destroy (hashcat_ctx); @@ -1216,7 +1216,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) hashes_destroy (hashcat_ctx); - hashconfig_destroy (hashconfig); + hashconfig_destroy (hashcat_ctx); wl_data_destroy (wl_data); diff --git a/src/hashes.c b/src/hashes.c index fee580078..935ac807f 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -627,7 +627,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (user_options->benchmark == true) { - hashconfig_benchmark_defaults ((hashconfig_t *) hashconfig, hashes_buf[0].salt, hashes_buf[0].esalt); + hashconfig_benchmark_defaults (hashcat_ctx, hashes_buf[0].salt, hashes_buf[0].esalt); hashes->hashfile = "-"; @@ -1280,7 +1280,7 @@ int hashes_init_stage3 (hashcat_ctx_t *hashcat_ctx) hashes_t *hashes = hashcat_ctx->hashes; user_options_t *user_options = hashcat_ctx->user_options; - hashconfig_general_defaults (hashconfig, hashes, user_options); + hashconfig_general_defaults (hashcat_ctx); if (hashes->salts_cnt == 1) hashconfig->opti_type |= OPTI_TYPE_SINGLE_SALT; diff --git a/src/interface.c b/src/interface.c index 552731706..a61859370 100644 --- a/src/interface.c +++ b/src/interface.c @@ -16158,8 +16158,11 @@ void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, cons #pragma GCC diagnostic pop -int hashconfig_init (hashconfig_t *hashconfig, const user_options_t *user_options) +int hashconfig_init (hashcat_ctx_t *hashcat_ctx) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + user_options_t *user_options = hashcat_ctx->user_options; + hashconfig->hash_mode = user_options->hash_mode; hashconfig->hash_type = 0; hashconfig->salt_type = 0; @@ -20101,13 +20104,17 @@ int hashconfig_init (hashconfig_t *hashconfig, const user_options_t *user_option return 0; } -void hashconfig_destroy (hashconfig_t *hashconfig) +void hashconfig_destroy (hashcat_ctx_t *hashcat_ctx) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + memset (hashconfig, 0, sizeof (hashconfig_t)); } -u32 hashconfig_enforce_kernel_threads (const hashconfig_t *hashconfig, const hc_device_param_t *device_param) +u32 hashconfig_enforce_kernel_threads (hashcat_ctx_t *hashcat_ctx, const hc_device_param_t *device_param) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + u32 kernel_threads = MIN (KERNEL_THREADS_MAX, device_param->device_maxworkgroup_size); if (hashconfig->hash_mode == 8900) kernel_threads = 64; // Scrypt @@ -20139,8 +20146,11 @@ u32 hashconfig_enforce_kernel_threads (const hashconfig_t *hashconfig, const hc_ return kernel_threads; } -u32 hashconfig_enforce_kernel_loops (const hashconfig_t *hashconfig, const user_options_t *user_options) +u32 hashconfig_enforce_kernel_loops (hashcat_ctx_t *hashcat_ctx) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + user_options_t *user_options = hashcat_ctx->user_options; + u32 kernel_loops_fixed = 0; if (hashconfig->hash_mode == 1500 && user_options->attack_mode == ATTACK_MODE_BF) @@ -20181,8 +20191,12 @@ u32 hashconfig_enforce_kernel_loops (const hashconfig_t *hashconfig, const user_ return kernel_loops_fixed; } -void hashconfig_general_defaults (hashconfig_t *hashconfig, hashes_t *hashes, const user_options_t *user_options) +void hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + hashes_t *hashes = hashcat_ctx->hashes; + user_options_t *user_options = hashcat_ctx->user_options; + salt_t *salts_buf = hashes->salts_buf; void *esalts_buf = hashes->esalts_buf; @@ -20252,8 +20266,10 @@ void hashconfig_general_defaults (hashconfig_t *hashconfig, hashes_t *hashes, co } } -void hashconfig_benchmark_defaults (const hashconfig_t *hashconfig, salt_t *salt, void *esalt) +void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, void *esalt) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + if (hashconfig->is_salted) { salt->salt_len = 8; @@ -20565,8 +20581,10 @@ void hashconfig_benchmark_defaults (const hashconfig_t *hashconfig, salt_t *salt } } -char *hashconfig_benchmark_mask (const hashconfig_t *hashconfig) +char *hashconfig_benchmark_mask (hashcat_ctx_t *hashcat_ctx) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + char *mask = NULL; switch (hashconfig->hash_mode) diff --git a/src/mpsp.c b/src/mpsp.c index e0b7120d2..7fdd7e1a8 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -1086,7 +1086,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - const char *mask = hashconfig_benchmark_mask (hashconfig); + const char *mask = hashconfig_benchmark_mask (hashcat_ctx); mask_append (mask_ctx, user_options, mask); } diff --git a/src/opencl.c b/src/opencl.c index 0d81c09b2..cf0a2ae72 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -2771,7 +2771,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * there needs to be some upper limit, otherwise there's too much overhead */ - u32 kernel_threads = hashconfig_enforce_kernel_threads (hashconfig, device_param); + u32 kernel_threads = hashconfig_enforce_kernel_threads (hashcat_ctx, device_param); device_param->kernel_threads = kernel_threads; @@ -2929,7 +2929,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * some algorithms need a fixed kernel-loops count */ - const u32 kernel_loops_fixed = hashconfig_enforce_kernel_loops (hashconfig, user_options); + const u32 kernel_loops_fixed = hashconfig_enforce_kernel_loops (hashcat_ctx); if (kernel_loops_fixed != 0) {