都是win10 的系统,都是使用的mysys2 编译的代码,
一台电脑正常运行,一台电脑 有问题
//////这里是标记
memcpy(all_encode_buf+count_gid*(pw.pw_len+12),encode_split,4*sizeof(u32));
这句memcpy 这样写,fwrite 运行都正常写出文件内容正确
//////这里是标记
memcpy(all_encode_buf+count_gid*(pw.pw_len+12)+4,encode_split,4*sizeof(u32));
只是加上偏移4个,一台电脑运行正常,另外一台电脑出现fwrite 出来的文件是0字节。
//------------------------------------------------------------------------
pw_t pw;
u32 encode_step = (pw.pw_len+12)*sizeof(u32);
u32 * all_encode_buf =(u32 *)malloc(encode_step*(pws_cnt));
u32 encode_split[4] ={pw.pw_len,pw.pw_len,pw.pw_len,pw.pw_len};
u32 encode_end[4] ={0x0b0b0b0b,0x0b0b0b0b,0x0b0b0b0b,0x0b0b0b0b};
int index_encode =0;
for(u32 count_gid = 0;count_gid < pws_cnt ;count_gid++)
{
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, count_gid, &pw);
printf("pass = %08X,%08X,%08X,%08X\r\n",pw.i[0],pw.i[1],pw.i[2],pw.i[3]);
pbkdf2_sha256_tmp_t tmps;
int CL_rc = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue,device_param->d_tmps, CL_TRUE, count_gid * sizeof (pbkdf2_sha256_tmp_t), sizeof (pbkdf2_sha256_tmp_t), &tmps, 0, NULL, NULL);
printf("%08X ,%08X,%08X,%08X,%08X,%08X,%08X,%08X\r\n",tmps.out[0],tmps.out[1],tmps.out[2],tmps.out[3],tmps.out[4],tmps.out[5],tmps.out[6],tmps.out[7]);
if (CL_rc == -1) return -1;
if (rc == -1) return -1;
//////这里是标记
memcpy(all_encode_buf+count_gid*(pw.pw_len+12),encode_split,4*sizeof(u32));
}
FILE *fp1 = fopen("test.txt","ab");
fwrite(encode_end,sizeof(u32),4,fp1);
fclose(fp1);
FILE *fp = fopen ("123", "ab");