From 14248d38e38b0299bab21a57242846d48b21b976 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 6 Oct 2016 16:51:01 +0200 Subject: [PATCH] Update tuning_db.c function parameters --- include/tuningdb.h | 6 +++--- src/hashcat.c | 5 ++--- src/opencl.c | 5 ++--- src/tuningdb.c | 14 +++++++++++--- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/tuningdb.h b/include/tuningdb.h index 4be2129f1..0d4c81856 100644 --- a/include/tuningdb.h +++ b/include/tuningdb.h @@ -11,9 +11,9 @@ #define TUNING_DB_FILE "hashcat.hctune" -int tuning_db_init (tuning_db_t *tuning_db, const user_options_t *user_options, const folder_config_t *folder_config); -void tuning_db_destroy (tuning_db_t *tuning_db); +int tuning_db_init (hashcat_ctx_t *hashcat_ctx); +void tuning_db_destroy (hashcat_ctx_t *hashcat_ctx); -tuning_db_entry_t *tuning_db_search (const tuning_db_t *tuning_db, const char *device_name, const cl_device_type device_type, int attack_mode, const int hash_type); +tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *device_name, const cl_device_type device_type, int attack_mode, const int hash_type); #endif // _TUNINGDB_H diff --git a/src/hashcat.c b/src/hashcat.c index 40e3c2bbf..5d50399cf 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1241,7 +1241,6 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - tuning_db_t *tuning_db = hashcat_ctx->tuning_db; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; user_options_t *user_options = hashcat_ctx->user_options; @@ -1297,7 +1296,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold * tuning db */ - const int rc_tuning_db = tuning_db_init (tuning_db, user_options, folder_config); + const int rc_tuning_db = tuning_db_init (hashcat_ctx); if (rc_tuning_db == -1) return -1; @@ -1490,7 +1489,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold debugfile_destroy (hashcat_ctx); - tuning_db_destroy (tuning_db); + tuning_db_destroy (hashcat_ctx); loopback_destroy (loopback_ctx); diff --git a/src/opencl.c b/src/opencl.c index 8a41d82b6..94e127480 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -2581,7 +2581,6 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) hashes_t *hashes = hashcat_ctx->hashes; opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - tuning_db_t *tuning_db = hashcat_ctx->tuning_db; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; user_options_t *user_options = hashcat_ctx->user_options; @@ -2628,7 +2627,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { // tuning db - tuning_db_entry_t *tuningdb_entry = tuning_db_search (tuning_db, device_param->device_name, device_param->device_type, user_options->attack_mode, hashconfig->hash_mode); + tuning_db_entry_t *tuningdb_entry = tuning_db_search (hashcat_ctx, device_param->device_name, device_param->device_type, user_options->attack_mode, hashconfig->hash_mode); if (tuningdb_entry == NULL || tuningdb_entry->vector_width == -1) { @@ -2679,7 +2678,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->kernel_loops_min = 1; device_param->kernel_loops_max = 1024; - tuning_db_entry_t *tuningdb_entry = tuning_db_search (tuning_db, device_param->device_name, device_param->device_type, user_options->attack_mode, hashconfig->hash_mode); + tuning_db_entry_t *tuningdb_entry = tuning_db_search (hashcat_ctx, device_param->device_name, device_param->device_type, user_options->attack_mode, hashconfig->hash_mode); if (tuningdb_entry != NULL) { diff --git a/src/tuningdb.c b/src/tuningdb.c index 8e82e5a68..88968e470 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -50,8 +50,12 @@ static int sort_by_tuning_db_entry (const void *v1, const void *v2) return 0; } -int tuning_db_init (tuning_db_t *tuning_db, const user_options_t *user_options, const folder_config_t *folder_config) +int tuning_db_init (hashcat_ctx_t *hashcat_ctx) { + folder_config_t *folder_config = hashcat_ctx->folder_config; + tuning_db_t *tuning_db = hashcat_ctx->tuning_db; + user_options_t *user_options = hashcat_ctx->user_options; + tuning_db->enabled = false; if (user_options->keyspace == true) return 0; @@ -239,8 +243,10 @@ int tuning_db_init (tuning_db_t *tuning_db, const user_options_t *user_options, return 0; } -void tuning_db_destroy (tuning_db_t *tuning_db) +void tuning_db_destroy (hashcat_ctx_t *hashcat_ctx) { + tuning_db_t *tuning_db = hashcat_ctx->tuning_db; + if (tuning_db->enabled == false) return; int i; @@ -266,8 +272,10 @@ void tuning_db_destroy (tuning_db_t *tuning_db) memset (tuning_db, 0, sizeof (tuning_db_t)); } -tuning_db_entry_t *tuning_db_search (const tuning_db_t *tuning_db, const char *device_name, const cl_device_type device_type, int attack_mode, const int hash_type) +tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *device_name, const cl_device_type device_type, int attack_mode, const int hash_type) { + tuning_db_t *tuning_db = hashcat_ctx->tuning_db; + static tuning_db_entry_t s; // first we need to convert all spaces in the device_name to underscore