From 8fc4da795b4dd4b69bc2f62b9f6ec931bfa6e616 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 10 Oct 2016 11:03:11 +0200 Subject: [PATCH] Replace fprintf(stderr, ...) on malloc.c with log_event_error() --- include/ext_ADL.h | 5 + include/filehandling.h | 2 +- include/folder.h | 6 +- include/hwmon.h | 103 ------------ include/interface.h | 4 +- include/memory.h | 10 +- include/mpsp.h | 17 -- src/affinity.c | 4 +- src/bitmap.c | 32 ++-- src/combinator.c | 4 +- src/cpt.c | 4 +- src/cpu_crc32.c | 4 +- src/dictstat.c | 8 +- src/dispatch.c | 12 +- src/ext_ADL.c | 4 +- src/filehandling.c | 6 +- src/folder.c | 72 ++++---- src/hashcat.c | 116 ++++++------- src/hashes.c | 90 +++++----- src/hlfmt.c | 6 +- src/hwmon.c | 367 +++++++++++++++++++++++++---------------- src/induct.c | 10 +- src/interface.c | 253 ++++++---------------------- src/logfile.c | 12 +- src/loopback.c | 2 +- src/main.c | 4 +- src/memory.c | 46 +++--- src/monitor.c | 63 +++---- src/mpsp.c | 267 +++++++++++------------------- src/opencl.c | 124 +++++++------- src/outfile_check.c | 32 ++-- src/potfile.c | 70 ++++---- src/restore.c | 32 ++-- src/rp.c | 26 +-- src/status.c | 20 +-- src/straight.c | 40 ++--- src/tuningdb.c | 34 ++-- src/user_options.c | 6 +- src/wordlist.c | 6 +- 39 files changed, 820 insertions(+), 1103 deletions(-) diff --git a/include/ext_ADL.h b/include/ext_ADL.h index 5961cbf97..9a3322fe0 100644 --- a/include/ext_ADL.h +++ b/include/ext_ADL.h @@ -7,6 +7,11 @@ #define _EXT_ADL_H #include +#include + +#if defined (_WIN) +#include +#endif // _WIN /** * Declarations from adl_sdk.h and subheaders diff --git a/include/filehandling.h b/include/filehandling.h index 582599453..b8f70d40c 100644 --- a/include/filehandling.h +++ b/include/filehandling.h @@ -10,7 +10,7 @@ #include #include -u64 count_lines (FILE *fd); +u64 count_lines (hashcat_ctx_t *hashcat_ctx, FILE *fd); int fgetl (FILE *fp, char *line_buf); diff --git a/include/folder.h b/include/folder.h index a8042ab65..d4ddc212b 100644 --- a/include/folder.h +++ b/include/folder.h @@ -29,13 +29,9 @@ int sort_by_stringptr (const void *p1, const void *p2); -char *get_install_dir (const char *progname); -char *get_profile_dir (const char *homedir); -char *get_session_dir (const char *profile_dir); - int count_dictionaries (char **dictionary_files); -char **scan_directory (const char *path); +char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path); int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *install_folder, MAYBE_UNUSED const char *shared_folder); void folder_config_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/hwmon.h b/include/hwmon.h index fed552356..1a0db1475 100644 --- a/include/hwmon.h +++ b/include/hwmon.h @@ -6,109 +6,6 @@ #ifndef _HWMON_H #define _HWMON_H -// nvml functions - -int nvml_init (hashcat_ctx_t *hashcat_ctx); -void nvml_close (hashcat_ctx_t *hashcat_ctx); - -int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx); -int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx); - -int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int index, nvmlDevice_t *device); - -int hm_NVML_nvmlDeviceGetName (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, char *name, unsigned int length); -int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp); -int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *speed); -int hm_NVML_nvmlDeviceGetPowerUsage (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *power); -int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlUtilization_t *utilization); -int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock); -int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp); -int hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkGen); -int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkWidth); -int hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *clocksThrottleReasons); -int hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons); -int hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlComputeMode_t mode); -int hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlGpuOperationMode_t mode); -int hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit); -int hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int limit); -int hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *limit); - -// nvapi functions - -int nvapi_init (hashcat_ctx_t *hashcat_ctx); -void nvapi_close (hashcat_ctx_t *hashcat_ctx); - -int hm_NvAPI_QueryInterface (hashcat_ctx_t *hashcat_ctx, unsigned int offset); - -int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx); -int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx); - -int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); -int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info); -int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status); -int hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels); -int hm_NvAPI_GPU_RestoreCoolerSettings (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex); - -// xnvctrl functions - -int xnvctrl_init (hashcat_ctx_t *hashcat_ctx); -void xnvctrl_close (hashcat_ctx_t *hashcat_ctx); - -int hm_XNVCTRL_XOpenDisplay (hashcat_ctx_t *hashcat_ctx); -void hm_XNVCTRL_XCloseDisplay (hashcat_ctx_t *hashcat_ctx); - -int get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); - -int get_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); -int set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val); - -int get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); -int get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); -int set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val); - -// ADL functions - -int adl_init (hashcat_ctx_t *hashcat_ctx); -void adl_close (hashcat_ctx_t *hashcat_ctx); - -int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx); -int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters); - -int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int *lpNumAdapters); -int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lpInfo, int iInputSize); -int hm_ADL_Display_DisplayInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect); -int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature); -int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iTemperature); -int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLPMActivity *lpActivity); -int hm_ADL_Overdrive_ThermalDevices_Enum (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo); -int hm_ADL_Adapter_ID_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpAdapterID); -int hm_ADL_Adapter_VideoBiosInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLBiosInfo *lpBiosInfo); -int hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo); -int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue); -int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo); -int hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue); -int hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue); -int hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex); -int hm_ADL_Overdrive_ODParameters_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODParameters *lpOdParameters); -int hm_ADL_Overdrive_ODPerformanceLevels_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels); -int hm_ADL_Overdrive_ODPerformanceLevels_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels); -int hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6PowerControlInfo *); -int hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *level); -int hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int level); -int hm_ADL_Adapter_Active_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpStatus); -//int hm_ADL_DisplayEnable_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly); -int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version); -int hm_ADL_Overdrive_CurrentStatus_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6CurrentStatus *status); -int hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6MemClockState *state); -int hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6Capabilities *caps); -int hm_ADL_Overdrive_State_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6StateInfo *state); -int hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpSupported); -int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *cur_temp, int *default_temp); -int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo); -int hm_ADL_Overdrive6_FanSpeed_Reset (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex); - -// general functions - int hm_get_threshold_slowdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id); int hm_get_threshold_shutdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id); int hm_get_temperature_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id); diff --git a/include/interface.h b/include/interface.h index ca5850afa..e0f1f69ea 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1505,9 +1505,9 @@ char *stroptitype (const u32 opti_type); char *strhashtype (const u32 hash_mode); char *strparser (const u32 parser_status); -void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes); +void to_hccap_t (hashcat_ctx_t *hashcat_ctx, hccap_t *hccap, const u32 salt_pos, const u32 digest_pos); -void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes); +void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos); int hashconfig_init (hashcat_ctx_t *hashcat_ctx); void hashconfig_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/memory.h b/include/memory.h index b68bc526b..b8920fa7c 100644 --- a/include/memory.h +++ b/include/memory.h @@ -12,10 +12,10 @@ #define MSG_ENOMEM "Insufficient memory available" -void *mycalloc (size_t nmemb, size_t size); -void myfree (void *ptr); -void *mymalloc (size_t size); -void *myrealloc (void *ptr, size_t oldsz, size_t add); -char *mystrdup (const char *s); +void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz); +void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz); +void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, const size_t addsz); +char *hcstrdup (hashcat_ctx_t *hashcat_ctx, const char *s); +void hcfree (void *ptr); #endif // _MEMORY_H diff --git a/include/mpsp.h b/include/mpsp.h index 44a6c0dca..5840704eb 100644 --- a/include/mpsp.h +++ b/include/mpsp.h @@ -20,24 +20,7 @@ #define INCR_MASKS 1000 -void mp_css_split_cnt (const mask_ctx_t *mask_ctx, const hashconfig_t *hashconfig, const u32 css_cnt_orig, u32 css_cnt_rl[2]); -void mp_css_append_salt (mask_ctx_t *mask_ctx, salt_t *salt_buf); -void mp_css_unicode_expand (mask_ctx_t *mask_ctx); -int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]); -void mp_cut_at (char *mask, u32 max); -u32 mp_get_length (char *mask); -void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt); -u64 mp_get_sum (u32 css_cnt, cs_t *css); -void mp_setup_sys (cs_t *mp_sys); -int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index); -void mp_reset_usr (cs_t *mp_usr, u32 index); - -u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf); void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop); -int sp_comp_val (const void *p1, const void *p2); -void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 threshold, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]); -void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out); -void sp_stretch_root (hcstat_table_t *in, hcstat_table_t *out); int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx); int mask_ctx_init (hashcat_ctx_t *hashcat_ctx); diff --git a/src/affinity.c b/src/affinity.c index 211baff08..893ce1250 100644 --- a/src/affinity.c +++ b/src/affinity.c @@ -61,7 +61,7 @@ int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx) CPU_ZERO (&cpuset); #endif - char *devices = mystrdup (user_options->cpu_affinity); + char *devices = hcstrdup (hashcat_ctx, user_options->cpu_affinity); char *next = strtok (devices, ","); @@ -95,7 +95,7 @@ int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx) } while ((next = strtok (NULL, ",")) != NULL); - myfree (devices); + hcfree (devices); #if defined (_WIN) diff --git a/src/bitmap.c b/src/bitmap.c index 0069f0f92..9cae87480 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -77,14 +77,14 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) const u32 bitmap_min = user_options->bitmap_min; const u32 bitmap_max = user_options->bitmap_max; - u32 *bitmap_s1_a = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s1_b = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s1_c = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s1_d = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_a = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_b = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_c = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_d = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); u32 bitmap_bits; u32 bitmap_nums; @@ -139,14 +139,14 @@ void bitmap_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (bitmap_ctx->enabled == false) return; - myfree (bitmap_ctx->bitmap_s1_a); - myfree (bitmap_ctx->bitmap_s1_b); - myfree (bitmap_ctx->bitmap_s1_c); - myfree (bitmap_ctx->bitmap_s1_d); - myfree (bitmap_ctx->bitmap_s2_a); - myfree (bitmap_ctx->bitmap_s2_b); - myfree (bitmap_ctx->bitmap_s2_c); - myfree (bitmap_ctx->bitmap_s2_d); + hcfree (bitmap_ctx->bitmap_s1_a); + hcfree (bitmap_ctx->bitmap_s1_b); + hcfree (bitmap_ctx->bitmap_s1_c); + hcfree (bitmap_ctx->bitmap_s1_d); + hcfree (bitmap_ctx->bitmap_s2_a); + hcfree (bitmap_ctx->bitmap_s2_b); + hcfree (bitmap_ctx->bitmap_s2_c); + hcfree (bitmap_ctx->bitmap_s2_d); memset (bitmap_ctx, 0, sizeof (bitmap_ctx_t)); } diff --git a/src/combinator.c b/src/combinator.c index f0f46b2ea..2bdbe8fa4 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -30,7 +30,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) combinator_ctx->enabled = true; - combinator_ctx->scratch_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + combinator_ctx->scratch_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { @@ -183,7 +183,7 @@ void combinator_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (combinator_ctx->enabled == false) return; - myfree (combinator_ctx->scratch_buf); + hcfree (combinator_ctx->scratch_buf); memset (combinator_ctx, 0, sizeof (combinator_ctx_t)); } diff --git a/src/cpt.c b/src/cpt.c index 7f2f2a263..8cf5c36b0 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -25,7 +25,7 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) cpt_ctx->enabled = true; - cpt_ctx->cpt_buf = (cpt_t *) mycalloc (CPT_BUF, sizeof (cpt_t)); + cpt_ctx->cpt_buf = (cpt_t *) hccalloc (hashcat_ctx, CPT_BUF, sizeof (cpt_t)); cpt_ctx->cpt_total = 0; cpt_ctx->cpt_pos = 0; @@ -40,7 +40,7 @@ void cpt_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (cpt_ctx->enabled == false) return; - myfree (cpt_ctx->cpt_buf); + hcfree (cpt_ctx->cpt_buf); memset (cpt_ctx, 0, sizeof (cpt_ctx_t)); } diff --git a/src/cpu_crc32.c b/src/cpu_crc32.c index 6ff88ac5e..98b248ef0 100644 --- a/src/cpu_crc32.c +++ b/src/cpu_crc32.c @@ -92,7 +92,7 @@ int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64]) #define MAX_KEY_SIZE (1024 * 1024) - u8 *buf = (u8 *) mymalloc (MAX_KEY_SIZE + 1); + u8 *buf = (u8 *) hcmalloc (hashcat_ctx, MAX_KEY_SIZE + 1); int nread = fread (buf, sizeof (u8), MAX_KEY_SIZE, fd); @@ -112,7 +112,7 @@ int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64]) if (kpos >= 64) kpos = 0; } - myfree (buf); + hcfree (buf); return 0; } diff --git a/src/dictstat.c b/src/dictstat.c index 3e13c2fe0..f6ff41783 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -42,8 +42,8 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) if (user_options->attack_mode == ATTACK_MODE_BF) return 0; dictstat_ctx->enabled = true; - dictstat_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY); - dictstat_ctx->base = (dictstat_t *) mycalloc (MAX_DICTSTAT, sizeof (dictstat_t)); + dictstat_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + dictstat_ctx->base = (dictstat_t *) hccalloc (hashcat_ctx, MAX_DICTSTAT, sizeof (dictstat_t)); dictstat_ctx->cnt = 0; snprintf (dictstat_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.dictstat", folder_config->profile_dir); @@ -68,8 +68,8 @@ void dictstat_destroy (hashcat_ctx_t *hashcat_ctx) if (dictstat_ctx->enabled == false) return; - myfree (dictstat_ctx->filename); - myfree (dictstat_ctx->base); + hcfree (dictstat_ctx->filename); + hcfree (dictstat_ctx->base); memset (dictstat_ctx, 0, sizeof (dictstat_ctx_t)); } diff --git a/src/dispatch.c b/src/dispatch.c index 5480c8b23..65d01fcbb 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -113,7 +113,7 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - char *buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); const u32 attack_kern = user_options_extra->attack_kern; @@ -223,7 +223,7 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa device_param->kernel_accel = 0; device_param->kernel_loops = 0; - myfree (buf); + hcfree (buf); } void *thread_calc_stdin (void *p) @@ -359,7 +359,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) } } - hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) mymalloc (sizeof (hashcat_ctx_t)); + hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_ctx_t)); /* hashcat_ctx_tmp->bitmap_ctx = hashcat_ctx->bitmap_ctx; @@ -389,7 +389,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) memcpy (hashcat_ctx_tmp, hashcat_ctx, sizeof (hashcat_ctx_t)); // yes we actually want to copy these pointers - hashcat_ctx_tmp->wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t)); + hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); wl_data_init (hashcat_ctx_tmp); @@ -534,9 +534,9 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) wl_data_destroy (hashcat_ctx_tmp); - myfree (hashcat_ctx_tmp->wl_data); + hcfree (hashcat_ctx_tmp->wl_data); - myfree (hashcat_ctx_tmp); + hcfree (hashcat_ctx_tmp); fclose (fd); } diff --git a/src/ext_ADL.c b/src/ext_ADL.c index b8384997e..ad4de4bd7 100644 --- a/src/ext_ADL.c +++ b/src/ext_ADL.c @@ -4,11 +4,9 @@ */ #include "common.h" -#include "types.h" -#include "memory.h" #include "ext_ADL.h" void *HC_API_CALL ADL_Main_Memory_Alloc (const int iSize) { - return mymalloc ((size_t) iSize); + return malloc ((size_t) iSize); } diff --git a/src/filehandling.c b/src/filehandling.c index f4225489c..77708b312 100644 --- a/src/filehandling.c +++ b/src/filehandling.c @@ -8,11 +8,11 @@ #include "memory.h" #include "filehandling.h" -u64 count_lines (FILE *fd) +u64 count_lines (hashcat_ctx_t *hashcat_ctx, FILE *fd) { u64 cnt = 0; - char *buf = (char *) mymalloc (HCBUFSIZ_LARGE + 1); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE + 1); char prev = '\n'; @@ -32,7 +32,7 @@ u64 count_lines (FILE *fd) } } - myfree (buf); + hcfree (buf); return cnt; } diff --git a/src/folder.c b/src/folder.c index 934475043..181342a11 100644 --- a/src/folder.c +++ b/src/folder.c @@ -26,11 +26,11 @@ int sort_by_stringptr (const void *p1, const void *p2) return strcmp (*s1, *s2); } -static char *get_exec_path () +static char *get_exec_path (hashcat_ctx_t *hashcat_ctx) { size_t exec_path_len = 1024; - char *exec_path = (char *) mymalloc (exec_path_len); + char *exec_path = (char *) hcmalloc (hashcat_ctx, exec_path_len); #if defined (__linux__) @@ -78,9 +78,9 @@ static char *get_exec_path () return exec_path; } -char *get_install_dir (const char *progname) +char *get_install_dir (hashcat_ctx_t *hashcat_ctx, const char *progname) { - char *install_dir = mystrdup (progname); + char *install_dir = hcstrdup (hashcat_ctx, progname); char *last_slash = NULL; if ((last_slash = strrchr (install_dir, '/')) != NULL) @@ -100,18 +100,18 @@ char *get_install_dir (const char *progname) return (install_dir); } -char *get_profile_dir (const char *homedir) +char *get_profile_dir (hashcat_ctx_t *hashcat_ctx, const char *homedir) { - char *profile_dir = (char *) mymalloc (HCBUFSIZ_TINY + 1); + char *profile_dir = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY + 1); snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", homedir, DOT_HASHCAT); return profile_dir; } -char *get_session_dir (const char *profile_dir) +char *get_session_dir (hashcat_ctx_t *hashcat_ctx, const char *profile_dir) { - char *session_dir = (char *) mymalloc (HCBUFSIZ_TINY); + char *session_dir = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (session_dir, HCBUFSIZ_TINY - 1, "%s/%s", profile_dir, SESSIONS_FOLDER); @@ -132,9 +132,9 @@ int count_dictionaries (char **dictionary_files) return (cnt); } -char **scan_directory (const char *path) +char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path) { - char *tmp_path = mystrdup (path); + char *tmp_path = hcstrdup (hashcat_ctx, path); size_t tmp_path_len = strlen (tmp_path); @@ -180,7 +180,7 @@ char **scan_directory (const char *path) size_t path_size = strlen (tmp_path) + 1 + strlen (de->d_name); - char *path_file = (char *) mymalloc (path_size + 1); + char *path_file = (char *) hcmalloc (hashcat_ctx, path_size + 1); snprintf (path_file, path_size + 1, "%s/%s", tmp_path, de->d_name); @@ -192,11 +192,11 @@ char **scan_directory (const char *path) { closedir (d_test); - myfree (path_file); + hcfree (path_file); } else { - files = (char **) myrealloc (files, (size_t) num_files * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *)); num_files++; @@ -208,20 +208,20 @@ char **scan_directory (const char *path) } else if (errno == ENOTDIR) { - files = (char **) myrealloc (files, (size_t) num_files * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *)); num_files++; - files[num_files - 1] = mystrdup (path); + files[num_files - 1] = hcstrdup (hashcat_ctx, path); } - files = (char **) myrealloc (files, (size_t) num_files * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *)); num_files++; files[num_files - 1] = NULL; - myfree (tmp_path); + hcfree (tmp_path); return (files); } @@ -237,7 +237,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * then chdir() back to where we came from so we need to save it first */ - char *cwd = (char *) mymalloc (HCBUFSIZ_TINY); + char *cwd = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); if (getcwd (cwd, HCBUFSIZ_TINY - 1) == NULL) { @@ -250,7 +250,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * folders, as discussed on https://github.com/hashcat/hashcat/issues/20 */ - char *exec_path = get_exec_path (); + char *exec_path = get_exec_path (hashcat_ctx); if (exec_path == NULL) { @@ -280,7 +280,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins return -1; } - char *install_dir = get_install_dir (resolved_exec_path); + char *install_dir = get_install_dir (hashcat_ctx, resolved_exec_path); char *profile_dir = NULL; char *session_dir = NULL; char *shared_dir = NULL; @@ -291,9 +291,9 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins const char *homedir = pw->pw_dir; - profile_dir = get_profile_dir (homedir); - session_dir = get_session_dir (profile_dir); - shared_dir = mystrdup (shared_folder); + profile_dir = get_profile_dir (hashcat_ctx, homedir); + session_dir = get_session_dir (hashcat_ctx, profile_dir); + shared_dir = hcstrdup (hashcat_ctx, shared_folder); hc_mkdir (profile_dir, 0700); hc_mkdir (session_dir, 0700); @@ -305,19 +305,19 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins shared_dir = install_dir; } - myfree (resolved_install_folder); - myfree (resolved_exec_path); + hcfree (resolved_install_folder); + hcfree (resolved_exec_path); #else - char *install_dir = get_install_dir (exec_path); + char *install_dir = get_install_dir (hashcat_ctx, exec_path); char *profile_dir = install_dir; char *session_dir = install_dir; char *shared_dir = install_dir; #endif - myfree (exec_path); + hcfree (exec_path); /** * There's alot of problem related to bad support -I parameters when building the kernel. @@ -326,13 +326,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * 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); + char *cpath = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); #if defined (_WIN) snprintf (cpath, HCBUFSIZ_TINY - 1, "%s\\OpenCL\\", shared_dir); - char *cpath_real = (char *) mymalloc (HCBUFSIZ_TINY); + char *cpath_real = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); if (GetFullPathName (cpath, HCBUFSIZ_TINY - 1, cpath_real, NULL) == 0) { @@ -345,7 +345,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins snprintf (cpath, HCBUFSIZ_TINY - 1, "%s/OpenCL/", shared_dir); - char *cpath_real = (char *) mymalloc (PATH_MAX); + char *cpath_real = (char *) hcmalloc (hashcat_ctx, PATH_MAX); if (realpath (cpath, cpath_real) == NULL) { @@ -356,7 +356,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins #endif - myfree (cpath); + hcfree (cpath); //if (getenv ("TMP") == NULL) if (1) @@ -385,13 +385,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * kernel cache, we need to make sure folder exist */ - char *kernels_folder = (char *) mymalloc (HCBUFSIZ_TINY); + char *kernels_folder = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (kernels_folder, HCBUFSIZ_TINY - 1, "%s/kernels", profile_dir); hc_mkdir (kernels_folder, 0700); - myfree (kernels_folder); + hcfree (kernels_folder); /** * store for later use @@ -411,9 +411,9 @@ void folder_config_destroy (hashcat_ctx_t *hashcat_ctx) { folder_config_t *folder_config = hashcat_ctx->folder_config; - myfree (folder_config->cpath_real); - myfree (folder_config->cwd); - myfree (folder_config->install_dir); + hcfree (folder_config->cpath_real); + hcfree (folder_config->cwd); + hcfree (folder_config->install_dir); memset (folder_config, 0, sizeof (folder_config_t)); } diff --git a/src/hashcat.c b/src/hashcat.c index 6ba021604..eb770acda 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -66,61 +66,61 @@ void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (const u32, stru hashcat_ctx->event = event; - hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) mymalloc (sizeof (bitmap_ctx_t)); - hashcat_ctx->combinator_ctx = (combinator_ctx_t *) mymalloc (sizeof (combinator_ctx_t)); - hashcat_ctx->cpt_ctx = (cpt_ctx_t *) mymalloc (sizeof (cpt_ctx_t)); - hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) mymalloc (sizeof (debugfile_ctx_t)); - hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) mymalloc (sizeof (dictstat_ctx_t)); - hashcat_ctx->event_ctx = (event_ctx_t *) mymalloc (sizeof (event_ctx_t)); - hashcat_ctx->folder_config = (folder_config_t *) mymalloc (sizeof (folder_config_t)); - hashcat_ctx->hashcat_user = (hashcat_user_t *) mymalloc (sizeof (hashcat_user_t)); - hashcat_ctx->hashconfig = (hashconfig_t *) mymalloc (sizeof (hashconfig_t)); - hashcat_ctx->hashes = (hashes_t *) mymalloc (sizeof (hashes_t)); - hashcat_ctx->hwmon_ctx = (hwmon_ctx_t *) mymalloc (sizeof (hwmon_ctx_t)); - hashcat_ctx->induct_ctx = (induct_ctx_t *) mymalloc (sizeof (induct_ctx_t)); - hashcat_ctx->logfile_ctx = (logfile_ctx_t *) mymalloc (sizeof (logfile_ctx_t)); - hashcat_ctx->loopback_ctx = (loopback_ctx_t *) mymalloc (sizeof (loopback_ctx_t)); - hashcat_ctx->mask_ctx = (mask_ctx_t *) mymalloc (sizeof (mask_ctx_t)); - hashcat_ctx->opencl_ctx = (opencl_ctx_t *) mymalloc (sizeof (opencl_ctx_t)); - hashcat_ctx->outcheck_ctx = (outcheck_ctx_t *) mymalloc (sizeof (outcheck_ctx_t)); - hashcat_ctx->outfile_ctx = (outfile_ctx_t *) mymalloc (sizeof (outfile_ctx_t)); - hashcat_ctx->potfile_ctx = (potfile_ctx_t *) mymalloc (sizeof (potfile_ctx_t)); - hashcat_ctx->restore_ctx = (restore_ctx_t *) mymalloc (sizeof (restore_ctx_t)); - hashcat_ctx->status_ctx = (status_ctx_t *) mymalloc (sizeof (status_ctx_t)); - hashcat_ctx->straight_ctx = (straight_ctx_t *) mymalloc (sizeof (straight_ctx_t)); - hashcat_ctx->tuning_db = (tuning_db_t *) mymalloc (sizeof (tuning_db_t)); - hashcat_ctx->user_options_extra = (user_options_extra_t *) mymalloc (sizeof (user_options_extra_t)); - hashcat_ctx->user_options = (user_options_t *) mymalloc (sizeof (user_options_t)); - hashcat_ctx->wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t)); + hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) hcmalloc (hashcat_ctx, sizeof (bitmap_ctx_t)); + hashcat_ctx->combinator_ctx = (combinator_ctx_t *) hcmalloc (hashcat_ctx, sizeof (combinator_ctx_t)); + hashcat_ctx->cpt_ctx = (cpt_ctx_t *) hcmalloc (hashcat_ctx, sizeof (cpt_ctx_t)); + hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (debugfile_ctx_t)); + hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (dictstat_ctx_t)); + hashcat_ctx->event_ctx = (event_ctx_t *) hcmalloc (hashcat_ctx, sizeof (event_ctx_t)); + hashcat_ctx->folder_config = (folder_config_t *) hcmalloc (hashcat_ctx, sizeof (folder_config_t)); + hashcat_ctx->hashcat_user = (hashcat_user_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_user_t)); + hashcat_ctx->hashconfig = (hashconfig_t *) hcmalloc (hashcat_ctx, sizeof (hashconfig_t)); + hashcat_ctx->hashes = (hashes_t *) hcmalloc (hashcat_ctx, sizeof (hashes_t)); + hashcat_ctx->hwmon_ctx = (hwmon_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hwmon_ctx_t)); + hashcat_ctx->induct_ctx = (induct_ctx_t *) hcmalloc (hashcat_ctx, sizeof (induct_ctx_t)); + hashcat_ctx->logfile_ctx = (logfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (logfile_ctx_t)); + hashcat_ctx->loopback_ctx = (loopback_ctx_t *) hcmalloc (hashcat_ctx, sizeof (loopback_ctx_t)); + hashcat_ctx->mask_ctx = (mask_ctx_t *) hcmalloc (hashcat_ctx, sizeof (mask_ctx_t)); + hashcat_ctx->opencl_ctx = (opencl_ctx_t *) hcmalloc (hashcat_ctx, sizeof (opencl_ctx_t)); + hashcat_ctx->outcheck_ctx = (outcheck_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outcheck_ctx_t)); + hashcat_ctx->outfile_ctx = (outfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outfile_ctx_t)); + hashcat_ctx->potfile_ctx = (potfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (potfile_ctx_t)); + hashcat_ctx->restore_ctx = (restore_ctx_t *) hcmalloc (hashcat_ctx, sizeof (restore_ctx_t)); + hashcat_ctx->status_ctx = (status_ctx_t *) hcmalloc (hashcat_ctx, sizeof (status_ctx_t)); + hashcat_ctx->straight_ctx = (straight_ctx_t *) hcmalloc (hashcat_ctx, sizeof (straight_ctx_t)); + hashcat_ctx->tuning_db = (tuning_db_t *) hcmalloc (hashcat_ctx, sizeof (tuning_db_t)); + hashcat_ctx->user_options_extra = (user_options_extra_t *) hcmalloc (hashcat_ctx, sizeof (user_options_extra_t)); + hashcat_ctx->user_options = (user_options_t *) hcmalloc (hashcat_ctx, sizeof (user_options_t)); + hashcat_ctx->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); } void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx) { - myfree (hashcat_ctx->bitmap_ctx); - myfree (hashcat_ctx->combinator_ctx); - myfree (hashcat_ctx->cpt_ctx); - myfree (hashcat_ctx->debugfile_ctx); - myfree (hashcat_ctx->dictstat_ctx); - myfree (hashcat_ctx->event_ctx); - myfree (hashcat_ctx->folder_config); - myfree (hashcat_ctx->hashconfig); - myfree (hashcat_ctx->hashes); - myfree (hashcat_ctx->hwmon_ctx); - myfree (hashcat_ctx->induct_ctx); - myfree (hashcat_ctx->logfile_ctx); - myfree (hashcat_ctx->loopback_ctx); - myfree (hashcat_ctx->mask_ctx); - myfree (hashcat_ctx->opencl_ctx); - myfree (hashcat_ctx->outcheck_ctx); - myfree (hashcat_ctx->outfile_ctx); - myfree (hashcat_ctx->potfile_ctx); - myfree (hashcat_ctx->restore_ctx); - myfree (hashcat_ctx->status_ctx); - myfree (hashcat_ctx->straight_ctx); - myfree (hashcat_ctx->tuning_db); - myfree (hashcat_ctx->user_options_extra); - myfree (hashcat_ctx->user_options); - myfree (hashcat_ctx->wl_data); + hcfree (hashcat_ctx->bitmap_ctx); + hcfree (hashcat_ctx->combinator_ctx); + hcfree (hashcat_ctx->cpt_ctx); + hcfree (hashcat_ctx->debugfile_ctx); + hcfree (hashcat_ctx->dictstat_ctx); + hcfree (hashcat_ctx->event_ctx); + hcfree (hashcat_ctx->folder_config); + hcfree (hashcat_ctx->hashconfig); + hcfree (hashcat_ctx->hashes); + hcfree (hashcat_ctx->hwmon_ctx); + hcfree (hashcat_ctx->induct_ctx); + hcfree (hashcat_ctx->logfile_ctx); + hcfree (hashcat_ctx->loopback_ctx); + hcfree (hashcat_ctx->mask_ctx); + hcfree (hashcat_ctx->opencl_ctx); + hcfree (hashcat_ctx->outcheck_ctx); + hcfree (hashcat_ctx->outfile_ctx); + hcfree (hashcat_ctx->potfile_ctx); + hcfree (hashcat_ctx->restore_ctx); + hcfree (hashcat_ctx->status_ctx); + hcfree (hashcat_ctx->straight_ctx); + hcfree (hashcat_ctx->tuning_db); + hcfree (hashcat_ctx->user_options_extra); + hcfree (hashcat_ctx->user_options); + hcfree (hashcat_ctx->wl_data); memset (hashcat_ctx, 0, sizeof (hashcat_ctx_t)); } @@ -227,9 +227,9 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_AUTOTUNE_STARTING); - thread_param_t *threads_param = (thread_param_t *) mycalloc (opencl_ctx->devices_cnt, sizeof (thread_param_t)); + thread_param_t *threads_param = (thread_param_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (thread_param_t)); - hc_thread_t *c_threads = (hc_thread_t *) mycalloc (opencl_ctx->devices_cnt, sizeof (hc_thread_t)); + hc_thread_t *c_threads = (hc_thread_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (hc_thread_t)); status_ctx->devices_status = STATUS_AUTOTUNE; @@ -303,9 +303,9 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) hc_thread_wait (opencl_ctx->devices_cnt, c_threads); - myfree (c_threads); + hcfree (c_threads); - myfree (threads_param); + hcfree (threads_param); if ((status_ctx->devices_status != STATUS_CRACKED) && (status_ctx->devices_status != STATUS_ABORTED) @@ -367,7 +367,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) unlink (induct_ctx->induction_dictionaries[induct_ctx->induction_dictionaries_pos]); } - myfree (induct_ctx->induction_dictionaries); + hcfree (induct_ctx->induction_dictionaries); induct_ctx_scan (hashcat_ctx); } @@ -692,7 +692,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) int inner_threads_cnt = 0; - hc_thread_t *inner_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t)); + hc_thread_t *inner_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 10, sizeof (hc_thread_t)); status_ctx->shutdown_inner = false; @@ -762,7 +762,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) hc_thread_wait (1, &inner_threads[thread_idx]); } - myfree (inner_threads); + hcfree (inner_threads); EVENT (EVENT_INNERLOOP1_FINISHED); diff --git a/src/hashes.c b/src/hashes.c index 40d9e59d6..8cccb6dcc 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -173,7 +173,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) out_buf[0] = 0; - ascii_digest (out_buf, salt_pos, digest_pos, hashconfig, hashes); + ascii_digest (hashcat_ctx, out_buf, salt_pos, digest_pos); fputs (out_buf, fp); @@ -183,7 +183,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) { hccap_t hccap; - to_hccap_t (&hccap, salt_pos, digest_pos, hashconfig, hashes); + to_hccap_t (hashcat_ctx, &hccap, salt_pos, digest_pos); fwrite (&hccap, sizeof (hccap_t), 1, fp); } @@ -220,8 +220,6 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain) { debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx; - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - hashes_t *hashes = hashcat_ctx->hashes; loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx; outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -235,7 +233,7 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl char out_buf[HCBUFSIZ_LARGE] = { 0 }; - ascii_digest (out_buf, salt_pos, digest_pos, hashconfig, hashes); + ascii_digest (hashcat_ctx, out_buf, salt_pos, digest_pos); // plain @@ -337,7 +335,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, event_log_info_nn (hashcat_ctx, ""); - plain_t *cracked = (plain_t *) mycalloc (num_cracked, sizeof (plain_t)); + plain_t *cracked = (plain_t *) hccalloc (hashcat_ctx, num_cracked, sizeof (plain_t)); CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, 0, num_cracked * sizeof (plain_t), cracked, 0, NULL, NULL); @@ -383,7 +381,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, hc_thread_mutex_unlock (status_ctx->mux_display); - myfree (cracked); + hcfree (cracked); if (cpt_cracked > 0) { @@ -508,7 +506,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Counting lines in %s", hashfile); - hashes_avail = count_lines (fp); + hashes_avail = count_lines (hashcat_ctx, fp); rewind (fp); @@ -556,9 +554,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) salt_t *salts_buf = NULL; void *esalts_buf = NULL; - hashes_buf = (hash_t *) mycalloc (hashes_avail, sizeof (hash_t)); + hashes_buf = (hash_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (hash_t)); - digests_buf = (void *) mycalloc (hashes_avail, hashconfig->dgst_size); + digests_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->dgst_size); if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { @@ -566,34 +564,34 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) for (hash_pos = 0; hash_pos < hashes_avail; hash_pos++) { - hashinfo_t *hash_info = (hashinfo_t *) mymalloc (sizeof (hashinfo_t)); + hashinfo_t *hash_info = (hashinfo_t *) hcmalloc (hashcat_ctx, sizeof (hashinfo_t)); hashes_buf[hash_pos].hash_info = hash_info; if (user_options->username && (user_options->remove || user_options->show || user_options->left)) { - hash_info->user = (user_t*) mymalloc (sizeof (user_t)); + hash_info->user = (user_t*) hcmalloc (hashcat_ctx, sizeof (user_t)); } if (user_options->benchmark) { - hash_info->orighash = (char *) mymalloc (256); + hash_info->orighash = (char *) hcmalloc (hashcat_ctx, 256); } } } if (hashconfig->is_salted) { - salts_buf = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t)); + salts_buf = (salt_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (salt_t)); if (hashconfig->esalt_size) { - esalts_buf = (void *) mycalloc (hashes_avail, hashconfig->esalt_size); + esalts_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->esalt_size); } } else { - salts_buf = (salt_t *) mycalloc (1, sizeof (salt_t)); + salts_buf = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); } for (u32 hash_pos = 0; hash_pos < hashes_avail; hash_pos++) @@ -675,7 +673,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info; - hash_info_tmp->orighash = mystrdup (hash_buf); + hash_info_tmp->orighash = hcstrdup (hashcat_ctx, hash_buf); } if (hashconfig->is_salted) @@ -718,7 +716,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) u32 hccap_size = sizeof (hccap_t); - char *in = (char *) mymalloc (hccap_size); + char *in = (char *) hcmalloc (hashcat_ctx, hccap_size); while (!feof (fp)) { @@ -789,7 +787,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) fclose (fp); - myfree (in); + hcfree (in); } else if (hashconfig->hash_mode == 3000) { @@ -889,7 +887,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) u32 line_num = 0; - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (fp)) { @@ -927,17 +925,17 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { user_t **user = &hashes_buf[hashes_cnt].hash_info->user; - *user = (user_t *) mymalloc (sizeof (user_t)); + *user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); user_t *user_ptr = *user; if (user_buf != NULL) { - user_ptr->user_name = mystrdup (user_buf); + user_ptr->user_name = hcstrdup (hashcat_ctx, user_buf); } else { - user_ptr->user_name = mystrdup (""); + user_ptr->user_name = hcstrdup (hashcat_ctx, ""); } user_ptr->user_len = user_len; @@ -948,7 +946,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info; - hash_info_tmp->orighash = mystrdup (hash_buf); + hash_info_tmp->orighash = hcstrdup (hashcat_ctx, hash_buf); } if (hashconfig->is_salted) @@ -1032,7 +1030,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } } - myfree (line_buf); + hcfree (line_buf); fclose (fp); @@ -1104,22 +1102,22 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) * Now generate all the buffers required for later */ - void *digests_buf_new = (void *) mycalloc (hashes_cnt, hashconfig->dgst_size); + void *digests_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->dgst_size); salt_t *salts_buf_new = NULL; void *esalts_buf_new = NULL; if (hashconfig->is_salted) { - salts_buf_new = (salt_t *) mycalloc (hashes_cnt, sizeof (salt_t)); + salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (salt_t)); if (hashconfig->esalt_size) { - esalts_buf_new = (void *) mycalloc (hashes_cnt, hashconfig->esalt_size); + esalts_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->esalt_size); } } else { - salts_buf_new = (salt_t *) mycalloc (1, sizeof (salt_t)); + salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); } if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Structuring salts for cracking task..."); @@ -1127,8 +1125,8 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) u32 digests_cnt = hashes_cnt; u32 digests_done = 0; - u32 *digests_shown = (u32 *) mycalloc (digests_cnt, sizeof (u32)); - u32 *digests_shown_tmp = (u32 *) mycalloc (digests_cnt, sizeof (u32)); + u32 *digests_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); + u32 *digests_shown_tmp = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); u32 salts_cnt = 0; u32 salts_done = 0; @@ -1137,7 +1135,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { - hash_info = (hashinfo_t **) mycalloc (hashes_cnt, sizeof (hashinfo_t *)); + hash_info = (hashinfo_t **) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t *)); if (user_options->username && (user_options->remove || user_options->show)) { @@ -1145,14 +1143,14 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) for (user_pos = 0; user_pos < hashes_cnt; user_pos++) { - hash_info[user_pos] = (hashinfo_t *) mycalloc (hashes_cnt, sizeof (hashinfo_t)); + hash_info[user_pos] = (hashinfo_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t)); - hash_info[user_pos]->user = (user_t *) mymalloc (sizeof (user_t)); + hash_info[user_pos]->user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); } } } - u32 *salts_shown = (u32 *) mycalloc (digests_cnt, sizeof (u32)); + u32 *salts_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); salt_t *salt_buf; @@ -1251,10 +1249,10 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) if (salts_done == salts_cnt) mycracked (hashcat_ctx); } - myfree (hashes->digests_buf); - myfree (hashes->salts_buf); - myfree (hashes->esalts_buf); - myfree (hashes->hashes_buf); + hcfree (hashes->digests_buf); + hcfree (hashes->salts_buf); + hcfree (hashes->esalts_buf); + hcfree (hashes->hashes_buf); hashes->digests_cnt = digests_cnt; hashes->digests_done = digests_done; @@ -1333,16 +1331,16 @@ void hashes_destroy (hashcat_ctx_t *hashcat_ctx) { hashes_t *hashes = hashcat_ctx->hashes; - myfree (hashes->digests_buf); - myfree (hashes->digests_shown); - myfree (hashes->digests_shown_tmp); + hcfree (hashes->digests_buf); + hcfree (hashes->digests_shown); + hcfree (hashes->digests_shown_tmp); - myfree (hashes->salts_buf); - myfree (hashes->salts_shown); + hcfree (hashes->salts_buf); + hcfree (hashes->salts_shown); - myfree (hashes->esalts_buf); + hcfree (hashes->esalts_buf); - myfree (hashes->hash_info); + hcfree (hashes->hash_info); memset (hashes, 0, sizeof (hashes_t)); } diff --git a/src/hlfmt.c b/src/hlfmt.c index e60d0e6f8..9cad42409 100644 --- a/src/hlfmt.c +++ b/src/hlfmt.c @@ -342,11 +342,11 @@ u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check) if (hashconfig->hash_mode == 5300) return HLFMT_HASHCAT; if (hashconfig->hash_mode == 5400) return HLFMT_HASHCAT; - u32 *formats_cnt = (u32 *) mycalloc (HLFMTS_CNT, sizeof (u32)); + u32 *formats_cnt = (u32 *) hccalloc (hashcat_ctx, HLFMTS_CNT, sizeof (u32)); u32 num_check = 0; - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (fp)) { @@ -363,7 +363,7 @@ u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check) num_check++; } - myfree (line_buf); + hcfree (line_buf); u32 hashlist_format = HLFMT_HASHCAT; diff --git a/src/hwmon.c b/src/hwmon.c index b83502c7b..55248235c 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -12,7 +12,7 @@ // nvml functions -int nvml_init (hashcat_ctx_t *hashcat_ctx) +static int nvml_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -29,7 +29,7 @@ int nvml_init (hashcat_ctx_t *hashcat_ctx) DWORD Type = REG_SZ; - char *Buffer = (char *) mymalloc (BufferSize + 1); + char *Buffer = (char *) hcmalloc (hashcat_ctx, BufferSize + 1); HKEY hKey = 0; @@ -61,7 +61,7 @@ int nvml_init (hashcat_ctx_t *hashcat_ctx) nvml->lib = hc_dlopen (Buffer); - myfree (Buffer); + hcfree (Buffer); } #elif defined (_POSIX) @@ -100,7 +100,7 @@ int nvml_init (hashcat_ctx_t *hashcat_ctx) return 0; } -void nvml_close (hashcat_ctx_t *hashcat_ctx) +static void nvml_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -111,7 +111,7 @@ void nvml_close (hashcat_ctx_t *hashcat_ctx) if (nvml->lib) hc_dlclose (nvml->lib); - myfree (nvml); + hcfree (nvml); } } @@ -120,7 +120,7 @@ static const char *hm_NVML_nvmlErrorString (NVML_PTR *nvml, const nvmlReturn_t n return nvml->nvmlErrorString (nvml_rc); } -int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx) +static int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -140,7 +140,7 @@ int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx) return 0; } -int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx) +static int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -160,7 +160,7 @@ int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx) return 0; } -int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int index, nvmlDevice_t *device) +static int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int index, nvmlDevice_t *device) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -180,7 +180,8 @@ int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int return 0; } -int hm_NVML_nvmlDeviceGetName (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, char *name, unsigned int length) +/* +static int hm_NVML_nvmlDeviceGetName (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, char *name, unsigned int length) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -199,8 +200,9 @@ int hm_NVML_nvmlDeviceGetName (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, return 0; } +*/ -int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp) +static int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -220,7 +222,7 @@ int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t d return 0; } -int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *speed) +static int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *speed) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -240,7 +242,8 @@ int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t devi return 0; } -int hm_NVML_nvmlDeviceGetPowerUsage (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *power) +/* +static int hm_NVML_nvmlDeviceGetPowerUsage (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *power) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -259,8 +262,9 @@ int hm_NVML_nvmlDeviceGetPowerUsage (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t de return 0; } +*/ -int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlUtilization_t *utilization) +static int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlUtilization_t *utilization) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -280,7 +284,7 @@ int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nvmlDevic return 0; } -int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock) +static int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -300,7 +304,7 @@ int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t dev return 0; } -int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp) +static int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -320,7 +324,8 @@ int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx, nvmlD return 0; } -int hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkGen) +/* +static int hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkGen) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -339,8 +344,9 @@ int hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (hashcat_ctx_t *hashcat_ctx, nvm return 0; } +*/ -int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkWidth) +static int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkWidth) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -360,7 +366,8 @@ int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, nvmlDevi return 0; } -int hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *clocksThrottleReasons) +/* +static int hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *clocksThrottleReasons) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -379,8 +386,10 @@ int hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx_t *hashcat_ct return 0; } +*/ -int hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons) +/* +static int hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -399,8 +408,10 @@ int hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx_t *hashcat_ return 0; } +*/ -int hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlComputeMode_t mode) +/* +static int hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlComputeMode_t mode) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -419,8 +430,10 @@ int hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t d return 0; } +*/ -int hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlGpuOperationMode_t mode) +/* +static int hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlGpuOperationMode_t mode) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -439,8 +452,9 @@ int hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx_t *hashcat_ctx, nvmlDevic return 0; } +*/ -int hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit) +static int hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -460,7 +474,7 @@ int hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx_t *hashcat return 0; } -int hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int limit) +static int hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int limit) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -480,7 +494,7 @@ int hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlD return 0; } -int hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *limit) +static int hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *limit) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -502,7 +516,7 @@ int hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlD // nvapi functions -int nvapi_init (hashcat_ctx_t *hashcat_ctx) +static int nvapi_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -541,7 +555,7 @@ int nvapi_init (hashcat_ctx_t *hashcat_ctx) return 0; } -void nvapi_close (hashcat_ctx_t *hashcat_ctx) +static void nvapi_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -552,7 +566,7 @@ void nvapi_close (hashcat_ctx_t *hashcat_ctx) if (nvapi->lib) hc_dlclose (nvapi->lib); - myfree (nvapi); + hcfree (nvapi); } } @@ -561,7 +575,7 @@ static void hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, const NvAPI_Status NvAPI nvapi->NvAPI_GetErrorMessage (NvAPI_rc, string); } -int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx) +static int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -585,7 +599,7 @@ int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx) return 0; } -int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx) +static int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -607,7 +621,7 @@ int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx) return 0; } -int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount) +static int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -629,7 +643,7 @@ int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle n return 0; } -int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info) +static int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -651,7 +665,7 @@ int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuH return 0; } -int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status) +static int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -673,7 +687,7 @@ int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhysicalGp return 0; } -int hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels) +static int hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -695,7 +709,7 @@ int hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandl return 0; } -int hm_NvAPI_GPU_RestoreCoolerSettings (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex) +static int hm_NvAPI_GPU_RestoreCoolerSettings (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -732,7 +746,7 @@ void __GSHandlerCheck () // xnvctrl functions -int xnvctrl_init (hashcat_ctx_t *hashcat_ctx) +static int xnvctrl_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -780,7 +794,7 @@ int xnvctrl_init (hashcat_ctx_t *hashcat_ctx) return 0; } -void xnvctrl_close (hashcat_ctx_t *hashcat_ctx) +static void xnvctrl_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -802,11 +816,11 @@ void xnvctrl_close (hashcat_ctx_t *hashcat_ctx) #endif - myfree (xnvctrl); + hcfree (xnvctrl); } } -int hm_XNVCTRL_XOpenDisplay (hashcat_ctx_t *hashcat_ctx) +static int hm_XNVCTRL_XOpenDisplay (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -828,7 +842,7 @@ int hm_XNVCTRL_XOpenDisplay (hashcat_ctx_t *hashcat_ctx) return 0; } -void hm_XNVCTRL_XCloseDisplay (hashcat_ctx_t *hashcat_ctx) +static void hm_XNVCTRL_XCloseDisplay (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -841,7 +855,7 @@ void hm_XNVCTRL_XCloseDisplay (hashcat_ctx_t *hashcat_ctx) xnvctrl->XCloseDisplay (xnvctrl->dpy); } -int get_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +static int hm_XNVCTRL_get_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -863,7 +877,7 @@ int get_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) return 0; } -int set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) +static int hm_XNVCTRL_set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -875,13 +889,13 @@ int set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) int cur; - int rc = get_fan_control (hashcat_ctx, gpu, &cur); + int rc = hm_XNVCTRL_get_fan_control (hashcat_ctx, gpu, &cur); if (rc == -1) return -1; xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val); - rc = get_fan_control (hashcat_ctx, gpu, &cur); + rc = hm_XNVCTRL_get_fan_control (hashcat_ctx, gpu, &cur); if (rc == -1) return -1; @@ -890,7 +904,8 @@ int set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) return 0; } -int get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +/* +static int hm_XNVCTRL_get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -911,8 +926,9 @@ int get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) return 0; } +*/ -int get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +static int hm_XNVCTRL_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -934,7 +950,7 @@ int get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) return 0; } -int get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +static int hm_XNVCTRL_get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -956,7 +972,7 @@ int get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) return 0; } -int set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) +static int hm_XNVCTRL_set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -968,13 +984,13 @@ int set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) int cur; - int rc = get_fan_speed_target (hashcat_ctx, gpu, &cur); + int rc = hm_XNVCTRL_get_fan_speed_target (hashcat_ctx, gpu, &cur); if (rc == -1) return -1; xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val); - rc = get_fan_speed_target (hashcat_ctx, gpu, &cur); + rc = hm_XNVCTRL_get_fan_speed_target (hashcat_ctx, gpu, &cur); if (rc == -1) return -1; @@ -985,7 +1001,7 @@ int set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) // ADL functions -int adl_init (hashcat_ctx_t *hashcat_ctx) +static int adl_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1050,7 +1066,7 @@ int adl_init (hashcat_ctx_t *hashcat_ctx) return 0; } -void adl_close (hashcat_ctx_t *hashcat_ctx) +static void adl_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1061,11 +1077,11 @@ void adl_close (hashcat_ctx_t *hashcat_ctx) if (adl->lib) hc_dlclose (adl->lib); - myfree (adl); + hcfree (adl); } } -int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx) +static int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1083,7 +1099,7 @@ int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx) return 0; } -int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters) +static int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1101,7 +1117,7 @@ int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALLOC_CALL return 0; } -int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int *lpNumAdapters) +static int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int *lpNumAdapters) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1119,7 +1135,7 @@ int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int *lpNumA return 0; } -int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lpInfo, int iInputSize) +static int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lpInfo, int iInputSize) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1137,7 +1153,8 @@ int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lp return 0; } -int hm_ADL_Display_DisplayInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect) +/* +static int hm_ADL_Display_DisplayInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1154,8 +1171,10 @@ int hm_ADL_Display_DisplayInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } +*/ -int hm_ADL_Adapter_ID_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpAdapterID) +/* +static int hm_ADL_Adapter_ID_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpAdapterID) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1172,8 +1191,10 @@ int hm_ADL_Adapter_ID_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *l return ADL_rc; } +*/ -int hm_ADL_Adapter_VideoBiosInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLBiosInfo *lpBiosInfo) +/* +static int hm_ADL_Adapter_VideoBiosInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLBiosInfo *lpBiosInfo) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1190,8 +1211,10 @@ int hm_ADL_Adapter_VideoBiosInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIn return ADL_rc; } +*/ -int hm_ADL_Overdrive_ThermalDevices_Enum (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo) +/* +static int hm_ADL_Overdrive_ThermalDevices_Enum (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1208,8 +1231,9 @@ int hm_ADL_Overdrive_ThermalDevices_Enum (hashcat_ctx_t *hashcat_ctx, int iAdapt return 0; } +*/ -int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature) +static int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1227,7 +1251,7 @@ int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } -int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iTemperature) +static int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iTemperature) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1245,7 +1269,7 @@ int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } -int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLPMActivity *lpActivity) +static int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLPMActivity *lpActivity) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1263,7 +1287,7 @@ int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int iAdapt return 0; } -int hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo) +static int hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1281,7 +1305,7 @@ int hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapter return ADL_rc; } -int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) +static int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1299,7 +1323,7 @@ int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } -int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo) +static int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1317,7 +1341,7 @@ int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } -int hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) +static int hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1335,7 +1359,7 @@ int hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } -int hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue) +static int hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1353,7 +1377,7 @@ int hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } -int hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex) +static int hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1371,7 +1395,8 @@ int hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx_t *hashcat_ctx, int iAd return 0; } -int hm_ADL_Overdrive_ODParameters_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODParameters *lpOdParameters) +/* +static int hm_ADL_Overdrive_ODParameters_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODParameters *lpOdParameters) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1388,8 +1413,10 @@ int hm_ADL_Overdrive_ODParameters_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } +*/ -int hm_ADL_Overdrive_ODPerformanceLevels_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels) +/* +static int hm_ADL_Overdrive_ODPerformanceLevels_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1406,8 +1433,10 @@ int hm_ADL_Overdrive_ODPerformanceLevels_Get (hashcat_ctx_t *hashcat_ctx, int iA return 0; } +*/ -int hm_ADL_Overdrive_ODPerformanceLevels_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels) +/* +static int hm_ADL_Overdrive_ODPerformanceLevels_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1424,8 +1453,9 @@ int hm_ADL_Overdrive_ODPerformanceLevels_Set (hashcat_ctx_t *hashcat_ctx, int iA return 0; } +*/ -int hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6PowerControlInfo *powertune) +static int hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6PowerControlInfo *powertune) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1443,7 +1473,7 @@ int hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdap return 0; } -int hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iCurrentValue) +static int hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iCurrentValue) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1463,7 +1493,7 @@ int hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } -int hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int level) +static int hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int level) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1505,7 +1535,8 @@ int hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } -int hm_ADL_Adapter_Active_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpStatus) +/* +static int hm_ADL_Adapter_Active_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpStatus) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1522,9 +1553,10 @@ int hm_ADL_Adapter_Active_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, in return 0; } +*/ /* -int hm_ADL_DisplayEnable_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly) +static int hm_ADL_DisplayEnable_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1543,7 +1575,7 @@ int hm_ADL_DisplayEnable_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int } */ -int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version) +static int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1561,7 +1593,7 @@ int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *o return 0; } -int hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpSupported) +static int hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpSupported) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1579,7 +1611,7 @@ int hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapte return 0; } -int hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6Capabilities *caps) +static int hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6Capabilities *caps) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1597,7 +1629,7 @@ int hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } -int hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6MemClockState *state) +static int hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6MemClockState *state) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1662,7 +1694,8 @@ int hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } -int hm_ADL_Overdrive_CurrentStatus_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6CurrentStatus *status) +/* +static int hm_ADL_Overdrive_CurrentStatus_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6CurrentStatus *status) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1679,8 +1712,9 @@ int hm_ADL_Overdrive_CurrentStatus_Get (hashcat_ctx_t *hashcat_ctx, int iAdapter return 0; } +*/ -int hm_ADL_Overdrive_State_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6StateInfo *state) +static int hm_ADL_Overdrive_State_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6StateInfo *state) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1734,7 +1768,7 @@ int hm_ADL_Overdrive_State_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, i return 0; } -int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *cur_temp, int *default_temp) +static int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *cur_temp, int *default_temp) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1752,7 +1786,8 @@ int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_ctx, int return 0; } -int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo) +/* +static int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1769,8 +1804,9 @@ int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (hashcat_ctx_t *hashcat_ctx return 0; } +*/ -int hm_ADL_Overdrive6_FanSpeed_Reset (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex) +static int hm_ADL_Overdrive6_FanSpeed_Reset (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1810,7 +1846,7 @@ static LPAdapterInfo hm_get_adapter_info_adl (hashcat_ctx_t *hashcat_ctx, int iN { size_t AdapterInfoSize = iNumberAdapters * sizeof (AdapterInfo); - LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) mymalloc (AdapterInfoSize); + LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) hcmalloc (hashcat_ctx, AdapterInfoSize); if (hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx, lpAdapterInfo, AdapterInfoSize) == -1) return NULL; @@ -1907,7 +1943,7 @@ static void hm_sort_adl_adapters_by_busid_devid (u32 *valid_adl_device_list, int } } -static u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo) +static u32 *hm_get_list_valid_adl_adapters (hashcat_ctx_t *hashcat_ctx, int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo) { *num_adl_adapters = 0; @@ -1946,14 +1982,14 @@ static u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_ad // add it to the list - adl_adapters = (u32 *) myrealloc (adl_adapters, (*num_adl_adapters) * sizeof (int), sizeof (int)); + adl_adapters = (u32 *) hcrealloc (hashcat_ctx, adl_adapters, (*num_adl_adapters) * sizeof (int), sizeof (int)); adl_adapters[*num_adl_adapters] = i; // rest is just bookkeeping - bus_numbers = (int*) myrealloc (bus_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); - device_numbers = (int*) myrealloc (device_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); + bus_numbers = (int*) hcrealloc (hashcat_ctx, bus_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); + device_numbers = (int*) hcrealloc (hashcat_ctx, device_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); bus_numbers[*num_adl_adapters] = info.iBusNumber; device_numbers[*num_adl_adapters] = info.iDeviceNumber; @@ -1961,8 +1997,8 @@ static u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_ad (*num_adl_adapters)++; } - myfree (bus_numbers); - myfree (device_numbers); + hcfree (bus_numbers); + hcfree (device_numbers); // sort the list by increasing bus id, device id number @@ -2479,6 +2515,7 @@ int hm_get_throttle_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV) { + /* this is triggered by mask generator, too. therefore useless unsigned long long clocksThrottleReasons = 0; unsigned long long supportedThrottleReasons = 0; @@ -2496,6 +2533,27 @@ int hm_get_throttle_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device } return (clocksThrottleReasons != nvmlClocksThrottleReasonNone); + */ + + if (hwmon_ctx->hm_nvapi) + { + NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 perfPolicies_info; + NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status; + + memset (&perfPolicies_info, 0, sizeof (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1)); + memset (&perfPolicies_status, 0, sizeof (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1)); + + perfPolicies_info.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1); + perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1); + + hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_info); + + perfPolicies_status.info_value = perfPolicies_info.info_value; + + hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_status); + + return perfPolicies_status.throttle & 2; + } } return -1; @@ -2610,7 +2668,26 @@ int hm_set_fanspeed_with_device_id_xnvctrl (hashcat_ctx_t *hashcat_ctx, const u3 { if (hwmon_ctx->hm_xnvctrl) { - if (set_fan_speed_target (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, fanspeed) == -1) return -1; + if (hm_XNVCTRL_set_fan_speed_target (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, fanspeed) == -1) return -1; + + return 0; + } + } + + return -1; +} + +int hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx_t *hashcat_ctx, const u32 device_id, const int val) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + if (hwmon_ctx->enabled == false) return -1; + + if (hwmon_ctx->hm_device[device_id].fan_set_supported == true) + { + if (hwmon_ctx->hm_xnvctrl) + { + if (hm_XNVCTRL_set_fan_control (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, val) == -1) return -1; return 0; } @@ -2636,21 +2713,21 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->version == true) return 0; if (user_options->gpu_temp_disable == true) return 0; - hwmon_ctx->hm_device = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); /** * Initialize shared libraries */ - ADL_PTR *adl = (ADL_PTR *) mymalloc (sizeof (ADL_PTR)); - NVAPI_PTR *nvapi = (NVAPI_PTR *) mymalloc (sizeof (NVAPI_PTR)); - NVML_PTR *nvml = (NVML_PTR *) mymalloc (sizeof (NVML_PTR)); - XNVCTRL_PTR *xnvctrl = (XNVCTRL_PTR *) mymalloc (sizeof (XNVCTRL_PTR)); + ADL_PTR *adl = (ADL_PTR *) hcmalloc (hashcat_ctx, sizeof (ADL_PTR)); + NVAPI_PTR *nvapi = (NVAPI_PTR *) hcmalloc (hashcat_ctx, sizeof (NVAPI_PTR)); + NVML_PTR *nvml = (NVML_PTR *) hcmalloc (hashcat_ctx, sizeof (NVML_PTR)); + XNVCTRL_PTR *xnvctrl = (XNVCTRL_PTR *) hcmalloc (hashcat_ctx, sizeof (XNVCTRL_PTR)); - hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_xnvctrl = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_xnvctrl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); if (opencl_ctx->need_nvml == true) { @@ -2658,7 +2735,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (nvml_init (hashcat_ctx) == -1) { - myfree (hwmon_ctx->hm_nvml); + hcfree (hwmon_ctx->hm_nvml); hwmon_ctx->hm_nvml = NULL; } @@ -2670,7 +2747,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (nvapi_init (hashcat_ctx) == -1) { - myfree (hwmon_ctx->hm_nvapi); + hcfree (hwmon_ctx->hm_nvapi); hwmon_ctx->hm_nvapi = NULL; } @@ -2682,7 +2759,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (xnvctrl_init (hashcat_ctx) == -1) { - myfree (hwmon_ctx->hm_xnvctrl); + hcfree (hwmon_ctx->hm_xnvctrl); hwmon_ctx->hm_xnvctrl = NULL; } @@ -2694,7 +2771,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (adl_init (hashcat_ctx) == -1) { - myfree (hwmon_ctx->hm_adl); + hcfree (hwmon_ctx->hm_adl); hwmon_ctx->hm_adl = NULL; } @@ -2704,7 +2781,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { if (hm_NVML_nvmlInit (hashcat_ctx) == 0) { - HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) mycalloc (DEVICES_MAX, sizeof (HM_ADAPTER_NVML)); + HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVML)); int tmp_in = hm_get_adapter_index_nvml (hashcat_ctx, nvmlGPUHandle); @@ -2726,7 +2803,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) //hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx, hm_adapters_nvml[i].nvml, NVML_GOM_ALL_ON); } - myfree (nvmlGPUHandle); + hcfree (nvmlGPUHandle); } } @@ -2734,7 +2811,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { if (hm_NvAPI_Initialize (hashcat_ctx) == 0) { - HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) mycalloc (DEVICES_MAX, sizeof (HM_ADAPTER_NVAPI)); + HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVAPI)); int tmp_in = hm_get_adapter_index_nvapi (hashcat_ctx, nvGPUHandle); @@ -2745,7 +2822,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hm_adapters_nvapi[tmp_out++].nvapi = nvGPUHandle[i]; } - myfree (nvGPUHandle); + hcfree (nvGPUHandle); } } @@ -2763,7 +2840,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) int speed = 0; - if (get_fan_speed_current (hashcat_ctx, device_id, &speed) == 0) hm_adapters_xnvctrl[device_id].fan_get_supported = true; + if (hm_XNVCTRL_get_fan_speed_current (hashcat_ctx, device_id, &speed) == 0) hm_adapters_xnvctrl[device_id].fan_get_supported = true; } } } @@ -2788,7 +2865,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) int num_adl_adapters = 0; - u32 *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo); + u32 *valid_adl_device_list = hm_get_list_valid_adl_adapters (hashcat_ctx, hm_adapters_num, &num_adl_adapters, lpAdapterInfo); if (num_adl_adapters > 0) { @@ -2799,9 +2876,9 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hm_check_fanspeed_control (hashcat_ctx, hm_adapters_adl, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); } - myfree (valid_adl_device_list); + hcfree (valid_adl_device_list); - myfree (lpAdapterInfo); + hcfree (lpAdapterInfo); } } @@ -2820,11 +2897,11 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) * save buffer required for later restores */ - hwmon_ctx->od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (opencl_ctx->devices_cnt, sizeof (ADLOD6MemClockState)); + hwmon_ctx->od_clock_mem_status = (ADLOD6MemClockState *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (ADLOD6MemClockState)); - hwmon_ctx->od_power_control_status = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int)); + hwmon_ctx->od_power_control_status = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); - hwmon_ctx->nvml_power_limit = (unsigned int *) mycalloc (opencl_ctx->devices_cnt, sizeof (unsigned int)); + hwmon_ctx->nvml_power_limit = (unsigned int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (unsigned int)); /** * HM devices: copy @@ -2863,10 +2940,10 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } } - myfree (hm_adapters_adl); - myfree (hm_adapters_nvapi); - myfree (hm_adapters_nvml); - myfree (hm_adapters_xnvctrl); + hcfree (hm_adapters_adl); + hcfree (hm_adapters_nvapi); + hcfree (hm_adapters_nvml); + hcfree (hm_adapters_xnvctrl); /** * powertune on user request @@ -2975,7 +3052,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) event_log_error (hashcat_ctx, "The custom profile seems to have too low maximum memory clock values. You therefore may not reach full performance"); } - ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); + ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) hccalloc (hashcat_ctx, 1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); performance_state->iNumberOfPerformanceLevels = 2; @@ -2991,7 +3068,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - myfree (performance_state); + hcfree (performance_state); } // set powertune value only @@ -3086,13 +3163,15 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } else if (device_param->device_vendor_id == VENDOR_ID_NV) { - #if defined (__linux__) - rc = set_fan_control (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE); - #endif + if (hwmon_ctx->hm_xnvctrl) + { + rc = hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx, device_id, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE); + } - #if defined (_WIN) - rc = hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, fanspeed, 1); - #endif + if (hwmon_ctx->hm_nvapi) + { + rc = hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, fanspeed, 1); + } } if (rc == 0) @@ -3101,7 +3180,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - event_log_error (hashcat_ctx, "Failed to set initial fan speed for device #%u", device_id + 1); + //event_log_error (hashcat_ctx, "Failed to set initial fan speed for device #%u", device_id + 1); hwmon_ctx->hm_device[device_id].fan_set_supported = false; } @@ -3145,13 +3224,15 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) } else if (device_param->device_vendor_id == VENDOR_ID_NV) { - #if defined (__linux__) - rc = set_fan_control (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE); - #endif + if (hwmon_ctx->hm_xnvctrl) + { + rc = hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx, device_id, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE); + } - #if defined (_WIN) - rc = hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, 100, 0); - #endif + if (hwmon_ctx->hm_nvapi) + { + rc = hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, 100, 0); + } } if (rc == -1) event_log_error (hashcat_ctx, "Failed to restore default fan speed and policy for device #%", device_id + 1); @@ -3195,7 +3276,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) // clocks - ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); + ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) hccalloc (hashcat_ctx, 1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); performance_state->iNumberOfPerformanceLevels = 2; @@ -3211,7 +3292,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) continue; } - myfree (performance_state); + hcfree (performance_state); } } } @@ -3259,11 +3340,11 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) // free memory - myfree (hwmon_ctx->nvml_power_limit); - myfree (hwmon_ctx->od_power_control_status); - myfree (hwmon_ctx->od_clock_mem_status); + hcfree (hwmon_ctx->nvml_power_limit); + hcfree (hwmon_ctx->od_power_control_status); + hcfree (hwmon_ctx->od_clock_mem_status); - myfree (hwmon_ctx->hm_device); + hcfree (hwmon_ctx->hm_device); memset (hwmon_ctx, 0, sizeof (hwmon_ctx_t)); } diff --git a/src/induct.c b/src/induct.c index 9a198c585..5d98a43f5 100644 --- a/src/induct.c +++ b/src/induct.c @@ -46,7 +46,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->induction_dir == NULL) { - char *root_directory = (char *) mymalloc (HCBUFSIZ_TINY); + char *root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, INDUCT_DIR); @@ -58,7 +58,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) } else if (errno == ENOTEMPTY) { - char *root_directory_mv = (char *) mymalloc (HCBUFSIZ_TINY); + char *root_directory_mv = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (root_directory_mv, HCBUFSIZ_TINY - 1, "%s/%s.induct.%d", folder_config->session_dir, user_options->session, (int) status_ctx->proc_start); @@ -88,7 +88,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - induct_ctx->root_directory = mystrdup (user_options->induction_dir); + induct_ctx->root_directory = hcstrdup (hashcat_ctx, user_options->induction_dir); } return 0; @@ -100,7 +100,7 @@ void induct_ctx_scan (hashcat_ctx_t *hashcat_ctx) if (induct_ctx->enabled == false) return; - induct_ctx->induction_dictionaries = scan_directory (induct_ctx->root_directory); + induct_ctx->induction_dictionaries = scan_directory (hashcat_ctx, induct_ctx->root_directory); induct_ctx->induction_dictionaries_cnt = count_dictionaries (induct_ctx->induction_dictionaries); @@ -148,7 +148,7 @@ void induct_ctx_destroy (hashcat_ctx_t *hashcat_ctx) } } - myfree (induct_ctx->root_directory); + hcfree (induct_ctx->root_directory); memset (induct_ctx, 0, sizeof (induct_ctx_t)); } diff --git a/src/interface.c b/src/interface.c index 0c5924e0b..6cd957295 100644 --- a/src/interface.c +++ b/src/interface.c @@ -5575,7 +5575,7 @@ int agilekey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE * handle cipher encoding */ - u32 *tmp = (u32 *) mymalloc (32); + u32 tmp[32]; char *cipherbuf_ptr = (char *) tmp; @@ -5601,8 +5601,6 @@ int agilekey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE salt->salt_buf[10] = byte_swap_32 (tmp[6]); salt->salt_buf[11] = byte_swap_32 (tmp[7]); - myfree (tmp); - for (u32 i = 0, j = 0; i < 1040; i += 1, j += 2) { const char p0 = cipherbuf_pos[j + 0]; @@ -10416,318 +10414,182 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE sip_t *sip = (sip_t *) hash_buf->esalt; // work with a temporary copy of input_buf (s.t. we can manipulate it directly) - - char *temp_input_buf = (char *) mymalloc (input_len + 1); - - memcpy (temp_input_buf, input_buf, input_len); + // why? should be fine to use original buffer + //char *temp_input_buf = (char *) hcmalloc (hashcat_ctx, input_len + 1); + //memcpy (temp_input_buf, input_buf, input_len); // URI_server: - char *URI_server_pos = temp_input_buf + 6; + char *URI_server_pos = input_buf + 6; char *URI_client_pos = strchr (URI_server_pos, '*'); - if (URI_client_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (URI_client_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); URI_client_pos[0] = 0; URI_client_pos++; u32 URI_server_len = strlen (URI_server_pos); - if (URI_server_len > 512) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (URI_server_len > 512) return (PARSER_SALT_LENGTH); // URI_client: char *user_pos = strchr (URI_client_pos, '*'); - if (user_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (user_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); user_pos[0] = 0; user_pos++; u32 URI_client_len = strlen (URI_client_pos); - if (URI_client_len > 512) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (URI_client_len > 512) return (PARSER_SALT_LENGTH); // user: char *realm_pos = strchr (user_pos, '*'); - if (realm_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (realm_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); realm_pos[0] = 0; realm_pos++; u32 user_len = strlen (user_pos); - if (user_len > 116) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (user_len > 116) return (PARSER_SALT_LENGTH); // realm: char *method_pos = strchr (realm_pos, '*'); - if (method_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (method_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); method_pos[0] = 0; method_pos++; u32 realm_len = strlen (realm_pos); - if (realm_len > 116) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (realm_len > 116) return (PARSER_SALT_LENGTH); // method: char *URI_prefix_pos = strchr (method_pos, '*'); - if (URI_prefix_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (URI_prefix_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); URI_prefix_pos[0] = 0; URI_prefix_pos++; u32 method_len = strlen (method_pos); - if (method_len > 246) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (method_len > 246) return (PARSER_SALT_LENGTH); // URI_prefix: char *URI_resource_pos = strchr (URI_prefix_pos, '*'); - if (URI_resource_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (URI_resource_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); URI_resource_pos[0] = 0; URI_resource_pos++; u32 URI_prefix_len = strlen (URI_prefix_pos); - if (URI_prefix_len > 245) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (URI_prefix_len > 245) return (PARSER_SALT_LENGTH); // URI_resource: char *URI_suffix_pos = strchr (URI_resource_pos, '*'); - if (URI_suffix_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (URI_suffix_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); URI_suffix_pos[0] = 0; URI_suffix_pos++; u32 URI_resource_len = strlen (URI_resource_pos); - if (URI_resource_len < 1 || URI_resource_len > 246) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (URI_resource_len < 1 || URI_resource_len > 246) return (PARSER_SALT_LENGTH); // URI_suffix: char *nonce_pos = strchr (URI_suffix_pos, '*'); - if (nonce_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (nonce_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); nonce_pos[0] = 0; nonce_pos++; u32 URI_suffix_len = strlen (URI_suffix_pos); - if (URI_suffix_len > 245) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (URI_suffix_len > 245) return (PARSER_SALT_LENGTH); // nonce: char *nonce_client_pos = strchr (nonce_pos, '*'); - if (nonce_client_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (nonce_client_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); nonce_client_pos[0] = 0; nonce_client_pos++; u32 nonce_len = strlen (nonce_pos); - if (nonce_len < 1 || nonce_len > 50) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (nonce_len < 1 || nonce_len > 50) return (PARSER_SALT_LENGTH); // nonce_client: char *nonce_count_pos = strchr (nonce_client_pos, '*'); - if (nonce_count_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (nonce_count_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); nonce_count_pos[0] = 0; nonce_count_pos++; u32 nonce_client_len = strlen (nonce_client_pos); - if (nonce_client_len > 50) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (nonce_client_len > 50) return (PARSER_SALT_LENGTH); // nonce_count: char *qop_pos = strchr (nonce_count_pos, '*'); - if (qop_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (qop_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); qop_pos[0] = 0; qop_pos++; u32 nonce_count_len = strlen (nonce_count_pos); - if (nonce_count_len > 50) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (nonce_count_len > 50) return (PARSER_SALT_LENGTH); // qop: char *directive_pos = strchr (qop_pos, '*'); - if (directive_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (directive_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); directive_pos[0] = 0; directive_pos++; u32 qop_len = strlen (qop_pos); - if (qop_len > 50) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (qop_len > 50) return (PARSER_SALT_LENGTH); // directive char *digest_pos = strchr (directive_pos, '*'); - if (digest_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (digest_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); digest_pos[0] = 0; digest_pos++; u32 directive_len = strlen (directive_pos); - if (directive_len != 3) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } - - if (memcmp (directive_pos, "MD5", 3)) - { - myfree (temp_input_buf); + if (directive_len != 3) return (PARSER_SALT_LENGTH); - return (PARSER_SIP_AUTH_DIRECTIVE); - } + if (memcmp (directive_pos, "MD5", 3)) return (PARSER_SIP_AUTH_DIRECTIVE); /* * first (pre-)compute: HA2 = md5 ($method . ":" . $uri) @@ -10799,12 +10661,7 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE { esalt_len = 1 + nonce_len + 1 + nonce_count_len + 1 + nonce_client_len + 1 + qop_len + 1 + 32; - if (esalt_len > max_esalt_len) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (esalt_len > max_esalt_len) return (PARSER_SALT_LENGTH); snprintf (esalt_buf_ptr, max_esalt_len, ":%s:%s:%s:%s:%08x%08x%08x%08x", nonce_pos, @@ -10820,12 +10677,7 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE { esalt_len = 1 + nonce_len + 1 + 32; - if (esalt_len > max_esalt_len) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (esalt_len > max_esalt_len) return (PARSER_SALT_LENGTH); snprintf (esalt_buf_ptr, max_esalt_len, ":%s:%08x%08x%08x%08x", nonce_pos, @@ -10851,12 +10703,7 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE u32 max_salt_len = 119; - if (salt_len > max_salt_len) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (salt_len > max_salt_len) return (PARSER_SALT_LENGTH); snprintf (sip_salt_ptr, max_salt_len + 1, "%s:%s:", user_pos, realm_pos); @@ -10895,8 +10742,6 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE digest[2] = byte_swap_32 (digest[2]); digest[3] = byte_swap_32 (digest[3]); - myfree (temp_input_buf); - return (PARSER_OK); } @@ -13023,8 +12868,11 @@ char *strparser (const u32 parser_status) return ((char *) PA_255); } -void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes) +void to_hccap_t (hashcat_ctx_t *hashcat_ctx, hccap_t *hccap, const u32 salt_pos, const u32 digest_pos) { + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const hashes_t *hashes = hashcat_ctx->hashes; + const void *digests_buf = hashes->digests_buf; const salt_t *salts_buf = hashes->salts_buf; const void *esalts_buf = hashes->esalts_buf; @@ -13086,8 +12934,11 @@ void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, MAYBE } } -void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes) +void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos) { + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const hashes_t *hashes = hashcat_ctx->hashes; + void *digests_buf = hashes->digests_buf; salt_t *salts_buf = hashes->salts_buf; void *esalts_buf = hashes->esalts_buf; @@ -15188,9 +15039,9 @@ void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYB const u32 ckey_len = bitcoin_wallet->ckey_len; const u32 public_key_len = bitcoin_wallet->public_key_len; - char *cry_master_buf = (char *) mymalloc ((cry_master_len * 2) + 1); - char *ckey_buf = (char *) mymalloc ((ckey_len * 2) + 1); - char *public_key_buf = (char *) mymalloc ((public_key_len * 2) + 1); + char *cry_master_buf = (char *) hcmalloc (hashcat_ctx, (cry_master_len * 2) + 1); + char *ckey_buf = (char *) hcmalloc (hashcat_ctx, (ckey_len * 2) + 1); + char *public_key_buf = (char *) hcmalloc (hashcat_ctx, (public_key_len * 2) + 1); for (u32 i = 0, j = 0; i < cry_master_len; i += 1, j += 2) { @@ -15226,9 +15077,9 @@ void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYB public_key_buf ); - myfree (cry_master_buf); - myfree (ckey_buf); - myfree (public_key_buf); + hcfree (cry_master_buf); + hcfree (ckey_buf); + hcfree (public_key_buf); } else if (hash_mode == 11400) { @@ -15247,7 +15098,7 @@ void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYB const u32 data_len = seven_zip->data_len; - char *data_buf = (char *) mymalloc ((data_len * 2) + 1); + char *data_buf = (char *) hcmalloc (hashcat_ctx, (data_len * 2) + 1); for (u32 i = 0, j = 0; i < data_len; i += 1, j += 2) { @@ -15272,7 +15123,7 @@ void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYB seven_zip->unpack_size, data_buf); - myfree (data_buf); + hcfree (data_buf); } else if (hash_mode == 11700) { @@ -20163,7 +20014,7 @@ int hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx) u32 *keyfile_buf = ((tc_t *) esalts_buf)->keyfile_buf; - char *keyfiles = mystrdup (tcvc_keyfiles); + char *keyfiles = hcstrdup (hashcat_ctx, tcvc_keyfiles); char *keyfile = strtok (keyfiles, ","); diff --git a/src/logfile.c b/src/logfile.c index 7f956c28a..0fc3804d9 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -77,12 +77,12 @@ int logfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->logfile_disable == true) return 0; - logfile_ctx->logfile = (char *) mymalloc (HCBUFSIZ_TINY); + logfile_ctx->logfile = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (logfile_ctx->logfile, HCBUFSIZ_TINY - 1, "%s/%s.log", folder_config->session_dir, user_options->session); - logfile_ctx->subid = (char *) mymalloc (HCBUFSIZ_TINY); - logfile_ctx->topid = (char *) mymalloc (HCBUFSIZ_TINY); + logfile_ctx->subid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + logfile_ctx->topid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); logfile_ctx->enabled = true; @@ -106,9 +106,9 @@ void logfile_destroy (hashcat_ctx_t *hashcat_ctx) if (logfile_ctx->enabled == false) return; - myfree (logfile_ctx->logfile); - myfree (logfile_ctx->topid); - myfree (logfile_ctx->subid); + hcfree (logfile_ctx->logfile); + hcfree (logfile_ctx->topid); + hcfree (logfile_ctx->subid); memset (logfile_ctx, 0, sizeof (logfile_ctx_t)); } diff --git a/src/loopback.c b/src/loopback.c index 63f60de9c..afbc66941 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -70,7 +70,7 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) loopback_ctx->enabled = true; loopback_ctx->fp = NULL; - loopback_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY); + loopback_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); return 0; } diff --git a/src/main.c b/src/main.c index 6b19a9956..c749e3f7f 100644 --- a/src/main.c +++ b/src/main.c @@ -174,7 +174,7 @@ static int main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY hashcat_user->outer_threads_cnt = 0; - hashcat_user->outer_threads = (hc_thread_t *) mycalloc (2, sizeof (hc_thread_t)); + hashcat_user->outer_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 2, sizeof (hc_thread_t)); status_ctx->shutdown_outer = false; @@ -207,7 +207,7 @@ static int main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY hc_thread_wait (1, &hashcat_user->outer_threads[thread_idx]); } - myfree (hashcat_user->outer_threads); + hcfree (hashcat_user->outer_threads); hashcat_user->outer_threads_cnt = 0; diff --git a/src/memory.c b/src/memory.c index 12ed019fb..e02093692 100644 --- a/src/memory.c +++ b/src/memory.c @@ -4,15 +4,17 @@ */ #include "common.h" +#include "types.h" +#include "event.h" #include "memory.h" -void *mycalloc (size_t nmemb, size_t size) +void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz) { - void *p = calloc (nmemb, size); + void *p = calloc (nmemb, sz); if (p == NULL) { - fprintf (stderr, "ERROR: %s", MSG_ENOMEM); + event_log_error (hashcat_ctx, "ERROR: %s", MSG_ENOMEM); exit (-1); } @@ -20,52 +22,54 @@ void *mycalloc (size_t nmemb, size_t size) return (p); } -void *mymalloc (size_t size) +void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz) { - void *p = malloc (size); + void *p = malloc (sz); if (p == NULL) { - fprintf (stderr, "ERROR: %s", MSG_ENOMEM); + event_log_error (hashcat_ctx, "ERROR: %s", MSG_ENOMEM); exit (-1); } - memset (p, 0, size); + memset (p, 0, sz); return (p); } -void myfree (void *ptr) +void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, const size_t addsz) { - if (ptr == NULL) return; - - free (ptr); -} - -void *myrealloc (void *ptr, size_t oldsz, size_t add) -{ - void *p = realloc (ptr, oldsz + add); + void *p = realloc (ptr, oldsz + addsz); if (p == NULL) { - fprintf (stderr, "ERROR: %s", MSG_ENOMEM); + event_log_error (hashcat_ctx, "ERROR: %s", MSG_ENOMEM); exit (-1); } - memset ((char *) p + oldsz, 0, add); + memset ((char *) p + oldsz, 0, addsz); return (p); } -char *mystrdup (const char *s) +char *hcstrdup (hashcat_ctx_t *hashcat_ctx, const char *s) { const size_t len = strlen (s); - char *b = (char *) mymalloc (len + 1); + char *b = (char *) hcmalloc (hashcat_ctx, len + 1); + + strncpy (b, s, len); - memcpy (b, s, len); + b[len] = 0; return (b); } + +void hcfree (void *ptr) +{ + if (ptr == NULL) return; + + free (ptr); +} diff --git a/src/monitor.c b/src/monitor.c index d9da8752b..edfd24642 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -69,12 +69,12 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) // these variables are mainly used for fan control - int *fan_speed_chgd = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int)); + int *fan_speed_chgd = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); // temperature controller "loopback" values - int *temp_diff_old = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int)); - int *temp_diff_sum = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int)); + int *temp_diff_old = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); + int *temp_diff_sum = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); time_t last_temp_check_time; @@ -102,49 +102,32 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - if (device_param->device_vendor_id == VENDOR_ID_NV) - { - if (hwmon_ctx->hm_nvapi) - { - NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 perfPolicies_info; - NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status; - - memset (&perfPolicies_info, 0, sizeof (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1)); - memset (&perfPolicies_status, 0, sizeof (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1)); + const int rc_throttle = hm_get_throttle_with_device_id (hashcat_ctx, device_id); - perfPolicies_info.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1); - perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1); + if (rc_throttle == -1) continue; - hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_info); - - perfPolicies_status.info_value = perfPolicies_info.info_value; + if (rc_throttle > 0) + { + if (slowdown_warnings < 3) + { + if (user_options->quiet == false) clear_prompt (); - hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_status); + event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", device_id + 1); - if (perfPolicies_status.throttle & 2) + if (slowdown_warnings == 2) { - if (slowdown_warnings < 3) - { - if (user_options->quiet == false) clear_prompt (); - - event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", device_id + 1); - - if (slowdown_warnings == 2) - { - event_log_info (hashcat_ctx, ""); - } + event_log_info (hashcat_ctx, ""); + } - if (user_options->quiet == false) send_prompt (); + if (user_options->quiet == false) send_prompt (); - slowdown_warnings++; - } - } - else - { - slowdown_warnings = 0; - } + slowdown_warnings++; } } + else + { + slowdown_warnings = 0; + } } hc_thread_mutex_unlock (status_ctx->mux_hwmon); @@ -358,10 +341,10 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (rc == -1) return -1; } - myfree (fan_speed_chgd); + hcfree (fan_speed_chgd); - myfree (temp_diff_old); - myfree (temp_diff_sum); + hcfree (temp_diff_old); + hcfree (temp_diff_sum); return 0; } diff --git a/src/mpsp.c b/src/mpsp.c index b28d8f43f..8ac698b9b 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -22,8 +22,35 @@ static const char DEF_MASK[] = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d"; #define MAX_MFS 5 // 4*charset, 1*mask -void mp_css_split_cnt (const mask_ctx_t *mask_ctx, const hashconfig_t *hashconfig, const u32 css_cnt_orig, u32 css_cnt_lr[2]) +static int sp_comp_val (const void *p1, const void *p2) { + hcstat_table_t *b1 = (hcstat_table_t *) p1; + hcstat_table_t *b2 = (hcstat_table_t *) p2; + + return b2->val - b1->val; +} + +static u32 mp_get_length (char *mask) +{ + u32 len = 0; + + u32 mask_len = strlen (mask); + + for (u32 i = 0; i < mask_len; i++) + { + if (mask[i] == '?') i++; + + len++; + } + + return len; +} + +static void mp_css_split_cnt (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_orig, u32 css_cnt_lr[2]) +{ + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + u32 css_cnt_l = mask_ctx->css_cnt; u32 css_cnt_r; @@ -87,14 +114,16 @@ void mp_css_split_cnt (const mask_ctx_t *mask_ctx, const hashconfig_t *hashconfi css_cnt_lr[1] = css_cnt_r; } -void mp_css_append_salt (mask_ctx_t *mask_ctx, salt_t *salt_buf) +static void mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf) { + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + u32 salt_len = (u32) salt_buf->salt_len; u8 *salt_buf_ptr = (u8 *) salt_buf->salt_buf; u32 css_cnt_salt = mask_ctx->css_cnt + salt_len; - cs_t *css_buf_salt = (cs_t *) mycalloc (css_cnt_salt, sizeof (cs_t)); + cs_t *css_buf_salt = (cs_t *) hccalloc (hashcat_ctx, css_cnt_salt, sizeof (cs_t)); memcpy (css_buf_salt, mask_ctx->css_buf, mask_ctx->css_cnt * sizeof (cs_t)); @@ -104,17 +133,19 @@ void mp_css_append_salt (mask_ctx_t *mask_ctx, salt_t *salt_buf) css_buf_salt[j].cs_len = 1; } - myfree (mask_ctx->css_buf); + hcfree (mask_ctx->css_buf); mask_ctx->css_buf = css_buf_salt; mask_ctx->css_cnt = css_cnt_salt; } -void mp_css_unicode_expand (mask_ctx_t *mask_ctx) +static void mp_css_unicode_expand (hashcat_ctx_t *hashcat_ctx) { + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + u32 css_cnt_unicode = mask_ctx->css_cnt * 2; - cs_t *css_buf_unicode = (cs_t *) mycalloc (css_cnt_unicode, sizeof (cs_t)); + cs_t *css_buf_unicode = (cs_t *) hccalloc (hashcat_ctx, css_cnt_unicode, sizeof (cs_t)); for (u32 i = 0, j = 0; i < mask_ctx->css_cnt; i += 1, j += 2) { @@ -124,13 +155,13 @@ void mp_css_unicode_expand (mask_ctx_t *mask_ctx) css_buf_unicode[j + 1].cs_len = 1; } - myfree (mask_ctx->css_buf); + hcfree (mask_ctx->css_buf); mask_ctx->css_buf = css_buf_unicode; mask_ctx->css_cnt = css_cnt_unicode; } -int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) +static int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) { /* generates a lookup table where key is the char itself for fastest possible lookup performance */ @@ -167,7 +198,7 @@ static void mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_le size_t css_uniq_sz = CHARSIZ * sizeof (u32); - u32 *css_uniq = (u32 *) mymalloc (css_uniq_sz); + u32 *css_uniq = (u32 *) hcmalloc (hashcat_ctx, css_uniq_sz); size_t i; @@ -193,7 +224,7 @@ static void mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_le cs->cs_len++; } - myfree (css_uniq); + hcfree (css_uniq); } static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, u32 mp_usr_offset, int interpret) @@ -291,7 +322,7 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask { const user_options_t *user_options = hashcat_ctx->user_options; - cs_t *css = (cs_t *) mycalloc (256, sizeof (cs_t)); + cs_t *css = (cs_t *) hccalloc (hashcat_ctx, 256, sizeof (cs_t)); u32 mask_pos; u32 css_pos; @@ -400,7 +431,7 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask { const user_options_t *user_options = hashcat_ctx->user_options; - char *new_mask_buf = (char *) mymalloc (256); + char *new_mask_buf = (char *) hcmalloc (hashcat_ctx, 256); u32 mask_pos; @@ -453,66 +484,12 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask if (css_pos == len) return (new_mask_buf); - myfree (new_mask_buf); + hcfree (new_mask_buf); return (NULL); } -u64 mp_get_sum (u32 css_cnt, cs_t *css) -{ - u64 sum = 1; - - for (u32 css_pos = 0; css_pos < css_cnt; css_pos++) - { - sum *= css[css_pos].cs_len; - } - - return (sum); -} - -void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt) -{ - for (int i = 0; i < css_cnt; i++) - { - u32 len = css[i].cs_len; - u64 next = val / len; - u32 pos = val % len; - buf[i] = (char) (css[i].cs_buf[pos] & 0xff); - val = next; - } -} - -u32 mp_get_length (char *mask) -{ - u32 len = 0; - - u32 mask_len = strlen (mask); - - for (u32 i = 0; i < mask_len; i++) - { - if (mask[i] == '?') i++; - - len++; - } - - return len; -} - -void mp_cut_at (char *mask, u32 max) -{ - u32 i; - u32 j; - u32 mask_len = strlen (mask); - - for (i = 0, j = 0; i < mask_len && j < max; i++, j++) - { - if (mask[i] == '?') i++; - } - - mask[i] = 0; -} - -void mp_setup_sys (cs_t *mp_sys) +static void mp_setup_sys (cs_t *mp_sys) { u32 pos; u32 chr; @@ -541,7 +518,7 @@ void mp_setup_sys (cs_t *mp_sys) mp_sys[5].cs_len = pos; } } -int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index) +static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index) { FILE *fp = fopen (buf, "rb"); @@ -580,7 +557,7 @@ int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, char * return 0; } -void mp_reset_usr (cs_t *mp_usr, u32 index) +static void mp_reset_usr (cs_t *mp_usr, u32 index) { mp_usr[index].cs_len = 0; @@ -610,7 +587,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) * Initialize hcstats */ - u64 *root_stats_buf = (u64 *) mycalloc (SP_ROOT_CNT, sizeof (u64)); + u64 *root_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_ROOT_CNT, sizeof (u64)); u64 *root_stats_ptr = root_stats_buf; @@ -623,7 +600,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) root_stats_ptr += CHARSIZ; } - u64 *markov_stats_buf = (u64 *) mycalloc (SP_MARKOV_CNT, sizeof (u64)); + u64 *markov_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (u64)); u64 *markov_stats_ptr = markov_stats_buf; @@ -782,8 +759,8 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) markov_table_buf[i].val = markov_stats_buf[i]; } - myfree (root_stats_buf); - myfree (markov_stats_buf); + hcfree (root_stats_buf); + hcfree (markov_stats_buf); /** * Finally sort them @@ -805,7 +782,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) return 0; } -u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf) +static u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf) { u64 sum = 1; @@ -819,38 +796,7 @@ u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf) return (sum); } -void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop) -{ - u64 v = ctx; - - cs_t *cs = &root_css_buf[start]; - - u32 i; - - for (i = start; i < stop; i++) - { - const u64 m = v % cs->cs_len; - const u64 d = v / cs->cs_len; - - v = d; - - const u32 k = cs->cs_buf[m]; - - pw_buf[i - start] = (char) k; - - cs = &markov_css_buf[(i * CHARSIZ) + k]; - } -} - -int sp_comp_val (const void *p1, const void *p2) -{ - hcstat_table_t *b1 = (hcstat_table_t *) p1; - hcstat_table_t *b2 = (hcstat_table_t *) p2; - - return b2->val - b1->val; -} - -void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 threshold, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) +static void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 threshold, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) { memset (root_css_buf, 0, SP_PW_MAX * sizeof (cs_t)); memset (markov_css_buf, 0, SP_PW_MAX * CHARSIZ * sizeof (cs_t)); @@ -917,74 +863,47 @@ void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table */ } -void sp_stretch_root (hcstat_table_t *in, hcstat_table_t *out) +void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop) { - for (u32 i = 0; i < SP_PW_MAX; i += 2) - { - memcpy (out, in, CHARSIZ * sizeof (hcstat_table_t)); - - out += CHARSIZ; - in += CHARSIZ; - - out->key = 0; - out->val = 1; - - out++; + u64 v = ctx; - for (u32 j = 1; j < CHARSIZ; j++) - { - out->key = j; - out->val = 0; + cs_t *cs = &root_css_buf[start]; - out++; - } - } -} + u32 i; -void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out) -{ - for (u32 i = 0; i < SP_PW_MAX; i += 2) + for (i = start; i < stop; i++) { - memcpy (out, in, CHARSIZ * CHARSIZ * sizeof (hcstat_table_t)); - - out += CHARSIZ * CHARSIZ; - in += CHARSIZ * CHARSIZ; + const u64 m = v % cs->cs_len; + const u64 d = v / cs->cs_len; - for (u32 j = 0; j < CHARSIZ; j++) - { - out->key = 0; - out->val = 1; + v = d; - out++; + const u32 k = cs->cs_buf[m]; - for (u32 k = 1; k < CHARSIZ; k++) - { - out->key = k; - out->val = 0; + pw_buf[i - start] = (char) k; - out++; - } - } + cs = &markov_css_buf[(i * CHARSIZ) + k]; } } -static void mask_append_final (mask_ctx_t *mask_ctx, const char *mask) +static void mask_append_final (hashcat_ctx_t *hashcat_ctx, const char *mask) { + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + if (mask_ctx->masks_avail == mask_ctx->masks_cnt) { - mask_ctx->masks = (char **) myrealloc (mask_ctx->masks, mask_ctx->masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *)); + mask_ctx->masks = (char **) hcrealloc (hashcat_ctx, mask_ctx->masks, mask_ctx->masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *)); mask_ctx->masks_avail += INCR_MASKS; } - mask_ctx->masks[mask_ctx->masks_cnt] = mystrdup (mask); + mask_ctx->masks[mask_ctx->masks_cnt] = hcstrdup (hashcat_ctx, mask); mask_ctx->masks_cnt++; } static void mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) { - mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; user_options_t *user_options = hashcat_ctx->user_options; if (user_options->increment == true) @@ -995,12 +914,12 @@ static void mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) if (mask_truncated == NULL) break; - mask_append_final (mask_ctx, mask_truncated); + mask_append_final (hashcat_ctx, mask_truncated); } } else { - mask_append_final (mask_ctx, mask); + mask_append_final (hashcat_ctx, mask); } } @@ -1110,7 +1029,7 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_PT_UNICODE) { - mp_css_unicode_expand (mask_ctx); + mp_css_unicode_expand (hashcat_ctx); } u32 css_cnt_orig = mask_ctx->css_cnt; @@ -1119,7 +1038,7 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) { if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT) { - mp_css_append_salt (mask_ctx, &hashes->salts_buf[0]); + mp_css_append_salt (hashcat_ctx, &hashes->salts_buf[0]); } } @@ -1135,7 +1054,7 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) u32 css_cnt_lr[2]; - mp_css_split_cnt (mask_ctx, hashconfig, css_cnt_orig, css_cnt_lr); + mp_css_split_cnt (hashcat_ctx, css_cnt_orig, css_cnt_lr); mask_ctx->bfs_cnt = sp_get_sum (0, css_cnt_lr[1], mask_ctx->root_css_buf); @@ -1167,13 +1086,13 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->enabled = true; - mask_ctx->root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t)); - mask_ctx->markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t)); + mask_ctx->root_table_buf = (hcstat_table_t *) hccalloc (hashcat_ctx, SP_ROOT_CNT, sizeof (hcstat_table_t)); + mask_ctx->markov_table_buf = (hcstat_table_t *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (hcstat_table_t)); sp_setup_tbl (hashcat_ctx); - mask_ctx->root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t)); - mask_ctx->markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t)); + mask_ctx->root_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX, sizeof (cs_t)); + mask_ctx->markov_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX * CHARSIZ, sizeof (cs_t)); mask_ctx->css_cnt = 0; mask_ctx->css_buf = NULL; @@ -1184,7 +1103,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->masks_pos = 0; mask_ctx->masks_cnt = 0; - mask_ctx->mfs = (mf_t *) mycalloc (MAX_MFS, sizeof (mf_t)); + mask_ctx->mfs = (mf_t *) hccalloc (hashcat_ctx, MAX_MFS, sizeof (mf_t)); mp_setup_sys (mask_ctx->mp_sys); @@ -1233,7 +1152,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (mask_fp)) { @@ -1246,7 +1165,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_append (hashcat_ctx, line_buf); } - myfree (line_buf); + hcfree (line_buf); fclose (mask_fp); } @@ -1302,7 +1221,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (mask_fp)) { @@ -1315,7 +1234,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_append (hashcat_ctx, line_buf); } - myfree (line_buf); + hcfree (line_buf); fclose (mask_fp); } @@ -1356,7 +1275,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (mask_fp)) { @@ -1369,7 +1288,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_append (hashcat_ctx, line_buf); } - myfree (line_buf); + hcfree (line_buf); fclose (mask_fp); } @@ -1400,22 +1319,22 @@ void mask_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (mask_ctx->enabled == false) return; - myfree (mask_ctx->css_buf); + hcfree (mask_ctx->css_buf); - myfree (mask_ctx->root_css_buf); - myfree (mask_ctx->markov_css_buf); + hcfree (mask_ctx->root_css_buf); + hcfree (mask_ctx->markov_css_buf); - myfree (mask_ctx->root_table_buf); - myfree (mask_ctx->markov_table_buf); + hcfree (mask_ctx->root_table_buf); + hcfree (mask_ctx->markov_table_buf); for (u32 mask_pos = 0; mask_pos < mask_ctx->masks_cnt; mask_pos++) { - myfree (mask_ctx->masks[mask_pos]); + hcfree (mask_ctx->masks[mask_pos]); } - myfree (mask_ctx->masks); + hcfree (mask_ctx->masks); - myfree (mask_ctx->mfs); + hcfree (mask_ctx->mfs); memset (mask_ctx, 0, sizeof (mask_ctx_t)); } diff --git a/src/opencl.c b/src/opencl.c index 85013a8ec..a8abf5efb 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -104,7 +104,7 @@ static int setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char if (opencl_platforms) { - char *platforms = mystrdup (opencl_platforms); + char *platforms = hcstrdup (hashcat_ctx, opencl_platforms); char *next = strtok (platforms, ","); @@ -123,7 +123,7 @@ static int setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char } while ((next = strtok (NULL, ",")) != NULL); - myfree (platforms); + hcfree (platforms); } else { @@ -141,7 +141,7 @@ static int setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_ if (opencl_devices) { - char *devices = mystrdup (opencl_devices); + char *devices = hcstrdup (hashcat_ctx, opencl_devices); char *next = strtok (devices, ","); @@ -160,7 +160,7 @@ static int setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_ } while ((next = strtok (NULL, ",")) != NULL); - myfree (devices); + hcfree (devices); } else { @@ -178,7 +178,7 @@ static int setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, const char *op if (opencl_device_types) { - char *device_types = mystrdup (opencl_device_types); + char *device_types = hcstrdup (hashcat_ctx, opencl_device_types); char *next = strtok (device_types, ","); @@ -197,7 +197,7 @@ static int setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, const char *op } while ((next = strtok (NULL, ",")) != NULL); - myfree (device_types); + hcfree (device_types); } else { @@ -224,7 +224,7 @@ static int read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_fi stat (kernel_file, &st); - char *buf = (char *) mymalloc (st.st_size + 1); + char *buf = (char *) hcmalloc (hashcat_ctx, st.st_size + 1); size_t num_read = fread (buf, sizeof (char), st.st_size, fp); @@ -1888,7 +1888,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage == true) return 0; if (user_options->version == true) return 0; - hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (DEVICES_MAX, sizeof (hc_device_param_t)); + hc_device_param_t *devices_param = (hc_device_param_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hc_device_param_t)); opencl_ctx->devices_param = devices_param; @@ -1896,7 +1896,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) * Load and map OpenCL library calls */ - OCL_PTR *ocl = (OCL_PTR *) mymalloc (sizeof (OCL_PTR)); + OCL_PTR *ocl = (OCL_PTR *) hcmalloc (hashcat_ctx, sizeof (OCL_PTR)); opencl_ctx->ocl = ocl; @@ -1943,9 +1943,9 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) */ cl_uint platforms_cnt = 0; - cl_platform_id *platforms = (cl_platform_id *) mycalloc (CL_PLATFORMS_MAX, sizeof (cl_platform_id)); + cl_platform_id *platforms = (cl_platform_id *) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (cl_platform_id)); cl_uint platform_devices_cnt = 0; - cl_device_id *platform_devices = (cl_device_id *) mycalloc (DEVICES_MAX, sizeof (cl_device_id)); + cl_device_id *platform_devices = (cl_device_id *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (cl_device_id)); cl_int CL_err = hc_clGetPlatformIDs (hashcat_ctx, CL_PLATFORMS_MAX, platforms, &platforms_cnt); @@ -2048,11 +2048,11 @@ void opencl_ctx_destroy (hashcat_ctx_t *hashcat_ctx) ocl_close (hashcat_ctx); - myfree (opencl_ctx->devices_param); + hcfree (opencl_ctx->devices_param); - myfree (opencl_ctx->platforms); + hcfree (opencl_ctx->platforms); - myfree (opencl_ctx->platform_devices); + hcfree (opencl_ctx->platform_devices); memset (opencl_ctx, 0, sizeof (opencl_ctx_t)); } @@ -2240,7 +2240,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_name = (char *) mymalloc (param_value_size); + char *device_name = (char *) hcmalloc (hashcat_ctx, param_value_size); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NAME, param_value_size, device_name, NULL); @@ -2254,7 +2254,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_vendor = (char *) mymalloc (param_value_size); + char *device_vendor = (char *) hcmalloc (hashcat_ctx, param_value_size); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, param_value_size, device_vendor, NULL); @@ -2309,7 +2309,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_version = (char *) mymalloc (param_value_size); + char *device_version = (char *) hcmalloc (hashcat_ctx, param_value_size); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VERSION, param_value_size, device_version, NULL); @@ -2323,7 +2323,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_opencl_version = (char *) mymalloc (param_value_size); + char *device_opencl_version = (char *) hcmalloc (hashcat_ctx, param_value_size); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, device_opencl_version, NULL); @@ -2450,7 +2450,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_extensions = mymalloc (device_extensions_size + 1); + char *device_extensions = hcmalloc (hashcat_ctx, device_extensions_size + 1); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL); @@ -2470,7 +2470,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->skipped = 1; } - myfree (device_extensions); + hcfree (device_extensions); // device_local_mem_size @@ -2518,7 +2518,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *driver_version = (char *) mymalloc (param_value_size); + char *driver_version = (char *) hcmalloc (hashcat_ctx, param_value_size); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DRIVER_VERSION, param_value_size, driver_version, NULL); @@ -2528,7 +2528,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // device_name_chksum - char *device_name_chksum = (char *) mymalloc (HCBUFSIZ_TINY); + char *device_name_chksum = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); #if defined (__x86_64__) snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%u-%u-%u-%s-%s-%s-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, comptime); @@ -2641,7 +2641,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_opencl_version); } - myfree (device_opencl_version); + hcfree (device_opencl_version); if ((user_options->benchmark == true || user_options->quiet == false)) { @@ -2818,10 +2818,10 @@ void opencl_ctx_devices_destroy (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - myfree (device_param->device_name); - myfree (device_param->device_name_chksum); - myfree (device_param->device_version); - myfree (device_param->driver_version); + hcfree (device_param->device_name); + hcfree (device_param->device_name_chksum); + hcfree (device_param->device_version); + hcfree (device_param->driver_version); } opencl_ctx->devices_cnt = 0; @@ -3494,9 +3494,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t)); + size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); - char **kernel_sources = (char **) mymalloc (sizeof (char *)); + char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); if (opencl_ctx->force_jit_compilation == -1) { @@ -3528,7 +3528,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) mymalloc (build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3536,7 +3536,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) puts (build_log); - myfree (build_log); + hcfree (build_log); } if (CL_err != CL_SUCCESS) @@ -3554,7 +3554,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; - char *binary = (char *) mymalloc (binary_size); + char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); @@ -3564,7 +3564,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (rc_write == -1) return -1; - myfree (binary); + hcfree (binary); } else { @@ -3630,7 +3630,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) mymalloc (build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3638,7 +3638,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) puts (build_log); - myfree (build_log); + hcfree (build_log); } if (CL_err != CL_SUCCESS) @@ -3649,9 +3649,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) } } - myfree (kernel_lengths); - myfree (kernel_sources[0]); - myfree (kernel_sources); + hcfree (kernel_lengths); + hcfree (kernel_sources[0]); + hcfree (kernel_sources); } /** @@ -3698,9 +3698,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t)); + size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); - char **kernel_sources = (char **) mymalloc (sizeof (char *)); + char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); if (cached == 0) { @@ -3731,7 +3731,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) mymalloc (build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3739,7 +3739,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) puts (build_log); - myfree (build_log); + hcfree (build_log); } if (CL_err != CL_SUCCESS) @@ -3757,7 +3757,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; - char *binary = (char *) mymalloc (binary_size); + char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); @@ -3765,7 +3765,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - myfree (binary); + hcfree (binary); } else { @@ -3786,9 +3786,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; } - myfree (kernel_lengths); - myfree (kernel_sources[0]); - myfree (kernel_sources); + hcfree (kernel_lengths); + hcfree (kernel_sources[0]); + hcfree (kernel_sources); } /** @@ -3839,9 +3839,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t)); + size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); - char **kernel_sources = (char **) mymalloc (sizeof (char *)); + char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); if (cached == 0) { @@ -3872,7 +3872,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) mymalloc (build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3880,7 +3880,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) puts (build_log); - myfree (build_log); + hcfree (build_log); } if (CL_err != CL_SUCCESS) @@ -3898,7 +3898,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; - char *binary = (char *) mymalloc (binary_size); + char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); @@ -3906,7 +3906,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - myfree (binary); + hcfree (binary); } else { @@ -3927,9 +3927,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; } - myfree (kernel_lengths); - myfree (kernel_sources[0]); - myfree (kernel_sources); + hcfree (kernel_lengths); + hcfree (kernel_sources[0]); + hcfree (kernel_sources); } // return back to the folder we came from initially (workaround) @@ -4043,15 +4043,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * main host data */ - pw_t *pws_buf = (pw_t *) mymalloc (size_pws); + pw_t *pws_buf = (pw_t *) hcmalloc (hashcat_ctx, size_pws); device_param->pws_buf = pws_buf; - comb_t *combs_buf = (comb_t *) mycalloc (KERNEL_COMBS, sizeof (comb_t)); + comb_t *combs_buf = (comb_t *) hccalloc (hashcat_ctx, KERNEL_COMBS, sizeof (comb_t)); device_param->combs_buf = combs_buf; - void *hooks_buf = mymalloc (size_hooks); + void *hooks_buf = hcmalloc (hashcat_ctx, size_hooks); device_param->hooks_buf = hooks_buf; @@ -4529,9 +4529,9 @@ void opencl_session_destroy (hashcat_ctx_t *hashcat_ctx) cl_int CL_err = CL_SUCCESS; - myfree (device_param->pws_buf); - myfree (device_param->combs_buf); - myfree (device_param->hooks_buf); + hcfree (device_param->pws_buf); + hcfree (device_param->combs_buf); + hcfree (device_param->hooks_buf); if (device_param->d_pws_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_pws_buf); if (device_param->d_pws_amp_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_pws_amp_buf); diff --git a/src/outfile_check.c b/src/outfile_check.c index 0032666b8..37b0a7e5c 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -38,10 +38,10 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) // buffers hash_t hash_buf = { 0, 0, 0, 0, 0 }; - hash_buf.digest = mymalloc (dgst_size); + hash_buf.digest = hcmalloc (hashcat_ctx, dgst_size); - if (is_salted) hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t)); - if (esalt_size) hash_buf.esalt = (void *) mymalloc (esalt_size); + if (is_salted) hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); + if (esalt_size) hash_buf.esalt = (void *) hcmalloc (hashcat_ctx, esalt_size); u32 digest_buf[64] = { 0 }; @@ -75,7 +75,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) { if (outfile_check_stat.st_mtime > folder_mtime) { - char **out_files_new = scan_directory (root_directory); + char **out_files_new = scan_directory (hashcat_ctx, root_directory); int out_cnt_new = count_dictionaries (out_files_new); @@ -83,7 +83,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) if (out_cnt_new > 0) { - out_info_new = (outfile_data_t *) mycalloc (out_cnt_new, sizeof (outfile_data_t)); + out_info_new = (outfile_data_t *) hccalloc (hashcat_ctx, out_cnt_new, sizeof (outfile_data_t)); for (int i = 0; i < out_cnt_new; i++) { @@ -110,8 +110,8 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) } } - myfree (out_info); - myfree (out_files); + hcfree (out_info); + hcfree (out_files); out_files = out_files_new; out_cnt = out_cnt_new; @@ -146,7 +146,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) fseek (fp, out_info[j].seek, SEEK_SET); - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (fp)) { @@ -282,7 +282,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_CRACKED) break; } - myfree (line_buf); + hcfree (line_buf); out_info[j].seek = ftell (fp); @@ -298,15 +298,15 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) } } - myfree (hash_buf.esalt); + hcfree (hash_buf.esalt); - myfree (hash_buf.salt); + hcfree (hash_buf.salt); - myfree (hash_buf.digest); + hcfree (hash_buf.digest); - myfree (out_info); + hcfree (out_info); - myfree (out_files); + hcfree (out_files); } void *thread_outfile_remove (void *p) @@ -339,7 +339,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->outfile_check_dir == NULL) { - outcheck_ctx->root_directory = (char *) mymalloc (HCBUFSIZ_TINY); + outcheck_ctx->root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (outcheck_ctx->root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, OUTFILES_DIR); } @@ -400,7 +400,7 @@ void outcheck_ctx_destroy (hashcat_ctx_t *hashcat_ctx) } } - myfree (outcheck_ctx->root_directory); + hcfree (outcheck_ctx->root_directory); memset (outcheck_ctx, 0, sizeof (outcheck_ctx_t)); } diff --git a/src/potfile.c b/src/potfile.c index f8e9f4c37..797977a6f 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -206,14 +206,14 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->potfile_path == NULL) { - potfile_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY); + potfile_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); potfile_ctx->fp = NULL; snprintf (potfile_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.potfile", folder_config->profile_dir); } else { - potfile_ctx->filename = mystrdup (user_options->potfile_path); + potfile_ctx->filename = hcstrdup (hashcat_ctx, user_options->potfile_path); potfile_ctx->fp = NULL; } @@ -267,13 +267,13 @@ void potfile_read_parse (hashcat_ctx_t *hashcat_ctx) if (potfile_ctx->fp == NULL) return; - potfile_ctx->pot_avail = count_lines (potfile_ctx->fp); + potfile_ctx->pot_avail = count_lines (hashcat_ctx, potfile_ctx->fp); - potfile_ctx->pot = (pot_t *) mycalloc (potfile_ctx->pot_avail, sizeof (pot_t)); + potfile_ctx->pot = (pot_t *) hccalloc (hashcat_ctx, potfile_ctx->pot_avail, sizeof (pot_t)); rewind (potfile_ctx->fp); - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); for (u32 line_num = 0; line_num < potfile_ctx->pot_avail; line_num++) { @@ -363,7 +363,7 @@ void potfile_read_parse (hashcat_ctx_t *hashcat_ctx) potfile_ctx->pot_cnt++; } - myfree (line_buf); + hcfree (line_buf); hc_qsort_r (potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); } @@ -440,16 +440,16 @@ void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num) hash_t *tmp_hash = &tmp_pot->hash; - tmp_hash->digest = mymalloc (hashconfig->dgst_size); + tmp_hash->digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); if (hashconfig->is_salted) { - tmp_hash->salt = (salt_t *) mymalloc (sizeof (salt_t)); + tmp_hash->salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); } if (hashconfig->esalt_size) { - tmp_hash->esalt = mymalloc (hashconfig->esalt_size); + tmp_hash->esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); } potfile_ctx->pot_hashes_avail++; @@ -469,20 +469,20 @@ void potfile_hash_free (hashcat_ctx_t *hashcat_ctx) hash_t *hashes_buf = &pot_ptr->hash; - myfree (hashes_buf->digest); + hcfree (hashes_buf->digest); if (hashconfig->is_salted) { - myfree (hashes_buf->salt); + hcfree (hashes_buf->salt); } if (hashconfig->esalt_size) { - myfree (hashes_buf->esalt); + hcfree (hashes_buf->esalt); } } - myfree (potfile_ctx->pot); + hcfree (potfile_ctx->pot); } void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)) @@ -585,7 +585,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i { weak_hash_found = 1; - pot_right_ptr = (pot_t *) mycalloc (1, sizeof (pot_t)); + pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); // in theory this is not needed, but we are paranoia: @@ -596,7 +596,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i if ((pot_left_ptr == NULL) && (pot_right_ptr == NULL)) { - if (weak_hash_found == 1) myfree (pot_right_ptr); // this shouldn't happen at all: if weak_hash_found == 1, than pot_right_ptr is not NULL for sure + if (weak_hash_found == 1) hcfree (pot_right_ptr); // this shouldn't happen at all: if weak_hash_found == 1, than pot_right_ptr is not NULL for sure return; } @@ -635,7 +635,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i { left_part_masked = 1; - pot_left_ptr = (pot_t *) mycalloc (1, sizeof (pot_t)); + pot_left_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); memset (pot_left_ptr->plain_buf, 0, sizeof (pot_left_ptr->plain_buf)); @@ -647,7 +647,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i { right_part_masked = 1; - pot_right_ptr = (pot_t *) mycalloc (1, sizeof (pot_t)); + pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); memset (pot_right_ptr->plain_buf, 0, sizeof (pot_right_ptr->plain_buf)); @@ -669,10 +669,10 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i outfile_write (hashcat_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len); - if (weak_hash_found == 1) myfree (pot_right_ptr); + if (weak_hash_found == 1) hcfree (pot_right_ptr); - if (left_part_masked == 1) myfree (pot_left_ptr); - if (right_part_masked == 1) myfree (pot_right_ptr); + if (left_part_masked == 1) hcfree (pot_left_ptr); + if (right_part_masked == 1) hcfree (pot_right_ptr); } void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)) @@ -710,13 +710,13 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i // we just need that pot_right_ptr is not a NULL pointer - pot_right_ptr = (pot_t *) mycalloc (1, sizeof (pot_t)); + pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); } } if ((pot_left_ptr != NULL) && (pot_right_ptr != NULL)) { - if (weak_hash_found == 1) myfree (pot_right_ptr); + if (weak_hash_found == 1) hcfree (pot_right_ptr); return; } @@ -731,7 +731,7 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i u32 user_len = (u32)input_len - 32u; - char *hash_output = (char *) mymalloc (33); + char *hash_output = (char *) hcmalloc (hashcat_ctx, 33); memcpy (hash_output, input_buf, input_len); @@ -755,9 +755,9 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i outfile_write (hashcat_ctx, hash_output, NULL, 0, 0, NULL, 0); - myfree (hash_output); + hcfree (hash_output); - if (weak_hash_found == 1) myfree (pot_right_ptr); + if (weak_hash_found == 1) hcfree (pot_right_ptr); } void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) @@ -782,7 +782,7 @@ void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) hash_t hash_buf; - hash_buf.digest = mymalloc (hashconfig->dgst_size); + hash_buf.digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); hash_buf.salt = NULL; hash_buf.esalt = NULL; hash_buf.hash_info = NULL; @@ -790,25 +790,25 @@ void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) if (hashconfig->is_salted) { - hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t)); + hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); } if (hashconfig->esalt_size) { - hash_buf.esalt = mymalloc (hashconfig->esalt_size); + hash_buf.esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); } const int rc = potfile_read_open (hashcat_ctx); if (rc == -1) return; - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); // to be safe work with a copy (because of line_len loop, i etc) // moved up here because it's easier to handle continue case // it's just 64kb - char *line_buf_cpy = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf_cpy = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (potfile_ctx->fp)) { @@ -945,21 +945,21 @@ void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) } } - myfree (line_buf_cpy); + hcfree (line_buf_cpy); - myfree (line_buf); + hcfree (line_buf); potfile_read_close (hashcat_ctx); if (hashconfig->esalt_size) { - myfree (hash_buf.esalt); + hcfree (hash_buf.esalt); } if (hashconfig->is_salted) { - myfree (hash_buf.salt); + hcfree (hash_buf.salt); } - myfree (hash_buf.digest); + hcfree (hash_buf.digest); } diff --git a/src/restore.c b/src/restore.c index 762cb26d5..0f708a934 100644 --- a/src/restore.c +++ b/src/restore.c @@ -62,7 +62,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) return 0; - restore_data_t *rd = (restore_data_t *) mymalloc (sizeof (restore_data_t)); + restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); const size_t nread = fread (rd, sizeof (restore_data_t), 1, fp); @@ -77,7 +77,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) if (rd->pid) { - char *pidbin = (char *) mymalloc (HCBUFSIZ_LARGE); + char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); int pidbin_len = -1; @@ -113,7 +113,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) #elif defined (_WIN) HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, rd->pid); - char *pidbin2 = (char *) mymalloc (HCBUFSIZ_LARGE); + char *pidbin2 = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); int pidbin2_len = -1; @@ -133,11 +133,11 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) } } - myfree (pidbin2); + hcfree (pidbin2); #endif - myfree (pidbin); + hcfree (pidbin); } if (rd->version < RESTORE_VERSION_MIN) @@ -147,7 +147,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) return -1; } - myfree (rd); + hcfree (rd); return 0; } @@ -156,7 +156,7 @@ static int init_restore (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - restore_data_t *rd = (restore_data_t *) mymalloc (sizeof (restore_data_t)); + restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); restore_ctx->rd = rd; @@ -211,9 +211,9 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) return -1; } - rd->argv = (char **) mycalloc (rd->argc, sizeof (char *)); + rd->argv = (char **) hccalloc (hashcat_ctx, rd->argc, sizeof (char *)); - char *buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); for (u32 i = 0; i < rd->argc; i++) { @@ -228,10 +228,10 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) if (len) buf[len - 1] = 0; - rd->argv[i] = mystrdup (buf); + rd->argv[i] = hcstrdup (hashcat_ctx, buf); } - myfree (buf); + hcfree (buf); fclose (fp); @@ -393,8 +393,8 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) restore_ctx->enabled = false; - char *eff_restore_file = (char *) mymalloc (HCBUFSIZ_TINY); - char *new_restore_file = (char *) mymalloc (HCBUFSIZ_TINY); + char *eff_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *new_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (eff_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore", folder_config->session_dir, user_options->session); snprintf (new_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore.new", folder_config->session_dir, user_options->session); @@ -459,10 +459,10 @@ void restore_ctx_destroy (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - myfree (restore_ctx->eff_restore_file); - myfree (restore_ctx->new_restore_file); + hcfree (restore_ctx->eff_restore_file); + hcfree (restore_ctx->new_restore_file); - myfree (restore_ctx->rd); + hcfree (restore_ctx->rd); if (restore_ctx->enabled == false) return; diff --git a/src/rp.c b/src/rp.c index 919e33f41..61b47ed5d 100644 --- a/src/rp.c +++ b/src/rp.c @@ -728,12 +728,12 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if (user_options->rp_files_cnt) { - all_kernel_rules_cnt = (u32 *) mycalloc (user_options->rp_files_cnt, sizeof (u32)); + all_kernel_rules_cnt = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (u32)); - all_kernel_rules_buf = (kernel_rule_t **) mycalloc (user_options->rp_files_cnt, sizeof (kernel_rule_t *)); + all_kernel_rules_buf = (kernel_rule_t **) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (kernel_rule_t *)); } - char *rule_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *rule_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); int rule_len = 0; @@ -773,7 +773,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if (kernel_rules_avail == kernel_rules_cnt) { - kernel_rules_buf = (kernel_rule_t *) myrealloc (kernel_rules_buf, kernel_rules_avail * sizeof (kernel_rule_t), INCR_RULES * sizeof (kernel_rule_t)); + kernel_rules_buf = (kernel_rule_t *) hcrealloc (hashcat_ctx, kernel_rules_buf, kernel_rules_avail * sizeof (kernel_rule_t), INCR_RULES * sizeof (kernel_rule_t)); kernel_rules_avail += INCR_RULES; } @@ -808,7 +808,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 all_kernel_rules_buf[i] = kernel_rules_buf; } - myfree (rule_buf); + hcfree (rule_buf); /** * merge rules @@ -816,7 +816,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 u32 kernel_rules_cnt = 1; - u32 *repeats = (u32 *) mycalloc (user_options->rp_files_cnt + 1, sizeof (u32)); + u32 *repeats = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt + 1, sizeof (u32)); repeats[0] = kernel_rules_cnt; @@ -827,7 +827,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 repeats[i + 1] = kernel_rules_cnt; } - kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) mycalloc (kernel_rules_cnt, sizeof (kernel_rule_t)); + kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) hccalloc (hashcat_ctx, kernel_rules_cnt, sizeof (kernel_rule_t)); for (u32 i = 0; i < kernel_rules_cnt; i++) { @@ -856,7 +856,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 } } - myfree (repeats); + hcfree (repeats); if (kernel_rules_cnt == 0) { @@ -865,8 +865,8 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 return -1; } - myfree (all_kernel_rules_cnt); - myfree (all_kernel_rules_buf); + hcfree (all_kernel_rules_cnt); + hcfree (all_kernel_rules_buf); *out_cnt = kernel_rules_cnt; *out_buf = kernel_rules_buf; @@ -879,9 +879,9 @@ int kernel_rules_generate (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, const user_options_t *user_options = hashcat_ctx->user_options; u32 kernel_rules_cnt = 0; - kernel_rule_t *kernel_rules_buf = mycalloc (user_options->rp_gen, sizeof (kernel_rule_t)); + kernel_rule_t *kernel_rules_buf = hccalloc (hashcat_ctx, user_options->rp_gen, sizeof (kernel_rule_t)); - char *rule_buf = (char *) mymalloc (RP_RULE_BUFSIZ); + char *rule_buf = (char *) hcmalloc (hashcat_ctx, RP_RULE_BUFSIZ); for (kernel_rules_cnt = 0; kernel_rules_cnt < user_options->rp_gen; kernel_rules_cnt++) { @@ -892,7 +892,7 @@ int kernel_rules_generate (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, if (cpu_rule_to_kernel_rule (rule_buf, rule_len, &kernel_rules_buf[kernel_rules_cnt]) == -1) continue; } - myfree (rule_buf); + hcfree (rule_buf); *out_cnt = kernel_rules_cnt; *out_buf = kernel_rules_buf; diff --git a/src/status.c b/src/status.c index 448f47971..40b152b4a 100644 --- a/src/status.c +++ b/src/status.c @@ -538,7 +538,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { char out_buf[HCBUFSIZ_LARGE] = { 0 }; - ascii_digest (out_buf, 0, 0, hashconfig, hashes); + ascii_digest (hashcat_ctx, out_buf, 0, 0); // limit length if (strlen (out_buf) > 40) @@ -559,8 +559,8 @@ void status_display (hashcat_ctx_t *hashcat_ctx) char out_buf1[32] = { 0 }; char out_buf2[32] = { 0 }; - ascii_digest (out_buf1, 0, 0, hashconfig, hashes); - ascii_digest (out_buf2, 0, 1, hashconfig, hashes); + ascii_digest (hashcat_ctx, out_buf1, 0, 0); + ascii_digest (hashcat_ctx, out_buf2, 0, 1); event_log_info (hashcat_ctx, "Hash.Target....: %s, %s", out_buf1, out_buf2); } @@ -1155,7 +1155,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) output_len = strlen (output_buf); } - if (num_throttle == 1) + if (num_throttle >= 0) { snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " *Throttled*"); @@ -1350,9 +1350,9 @@ int status_progress_init (hashcat_ctx_t *hashcat_ctx) status_ctx_t *status_ctx = hashcat_ctx->status_ctx; hashes_t *hashes = hashcat_ctx->hashes; - status_ctx->words_progress_done = (u64 *) mycalloc (hashes->salts_cnt, sizeof (u64)); - status_ctx->words_progress_rejected = (u64 *) mycalloc (hashes->salts_cnt, sizeof (u64)); - status_ctx->words_progress_restored = (u64 *) mycalloc (hashes->salts_cnt, sizeof (u64)); + status_ctx->words_progress_done = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); + status_ctx->words_progress_rejected = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); + status_ctx->words_progress_restored = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); return 0; } @@ -1361,9 +1361,9 @@ void status_progress_destroy (hashcat_ctx_t *hashcat_ctx) { status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - myfree (status_ctx->words_progress_done); - myfree (status_ctx->words_progress_rejected); - myfree (status_ctx->words_progress_restored); + hcfree (status_ctx->words_progress_done); + hcfree (status_ctx->words_progress_rejected); + hcfree (status_ctx->words_progress_restored); status_ctx->words_progress_done = NULL; status_ctx->words_progress_rejected = NULL; diff --git a/src/straight.c b/src/straight.c index e89fa827f..97132d7ca 100644 --- a/src/straight.c +++ b/src/straight.c @@ -20,16 +20,18 @@ #include "straight.h" #include "wordlist.h" -static void straight_ctx_add_wl (straight_ctx_t *straight_ctx, const char *dict) +static void straight_ctx_add_wl (hashcat_ctx_t *hashcat_ctx, const char *dict) { + straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + if (straight_ctx->dicts_avail == straight_ctx->dicts_cnt) { - straight_ctx->dicts = (char **) myrealloc (straight_ctx->dicts, straight_ctx->dicts_avail * sizeof (char *), INCR_DICTS * sizeof (char *)); + straight_ctx->dicts = (char **) hcrealloc (hashcat_ctx, straight_ctx->dicts, straight_ctx->dicts_avail * sizeof (char *), INCR_DICTS * sizeof (char *)); straight_ctx->dicts_avail += INCR_DICTS; } - straight_ctx->dicts[straight_ctx->dicts_cnt] = mystrdup (dict); + straight_ctx->dicts[straight_ctx->dicts_cnt] = hcstrdup (hashcat_ctx, dict); straight_ctx->dicts_cnt++; } @@ -196,7 +198,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0)) { - straight_ctx->kernel_rules_buf = (kernel_rule_t *) mymalloc (sizeof (kernel_rule_t)); + straight_ctx->kernel_rules_buf = (kernel_rule_t *) hcmalloc (hashcat_ctx, sizeof (kernel_rule_t)); straight_ctx->kernel_rules_buf[0].cmds[0] = RULE_OP_MANGLE_NOOP; @@ -281,7 +283,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) { char **dictionary_files = NULL; - dictionary_files = scan_directory (l0_filename); + dictionary_files = scan_directory (hashcat_ctx, l0_filename); if (dictionary_files != NULL) { @@ -302,16 +304,16 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISREG (l1_stat.st_mode)) { - straight_ctx_add_wl (straight_ctx, l1_filename); + straight_ctx_add_wl (hashcat_ctx, l1_filename); } } } - myfree (dictionary_files); + hcfree (dictionary_files); } else { - straight_ctx_add_wl (straight_ctx, l0_filename); + straight_ctx_add_wl (hashcat_ctx, l0_filename); } } @@ -350,7 +352,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) { char **dictionary_files = NULL; - dictionary_files = scan_directory (l0_filename); + dictionary_files = scan_directory (hashcat_ctx, l0_filename); if (dictionary_files != NULL) { @@ -371,16 +373,16 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISREG (l1_stat.st_mode)) { - straight_ctx_add_wl (straight_ctx, l1_filename); + straight_ctx_add_wl (hashcat_ctx, l1_filename); } } } - myfree (dictionary_files); + hcfree (dictionary_files); } else { - straight_ctx_add_wl (straight_ctx, l0_filename); + straight_ctx_add_wl (hashcat_ctx, l0_filename); } } @@ -410,7 +412,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) { char **dictionary_files = NULL; - dictionary_files = scan_directory (l0_filename); + dictionary_files = scan_directory (hashcat_ctx, l0_filename); if (dictionary_files != NULL) { @@ -431,16 +433,16 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISREG (l1_stat.st_mode)) { - straight_ctx_add_wl (straight_ctx, l1_filename); + straight_ctx_add_wl (hashcat_ctx, l1_filename); } } } - myfree (dictionary_files); + hcfree (dictionary_files); } else { - straight_ctx_add_wl (straight_ctx, l0_filename); + straight_ctx_add_wl (hashcat_ctx, l0_filename); } } @@ -463,12 +465,12 @@ void straight_ctx_destroy (hashcat_ctx_t *hashcat_ctx) for (u32 dict_pos = 0; dict_pos < straight_ctx->dicts_cnt; dict_pos++) { - myfree (straight_ctx->dicts[dict_pos]); + hcfree (straight_ctx->dicts[dict_pos]); } - myfree (straight_ctx->dicts); + hcfree (straight_ctx->dicts); - myfree (straight_ctx->kernel_rules_buf); + hcfree (straight_ctx->kernel_rules_buf); memset (straight_ctx, 0, sizeof (straight_ctx_t)); } diff --git a/src/tuningdb.c b/src/tuningdb.c index 6aa11307c..535289446 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -67,7 +67,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db->enabled = true; - char *tuning_db_file = (char *) mymalloc (HCBUFSIZ_TINY); + char *tuning_db_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (tuning_db_file, HCBUFSIZ_TINY - 1, "%s/%s", folder_config->shared_dir, TUNING_DB_FILE); @@ -80,23 +80,23 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) return -1; } - myfree (tuning_db_file); + hcfree (tuning_db_file); - int num_lines = count_lines (fp); + int num_lines = count_lines (hashcat_ctx, fp); // a bit over-allocated - tuning_db->alias_buf = (tuning_db_alias_t *) mycalloc (num_lines + 1, sizeof (tuning_db_alias_t)); + tuning_db->alias_buf = (tuning_db_alias_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_alias_t)); tuning_db->alias_cnt = 0; - tuning_db->entry_buf = (tuning_db_entry_t *) mycalloc (num_lines + 1, sizeof (tuning_db_entry_t)); + tuning_db->entry_buf = (tuning_db_entry_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_entry_t)); tuning_db->entry_cnt = 0; rewind (fp); int line_num = 0; - char *buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (fp)) { @@ -138,8 +138,8 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db_alias_t *alias = &tuning_db->alias_buf[tuning_db->alias_cnt]; - alias->device_name = mystrdup (device_name); - alias->alias_name = mystrdup (alias_name); + alias->device_name = hcstrdup (hashcat_ctx, device_name); + alias->alias_name = hcstrdup (hashcat_ctx, alias_name); tuning_db->alias_cnt++; } @@ -212,7 +212,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db_entry_t *entry = &tuning_db->entry_buf[tuning_db->entry_cnt]; - entry->device_name = mystrdup (device_name); + entry->device_name = hcstrdup (hashcat_ctx, device_name); entry->attack_mode = attack_mode; entry->hash_type = hash_type; entry->vector_width = vector_width; @@ -229,7 +229,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) } } - myfree (buf); + hcfree (buf); fclose (fp); @@ -255,19 +255,19 @@ void tuning_db_destroy (hashcat_ctx_t *hashcat_ctx) { tuning_db_alias_t *alias = &tuning_db->alias_buf[i]; - myfree (alias->device_name); - myfree (alias->alias_name); + hcfree (alias->device_name); + hcfree (alias->alias_name); } for (i = 0; i < tuning_db->entry_cnt; i++) { tuning_db_entry_t *entry = &tuning_db->entry_buf[i]; - myfree (entry->device_name); + hcfree (entry->device_name); } - myfree (tuning_db->alias_buf); - myfree (tuning_db->entry_buf); + hcfree (tuning_db->alias_buf); + hcfree (tuning_db->entry_buf); memset (tuning_db, 0, sizeof (tuning_db_t)); } @@ -280,7 +280,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev // first we need to convert all spaces in the device_name to underscore - char *device_name_nospace = mystrdup (device_name); + char *device_name_nospace = hcstrdup (hashcat_ctx, device_name); int device_name_length = strlen (device_name_nospace); @@ -364,7 +364,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev // free converted device_name - myfree (device_name_nospace); + hcfree (device_name_nospace); return entry; } diff --git a/src/user_options.c b/src/user_options.c index f12e2deb0..af4271028 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -192,7 +192,7 @@ void user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->weak_hash_threshold = WEAK_HASH_THRESHOLD; user_options->workload_profile = WORKLOAD_PROFILE; user_options->rp_files_cnt = 0; - user_options->rp_files = (char **) mycalloc (256, sizeof (char *)); + user_options->rp_files = (char **) hccalloc (hashcat_ctx, 256, sizeof (char *)); user_options->hc_bin = PROGNAME; user_options->hc_argc = 0; user_options->hc_argv = NULL; @@ -202,7 +202,7 @@ void user_options_destroy (hashcat_ctx_t *hashcat_ctx) { user_options_t *user_options = hashcat_ctx->user_options; - myfree (user_options->rp_files); + hcfree (user_options->rp_files); //do not reset this, it might be used from main.c //memset (user_options, 0, sizeof (user_options_t)); @@ -966,7 +966,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->quiet = true; user_options->opencl_platforms = NULL; user_options->opencl_devices = NULL; - user_options->opencl_device_types = mystrdup ("1,2,3"); + user_options->opencl_device_types = hcstrdup (hashcat_ctx, "1,2,3"); } if (user_options->left == true) diff --git a/src/wordlist.c b/src/wordlist.c index 28e0d23d9..4d8630442 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -78,7 +78,7 @@ void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) { if (wl_data->cnt == wl_data->avail) { - wl_data->buf = (char *) myrealloc (wl_data->buf, wl_data->avail, wl_data->incr); + wl_data->buf = (char *) hcrealloc (hashcat_ctx, wl_data->buf, wl_data->avail, wl_data->incr); wl_data->avail += wl_data->incr; } @@ -431,7 +431,7 @@ void wl_data_init (hashcat_ctx_t *hashcat_ctx) wl_data->enabled = true; - wl_data->buf = (char *) mymalloc (user_options->segment_size); + wl_data->buf = (char *) hcmalloc (hashcat_ctx, user_options->segment_size); wl_data->avail = user_options->segment_size; wl_data->incr = user_options->segment_size; wl_data->cnt = 0; @@ -460,7 +460,7 @@ void wl_data_destroy (hashcat_ctx_t *hashcat_ctx) if (wl_data->enabled == false) return; - myfree (wl_data->buf); + hcfree (wl_data->buf); memset (wl_data, 0, sizeof (wl_data_t)); }