mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-23 00:28:11 +00:00
Get rid of all event_log_* calls in monitor.c and replace them with real events
This commit is contained in:
parent
1f72aa95e6
commit
0fd48b228f
@ -115,6 +115,12 @@ typedef enum event_identifier
|
||||
EVENT_WEAK_HASH_PRE = 0x00000091,
|
||||
EVENT_WEAK_HASH_POST = 0x00000092,
|
||||
EVENT_SET_KERNEL_POWER_FINAL = 0x000000a1,
|
||||
EVENT_MONITOR_THROTTLE1 = 0x000000b1,
|
||||
EVENT_MONITOR_THROTTLE2 = 0x000000b2,
|
||||
EVENT_MONITOR_THROTTLE3 = 0x000000b3,
|
||||
EVENT_MONITOR_TEMP_ABORT = 0x000000c1,
|
||||
EVENT_MONITOR_RUNTIME_LIMIT = 0x000000d1,
|
||||
EVENT_MONITOR_STATUS_REFRESH = 0x000000e1,
|
||||
|
||||
// there will be much more event types soon
|
||||
|
||||
|
134
src/main.c
134
src/main.c
@ -540,6 +540,134 @@ static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx
|
||||
send_prompt ();
|
||||
}
|
||||
|
||||
static void main_monitor_throttle1 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
|
||||
if (user_options->quiet == true) return;
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
clear_prompt ();
|
||||
}
|
||||
|
||||
u32 *device_id = (u32 *) buf;
|
||||
|
||||
event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", *device_id + 1);
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
send_prompt ();
|
||||
}
|
||||
}
|
||||
|
||||
static void main_monitor_throttle2 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
|
||||
if (user_options->quiet == true) return;
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
clear_prompt ();
|
||||
}
|
||||
|
||||
u32 *device_id = (u32 *) buf;
|
||||
|
||||
event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", *device_id + 1);
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
send_prompt ();
|
||||
}
|
||||
}
|
||||
|
||||
static void main_monitor_throttle3 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
|
||||
if (user_options->quiet == true) return;
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
clear_prompt ();
|
||||
}
|
||||
|
||||
u32 *device_id = (u32 *) buf;
|
||||
|
||||
event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", *device_id + 1);
|
||||
event_log_warning (hashcat_ctx, "");
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
send_prompt ();
|
||||
}
|
||||
}
|
||||
|
||||
static void main_monitor_temp_abort (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
|
||||
if (user_options->quiet == true) return;
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
clear_prompt ();
|
||||
}
|
||||
|
||||
u32 *device_id = (u32 *) buf;
|
||||
|
||||
event_log_error (hashcat_ctx, "Temperature limit on GPU #%u reached, aborting...", *device_id + 1);
|
||||
}
|
||||
|
||||
static void main_monitor_runtime_limit (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
|
||||
if (user_options->quiet == true) return;
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
clear_prompt ();
|
||||
}
|
||||
|
||||
event_log_warning (hashcat_ctx, "Runtime limit reached, aborting...");
|
||||
}
|
||||
|
||||
static void main_monitor_status_refresh (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
if (user_options->quiet == false)
|
||||
{
|
||||
//clear_prompt ();
|
||||
|
||||
event_log_info (hashcat_ctx, "");
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
}
|
||||
|
||||
status_display (hashcat_ctx);
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
if (user_options->quiet == false)
|
||||
{
|
||||
event_log_info (hashcat_ctx, "");
|
||||
|
||||
send_prompt ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
switch (id)
|
||||
@ -568,6 +696,12 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz
|
||||
case EVENT_WEAK_HASH_PRE: main_weak_hash_pre (hashcat_ctx, buf, len); break;
|
||||
case EVENT_WEAK_HASH_POST: main_weak_hash_post (hashcat_ctx, buf, len); break;
|
||||
case EVENT_SET_KERNEL_POWER_FINAL: main_set_kernel_power_final (hashcat_ctx, buf, len); break;
|
||||
case EVENT_MONITOR_THROTTLE1: main_monitor_throttle1 (hashcat_ctx, buf, len); break;
|
||||
case EVENT_MONITOR_THROTTLE2: main_monitor_throttle2 (hashcat_ctx, buf, len); break;
|
||||
case EVENT_MONITOR_THROTTLE3: main_monitor_throttle3 (hashcat_ctx, buf, len); break;
|
||||
case EVENT_MONITOR_TEMP_ABORT: main_monitor_temp_abort (hashcat_ctx, buf, len); break;
|
||||
case EVENT_MONITOR_RUNTIME_LIMIT: main_monitor_runtime_limit (hashcat_ctx, buf, len); break;
|
||||
case EVENT_MONITOR_STATUS_REFRESH: main_monitor_status_refresh (hashcat_ctx, buf, len); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
#include "hashes.h"
|
||||
#include "thread.h"
|
||||
#include "restore.h"
|
||||
#include "terminal.h"
|
||||
#include "status.h"
|
||||
#include "shared.h"
|
||||
#include "monitor.h"
|
||||
|
||||
@ -131,21 +129,11 @@ static int monitor (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (rc_throttle > 0)
|
||||
{
|
||||
if (slowdown_warnings < 3)
|
||||
{
|
||||
if (user_options->quiet == false) clear_prompt ();
|
||||
slowdown_warnings++;
|
||||
|
||||
event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", device_id + 1);
|
||||
|
||||
if (slowdown_warnings == 2)
|
||||
{
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
|
||||
if (user_options->quiet == false) send_prompt ();
|
||||
|
||||
slowdown_warnings++;
|
||||
}
|
||||
if (slowdown_warnings == 1) EVENT_DATA (EVENT_MONITOR_THROTTLE1, &device_id, sizeof (u32));
|
||||
if (slowdown_warnings == 2) EVENT_DATA (EVENT_MONITOR_THROTTLE2, &device_id, sizeof (u32));
|
||||
if (slowdown_warnings == 3) EVENT_DATA (EVENT_MONITOR_THROTTLE3, &device_id, sizeof (u32));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -180,13 +168,9 @@ static int monitor (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (temperature > (int) user_options->gpu_temp_abort)
|
||||
{
|
||||
if (user_options->quiet == false) clear_prompt ();
|
||||
|
||||
event_log_error (hashcat_ctx, "Temperature limit on GPU #%u reached, aborting...", device_id + 1);
|
||||
EVENT_DATA (EVENT_MONITOR_TEMP_ABORT, &device_id, sizeof (u32));
|
||||
|
||||
myabort (hashcat_ctx);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
const u32 gpu_temp_retain = user_options->gpu_temp_retain;
|
||||
@ -281,12 +265,7 @@ static int monitor (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (runtime_left <= 0)
|
||||
{
|
||||
if (user_options->benchmark == false)
|
||||
{
|
||||
if (user_options->quiet == false) clear_prompt ();
|
||||
|
||||
if (user_options->quiet == false) event_log_info (hashcat_ctx, "NOTE: Runtime limit reached, aborting...");
|
||||
}
|
||||
EVENT_DATA (EVENT_MONITOR_RUNTIME_LIMIT, NULL, 0);
|
||||
|
||||
myabort (hashcat_ctx);
|
||||
}
|
||||
@ -319,13 +298,7 @@ static int monitor (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
hc_thread_mutex_lock (status_ctx->mux_display);
|
||||
|
||||
if (user_options->quiet == false) clear_prompt ();
|
||||
|
||||
status_display (hashcat_ctx);
|
||||
|
||||
if (user_options->quiet == false) event_log_info (hashcat_ctx, "");
|
||||
|
||||
if (user_options->quiet == false) send_prompt ();
|
||||
EVENT_DATA (EVENT_MONITOR_STATUS_REFRESH, NULL, 0);
|
||||
|
||||
hc_thread_mutex_unlock (status_ctx->mux_display);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user