From f4696940302d7bda94778f89c5fe3c7fe59ecafd Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 7 Oct 2016 22:25:52 +0200 Subject: [PATCH] Add event_set_kernel_power_final() --- include/types.h | 1 + src/bitmap.c | 1 - src/dispatch.c | 29 +++++++++++++---------------- src/main.c | 17 +++++++++++++++++ 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/include/types.h b/include/types.h index 4935f8b70..e0ed1c663 100644 --- a/include/types.h +++ b/include/types.h @@ -112,6 +112,7 @@ typedef enum event_identifier EVENT_BITMAP_INIT_POST = 0x00000082, EVENT_WEAK_HASH_PRE = 0x00000091, EVENT_WEAK_HASH_POST = 0x00000092, + EVENT_SET_KERNEL_POWER_FINAL = 0x000000a1, // there will be much more event types soon diff --git a/src/bitmap.c b/src/bitmap.c index a66bf5e9a..0069f0f92 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -6,7 +6,6 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" #include "bitmap.h" static u32 generate_bitmaps (const u32 digests_cnt, const u32 dgst_size, const u32 dgst_shifts, char *digests_buf_ptr, const u32 dgst_pos0, const u32 dgst_pos1, const u32 dgst_pos2, const u32 dgst_pos3, const u32 bitmap_mask, const u32 bitmap_size, u32 *bitmap_a, u32 *bitmap_b, u32 *bitmap_c, u32 *bitmap_d, const u64 collisions_max) diff --git a/src/dispatch.c b/src/dispatch.c index b38dd84a7..361e18fdf 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -35,21 +35,15 @@ #include "shared.h" #include "dispatch.h" -static void set_kernel_power_final (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const u64 kernel_power_final) +static int set_kernel_power_final (hashcat_ctx_t *hashcat_ctx, const u32 kernel_power_final) { - if (user_options->quiet == false) - { - clear_prompt (); + EVENT_SEND (EVENT_SET_KERNEL_POWER_FINAL); - //log_info (""); - - log_info ("INFO: approaching final keyspace, workload adjusted"); - log_info (""); - - send_prompt (); - } + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; opencl_ctx->kernel_power_final = kernel_power_final; + + return 0; } static u32 get_power (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param) @@ -72,8 +66,12 @@ static u32 get_power (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param) return device_param->kernel_power; } -static u32 get_work (opencl_ctx_t *opencl_ctx, status_ctx_t *status_ctx, const user_options_t *user_options, hc_device_param_t *device_param, const u64 max) +static u32 get_work (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 max) { + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + user_options_t *user_options = hashcat_ctx->user_options; + hc_thread_mutex_lock (status_ctx->mux_dispatcher); const u64 words_cur = status_ctx->words_cur; @@ -89,7 +87,7 @@ static u32 get_work (opencl_ctx_t *opencl_ctx, status_ctx_t *status_ctx, const u { if (opencl_ctx->kernel_power_final == 0) { - set_kernel_power_final (opencl_ctx, user_options, words_left); + set_kernel_power_final (hashcat_ctx, words_left); } } @@ -255,7 +253,6 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) hashes_t *hashes = hashcat_ctx->hashes; straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; const u32 attack_mode = user_options->attack_mode; @@ -265,7 +262,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { while (status_ctx->run_thread_level1 == true) { - const u32 work = get_work (opencl_ctx, status_ctx, user_options, device_param, -1u); + const u32 work = get_work (hashcat_ctx, device_param, -1u); if (work == 0) break; @@ -407,7 +404,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) while (max) { - const u32 work = get_work (opencl_ctx, status_ctx, user_options, device_param, max); + const u32 work = get_work (hashcat_ctx, device_param, max); if (work == 0) break; diff --git a/src/main.c b/src/main.c index 19bb43ce3..d3aee33d1 100644 --- a/src/main.c +++ b/src/main.c @@ -462,6 +462,21 @@ static int event_bitmap_init_post (hashcat_ctx_t *hashcat_ctx) return 0; } +static int event_set_kernel_power_final (hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return 0; + + clear_prompt (); + + log_info ("INFO: approaching final keyspace, workload adjusted"); + log_info (""); + + send_prompt (); + + return 0; +} int event (hashcat_ctx_t *hashcat_ctx, const u32 event) { @@ -492,6 +507,8 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event) case EVENT_BITMAP_INIT_POST: rc = event_bitmap_init_post (hashcat_ctx); break; case EVENT_WEAK_HASH_PRE: rc = event_weak_hash_pre (hashcat_ctx); break; case EVENT_WEAK_HASH_POST: rc = event_weak_hash_post (hashcat_ctx); break; + case EVENT_SET_KERNEL_POWER_FINAL: rc = event_set_kernel_power_final (hashcat_ctx); break; + } return rc;