Update user_options.c function parameters

pull/533/head
jsteube 8 years ago
parent 14334e4129
commit 076784d235

@ -156,19 +156,19 @@ typedef enum user_options_map
} user_options_map_t;
void user_options_init (user_options_t *user_options);
void user_options_init (hashcat_ctx_t *hashcat_ctx);
void user_options_destroy (user_options_t *user_options);
void user_options_destroy (hashcat_ctx_t *hashcat_ctx);
int user_options_getopt (user_options_t *user_options, int argc, char **argv);
int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv);
int user_options_sanity (const user_options_t *user_options);
int user_options_sanity (hashcat_ctx_t *hashcat_ctx);
void user_options_preprocess (user_options_t *user_options);
void user_options_preprocess (hashcat_ctx_t *hashcat_ctx);
void user_options_extra_init (const user_options_t *user_options, user_options_extra_t *user_options_extra);
void user_options_extra_init (hashcat_ctx_t *hashcat_ctx);
void user_options_extra_destroy (user_options_extra_t *user_options_extra);
void user_options_extra_destroy (hashcat_ctx_t *hashcat_ctx);
void user_options_logger (hashcat_ctx_t *hashcat_ctx);

@ -1273,9 +1273,9 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
* process user input
*/
user_options_preprocess (user_options);
user_options_preprocess (hashcat_ctx);
user_options_extra_init (user_options, user_options_extra);
user_options_extra_init (hashcat_ctx);
/**
* prepare seeding for random number generator, required by logfile and rules generator
@ -1508,8 +1508,6 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
folder_config_destroy (hashcat_ctx);
user_options_extra_destroy (user_options_extra);
hwmon_ctx_destroy (hashcat_ctx);
opencl_ctx_devices_destroy (hashcat_ctx);
@ -1527,7 +1525,9 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
logfile_destroy (hashcat_ctx);
user_options_destroy (user_options);
user_options_extra_destroy (hashcat_ctx);
user_options_destroy (hashcat_ctx);
int rc_final = -1;

@ -24,11 +24,9 @@ int main (int argc, char **argv)
hashcat_ctx_init (hashcat_ctx);
// initialize the user options with some defaults (you can override them)
// initialize the user options with some defaults (you can override them later)
user_options_t *user_options = hashcat_ctx->user_options;
user_options_init (user_options);
user_options_init (hashcat_ctx);
// initialize the session via getops for commandline use or
// alternatively you can set the user_options directly
@ -60,16 +58,18 @@ int main (int argc, char **argv)
// parse commandline parameters and check them
const int rc_options_getopt = user_options_getopt (user_options, argc, argv);
const int rc_options_getopt = user_options_getopt (hashcat_ctx, argc, argv);
if (rc_options_getopt == -1) return -1;
const int rc_options_sanity = user_options_sanity (user_options);
const int rc_options_sanity = user_options_sanity (hashcat_ctx);
if (rc_options_sanity == -1) return -1;
// some early exits
user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->version == true)
{
printf ("%s\n", VERSION_TAG);
@ -113,6 +113,8 @@ int main (int argc, char **argv)
char *hc_argv[] = { hash, mask, NULL };
user_options_t *user_options = hashcat_ctx->user_options;
user_options->hc_argv = hc_argv;
user_options->hc_argc = 2;
user_options->quiet = true;

@ -427,9 +427,9 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
rd->pid = GetCurrentProcessId ();
#endif
user_options_init (user_options);
user_options_init (hashcat_ctx);
const int rc_options_getopt = user_options_getopt (user_options, rd->argc, rd->argv);
const int rc_options_getopt = user_options_getopt (hashcat_ctx, rd->argc, rd->argv);
if (rc_options_getopt == -1) return -1;
}

@ -108,8 +108,10 @@ static char DEF_MASK_CS_1[] = "?l?d?u";
static char DEF_MASK_CS_2[] = "?l?d";
static char DEF_MASK_CS_3[] = "?l?d*!$@_";
void user_options_init (user_options_t *user_options)
void user_options_init (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
user_options->attack_mode = ATTACK_MODE;
user_options->benchmark = BENCHMARK;
user_options->bitmap_max = BITMAP_MAX;
@ -196,16 +198,20 @@ void user_options_init (user_options_t *user_options)
user_options->hc_argv = NULL;
}
void user_options_destroy (user_options_t *user_options)
void user_options_destroy (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
myfree (user_options->rp_files);
//do not reset this, it might be used from main.c
//memset (user_options, 0, sizeof (user_options_t));
}
int user_options_getopt (user_options_t *user_options, int argc, char **argv)
int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
{
user_options_t *user_options = hashcat_ctx->user_options;
int c = -1;
optind = 1;
@ -336,8 +342,10 @@ int user_options_getopt (user_options_t *user_options, int argc, char **argv)
return 0;
}
int user_options_sanity (const user_options_t *user_options)
int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->hc_argc < 0)
{
log_error ("ERROR: hc_argc %d is invalid", user_options->hc_argc);
@ -883,8 +891,10 @@ int user_options_sanity (const user_options_t *user_options)
return 0;
}
void user_options_preprocess (user_options_t *user_options)
void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
#if !defined (WITH_HWMON)
user_options->powertune_enable = false;
user_options->gpu_temp_disable = true;
@ -1070,8 +1080,11 @@ void user_options_preprocess (user_options_t *user_options)
}
}
void user_options_extra_init (const user_options_t *user_options, user_options_extra_t *user_options_extra)
void user_options_extra_init (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
// attack-kern
user_options_extra->attack_kern = ATTACK_KERN_NONE;
@ -1139,8 +1152,10 @@ void user_options_extra_init (const user_options_t *user_options, user_options_e
}
}
void user_options_extra_destroy (user_options_extra_t *user_options_extra)
void user_options_extra_destroy (hashcat_ctx_t *hashcat_ctx)
{
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
memset (user_options_extra, 0, sizeof (user_options_extra_t));
}

Loading…
Cancel
Save