Introduce folder_config_t

pull/518/head
jsteube 8 years ago
parent b2b2855ac3
commit 1cc4358820

@ -15,6 +15,11 @@
#endif // __APPLE__
#endif // _POSIX
#if defined (_POSIX)
#include <sys/types.h>
#include <pwd.h>
#endif
#if defined (_WIN)
#include <windows.h>
#endif
@ -36,3 +41,6 @@ char *get_session_dir (const char *profile_dir);
int count_dictionaries (char **dictionary_files);
char **scan_directory (const char *path);
int folder_config_init (folder_config_t *folder_config, const char *install_folder, const char *shared_folder);
void folder_config_destroy (folder_config_t *folder_config);

@ -91,7 +91,7 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const user_options_t *user_options, const uint algorithm_pos);
void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx);
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra);
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config);
int opencl_session_destroy (opencl_ctx_t *opencl_ctx);
#endif // _OPENCL_H

@ -6,7 +6,7 @@
#ifndef _SESSION_H
#define _SESSION_H
void session_ctx_init (session_ctx_t *session_ctx, char *cwd, char *install_dir, char *profile_dir, char *session_dir, char *shared_dir, char *cpath_real, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf,const u32 bitmap_size, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, u32 *bitmap_s1_a, u32 *bitmap_s1_b, u32 *bitmap_s1_c, u32 *bitmap_s1_d, u32 *bitmap_s2_a, u32 *bitmap_s2_b, u32 *bitmap_s2_c, u32 *bitmap_s2_d);
void session_ctx_init (session_ctx_t *session_ctx, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf, const u32 bitmap_size, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, u32 *bitmap_s1_a, u32 *bitmap_s1_b, u32 *bitmap_s1_c, u32 *bitmap_s1_d, u32 *bitmap_s2_a, u32 *bitmap_s2_b, u32 *bitmap_s2_c, u32 *bitmap_s2_d);
void session_ctx_destroy (session_ctx_t *session_ctx);

@ -857,13 +857,6 @@ typedef struct
typedef struct
{
char *cwd;
char *install_dir;
char *profile_dir;
char *session_dir;
char *shared_dir;
char *cpath_real;
u32 kernel_rules_cnt;
kernel_rule_t *kernel_rules_buf;
@ -883,6 +876,17 @@ typedef struct
} session_ctx_t;
typedef struct
{
char *cwd;
char *install_dir;
char *profile_dir;
char *session_dir;
char *shared_dir;
char *cpath_real;
} folder_config_t;
typedef struct
{
/**

@ -10,6 +10,8 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "shared.h"
#include "folder.h"
#if defined (__APPLE__)
@ -103,22 +105,18 @@ char *get_install_dir (const char *progname)
char *get_profile_dir (const char *homedir)
{
size_t len = strlen (homedir) + 1 + strlen (DOT_HASHCAT) + 1;
char *profile_dir = (char *) mymalloc (len + 1);
char *profile_dir = (char *) mymalloc (HCBUFSIZ_TINY + 1);
snprintf (profile_dir, len, "%s/%s", homedir, DOT_HASHCAT);
snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", homedir, DOT_HASHCAT);
return profile_dir;
}
char *get_session_dir (const char *profile_dir)
{
size_t len = strlen (profile_dir) + 1 + strlen (SESSIONS_FOLDER) + 1;
char *session_dir = (char *) mymalloc (len + 1);
char *session_dir = (char *) mymalloc (HCBUFSIZ_TINY);
snprintf (session_dir, len, "%s/%s", profile_dir, SESSIONS_FOLDER);
snprintf (session_dir, HCBUFSIZ_TINY - 1, "%s/%s", profile_dir, SESSIONS_FOLDER);
return session_dir;
}
@ -235,3 +233,188 @@ char **scan_directory (const char *path)
return (files);
}
int folder_config_init (folder_config_t *folder_config, const char *install_folder, const char *shared_folder)
{
/**
* There's some buggy OpenCL runtime that do not support -I.
* A workaround is to chdir() to the OpenCL folder,
* then compile the kernels,
* then chdir() back to where we came from so we need to save it first
*/
char *cwd = (char *) mymalloc (HCBUFSIZ_TINY);
if (getcwd (cwd, HCBUFSIZ_TINY - 1) == NULL)
{
log_error ("ERROR: getcwd(): %s", strerror (errno));
return -1;
}
/**
* folders, as discussed on https://github.com/hashcat/hashcat/issues/20
*/
char *exec_path = get_exec_path ();
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
char *resolved_install_folder = realpath (install_folder, NULL);
char *resolved_exec_path = realpath (exec_path, NULL);
if (resolved_install_folder == NULL)
{
log_error ("ERROR: %s: %s", resolved_install_folder, strerror (errno));
return -1;
}
if (resolved_exec_path == NULL)
{
log_error ("ERROR: %s: %s", resolved_exec_path, strerror (errno));
return -1;
}
char *install_dir = get_install_dir (resolved_exec_path);
char *profile_dir = NULL;
char *session_dir = NULL;
char *shared_dir = NULL;
if (strcmp (install_dir, resolved_install_folder) == 0)
{
struct passwd *pw = getpwuid (getuid ());
const char *homedir = pw->pw_dir;
profile_dir = get_profile_dir (homedir);
session_dir = get_session_dir (profile_dir);
shared_dir = mystrdup (shared_folder);
mkdir (profile_dir, 0700);
mkdir (session_dir, 0700);
}
else
{
profile_dir = install_dir;
session_dir = install_dir;
shared_dir = install_dir;
}
myfree (resolved_install_folder);
myfree (resolved_exec_path);
#else
if (install_folder == NULL) install_folder = NULL; // make compiler happy
if (shared_folder == NULL) shared_folder = NULL; // make compiler happy
char *install_dir = get_install_dir (exec_path);
char *profile_dir = install_dir;
char *session_dir = install_dir;
char *shared_dir = install_dir;
#endif
myfree (exec_path);
/**
* There's alot of problem related to bad support -I parameters when building the kernel.
* Each OpenCL runtime handles it slightly different.
* The most problematic is with new AMD drivers on Windows, which can not handle quote characters!
* The best workaround found so far is to modify the TMP variable (only inside hashcat process) before the runtime is load
*/
char *cpath = (char *) mymalloc (HCBUFSIZ_TINY);
#if defined (_WIN)
snprintf (cpath, HCBUFSIZ_TINY - 1, "%s\\OpenCL\\", shared_dir);
char *cpath_real = (char *) mymalloc (HCBUFSIZ_TINY);
if (GetFullPathName (cpath, HCBUFSIZ_TINY - 1, cpath_real, NULL) == 0)
{
log_error ("ERROR: %s: %s", cpath, "GetFullPathName()");
return -1;
}
#else
snprintf (cpath, HCBUFSIZ_TINY - 1, "%s/OpenCL/", shared_dir);
char *cpath_real = (char *) mymalloc (PATH_MAX);
if (realpath (cpath, cpath_real) == NULL)
{
log_error ("ERROR: %s: %s", cpath, strerror (errno));
return -1;
}
#endif
myfree (cpath);
//if (getenv ("TMP") == NULL)
if (1)
{
char tmp[1000];
snprintf (tmp, sizeof (tmp) - 1, "TMP=%s", cpath_real);
putenv (tmp);
}
#if defined (_WIN)
naive_replace (cpath_real, '\\', '/');
// not escaping here, windows using quotes later
// naive_escape (cpath_real, PATH_MAX, ' ', '\\');
#else
naive_escape (cpath_real, PATH_MAX, ' ', '\\');
#endif
/**
* kernel cache, we need to make sure folder exist
*/
char *kernels_folder = (char *) mymalloc (HCBUFSIZ_TINY);
snprintf (kernels_folder, HCBUFSIZ_TINY - 1, "%s/kernels", profile_dir);
mkdir (kernels_folder, 0700);
myfree (kernels_folder);
/**
* store for later use
*/
folder_config->cwd = cwd;
folder_config->install_dir = install_dir;
folder_config->profile_dir = profile_dir;
folder_config->session_dir = session_dir;
folder_config->shared_dir = shared_dir;
folder_config->cpath_real = cpath_real;
return 0;
}
void folder_config_destroy (folder_config_t *folder_config)
{
myfree (folder_config->cwd);
folder_config->cwd = NULL;
folder_config->install_dir = NULL;
folder_config->profile_dir = NULL;
folder_config->session_dir = NULL;
folder_config->shared_dir = NULL;
folder_config->cpath_real = NULL;
}

@ -145,22 +145,6 @@ int main (int argc, char **argv)
umask (077);
/**
* There's some buggy OpenCL runtime that do not support -I.
* A workaround is to chdir() to the OpenCL folder,
* then compile the kernels,
* then chdir() back to where we came from so we need to save it first
*/
char cwd[1024];
if (getcwd (cwd, sizeof (cwd) - 1) == NULL)
{
log_error ("ERROR: getcwd(): %s", strerror (errno));
return -1;
}
/**
* Real init
*/
@ -180,149 +164,29 @@ int main (int argc, char **argv)
hc_thread_mutex_init (mux_display);
hc_thread_mutex_init (mux_hwmon);
/**
* folders, as discussed on https://github.com/hashcat/hashcat/issues/20
*/
char *exec_path = get_exec_path ();
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
char *resolved_install_folder = realpath (INSTALL_FOLDER, NULL);
char *resolved_exec_path = realpath (exec_path, NULL);
if (resolved_install_folder == NULL)
{
log_error ("ERROR: %s: %s", resolved_install_folder, strerror (errno));
return -1;
}
if (resolved_exec_path == NULL)
{
log_error ("ERROR: %s: %s", resolved_exec_path, strerror (errno));
return -1;
}
char *install_dir = get_install_dir (resolved_exec_path);
char *profile_dir = NULL;
char *session_dir = NULL;
char *shared_dir = NULL;
if (strcmp (install_dir, resolved_install_folder) == 0)
{
struct passwd *pw = getpwuid (getuid ());
const char *homedir = pw->pw_dir;
profile_dir = get_profile_dir (homedir);
session_dir = get_session_dir (profile_dir);
shared_dir = mystrdup (SHARED_FOLDER);
mkdir (profile_dir, 0700);
mkdir (session_dir, 0700);
}
else
{
profile_dir = install_dir;
session_dir = install_dir;
shared_dir = install_dir;
}
myfree (resolved_install_folder);
myfree (resolved_exec_path);
#else
char *install_dir = get_install_dir (exec_path);
char *profile_dir = install_dir;
char *session_dir = install_dir;
char *shared_dir = install_dir;
#endif
data.install_dir = install_dir;
data.profile_dir = profile_dir;
data.session_dir = session_dir;
data.shared_dir = shared_dir;
myfree (exec_path);
/**
* There's alot of problem related to bad support -I parameters when building the kernel.
* Each OpenCL runtime handles it slightly different.
* The most problematic is with new AMD drivers on Windows, which can not handle quote characters!
* The best workaround found so far is to modify the TMP variable (only inside hashcat process) before the runtime is load
* folder
*/
char cpath[1024] = { 0 };
#if defined (_WIN)
snprintf (cpath, sizeof (cpath) - 1, "%s\\OpenCL\\", shared_dir);
char *cpath_real = mymalloc (MAX_PATH);
if (GetFullPathName (cpath, MAX_PATH, cpath_real, NULL) == 0)
{
log_error ("ERROR: %s: %s", cpath, "GetFullPathName()");
return -1;
}
#else
snprintf (cpath, sizeof (cpath) - 1, "%s/OpenCL/", shared_dir);
folder_config_t *folder_config = (folder_config_t *) mymalloc (sizeof (folder_config_t));
char *cpath_real = mymalloc (PATH_MAX);
if (realpath (cpath, cpath_real) == NULL)
{
log_error ("ERROR: %s: %s", cpath, strerror (errno));
return -1;
}
char *install_folder = NULL;
char *shared_folder = NULL;
#if defined (INSTALL_FOLDER)
install_folder = INSTALL_FOLDER;
#endif
//if (getenv ("TMP") == NULL)
if (1)
{
char tmp[1000];
snprintf (tmp, sizeof (tmp) - 1, "TMP=%s", cpath_real);
putenv (tmp);
}
#if defined (_WIN)
naive_replace (cpath_real, '\\', '/');
// not escaping here, windows using quotes later
// naive_escape (cpath_real, PATH_MAX, ' ', '\\');
#else
naive_escape (cpath_real, PATH_MAX, ' ', '\\');
#if defined (SHARED_FOLDER)
shared_folder = SHARED_FOLDER;
#endif
/**
* kernel cache, we need to make sure folder exist
*/
int kernels_folder_size = strlen (profile_dir) + 1 + 7 + 1 + 1;
folder_config_init (folder_config, install_folder, shared_folder);
char *kernels_folder = (char *) mymalloc (kernels_folder_size);
snprintf (kernels_folder, kernels_folder_size - 1, "%s/kernels", profile_dir);
mkdir (kernels_folder, 0700);
myfree (kernels_folder);
data.install_dir = folder_config->install_dir;
data.profile_dir = folder_config->profile_dir;
data.session_dir = folder_config->session_dir;
data.shared_dir = folder_config->shared_dir;
/**
* commandline parameters
@ -526,7 +390,7 @@ int main (int argc, char **argv)
{
induction_directory = (char *) mymalloc (HCBUFSIZ_TINY);
snprintf (induction_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", session_dir, user_options->session, INDUCT_DIR);
snprintf (induction_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, INDUCT_DIR);
// create induction folder if it does not already exist
@ -542,7 +406,7 @@ int main (int argc, char **argv)
{
char *induction_directory_mv = (char *) mymalloc (HCBUFSIZ_TINY);
snprintf (induction_directory_mv, HCBUFSIZ_TINY - 1, "%s/%s.induct.%d", session_dir, user_options->session, (int) proc_start);
snprintf (induction_directory_mv, HCBUFSIZ_TINY - 1, "%s/%s.induct.%d", folder_config->session_dir, user_options->session, (int) proc_start);
if (rename (induction_directory, induction_directory_mv) != 0)
{
@ -582,7 +446,7 @@ int main (int argc, char **argv)
char tuning_db_file[256] = { 0 };
snprintf (tuning_db_file, sizeof (tuning_db_file) - 1, "%s/%s", shared_dir, TUNING_DB_FILE);
snprintf (tuning_db_file, sizeof (tuning_db_file) - 1, "%s/%s", folder_config->shared_dir, TUNING_DB_FILE);
tuning_db_t *tuning_db = tuning_db_init (tuning_db_file);
@ -598,7 +462,7 @@ int main (int argc, char **argv)
{
outfile_check_directory = (char *) mymalloc (HCBUFSIZ_TINY);
snprintf (outfile_check_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", session_dir, user_options->session, OUTFILES_DIR);
snprintf (outfile_check_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, OUTFILES_DIR);
}
else
{
@ -657,7 +521,7 @@ int main (int argc, char **argv)
{
char *logfile = (char *) mymalloc (HCBUFSIZ_TINY);
snprintf (logfile, HCBUFSIZ_TINY - 1, "%s/%s.log", session_dir, user_options->session);
snprintf (logfile, HCBUFSIZ_TINY - 1, "%s/%s.log", folder_config->session_dir, user_options->session);
data.logfile = logfile;
@ -870,7 +734,7 @@ int main (int argc, char **argv)
data.potfile_ctx = potfile_ctx;
potfile_init (potfile_ctx, profile_dir, user_options->potfile_path, user_options->potfile_disable);
potfile_init (potfile_ctx, folder_config->profile_dir, user_options->potfile_path, user_options->potfile_disable);
if (user_options->show == true || user_options->left == true)
{
@ -1015,7 +879,7 @@ int main (int argc, char **argv)
dictstat_ctx_t *dictstat_ctx = mymalloc (sizeof (dictstat_ctx_t));
dictstat_init (dictstat_ctx, profile_dir);
dictstat_init (dictstat_ctx, folder_config->profile_dir);
if (user_options->keyspace == false)
{
@ -1885,9 +1749,9 @@ int main (int argc, char **argv)
data.session_ctx = session_ctx;
session_ctx_init (session_ctx, cwd, install_dir, profile_dir, session_dir, shared_dir, cpath_real, kernel_rules_cnt, kernel_rules_buf, bitmap_size, bitmap_mask, bitmap_shift1, bitmap_shift2, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, bitmap_s2_a, bitmap_s2_b, bitmap_s2_c, bitmap_s2_d);
session_ctx_init (session_ctx, kernel_rules_cnt, kernel_rules_buf, bitmap_size, bitmap_mask, bitmap_shift1, bitmap_shift2, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, bitmap_s2_a, bitmap_s2_b, bitmap_s2_c, bitmap_s2_d);
opencl_session_begin (opencl_ctx, hashconfig, hashes, session_ctx, user_options, user_options_extra);
opencl_session_begin (opencl_ctx, hashconfig, hashes, session_ctx, user_options, user_options_extra, folder_config);
if (user_options->quiet == false) log_info_nn ("");
@ -3019,7 +2883,7 @@ int main (int argc, char **argv)
if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
sp_setup_tbl (shared_dir, user_options->markov_hcstat, user_options->markov_disable, user_options->markov_classic, root_table_buf, markov_table_buf);
sp_setup_tbl (folder_config->shared_dir, user_options->markov_hcstat, user_options->markov_disable, user_options->markov_classic, root_table_buf, markov_table_buf);
cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
@ -3488,7 +3352,7 @@ int main (int argc, char **argv)
if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
sp_setup_tbl (shared_dir, user_options->markov_hcstat, user_options->markov_disable, user_options->markov_classic, root_table_buf, markov_table_buf);
sp_setup_tbl (folder_config->shared_dir, user_options->markov_hcstat, user_options->markov_disable, user_options->markov_classic, root_table_buf, markov_table_buf);
cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
@ -4352,5 +4216,7 @@ int main (int argc, char **argv)
opencl_ctx_destroy (opencl_ctx);
folder_config_destroy (folder_config);
return rc_final;
}

@ -2518,7 +2518,7 @@ void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx)
opencl_ctx->need_xnvctrl = 0;
}
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra)
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config)
{
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
@ -3013,9 +3013,9 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
* default building options
*/
if (chdir (session_ctx->cpath_real) == -1)
if (chdir (folder_config->cpath_real) == -1)
{
log_error ("ERROR: %s: %s", session_ctx->cpath_real, strerror (errno));
log_error ("ERROR: %s: %s", folder_config->cpath_real, strerror (errno));
return -1;
}
@ -3023,9 +3023,9 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
char build_opts[1024] = { 0 };
#if defined (_WIN)
snprintf (build_opts, sizeof (build_opts) - 1, "-I \"%s\"", session_ctx->cpath_real);
snprintf (build_opts, sizeof (build_opts) - 1, "-I \"%s\"", folder_config->cpath_real);
#else
snprintf (build_opts, sizeof (build_opts) - 1, "-I %s", session_ctx->cpath_real);
snprintf (build_opts, sizeof (build_opts) - 1, "-I %s", folder_config->cpath_real);
#endif
// include check
@ -3105,7 +3105,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
char source_file[256] = { 0 };
generate_source_kernel_filename (hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, session_ctx->shared_dir, source_file);
generate_source_kernel_filename (hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, folder_config->shared_dir, source_file);
struct stat sst;
@ -3122,7 +3122,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
char cached_file[256] = { 0 };
generate_cached_kernel_filename (hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, session_ctx->profile_dir, device_name_chksum, cached_file);
generate_cached_kernel_filename (hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, folder_config->profile_dir, device_name_chksum, cached_file);
int cached = 1;
@ -3369,7 +3369,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
char source_file[256] = { 0 };
generate_source_kernel_mp_filename (hashconfig->opti_type, hashconfig->opts_type, session_ctx->shared_dir, source_file);
generate_source_kernel_mp_filename (hashconfig->opti_type, hashconfig->opts_type, folder_config->shared_dir, source_file);
struct stat sst;
@ -3386,7 +3386,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
char cached_file[256] = { 0 };
generate_cached_kernel_mp_filename (hashconfig->opti_type, hashconfig->opts_type, session_ctx->profile_dir, device_name_chksum, cached_file);
generate_cached_kernel_mp_filename (hashconfig->opti_type, hashconfig->opts_type, folder_config->profile_dir, device_name_chksum, cached_file);
int cached = 1;
@ -3550,7 +3550,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
char source_file[256] = { 0 };
generate_source_kernel_amp_filename (user_options_extra->attack_kern, session_ctx->shared_dir, source_file);
generate_source_kernel_amp_filename (user_options_extra->attack_kern, folder_config->shared_dir, source_file);
struct stat sst;
@ -3567,7 +3567,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
char cached_file[256] = { 0 };
generate_cached_kernel_amp_filename (user_options_extra->attack_kern, session_ctx->profile_dir, device_name_chksum, cached_file);
generate_cached_kernel_amp_filename (user_options_extra->attack_kern, folder_config->profile_dir, device_name_chksum, cached_file);
int cached = 1;
@ -3717,9 +3717,9 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
// return back to the folder we came from initially (workaround)
if (chdir (session_ctx->cwd) == -1)
if (chdir (folder_config->cwd) == -1)
{
log_error ("ERROR: %s: %s", session_ctx->cwd, strerror (errno));
log_error ("ERROR: %s: %s", folder_config->cwd, strerror (errno));
return -1;
}

@ -7,15 +7,8 @@
#include "types.h"
#include "session.h"
void session_ctx_init (session_ctx_t *session_ctx, char *cwd, char *install_dir, char *profile_dir, char *session_dir, char *shared_dir, char *cpath_real, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf,const u32 bitmap_size, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, u32 *bitmap_s1_a, u32 *bitmap_s1_b, u32 *bitmap_s1_c, u32 *bitmap_s1_d, u32 *bitmap_s2_a, u32 *bitmap_s2_b, u32 *bitmap_s2_c, u32 *bitmap_s2_d)
void session_ctx_init (session_ctx_t *session_ctx, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf, const u32 bitmap_size, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, u32 *bitmap_s1_a, u32 *bitmap_s1_b, u32 *bitmap_s1_c, u32 *bitmap_s1_d, u32 *bitmap_s2_a, u32 *bitmap_s2_b, u32 *bitmap_s2_c, u32 *bitmap_s2_d)
{
session_ctx->cwd = cwd;
session_ctx->install_dir = install_dir;
session_ctx->profile_dir = profile_dir;
session_ctx->session_dir = session_dir;
session_ctx->shared_dir = shared_dir;
session_ctx->cpath_real = cpath_real;
session_ctx->kernel_rules_cnt = kernel_rules_cnt;
session_ctx->kernel_rules_buf = kernel_rules_buf;
@ -36,13 +29,6 @@ void session_ctx_init (session_ctx_t *session_ctx, char *cwd, char *install_dir,
void session_ctx_destroy (session_ctx_t *session_ctx)
{
session_ctx->cwd = NULL;
session_ctx->install_dir = NULL;
session_ctx->profile_dir = NULL;
session_ctx->session_dir = NULL;
session_ctx->shared_dir = NULL;
session_ctx->cpath_real = NULL;
session_ctx->kernel_rules_buf = NULL;
session_ctx->kernel_rules_cnt = 0;

Loading…
Cancel
Save