mirror of
https://github.com/hashcat/hashcat
synced 2024-12-23 14:13:43 +01:00
Limit status_ctx access with a flag, easier to test
This commit is contained in:
parent
34ee05eb11
commit
f3fc5d96c4
@ -1402,6 +1402,8 @@ typedef struct status_ctx
|
||||
* main status
|
||||
*/
|
||||
|
||||
bool accessible;
|
||||
|
||||
u32 devices_status;
|
||||
|
||||
/**
|
||||
|
@ -223,6 +223,8 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
status_ctx->devices_status = STATUS_RUNNING;
|
||||
|
||||
status_ctx->accessible = true;
|
||||
|
||||
for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
||||
{
|
||||
thread_param_t *thread_param = threads_param + device_id;
|
||||
@ -269,6 +271,8 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
EVENT (EVENT_CRACKER_FINISHED);
|
||||
|
||||
status_ctx->accessible = false;
|
||||
|
||||
// mark sub logfile
|
||||
|
||||
logfile_sub_var_uint ("status-after-work", status_ctx->devices_status);
|
||||
@ -1169,28 +1173,7 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st
|
||||
|
||||
if (status_ctx == NULL) return -1; // ways too early
|
||||
|
||||
/*
|
||||
if (status_ctx->devices_status == STATUS_INIT)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Status view is not available during initialization phase");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (status_ctx->devices_status == STATUS_AUTOTUNE)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Status view is not available during autotune phase");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (status_ctx->devices_status == STATUS_RUNNING)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Status view is not available during autotune phase");
|
||||
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
if (status_ctx->accessible == false) return -1; // either too early or too late
|
||||
|
||||
hashcat_status->digests_cnt = status_get_digests_cnt (hashcat_ctx);
|
||||
hashcat_status->digests_done = status_get_digests_done (hashcat_ctx);
|
||||
|
10
src/status.c
10
src/status.c
@ -530,9 +530,7 @@ char *status_get_input_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const i
|
||||
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
|
||||
if (status_ctx->devices_status == STATUS_INIT) return NULL;
|
||||
if (status_ctx->devices_status == STATUS_AUTOTUNE) return NULL;
|
||||
if (status_ctx->devices_status == STATUS_AUTOTUNE) return NULL;
|
||||
if (status_ctx->accessible == false) return NULL;
|
||||
|
||||
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
|
||||
|
||||
@ -1247,7 +1245,7 @@ int status_get_cpt_cur_min (const hashcat_ctx_t *hashcat_ctx)
|
||||
const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
|
||||
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
if (status_ctx->devices_status != STATUS_RUNNING) return 0;
|
||||
if (status_ctx->accessible == false) return 0;
|
||||
|
||||
const time_t now = time (NULL);
|
||||
|
||||
@ -1272,7 +1270,7 @@ int status_get_cpt_cur_hour (const hashcat_ctx_t *hashcat_ctx)
|
||||
const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
|
||||
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
if (status_ctx->devices_status != STATUS_RUNNING) return 0;
|
||||
if (status_ctx->accessible == false) return 0;
|
||||
|
||||
const time_t now = time (NULL);
|
||||
|
||||
@ -1297,7 +1295,7 @@ int status_get_cpt_cur_day (const hashcat_ctx_t *hashcat_ctx)
|
||||
const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
|
||||
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
if (status_ctx->devices_status != STATUS_RUNNING) return 0;
|
||||
if (status_ctx->accessible == false) return 0;
|
||||
|
||||
const time_t now = time (NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user