void read_rom_list (void) { char tmp2[1000]; int idx, idx2; char tmp[1000]; int size, size2, exists; romlist_clear (); exists = regexiststree ("DetectedROMs"); if (!exists || forceroms) { load_keyring (NULL, NULL); scan_roms (forceroms ? 0 : 1); } forceroms = 0; }
/* Main thread - rule */ hash_stat ocl_rule_keyring(void) { int a,i; int err; int worker_thread_keys[32]; /* setup initial OpenCL vars */ int numplatforms=0; _clGetPlatformIDs(4, platform, (cl_uint *)&numplatforms); if (hash_err==load_keyring(hashlist_file)) return hash_err; for (i=0;i<nwthreads;i++) if (wthreads[i].type!=cpu_thread) { _clGetDeviceIDs(platform[wthreads[i].platform], CL_DEVICE_TYPE_GPU, 64, device, (cl_uint *)&devicesnum); context[i] = _clCreateContext(NULL, 1, &device[wthreads[i].deviceid], NULL, NULL, &err); if (wthreads[i].type != nv_thread) { char *binary; size_t binary_size; FILE *fp; char pbuf[100]; bzero(pbuf,100); char kernelfile[255]; _clGetDeviceInfo(device[wthreads[i].deviceid], CL_DEVICE_NAME, sizeof(pbuf),pbuf, NULL ); sprintf(kernelfile,"%s/hashkill/kernels/amd_keyring__%s.bin",DATADIR,pbuf); char *ofname = kernel_decompress(kernelfile); if (!ofname) return hash_err; fp=fopen(ofname,"r"); if (!fp) { elog("Can't open kernel: %s\n",kernelfile); exit(1); } fseek(fp, 0, SEEK_END); binary_size = ftell(fp); fseek(fp, 0, SEEK_SET); binary=malloc(binary_size); fread(binary,binary_size,1,fp); fclose(fp); unlink(ofname); free(ofname); if (wthreads[i].first==1) hlog("Loading kernel: %s\n",kernelfile); program[i] = _clCreateProgramWithBinary(context[i], 1, &device[wthreads[i].deviceid], (size_t *)&binary_size, (const unsigned char **)&binary, NULL, &err ); _clBuildProgram(program[i], 1, &device[wthreads[i].deviceid], "", NULL, NULL ); free(binary); } else { #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 char *binary; size_t binary_size; FILE *fp; char pbuf[100]; bzero(pbuf,100); char kernelfile[255]; _clGetDeviceInfo(device[wthreads[i].deviceid], CL_DEVICE_NAME, sizeof(pbuf),pbuf, NULL ); cl_uint compute_capability_major, compute_capability_minor; _clGetDeviceInfo(device[wthreads[i].deviceid], CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, sizeof(cl_uint), &compute_capability_major, NULL); _clGetDeviceInfo(device[wthreads[i].deviceid], CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, sizeof(cl_uint), &compute_capability_minor, NULL); if ((compute_capability_major==1)&&(compute_capability_minor==0)) sprintf(pbuf,"sm10"); if ((compute_capability_major==1)&&(compute_capability_minor==1)) sprintf(pbuf,"sm11"); if ((compute_capability_major==1)&&(compute_capability_minor==2)) sprintf(pbuf,"sm12"); if ((compute_capability_major==1)&&(compute_capability_minor==3)) sprintf(pbuf,"sm13"); if ((compute_capability_major==2)&&(compute_capability_minor==0)) sprintf(pbuf,"sm20"); if ((compute_capability_major==2)&&(compute_capability_minor==1)) sprintf(pbuf,"sm21"); if ((compute_capability_major==3)&&(compute_capability_minor==0)) sprintf(pbuf,"sm30"); sprintf(kernelfile,"%s/hashkill/kernels/nvidia_keyring__%s.ptx",DATADIR,pbuf); char *ofname = kernel_decompress(kernelfile); if (!ofname) return hash_err; fp=fopen(ofname,"r"); if (!fp) { elog("Can't open kernel: %s\n",kernelfile); exit(1); } fseek(fp, 0, SEEK_END); binary_size = ftell(fp); fseek(fp, 0, SEEK_SET); binary=malloc(binary_size); fread(binary,binary_size,1,fp); fclose(fp); unlink(ofname); free(ofname); if (wthreads[i].first==1) hlog("Loading kernel: %s\n",kernelfile); program[i] = _clCreateProgramWithBinary(context[i], 1, &device[wthreads[i].deviceid], (size_t *)&binary_size, (const unsigned char **)&binary, NULL, &err ); _clBuildProgram(program[i], 1, &device[wthreads[i].deviceid], NULL, NULL, NULL ); free(binary); } } pthread_mutex_init(&biglock, NULL); for (a=0;a<nwthreads;a++) { worker_thread_keys[a]=a; pthread_create(&crack_threads[a], NULL, ocl_rule_keyring_thread, &worker_thread_keys[a]); } rule_gen_parse(rule_file,ocl_keyring_callback,nwthreads,SELF_THREAD); for (a=0;a<nwthreads;a++) pthread_join(crack_threads[a], NULL); attack_over=2; printf("\n"); hlog("Done!\n%s",""); return hash_ok; }