1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-30 03:48:17 +00:00

Cleaned up data_t, only contexts left

This commit is contained in:
jsteube 2016-09-29 23:49:33 +02:00
parent 12a2d6d2a0
commit 133c9295f5
14 changed files with 158 additions and 169 deletions

View File

@ -12,7 +12,7 @@
static const char INDUCT_DIR[] = "induct"; static const char INDUCT_DIR[] = "induct";
int induct_ctx_init (induct_ctx_t *induct_ctx, const user_options_t *user_options, const folder_config_t *folder_config, const time_t proc_start); int induct_ctx_init (induct_ctx_t *induct_ctx, const user_options_t *user_options, const folder_config_t *folder_config, const status_ctx_t *status_ctx);
void induct_ctx_scan (induct_ctx_t *induct_ctx); void induct_ctx_scan (induct_ctx_t *induct_ctx);
void induct_ctx_cleanup (induct_ctx_t *induct_ctx); void induct_ctx_cleanup (induct_ctx_t *induct_ctx);
void induct_ctx_destroy (induct_ctx_t *induct_ctx); void induct_ctx_destroy (induct_ctx_t *induct_ctx);

View File

@ -41,7 +41,7 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options); int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options);
void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx); void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx);
void opencl_ctx_devices_update_power (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra); void opencl_ctx_devices_update_power (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, status_ctx_t *status_ctx);
void opencl_ctx_devices_kernel_loops (opencl_ctx_t *opencl_ctx, const user_options_extra_t *user_options_extra, const hashconfig_t *hashconfig, const hashes_t *hashes, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx); void opencl_ctx_devices_kernel_loops (opencl_ctx_t *opencl_ctx, const user_options_extra_t *user_options_extra, const hashconfig_t *hashconfig, const hashes_t *hashes, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx);
int opencl_session_begin (opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, const hashes_t *hashes, const straight_ctx_t *straight_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx, const tuning_db_t *tuning_db); int opencl_session_begin (opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, const hashes_t *hashes, const straight_ctx_t *straight_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx, const tuning_db_t *tuning_db);

View File

@ -23,8 +23,8 @@
#include <windows.h> #include <windows.h>
#endif // _WIN #endif // _WIN
void welcome_screen (const user_options_t *user_options, const time_t proc_start); void welcome_screen (const user_options_t *user_options, const status_ctx_t *status_ctx);
void goodbye_screen (const user_options_t *user_options, const time_t proc_start, const time_t proc_stop); void goodbye_screen (const user_options_t *user_options, const status_ctx_t *status_ctx);
int setup_console (); int setup_console ();

View File

@ -721,9 +721,6 @@ typedef struct
int force_jit_compilation; int force_jit_compilation;
hc_thread_mutex_t mux_dispatcher;
hc_thread_mutex_t mux_counter;
} opencl_ctx_t; } opencl_ctx_t;
#if defined (__APPLE__) #if defined (__APPLE__)
@ -1219,26 +1216,68 @@ typedef struct
typedef struct typedef struct
{ {
/**
* main status
*/
u32 devices_status; u32 devices_status;
/**
* thread control
*/
bool run_main_level1; bool run_main_level1;
bool run_main_level2; bool run_main_level2;
bool run_main_level3; bool run_main_level3;
bool run_thread_level1; bool run_thread_level1;
bool run_thread_level2; bool run_thread_level2;
bool shutdown_inner;
bool shutdown_outer;
hc_thread_mutex_t mux_dispatcher;
hc_thread_mutex_t mux_counter;
hc_thread_mutex_t mux_hwmon;
hc_thread_mutex_t mux_display;
/**
* workload
*/
u64 words_cnt;
u64 words_cur;
u64 words_base;
/**
* progress
*/
u64 *words_progress_done; // progress number of words done per salt u64 *words_progress_done; // progress number of words done per salt
u64 *words_progress_rejected; // progress number of words rejected per salt u64 *words_progress_rejected; // progress number of words rejected per salt
u64 *words_progress_restored; // progress number of words restored per salt u64 *words_progress_restored; // progress number of words restored per salt
/**
* timer
*/
time_t runtime_start;
time_t runtime_stop;
time_t prepare_start;
time_t prepare_time;
time_t proc_start;
time_t proc_stop;
hc_timer_t timer_running; // timer on current dict
hc_timer_t timer_paused; // timer on current dict
double ms_paused; // timer on current dict
} status_ctx_t; } status_ctx_t;
typedef struct typedef struct
{ {
/**
* migrated
*/
bitmap_ctx_t *bitmap_ctx; bitmap_ctx_t *bitmap_ctx;
combinator_ctx_t *combinator_ctx; combinator_ctx_t *combinator_ctx;
cpt_ctx_t *cpt_ctx; cpt_ctx_t *cpt_ctx;
@ -1261,35 +1300,6 @@ typedef struct
user_options_extra_t *user_options_extra; user_options_extra_t *user_options_extra;
user_options_t *user_options; user_options_t *user_options;
/**
* threads
*/
bool shutdown_inner;
bool shutdown_outer;
/**
* status, timer
*/
time_t runtime_start;
time_t runtime_stop;
time_t prepare_start;
time_t prepare_time;
time_t proc_start;
time_t proc_stop;
u64 words_cnt;
u64 words_cur;
u64 words_base;
hc_timer_t timer_running; // timer on current dict
hc_timer_t timer_paused; // timer on current dict
double ms_paused; // timer on current dict
} hc_global_data_t; } hc_global_data_t;
#endif // _TYPES_H #endif // _TYPES_H

View File

@ -75,12 +75,12 @@ static u32 get_power (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param)
return device_param->kernel_power; return device_param->kernel_power;
} }
static uint get_work (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, hc_device_param_t *device_param, const u64 max) static uint 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)
{ {
hc_thread_mutex_lock (opencl_ctx->mux_dispatcher); hc_thread_mutex_lock (status_ctx->mux_dispatcher);
const u64 words_cur = data.words_cur; const u64 words_cur = status_ctx->words_cur;
const u64 words_base = (user_options->limit == 0) ? data.words_base : MIN (user_options->limit, data.words_base); const u64 words_base = (user_options->limit == 0) ? status_ctx->words_base : MIN (user_options->limit, status_ctx->words_base);
device_param->words_off = words_cur; device_param->words_off = words_cur;
@ -102,9 +102,9 @@ static uint get_work (opencl_ctx_t *opencl_ctx, const user_options_t *user_optio
work = MIN (work, max); work = MIN (work, max);
data.words_cur += work; status_ctx->words_cur += work;
hc_thread_mutex_unlock (opencl_ctx->mux_dispatcher); hc_thread_mutex_unlock (status_ctx->mux_dispatcher);
return work; return work;
} }
@ -133,11 +133,11 @@ void *thread_calc_stdin (void *p)
while (status_ctx->run_thread_level1 == true) while (status_ctx->run_thread_level1 == true)
{ {
hc_thread_mutex_lock (opencl_ctx->mux_dispatcher); hc_thread_mutex_lock (status_ctx->mux_dispatcher);
if (feof (stdin) != 0) if (feof (stdin) != 0)
{ {
hc_thread_mutex_unlock (opencl_ctx->mux_dispatcher); hc_thread_mutex_unlock (status_ctx->mux_dispatcher);
break; break;
} }
@ -184,14 +184,14 @@ void *thread_calc_stdin (void *p)
{ {
if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max)) if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max))
{ {
hc_thread_mutex_lock (opencl_ctx->mux_counter); hc_thread_mutex_lock (status_ctx->mux_counter);
for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{ {
status_ctx->words_progress_rejected[salt_pos] += straight_ctx->kernel_rules_cnt; status_ctx->words_progress_rejected[salt_pos] += straight_ctx->kernel_rules_cnt;
} }
hc_thread_mutex_unlock (opencl_ctx->mux_counter); hc_thread_mutex_unlock (status_ctx->mux_counter);
continue; continue;
} }
@ -204,7 +204,7 @@ void *thread_calc_stdin (void *p)
while (status_ctx->run_thread_level1 == false) break; while (status_ctx->run_thread_level1 == false) break;
} }
hc_thread_mutex_unlock (opencl_ctx->mux_dispatcher); hc_thread_mutex_unlock (status_ctx->mux_dispatcher);
while (status_ctx->run_thread_level1 == false) break; while (status_ctx->run_thread_level1 == false) break;
@ -267,7 +267,7 @@ void *thread_calc (void *p)
{ {
while (status_ctx->run_thread_level1 == true) while (status_ctx->run_thread_level1 == true)
{ {
const uint work = get_work (opencl_ctx, user_options, device_param, -1u); const uint work = get_work (opencl_ctx, status_ctx, user_options, device_param, -1u);
if (work == 0) break; if (work == 0) break;
@ -379,7 +379,7 @@ void *thread_calc (void *p)
while (max) while (max)
{ {
const uint work = get_work (opencl_ctx, user_options, device_param, max); const uint work = get_work (opencl_ctx, status_ctx, user_options, device_param, max);
if (work == 0) break; if (work == 0) break;
@ -424,14 +424,14 @@ void *thread_calc (void *p)
{ {
max++; max++;
hc_thread_mutex_lock (opencl_ctx->mux_counter); hc_thread_mutex_lock (status_ctx->mux_counter);
for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{ {
status_ctx->words_progress_rejected[salt_pos] += straight_ctx->kernel_rules_cnt; status_ctx->words_progress_rejected[salt_pos] += straight_ctx->kernel_rules_cnt;
} }
hc_thread_mutex_unlock (opencl_ctx->mux_counter); hc_thread_mutex_unlock (status_ctx->mux_counter);
continue; continue;
} }
@ -445,14 +445,14 @@ void *thread_calc (void *p)
{ {
max++; max++;
hc_thread_mutex_lock (opencl_ctx->mux_counter); hc_thread_mutex_lock (status_ctx->mux_counter);
for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{ {
status_ctx->words_progress_rejected[salt_pos] += combinator_ctx->combs_cnt; status_ctx->words_progress_rejected[salt_pos] += combinator_ctx->combs_cnt;
} }
hc_thread_mutex_unlock (opencl_ctx->mux_counter); hc_thread_mutex_unlock (status_ctx->mux_counter);
continue; continue;
} }

View File

@ -57,9 +57,6 @@ extern hc_global_data_t data;
extern int SUPPRESS_OUTPUT; extern int SUPPRESS_OUTPUT;
extern hc_thread_mutex_t mux_hwmon;
extern hc_thread_mutex_t mux_display;
extern const int DEFAULT_BENCHMARK_ALGORITHMS_CNT; extern const int DEFAULT_BENCHMARK_ALGORITHMS_CNT;
extern const int DEFAULT_BENCHMARK_ALGORITHMS_BUF[]; extern const int DEFAULT_BENCHMARK_ALGORITHMS_BUF[];
@ -82,25 +79,25 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
status_progress_reset (status_ctx, hashes); status_progress_reset (status_ctx, hashes);
data.words_cur = 0; status_ctx->words_cur = 0;
restore_data_t *rd = restore_ctx->rd; restore_data_t *rd = restore_ctx->rd;
if (rd->words_cur) if (rd->words_cur)
{ {
data.words_cur = rd->words_cur; status_ctx->words_cur = rd->words_cur;
user_options->skip = 0; user_options->skip = 0;
} }
if (user_options->skip) if (user_options->skip)
{ {
data.words_cur = user_options->skip; status_ctx->words_cur = user_options->skip;
user_options->skip = 0; user_options->skip = 0;
} }
data.ms_paused = 0; status_ctx->ms_paused = 0;
opencl_session_reset (opencl_ctx); opencl_session_reset (opencl_ctx);
@ -137,11 +134,11 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
return -1; return -1;
} }
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, straight_ctx->dict, dictstat_ctx); status_ctx->words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, straight_ctx->dict, dictstat_ctx);
fclose (fd2); fclose (fd2);
if (data.words_cnt == 0) if (status_ctx->words_cnt == 0)
{ {
logfile_sub_msg ("STOP"); logfile_sub_msg ("STOP");
@ -165,7 +162,7 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
return -1; return -1;
} }
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, combinator_ctx->dict1, dictstat_ctx); status_ctx->words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, combinator_ctx->dict1, dictstat_ctx);
fclose (fd2); fclose (fd2);
} }
@ -180,12 +177,12 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
return -1; return -1;
} }
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, combinator_ctx->dict2, dictstat_ctx); status_ctx->words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, combinator_ctx->dict2, dictstat_ctx);
fclose (fd2); fclose (fd2);
} }
if (data.words_cnt == 0) if (status_ctx->words_cnt == 0)
{ {
logfile_sub_msg ("STOP"); logfile_sub_msg ("STOP");
@ -215,11 +212,11 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
return -1; return -1;
} }
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, straight_ctx->dict, dictstat_ctx); status_ctx->words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, straight_ctx->dict, dictstat_ctx);
fclose (fd2); fclose (fd2);
if (data.words_cnt == 0) if (status_ctx->words_cnt == 0)
{ {
logfile_sub_msg ("STOP"); logfile_sub_msg ("STOP");
@ -231,7 +228,7 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
logfile_sub_string (mask_ctx->mask); logfile_sub_string (mask_ctx->mask);
} }
u64 words_base = data.words_cnt; u64 words_base = status_ctx->words_cnt;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{ {
@ -255,7 +252,7 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
} }
} }
data.words_base = words_base; status_ctx->words_base = words_base;
if (user_options->keyspace == true) if (user_options->keyspace == true)
{ {
@ -264,34 +261,34 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
return 0; return 0;
} }
if (data.words_cur > data.words_base) if (status_ctx->words_cur > status_ctx->words_base)
{ {
log_error ("ERROR: Restore value greater keyspace"); log_error ("ERROR: Restore value greater keyspace");
return -1; return -1;
} }
if (data.words_cur) if (status_ctx->words_cur)
{ {
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{ {
for (uint i = 0; i < hashes->salts_cnt; i++) for (uint i = 0; i < hashes->salts_cnt; i++)
{ {
status_ctx->words_progress_restored[i] = data.words_cur * straight_ctx->kernel_rules_cnt; status_ctx->words_progress_restored[i] = status_ctx->words_cur * straight_ctx->kernel_rules_cnt;
} }
} }
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{ {
for (uint i = 0; i < hashes->salts_cnt; i++) for (uint i = 0; i < hashes->salts_cnt; i++)
{ {
status_ctx->words_progress_restored[i] = data.words_cur * combinator_ctx->combs_cnt; status_ctx->words_progress_restored[i] = status_ctx->words_cur * combinator_ctx->combs_cnt;
} }
} }
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
{ {
for (uint i = 0; i < hashes->salts_cnt; i++) for (uint i = 0; i < hashes->salts_cnt; i++)
{ {
status_ctx->words_progress_restored[i] = data.words_cur * mask_ctx->bfs_cnt; status_ctx->words_progress_restored[i] = status_ctx->words_cur * mask_ctx->bfs_cnt;
} }
} }
} }
@ -331,7 +328,7 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
* autotune modified kernel_accel, which modifies opencl_ctx->kernel_power_all * autotune modified kernel_accel, which modifies opencl_ctx->kernel_power_all
*/ */
opencl_ctx_devices_update_power (opencl_ctx, user_options, user_options_extra); opencl_ctx_devices_update_power (opencl_ctx, user_options, user_options_extra, status_ctx);
/** /**
* Begin loopback recording * Begin loopback recording
@ -363,15 +360,15 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
* Prepare cracking stats * Prepare cracking stats
*/ */
hc_timer_set (&data.timer_running); hc_timer_set (&status_ctx->timer_running);
time_t runtime_start; time_t runtime_start;
time (&runtime_start); time (&runtime_start);
data.runtime_start = runtime_start; status_ctx->runtime_start = runtime_start;
data.prepare_time = runtime_start - data.prepare_start; status_ctx->prepare_time = runtime_start - status_ctx->prepare_start;
/** /**
* create cracker threads * create cracker threads
@ -415,12 +412,12 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
time (&runtime_stop); time (&runtime_stop);
data.runtime_stop = runtime_stop; status_ctx->runtime_stop = runtime_stop;
logfile_sub_uint (runtime_start); logfile_sub_uint (runtime_start);
logfile_sub_uint (runtime_stop); logfile_sub_uint (runtime_stop);
time (&data.prepare_start); time (&status_ctx->prepare_start);
logfile_sub_msg ("STOP"); logfile_sub_msg ("STOP");
@ -684,7 +681,7 @@ static int inner1_loop (status_ctx_t *status_ctx, user_options_t *user_options,
sp_tbl_to_css (mask_ctx->root_table_buf, mask_ctx->markov_table_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, user_options->markov_threshold, uniq_tbls); sp_tbl_to_css (mask_ctx->root_table_buf, mask_ctx->markov_table_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, user_options->markov_threshold, uniq_tbls);
data.words_cnt = sp_get_sum (0, mask_ctx->css_cnt, mask_ctx->root_css_buf); status_ctx->words_cnt = sp_get_sum (0, mask_ctx->css_cnt, mask_ctx->root_css_buf);
// copy + args // copy + args
@ -1190,7 +1187,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
* setup prepare timer * setup prepare timer
*/ */
time (&data.prepare_start); time (&status_ctx->prepare_start);
/** /**
* setup variables and buffers depending on hash_mode * setup variables and buffers depending on hash_mode
@ -1503,7 +1500,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
hc_thread_t *inner_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t)); hc_thread_t *inner_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t));
data.shutdown_inner = false; status_ctx->shutdown_inner = false;
/** /**
* Outfile remove * Outfile remove
@ -1577,7 +1574,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
// wait for inner threads // wait for inner threads
data.shutdown_inner = true; status_ctx->shutdown_inner = true;
for (uint thread_idx = 0; thread_idx < inner_threads_cnt; thread_idx++) for (uint thread_idx = 0; thread_idx < inner_threads_cnt; thread_idx++)
{ {
@ -1656,21 +1653,6 @@ int main (int argc, char **argv)
setup_umask (); setup_umask ();
/**
* Real init
*/
memset (&data, 0, sizeof (hc_global_data_t));
time_t proc_start;
time (&proc_start);
data.proc_start = proc_start;
hc_thread_mutex_init (mux_display);
hc_thread_mutex_init (mux_hwmon);
/** /**
* status init * status init
*/ */
@ -1773,7 +1755,7 @@ int main (int argc, char **argv)
* - this is giving us a visual header before preparations start, so we do not need to clear them afterwards * - this is giving us a visual header before preparations start, so we do not need to clear them afterwards
*/ */
welcome_screen (user_options, proc_start); welcome_screen (user_options, status_ctx);
/** /**
* logfile init * logfile init
@ -1809,7 +1791,7 @@ int main (int argc, char **argv)
data.induct_ctx = induct_ctx; data.induct_ctx = induct_ctx;
const int rc_induct_ctx_init = induct_ctx_init (induct_ctx, user_options, folder_config, proc_start); const int rc_induct_ctx_init = induct_ctx_init (induct_ctx, user_options, folder_config, status_ctx);
if (rc_induct_ctx_init == -1) return -1; if (rc_induct_ctx_init == -1) return -1;
@ -1947,7 +1929,7 @@ int main (int argc, char **argv)
hc_thread_t *outer_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t)); hc_thread_t *outer_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t));
data.shutdown_outer = false; status_ctx->shutdown_outer = false;
if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false) if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false)
{ {
@ -1996,7 +1978,7 @@ int main (int argc, char **argv)
// wait for outer threads // wait for outer threads
data.shutdown_outer = true; status_ctx->shutdown_outer = true;
for (uint thread_idx = 0; thread_idx < outer_threads_cnt; thread_idx++) for (uint thread_idx = 0; thread_idx < outer_threads_cnt; thread_idx++)
{ {
@ -2010,11 +1992,6 @@ int main (int argc, char **argv)
user_options->quiet = false; user_options->quiet = false;
} }
// destroy others mutex
hc_thread_mutex_delete (mux_display);
hc_thread_mutex_delete (mux_hwmon);
// free memory // free memory
debugfile_destroy (debugfile_ctx); debugfile_destroy (debugfile_ctx);
@ -2041,20 +2018,20 @@ int main (int argc, char **argv)
opencl_ctx_devices_destroy (opencl_ctx); opencl_ctx_devices_destroy (opencl_ctx);
opencl_ctx_destroy (opencl_ctx);
restore_ctx_destroy (restore_ctx); restore_ctx_destroy (restore_ctx);
time_t proc_stop; time (&status_ctx->proc_stop);
time (&proc_stop); logfile_top_uint (status_ctx->proc_start);
logfile_top_uint (status_ctx->proc_stop);
logfile_top_uint (proc_start);
logfile_top_uint (proc_stop);
logfile_top_msg ("STOP"); logfile_top_msg ("STOP");
logfile_destroy (logfile_ctx); logfile_destroy (logfile_ctx);
goodbye_screen (user_options, proc_start, proc_stop); goodbye_screen (user_options, status_ctx);
user_options_destroy (user_options); user_options_destroy (user_options);
@ -2065,8 +2042,6 @@ int main (int argc, char **argv)
if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_final = 1; if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_final = 1;
if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0; if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0;
opencl_ctx_destroy (opencl_ctx);
status_ctx_destroy (status_ctx); status_ctx_destroy (status_ctx);
return rc_final; return rc_final;

View File

@ -21,7 +21,7 @@ static int sort_by_mtime (const void *p1, const void *p2)
return s2.st_mtime - s1.st_mtime; return s2.st_mtime - s1.st_mtime;
} }
int induct_ctx_init (induct_ctx_t *induct_ctx, const user_options_t *user_options, const folder_config_t *folder_config, const time_t proc_start) int induct_ctx_init (induct_ctx_t *induct_ctx, const user_options_t *user_options, const folder_config_t *folder_config, const status_ctx_t *status_ctx)
{ {
induct_ctx->enabled = false; induct_ctx->enabled = false;
@ -47,7 +47,7 @@ int induct_ctx_init (induct_ctx_t *induct_ctx, const user_options_t *user_option
{ {
char *root_directory_mv = (char *) mymalloc (HCBUFSIZ_TINY); char *root_directory_mv = (char *) mymalloc (HCBUFSIZ_TINY);
snprintf (root_directory_mv, HCBUFSIZ_TINY - 1, "%s/%s.induct.%d", folder_config->session_dir, user_options->session, (int) proc_start); snprintf (root_directory_mv, HCBUFSIZ_TINY - 1, "%s/%s.induct.%d", folder_config->session_dir, user_options->session, (int) status_ctx->proc_start);
if (rename (root_directory, root_directory_mv) != 0) if (rename (root_directory, root_directory_mv) != 0)
{ {

View File

@ -112,7 +112,7 @@ void *thread_monitor (void *p)
u32 remove_left = user_options->remove_timer; u32 remove_left = user_options->remove_timer;
u32 status_left = user_options->status_timer; u32 status_left = user_options->status_timer;
while (data.shutdown_inner == false) while (status_ctx->shutdown_inner == false)
{ {
hc_sleep (sleep_time); hc_sleep (sleep_time);
@ -291,15 +291,15 @@ void *thread_monitor (void *p)
} }
} }
if ((runtime_check == true) && (data.runtime_start > 0)) if ((runtime_check == true) && (status_ctx->runtime_start > 0))
{ {
double ms_paused = data.ms_paused; double ms_paused = status_ctx->ms_paused;
if (status_ctx->devices_status == STATUS_PAUSED) if (status_ctx->devices_status == STATUS_PAUSED)
{ {
double ms_paused_tmp = 0; double ms_paused_tmp = 0;
hc_timer_get (data.timer_paused, ms_paused_tmp); hc_timer_get (status_ctx->timer_paused, ms_paused_tmp);
ms_paused += ms_paused_tmp; ms_paused += ms_paused_tmp;
} }
@ -308,7 +308,7 @@ void *thread_monitor (void *p)
time (&runtime_cur); time (&runtime_cur);
int runtime_left = data.proc_start + user_options->runtime + data.prepare_time + (ms_paused / 1000) - runtime_cur; int runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (ms_paused / 1000) - runtime_cur;
if (runtime_left <= 0) if (runtime_left <= 0)
{ {

View File

@ -1299,11 +1299,11 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
u64 perf_sum_all = (u64) pws_cnt * (u64) innerloop_left; u64 perf_sum_all = (u64) pws_cnt * (u64) innerloop_left;
hc_thread_mutex_lock (opencl_ctx->mux_counter); hc_thread_mutex_lock (status_ctx->mux_counter);
status_ctx->words_progress_done[salt_pos] += perf_sum_all; status_ctx->words_progress_done[salt_pos] += perf_sum_all;
hc_thread_mutex_unlock (opencl_ctx->mux_counter); hc_thread_mutex_unlock (status_ctx->mux_counter);
/** /**
* speed * speed
@ -1359,9 +1359,6 @@ int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_option
if (user_options->left == true) return 0; if (user_options->left == true) return 0;
if (user_options->keyspace == true) return 0; if (user_options->keyspace == true) return 0;
hc_thread_mutex_init (opencl_ctx->mux_dispatcher);
hc_thread_mutex_init (opencl_ctx->mux_counter);
opencl_ctx->ocl = (OCL_PTR *) mymalloc (sizeof (OCL_PTR)); opencl_ctx->ocl = (OCL_PTR *) mymalloc (sizeof (OCL_PTR));
hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (DEVICES_MAX, sizeof (hc_device_param_t)); hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (DEVICES_MAX, sizeof (hc_device_param_t));
@ -1534,9 +1531,6 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx)
myfree (opencl_ctx->platform_devices); myfree (opencl_ctx->platform_devices);
hc_thread_mutex_delete (opencl_ctx->mux_counter);
hc_thread_mutex_delete (opencl_ctx->mux_dispatcher);
myfree (opencl_ctx); myfree (opencl_ctx);
} }
@ -2454,7 +2448,7 @@ void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx)
opencl_ctx->need_xnvctrl = 0; opencl_ctx->need_xnvctrl = 0;
} }
void opencl_ctx_devices_update_power (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra) void opencl_ctx_devices_update_power (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, status_ctx_t *status_ctx)
{ {
u32 kernel_power_all = 0; u32 kernel_power_all = 0;
@ -2473,7 +2467,7 @@ void opencl_ctx_devices_update_power (opencl_ctx_t *opencl_ctx, const user_optio
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{ {
if (data.words_base < kernel_power_all) if (status_ctx->words_base < kernel_power_all)
{ {
if (user_options->quiet == false) if (user_options->quiet == false)
{ {

View File

@ -74,7 +74,7 @@ void *thread_outfile_remove (void *p)
uint check_left = outfile_check_timer; // or 1 if we want to check it at startup uint check_left = outfile_check_timer; // or 1 if we want to check it at startup
while (data.shutdown_inner == false) while (status_ctx->shutdown_inner == false)
{ {
hc_sleep (1); hc_sleep (1);

View File

@ -40,7 +40,7 @@ u64 get_lowest_words_done (const restore_ctx_t *restore_ctx, const opencl_ctx_t
// It's possible that a device's workload isn't finished right after a restore-case. // It's possible that a device's workload isn't finished right after a restore-case.
// In that case, this function would return 0 and overwrite the real restore point // In that case, this function would return 0 and overwrite the real restore point
// There's also data.words_cur which is set to rd->words_cur but it changes while // There's also status_ctx->words_cur which is set to rd->words_cur but it changes while
// the attack is running therefore we should stick to rd->words_cur. // the attack is running therefore we should stick to rd->words_cur.
// Note that -s influences rd->words_cur we should keep a close look on that. // Note that -s influences rd->words_cur we should keep a close look on that.

View File

@ -233,7 +233,7 @@ void status_display_machine_readable (status_ctx_t *status_ctx, opencl_ctx_t *op
* counter * counter
*/ */
u64 progress_total = data.words_cnt * hashes->salts_cnt; u64 progress_total = status_ctx->words_cnt * hashes->salts_cnt;
u64 all_done = 0; u64 all_done = 0;
u64 all_rejected = 0; u64 all_rejected = 0;
@ -253,7 +253,7 @@ void status_display_machine_readable (status_ctx_t *status_ctx, opencl_ctx_t *op
if (user_options->skip) if (user_options->skip)
{ {
progress_skip = MIN (user_options->skip, data.words_base) * hashes->salts_cnt; progress_skip = MIN (user_options->skip, status_ctx->words_base) * hashes->salts_cnt;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt; if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt; else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt;
@ -262,7 +262,7 @@ void status_display_machine_readable (status_ctx_t *status_ctx, opencl_ctx_t *op
if (user_options->limit) if (user_options->limit)
{ {
progress_end = MIN (user_options->limit, data.words_base) * hashes->salts_cnt; progress_end = MIN (user_options->limit, status_ctx->words_base) * hashes->salts_cnt;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt; if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt; else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt;
@ -323,7 +323,7 @@ void status_display (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const h
} }
// in this case some required buffers are free'd, ascii_digest() would run into segfault // in this case some required buffers are free'd, ascii_digest() would run into segfault
if (data.shutdown_inner == 1) return; if (status_ctx->shutdown_inner == 1) return;
if (user_options->machine_readable == true) if (user_options->machine_readable == true)
{ {
@ -625,15 +625,15 @@ void status_display (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const h
double ms_running = 0; double ms_running = 0;
hc_timer_get (data.timer_running, ms_running); hc_timer_get (status_ctx->timer_running, ms_running);
double ms_paused = data.ms_paused; double ms_paused = status_ctx->ms_paused;
if (status_ctx->devices_status == STATUS_PAUSED) if (status_ctx->devices_status == STATUS_PAUSED)
{ {
double ms_paused_tmp = 0; double ms_paused_tmp = 0;
hc_timer_get (data.timer_paused, ms_paused_tmp); hc_timer_get (status_ctx->timer_paused, ms_paused_tmp);
ms_paused += ms_paused_tmp; ms_paused += ms_paused_tmp;
} }
@ -674,7 +674,7 @@ void status_display (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const h
format_timer_display (&tm_run, display_run, sizeof (tm_run)); format_timer_display (&tm_run, display_run, sizeof (tm_run));
char *start = ctime (&data.proc_start); char *start = ctime (&status_ctx->proc_start);
size_t start_len = strlen (start); size_t start_len = strlen (start);
@ -693,7 +693,7 @@ void status_display (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const h
* counters * counters
*/ */
u64 progress_total = data.words_cnt * hashes->salts_cnt; u64 progress_total = status_ctx->words_cnt * hashes->salts_cnt;
u64 all_done = 0; u64 all_done = 0;
u64 all_rejected = 0; u64 all_rejected = 0;
@ -715,7 +715,7 @@ void status_display (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const h
+ status_ctx->words_progress_rejected[salt_pos] + status_ctx->words_progress_rejected[salt_pos]
+ status_ctx->words_progress_restored[salt_pos]; + status_ctx->words_progress_restored[salt_pos];
const u64 left = data.words_cnt - all; const u64 left = status_ctx->words_cnt - all;
progress_noneed += left; progress_noneed += left;
} }
@ -728,7 +728,7 @@ void status_display (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const h
if (user_options->skip) if (user_options->skip)
{ {
progress_skip = MIN (user_options->skip, data.words_base) * hashes->salts_cnt; progress_skip = MIN (user_options->skip, status_ctx->words_base) * hashes->salts_cnt;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt; if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt; else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt;
@ -737,7 +737,7 @@ void status_display (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const h
if (user_options->limit) if (user_options->limit)
{ {
progress_end = MIN (user_options->limit, data.words_base) * hashes->salts_cnt; progress_end = MIN (user_options->limit, status_ctx->words_base) * hashes->salts_cnt;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt; if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt; else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt;
@ -819,13 +819,13 @@ void status_display (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const h
#if defined (_WIN) #if defined (_WIN)
__time64_t runtime_left = data.proc_start + user_options->runtime + data.prepare_time + (ms_paused / 1000) - runtime_cur; __time64_t runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (ms_paused / 1000) - runtime_cur;
tmp = _gmtime64 (&runtime_left); tmp = _gmtime64 (&runtime_left);
#else #else
time_t runtime_left = data.proc_start + user_options->runtime + data.prepare_time + (ms_paused / 1000) - runtime_cur; time_t runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (ms_paused / 1000) - runtime_cur;
tmp = gmtime (&runtime_left); tmp = gmtime (&runtime_left);
@ -958,7 +958,7 @@ void status_display (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const h
u64 restore_point = get_lowest_words_done (restore_ctx, opencl_ctx); u64 restore_point = get_lowest_words_done (restore_ctx, opencl_ctx);
u64 restore_total = data.words_base; u64 restore_total = status_ctx->words_base;
double percent_restore = 0; double percent_restore = 0;
@ -1160,7 +1160,7 @@ void status_benchmark (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const
return; return;
} }
if (data.shutdown_inner == 1) return; if (status_ctx->shutdown_inner == 1) return;
if (user_options->machine_readable == true) if (user_options->machine_readable == true)
{ {
@ -1283,12 +1283,22 @@ int status_ctx_init (status_ctx_t *status_ctx)
status_ctx->run_thread_level1 = true; status_ctx->run_thread_level1 = true;
status_ctx->run_thread_level2 = true; status_ctx->run_thread_level2 = true;
hc_thread_mutex_init (status_ctx->mux_dispatcher);
hc_thread_mutex_init (status_ctx->mux_counter);
hc_thread_mutex_init (status_ctx->mux_display);
hc_thread_mutex_init (status_ctx->mux_hwmon);
time (&status_ctx->proc_start);
return 0; return 0;
} }
void status_ctx_destroy (status_ctx_t *status_ctx) void status_ctx_destroy (status_ctx_t *status_ctx)
{ {
hc_thread_mutex_delete (status_ctx->mux_dispatcher);
hc_thread_mutex_delete (status_ctx->mux_counter);
hc_thread_mutex_delete (status_ctx->mux_display);
hc_thread_mutex_delete (status_ctx->mux_hwmon);
myfree (status_ctx); myfree (status_ctx);
} }

View File

@ -38,7 +38,7 @@ extern const char *version_tag;
const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint [q]uit => "; const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint [q]uit => ";
void welcome_screen (const user_options_t *user_options, const time_t proc_start) void welcome_screen (const user_options_t *user_options, const status_ctx_t *status_ctx)
{ {
if (user_options->quiet == true) return; if (user_options->quiet == true) return;
if (user_options->keyspace == true) return; if (user_options->keyspace == true) return;
@ -55,7 +55,7 @@ void welcome_screen (const user_options_t *user_options, const time_t proc_start
} }
else else
{ {
log_info ("# %s (%s) %s", PROGNAME, version_tag, ctime (&proc_start)); log_info ("# %s (%s) %s", PROGNAME, version_tag, ctime (&status_ctx->proc_start));
} }
} }
else if (user_options->restore == true) else if (user_options->restore == true)
@ -70,7 +70,7 @@ void welcome_screen (const user_options_t *user_options, const time_t proc_start
} }
} }
void goodbye_screen (const user_options_t *user_options, const time_t proc_start, const time_t proc_stop) void goodbye_screen (const user_options_t *user_options, const status_ctx_t *status_ctx)
{ {
if (user_options->quiet == true) return; if (user_options->quiet == true) return;
if (user_options->keyspace == true) return; if (user_options->keyspace == true) return;
@ -78,8 +78,8 @@ void goodbye_screen (const user_options_t *user_options, const time_t proc_start
if (user_options->show == true) return; if (user_options->show == true) return;
if (user_options->left == true) return; if (user_options->left == true) return;
log_info_nn ("Started: %s", ctime (&proc_start)); log_info_nn ("Started: %s", ctime (&status_ctx->proc_start));
log_info_nn ("Stopped: %s", ctime (&proc_stop)); log_info_nn ("Stopped: %s", ctime (&status_ctx->proc_stop));
} }
int setup_console () int setup_console ()
@ -155,7 +155,7 @@ void *thread_keypress (void *p)
tty_break (); tty_break ();
while (data.shutdown_outer == false) while (status_ctx->shutdown_outer == false)
{ {
int ch = tty_getchar (); int ch = tty_getchar ();

View File

@ -51,7 +51,7 @@ BOOL WINAPI sigHandler_default (DWORD sig)
* function otherwise it is too late (e.g. after returning from this function) * function otherwise it is too late (e.g. after returning from this function)
*/ */
myabort (data.opencl_ctx); myabort (data.status_ctx);
SetConsoleCtrlHandler (NULL, TRUE); SetConsoleCtrlHandler (NULL, TRUE);
@ -63,7 +63,7 @@ BOOL WINAPI sigHandler_default (DWORD sig)
case CTRL_LOGOFF_EVENT: case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT: case CTRL_SHUTDOWN_EVENT:
myabort (data.opencl_ctx); myabort (data.status_ctx);
SetConsoleCtrlHandler (NULL, TRUE); SetConsoleCtrlHandler (NULL, TRUE);
@ -79,7 +79,7 @@ BOOL WINAPI sigHandler_benchmark (DWORD sig)
{ {
case CTRL_CLOSE_EVENT: case CTRL_CLOSE_EVENT:
myquit (data.opencl_ctx); myquit (data.status_ctx);
SetConsoleCtrlHandler (NULL, TRUE); SetConsoleCtrlHandler (NULL, TRUE);
@ -91,7 +91,7 @@ BOOL WINAPI sigHandler_benchmark (DWORD sig)
case CTRL_LOGOFF_EVENT: case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT: case CTRL_SHUTDOWN_EVENT:
myquit (data.opencl_ctx); myquit (data.status_ctx);
SetConsoleCtrlHandler (NULL, TRUE); SetConsoleCtrlHandler (NULL, TRUE);
@ -198,7 +198,7 @@ void SuspendThreads (status_ctx_t *status_ctx)
{ {
if (status_ctx->devices_status != STATUS_RUNNING) return; if (status_ctx->devices_status != STATUS_RUNNING) return;
hc_timer_set (&data.timer_paused); hc_timer_set (&status_ctx->timer_paused);
status_ctx->devices_status = STATUS_PAUSED; status_ctx->devices_status = STATUS_PAUSED;
@ -211,9 +211,9 @@ void ResumeThreads (status_ctx_t *status_ctx)
double ms_paused; double ms_paused;
hc_timer_get (data.timer_paused, ms_paused); hc_timer_get (status_ctx->timer_paused, ms_paused);
data.ms_paused += ms_paused; status_ctx->ms_paused += ms_paused;
status_ctx->devices_status = STATUS_RUNNING; status_ctx->devices_status = STATUS_RUNNING;