mirror of
https://github.com/hashcat/hashcat.git
synced 2025-06-27 02:12:38 +00:00
Show host memory requirement on startup
This commit is contained in:
parent
53be3e74a3
commit
d378aa7ab9
@ -128,8 +128,9 @@ typedef enum event_identifier
|
|||||||
EVENT_MONITOR_NOINPUT_ABORT = 0x00000088,
|
EVENT_MONITOR_NOINPUT_ABORT = 0x00000088,
|
||||||
EVENT_BACKEND_SESSION_POST = 0x00000090,
|
EVENT_BACKEND_SESSION_POST = 0x00000090,
|
||||||
EVENT_BACKEND_SESSION_PRE = 0x00000091,
|
EVENT_BACKEND_SESSION_PRE = 0x00000091,
|
||||||
EVENT_BACKEND_DEVICE_INIT_POST = 0x00000092,
|
EVENT_BACKEND_SESSION_HOSTMEM = 0x00000092,
|
||||||
EVENT_BACKEND_DEVICE_INIT_PRE = 0x00000093,
|
EVENT_BACKEND_DEVICE_INIT_POST = 0x00000093,
|
||||||
|
EVENT_BACKEND_DEVICE_INIT_PRE = 0x00000094,
|
||||||
EVENT_OUTERLOOP_FINISHED = 0x000000a0,
|
EVENT_OUTERLOOP_FINISHED = 0x000000a0,
|
||||||
EVENT_OUTERLOOP_MAINSCREEN = 0x000000a1,
|
EVENT_OUTERLOOP_MAINSCREEN = 0x000000a1,
|
||||||
EVENT_OUTERLOOP_STARTING = 0x000000a2,
|
EVENT_OUTERLOOP_STARTING = 0x000000a2,
|
||||||
|
@ -6944,6 +6944,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (backend_ctx->enabled == false) return 0;
|
if (backend_ctx->enabled == false) return 0;
|
||||||
|
|
||||||
|
u64 size_total_host_all = 0;
|
||||||
|
|
||||||
u32 hardware_power_all = 0;
|
u32 hardware_power_all = 0;
|
||||||
|
|
||||||
int CU_rc;
|
int CU_rc;
|
||||||
@ -10315,12 +10317,12 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
|||||||
// this value should represent a reasonable amount of memory a host system has per GPU.
|
// this value should represent a reasonable amount of memory a host system has per GPU.
|
||||||
// note we're allocating 3 blocks of that size.
|
// note we're allocating 3 blocks of that size.
|
||||||
|
|
||||||
#define PWS_SPACE (1024 * 1024 * 1024)
|
const u64 PWS_SPACE = 4ull * 1024ull * 1024ull * 1024ull;
|
||||||
|
|
||||||
// sometimes device_available_mem and device_maxmem_alloc reported back from the opencl runtime are a bit inaccurate.
|
// sometimes device_available_mem and device_maxmem_alloc reported back from the opencl runtime are a bit inaccurate.
|
||||||
// let's add some extra space just to be sure.
|
// let's add some extra space just to be sure.
|
||||||
|
|
||||||
#define EXTRA_SPACE (64 * 1024 * 1024)
|
const u64 EXTRA_SPACE = 64ull * 1024ull * 1024ull;
|
||||||
|
|
||||||
while (kernel_accel_max >= kernel_accel_min)
|
while (kernel_accel_max >= kernel_accel_min)
|
||||||
{
|
{
|
||||||
@ -10412,6 +10414,13 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if ((size_total + EXTRA_SPACE) > device_param->device_available_mem) memory_limit_hit = 1;
|
if ((size_total + EXTRA_SPACE) > device_param->device_available_mem) memory_limit_hit = 1;
|
||||||
|
|
||||||
|
if (memory_limit_hit == 1)
|
||||||
|
{
|
||||||
|
kernel_accel_max--;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const u64 size_total_host
|
const u64 size_total_host
|
||||||
= size_pws_comp
|
= size_pws_comp
|
||||||
+ size_pws_idx
|
+ size_pws_idx
|
||||||
@ -10423,23 +10432,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
|||||||
+ size_pws_pre
|
+ size_pws_pre
|
||||||
+ size_pws_base;
|
+ size_pws_base;
|
||||||
|
|
||||||
if ((size_total_host + EXTRA_SPACE) > device_param->device_maxmem_alloc) memory_limit_hit = 1;
|
size_total_host_all += size_total_host + EXTRA_SPACE;
|
||||||
|
|
||||||
#if defined (__x86_x64__)
|
|
||||||
const u64 MAX_HOST_MEMORY = 16ull * 1024ull * 1024ull * 1024ull; // don't be too memory hungry
|
|
||||||
#else
|
|
||||||
const u64 MAX_HOST_MEMORY = 2ull * 1024ull * 1024ull * 1024ull; // windows 7 starter limits to 2gb instead of 4gb
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// we assume all devices have the same specs here, which is wrong, it's a start
|
|
||||||
if ((size_total_host * backend_ctx->backend_devices_cnt) > MAX_HOST_MEMORY) memory_limit_hit = 1;
|
|
||||||
|
|
||||||
if (memory_limit_hit == 1)
|
|
||||||
{
|
|
||||||
kernel_accel_max--;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -10680,6 +10673,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
backend_ctx->hardware_power_all = hardware_power_all;
|
backend_ctx->hardware_power_all = hardware_power_all;
|
||||||
|
|
||||||
|
EVENT_DATA (EVENT_BACKEND_SESSION_HOSTMEM, &size_total_host_all, sizeof (u64));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
src/main.c
13
src/main.c
@ -567,6 +567,18 @@ static void main_backend_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx,
|
|||||||
event_log_info_nn (hashcat_ctx, "Initialized device kernels and memory...");
|
event_log_info_nn (hashcat_ctx, "Initialized device kernels and memory...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void main_backend_session_hostmem (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||||
|
{
|
||||||
|
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||||
|
|
||||||
|
if (user_options->quiet == true) return;
|
||||||
|
|
||||||
|
const u64 *hostmem = (const u64 *) buf;
|
||||||
|
|
||||||
|
event_log_info (hashcat_ctx, "Host memory required for this attack: %" PRIu64 " MB", *hostmem / (1024 * 1024));
|
||||||
|
event_log_info (hashcat_ctx, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void main_backend_device_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
static void main_backend_device_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||||
{
|
{
|
||||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||||
@ -1024,6 +1036,7 @@ static void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, co
|
|||||||
case EVENT_MONITOR_NOINPUT_ABORT: main_monitor_noinput_abort (hashcat_ctx, buf, len); break;
|
case EVENT_MONITOR_NOINPUT_ABORT: main_monitor_noinput_abort (hashcat_ctx, buf, len); break;
|
||||||
case EVENT_BACKEND_SESSION_POST: main_backend_session_post (hashcat_ctx, buf, len); break;
|
case EVENT_BACKEND_SESSION_POST: main_backend_session_post (hashcat_ctx, buf, len); break;
|
||||||
case EVENT_BACKEND_SESSION_PRE: main_backend_session_pre (hashcat_ctx, buf, len); break;
|
case EVENT_BACKEND_SESSION_PRE: main_backend_session_pre (hashcat_ctx, buf, len); break;
|
||||||
|
case EVENT_BACKEND_SESSION_HOSTMEM: main_backend_session_hostmem (hashcat_ctx, buf, len); break;
|
||||||
case EVENT_BACKEND_DEVICE_INIT_POST: main_backend_device_init_post (hashcat_ctx, buf, len); break;
|
case EVENT_BACKEND_DEVICE_INIT_POST: main_backend_device_init_post (hashcat_ctx, buf, len); break;
|
||||||
case EVENT_BACKEND_DEVICE_INIT_PRE: main_backend_device_init_pre (hashcat_ctx, buf, len); break;
|
case EVENT_BACKEND_DEVICE_INIT_PRE: main_backend_device_init_pre (hashcat_ctx, buf, len); break;
|
||||||
case EVENT_OUTERLOOP_FINISHED: main_outerloop_finished (hashcat_ctx, buf, len); break;
|
case EVENT_OUTERLOOP_FINISHED: main_outerloop_finished (hashcat_ctx, buf, len); break;
|
||||||
|
Loading…
Reference in New Issue
Block a user