1
mirror of https://github.com/hashcat/hashcat synced 2024-11-20 23:27:31 +01:00

Move opencl_info() to terminal.c

This commit is contained in:
jsteube 2016-10-25 16:40:06 +02:00
parent 001ba8a655
commit e26b08f61f
7 changed files with 79 additions and 77 deletions

View File

@ -10,7 +10,7 @@ int hashcat_init (hashcat_ctx_t *hashcat_ctx, void (*event) (con
void hashcat_destroy (hashcat_ctx_t *hashcat_ctx);
int hashcat_session_init (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime);
int hashcat_session_run (hashcat_ctx_t *hashcat_ctx);
int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx);
int hashcat_session_pause (hashcat_ctx_t *hashcat_ctx);
int hashcat_session_resume (hashcat_ctx_t *hashcat_ctx);
int hashcat_session_bypass (hashcat_ctx_t *hashcat_ctx);

View File

@ -69,7 +69,6 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx);
void opencl_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime);
void opencl_ctx_devices_show (hashcat_ctx_t *hashcat_ctx);
void opencl_ctx_devices_destroy (hashcat_ctx_t *hashcat_ctx);
void opencl_ctx_devices_update_power (hashcat_ctx_t *hashcat_ctx);
void opencl_ctx_devices_kernel_loops (hashcat_ctx_t *hashcat_ctx);

View File

@ -41,9 +41,10 @@ int tty_break();
int tty_getchar();
int tty_fix();
#endif // _TERMINAL_H
void opencl_info (hashcat_ctx_t *hashcat_ctx);
void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx);
void status_display (hashcat_ctx_t *hashcat_ctx);
void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx);
void status_benchmark (hashcat_ctx_t *hashcat_ctx);
#endif // _TERMINAL_H

View File

@ -1004,7 +1004,7 @@ int hashcat_session_init (hashcat_ctx_t *hashcat_ctx, char *install_folder, char
return 0;
}
int hashcat_session_run (hashcat_ctx_t *hashcat_ctx)
int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx)
{
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
@ -1022,15 +1022,6 @@ int hashcat_session_run (hashcat_ctx_t *hashcat_ctx)
logfile_top_msg ("START");
// if this is just opencl_info, no need to go deeper from here
if (user_options->opencl_info == true)
{
opencl_ctx_devices_show (hashcat_ctx);
return 0;
}
// read dictionary cache
dictstat_read (hashcat_ctx);

View File

@ -901,9 +901,20 @@ int main (int argc, char **argv)
if (rc_session_init == 0)
{
// now run hashcat
if (user_options->opencl_info == true)
{
// if this is just opencl_info, no need to execute some real cracking session
rc_final = hashcat_session_run (hashcat_ctx);
opencl_info (hashcat_ctx);
rc_final = 0;
}
else
{
// now execute hashcat
rc_final = hashcat_session_execute (hashcat_ctx);
}
}
// finish the hashcat session, this shuts down opencl devices, hwmon, etc

View File

@ -2812,67 +2812,6 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
return 0;
}
void opencl_ctx_devices_show (hashcat_ctx_t *hashcat_ctx)
{
const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
event_log_info (hashcat_ctx, "OpenCL Info:");
event_log_info (hashcat_ctx, "");
cl_uint platforms_cnt = opencl_ctx->platforms_cnt;
cl_platform_id *platforms = opencl_ctx->platforms;
char **platforms_vendor = opencl_ctx->platforms_vendor;
char **platforms_name = opencl_ctx->platforms_name;
char **platforms_version = opencl_ctx->platforms_version;
cl_uint devices_cnt = opencl_ctx->devices_cnt;
for (cl_uint platforms_idx = 0; platforms_idx < platforms_cnt; platforms_idx++)
{
cl_platform_id platform_id = platforms[platforms_idx];
char *platform_vendor = platforms_vendor[platforms_idx];
char *platform_name = platforms_name[platforms_idx];
char *platform_version = platforms_version[platforms_idx];
event_log_info (hashcat_ctx, "Platform ID #%u", platforms_idx + 1);
event_log_info (hashcat_ctx, " Vendor : %s", platform_vendor);
event_log_info (hashcat_ctx, " Name : %s", platform_name);
event_log_info (hashcat_ctx, " Version : %s", platform_version);
event_log_info (hashcat_ctx, "");
for (cl_uint devices_idx = 0; devices_idx < devices_cnt; devices_idx++)
{
const hc_device_param_t *hc_device_param = opencl_ctx->devices_param + devices_idx;
if (hc_device_param->platform != platform_id) continue;
cl_device_type device_type = hc_device_param->device_type;
cl_uint device_vendor_id = hc_device_param->device_vendor_id;
char *device_vendor = hc_device_param->device_vendor;
char *device_name = hc_device_param->device_name;
u32 device_processors = hc_device_param->device_processors;
u32 device_maxclock_frequency = hc_device_param->device_maxclock_frequency;
u64 device_maxmem_alloc = hc_device_param->device_maxmem_alloc;
u64 device_global_mem = hc_device_param->device_global_mem;
char *device_opencl_version = hc_device_param->device_opencl_version;
char *device_version = hc_device_param->device_version;
char *driver_version = hc_device_param->driver_version;
event_log_info (hashcat_ctx, " Device ID #%u", devices_idx + 1);
event_log_info (hashcat_ctx, " Type : %s", ((device_type & CL_DEVICE_TYPE_CPU) ? "CPU" : ((device_type & CL_DEVICE_TYPE_GPU) ? "GPU" : "Accelerator")));
event_log_info (hashcat_ctx, " Vendor ID : %u", device_vendor_id);
event_log_info (hashcat_ctx, " Vendor : %s", device_vendor);
event_log_info (hashcat_ctx, " Name : %s", device_name);
event_log_info (hashcat_ctx, " Version : %s", device_version);
event_log_info (hashcat_ctx, " Processor(s) : %u", device_processors);
event_log_info (hashcat_ctx, " Clock : %u", device_maxclock_frequency);
event_log_info (hashcat_ctx, " Memory : %" PRIu64 "/%" PRIu64 " MB allocatable", device_maxmem_alloc / 1024 / 1024, device_global_mem / 1024 / 1024);
event_log_info (hashcat_ctx, " OpenCL Version : %u", device_opencl_version);
event_log_info (hashcat_ctx, " Driver Version : %u", driver_version);
event_log_info (hashcat_ctx, "");
}
}
}
void opencl_ctx_devices_destroy (hashcat_ctx_t *hashcat_ctx)
{
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;

View File

@ -455,6 +455,67 @@ int tty_fix()
}
#endif
void opencl_info (hashcat_ctx_t *hashcat_ctx)
{
const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
event_log_info (hashcat_ctx, "OpenCL Info:");
event_log_info (hashcat_ctx, "");
cl_uint platforms_cnt = opencl_ctx->platforms_cnt;
cl_platform_id *platforms = opencl_ctx->platforms;
char **platforms_vendor = opencl_ctx->platforms_vendor;
char **platforms_name = opencl_ctx->platforms_name;
char **platforms_version = opencl_ctx->platforms_version;
cl_uint devices_cnt = opencl_ctx->devices_cnt;
for (cl_uint platforms_idx = 0; platforms_idx < platforms_cnt; platforms_idx++)
{
cl_platform_id platform_id = platforms[platforms_idx];
char *platform_vendor = platforms_vendor[platforms_idx];
char *platform_name = platforms_name[platforms_idx];
char *platform_version = platforms_version[platforms_idx];
event_log_info (hashcat_ctx, "Platform ID #%u", platforms_idx + 1);
event_log_info (hashcat_ctx, " Vendor : %s", platform_vendor);
event_log_info (hashcat_ctx, " Name : %s", platform_name);
event_log_info (hashcat_ctx, " Version : %s", platform_version);
event_log_info (hashcat_ctx, "");
for (cl_uint devices_idx = 0; devices_idx < devices_cnt; devices_idx++)
{
const hc_device_param_t *hc_device_param = opencl_ctx->devices_param + devices_idx;
if (hc_device_param->platform != platform_id) continue;
cl_device_type device_type = hc_device_param->device_type;
cl_uint device_vendor_id = hc_device_param->device_vendor_id;
char *device_vendor = hc_device_param->device_vendor;
char *device_name = hc_device_param->device_name;
u32 device_processors = hc_device_param->device_processors;
u32 device_maxclock_frequency = hc_device_param->device_maxclock_frequency;
u64 device_maxmem_alloc = hc_device_param->device_maxmem_alloc;
u64 device_global_mem = hc_device_param->device_global_mem;
char *device_opencl_version = hc_device_param->device_opencl_version;
char *device_version = hc_device_param->device_version;
char *driver_version = hc_device_param->driver_version;
event_log_info (hashcat_ctx, " Device ID #%u", devices_idx + 1);
event_log_info (hashcat_ctx, " Type : %s", ((device_type & CL_DEVICE_TYPE_CPU) ? "CPU" : ((device_type & CL_DEVICE_TYPE_GPU) ? "GPU" : "Accelerator")));
event_log_info (hashcat_ctx, " Vendor ID : %u", device_vendor_id);
event_log_info (hashcat_ctx, " Vendor : %s", device_vendor);
event_log_info (hashcat_ctx, " Name : %s", device_name);
event_log_info (hashcat_ctx, " Version : %s", device_version);
event_log_info (hashcat_ctx, " Processor(s) : %u", device_processors);
event_log_info (hashcat_ctx, " Clock : %u", device_maxclock_frequency);
event_log_info (hashcat_ctx, " Memory : %" PRIu64 "/%" PRIu64 " MB allocatable", device_maxmem_alloc / 1024 / 1024, device_global_mem / 1024 / 1024);
event_log_info (hashcat_ctx, " OpenCL Version : %u", device_opencl_version);
event_log_info (hashcat_ctx, " Driver Version : %u", driver_version);
event_log_info (hashcat_ctx, "");
}
}
}
void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;