1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 16:18:09 +00:00

Move more code from hashcat.c to opencl.c related to opencl device initialization and shutdown

This commit is contained in:
jsteube 2016-09-17 17:05:01 +02:00
parent f273d4771b
commit caeedd5646
7 changed files with 2298 additions and 2102 deletions

View File

@ -63,7 +63,10 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, const char *opencl_devices, const char *opencl_device_types, const uint opencl_vector_width, const uint opencl_vector_width_chgd, const uint nvidia_spin_damp, const uint nvidia_spin_damp_chgd, const uint workload_profile, const uint kernel_accel, const uint kernel_accel_chgd, const uint kernel_loops, const uint kernel_loops_chgd, const uint keyspace, const uint stdout_flag);
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 uint attack_mode, const uint quiet, const uint force, const uint benchmark, const uint machine_readable, const uint algorithm_pos);
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const uint attack_mode, const bool quiet, const bool force, const bool benchmark, const bool machine_readable, 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);
int opencl_session_destroy (opencl_ctx_t *opencl_ctx);
#endif // _OPENCL_H

13
include/session.h Normal file
View File

@ -0,0 +1,13 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _SESSION_H
#define _SESSION_H
void session_ctx_init (session_ctx_t *session_ctx, const bool quiet, const bool force, const bool benchmark, const u32 scrypt_tmto, char *cwd, char *install_dir, char *profile_dir, char *session_dir, char *shared_dir, char *cpath_real, const u32 wordlist_mode, char *rule_buf_l, char *rule_buf_r, const int rule_len_l, const int rule_len_r, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf, const u32 attack_mode, const u32 attack_kern, 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);
#endif // _SESSION_H

View File

@ -482,10 +482,10 @@ typedef struct
void *ocl;
cl_uint platforms_cnt;
cl_uint platforms_cnt;
cl_platform_id *platforms;
cl_uint platform_devices_cnt;
cl_uint platform_devices_cnt;
cl_device_id *platform_devices;
u32 devices_cnt;
@ -518,6 +518,8 @@ typedef struct
int need_nvapi;
int need_xnvctrl;
int force_jit_compilation;
} opencl_ctx_t;
#if defined (__APPLE__)
@ -731,6 +733,50 @@ typedef struct
} wl_data_t;
typedef struct
{
bool quiet;
bool force;
bool benchmark;
u32 scrypt_tmto;
char *cwd;
char *install_dir;
char *profile_dir;
char *session_dir;
char *shared_dir;
char *cpath_real;
u32 wordlist_mode;
char *rule_buf_l;
char *rule_buf_r;
int rule_len_l;
int rule_len_r;
u32 kernel_rules_cnt;
kernel_rule_t *kernel_rules_buf;
u32 attack_mode;
u32 attack_kern;
u32 bitmap_size;
u32 bitmap_mask;
u32 bitmap_shift1;
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_t;
typedef struct
{
/**
@ -794,13 +840,6 @@ typedef struct
hm_attrs_t hm_device[DEVICES_MAX];
#endif
/**
* hashes
*/
u32 scrypt_tmp_size;
u32 scrypt_tmto_final;
/**
* logging
*/
@ -830,7 +869,6 @@ typedef struct
u32 maskpos;
char *session;
char *homedir;
char *install_dir;
char *profile_dir;
char *session_dir;
@ -880,6 +918,7 @@ typedef struct
potfile_ctx_t *potfile_ctx;
loopback_ctx_t *loopback_ctx;
debugfile_ctx_t *debugfile_ctx;
session_ctx_t *session_ctx;
#if defined (HAVE_HWMON)
u32 gpu_temp_disable;

View File

@ -163,7 +163,7 @@ LFLAGS_CROSS_WIN := -lpsapi
## Objects
##
OBJS_ALL := affinity attack_mode autotune benchmark bitmap bitops common convert cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 data debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling filenames folder hash_management hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile powertune remove restore rp_cpu rp_kernel_on_cpu runtime shared status stdout terminal thread timer tuningdb usage version weak_hash wordlist
OBJS_ALL := affinity attack_mode autotune benchmark bitmap bitops common convert cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 data debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling filenames folder hash_management hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile powertune remove restore rp_cpu rp_kernel_on_cpu runtime session shared status stdout terminal thread timer tuningdb usage version weak_hash wordlist
NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

94
src/session.c Normal file
View File

@ -0,0 +1,94 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "types.h"
#include "session.h"
void session_ctx_init (session_ctx_t *session_ctx, const bool quiet, const bool force, const bool benchmark, const u32 scrypt_tmto, char *cwd, char *install_dir, char *profile_dir, char *session_dir, char *shared_dir, char *cpath_real, const u32 wordlist_mode, char *rule_buf_l, char *rule_buf_r, const int rule_len_l, const int rule_len_r, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf, const u32 attack_mode, const u32 attack_kern, 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->quiet = quiet;
session_ctx->force = force;
session_ctx->benchmark = benchmark;
session_ctx->scrypt_tmto = scrypt_tmto;
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->wordlist_mode = wordlist_mode;
session_ctx->rule_buf_l = rule_buf_l;
session_ctx->rule_buf_r = rule_buf_r;
session_ctx->rule_len_l = rule_len_l;
session_ctx->rule_len_r = rule_len_r;
session_ctx->kernel_rules_cnt = kernel_rules_cnt;
session_ctx->kernel_rules_buf = kernel_rules_buf;
session_ctx->attack_mode = attack_mode;
session_ctx->attack_kern = attack_kern;
session_ctx->bitmap_size = bitmap_size;
session_ctx->bitmap_mask = bitmap_mask;
session_ctx->bitmap_shift1 = bitmap_shift1;
session_ctx->bitmap_shift2 = bitmap_shift2;
session_ctx->bitmap_s1_a = bitmap_s1_a;
session_ctx->bitmap_s1_b = bitmap_s1_b;
session_ctx->bitmap_s1_c = bitmap_s1_c;
session_ctx->bitmap_s1_d = bitmap_s1_d;
session_ctx->bitmap_s2_a = bitmap_s2_a;
session_ctx->bitmap_s2_b = bitmap_s2_b;
session_ctx->bitmap_s2_c = bitmap_s2_c;
session_ctx->bitmap_s2_d = bitmap_s2_d;
}
void session_ctx_destroy (session_ctx_t *session_ctx)
{
session_ctx->quiet = false;
session_ctx->force = false;
session_ctx->benchmark = false;
session_ctx->scrypt_tmto = 0;
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->wordlist_mode = 0;
session_ctx->rule_buf_l = NULL;
session_ctx->rule_buf_r = NULL;
session_ctx->rule_len_l = 0;
session_ctx->rule_len_r = 0;
session_ctx->kernel_rules_buf = NULL;
session_ctx->kernel_rules_cnt = 0;
session_ctx->attack_mode = 0;
session_ctx->attack_kern = 0;
session_ctx->bitmap_size = 0;
session_ctx->bitmap_mask = 0;
session_ctx->bitmap_shift1 = 0;
session_ctx->bitmap_shift2 = 0;
session_ctx->bitmap_s1_a = NULL;
session_ctx->bitmap_s1_b = NULL;
session_ctx->bitmap_s1_c = NULL;
session_ctx->bitmap_s1_d = NULL;
session_ctx->bitmap_s2_a = NULL;
session_ctx->bitmap_s2_b = NULL;
session_ctx->bitmap_s2_c = NULL;
session_ctx->bitmap_s2_d = NULL;
}