尽管所有参数都是正确的,但它返回读取的项目的正确值,函数 fread_s 没有以“字节”为单位的任何内容,它是空的。当我交换 10485760 和 1 时它也是空的。有谁知道是什么导致了这个问题?文件完全没有问题。
float EncryptBig(CRYPTIN* handle)
{
int i, index = 0;
float calc;
char* bytes;
i = (handle->size - handle->huidig);
if ((i-10485760) < 0)
{
bytes = (char*)malloc(i);
if (bytes == NULL)
{
fcloseall();
free(handle);
return 100.0f;
}
fread_s(&bytes, i, 1, i, handle->bestand); // Here and down below
fclose(handle->bestand);
for (index = 0; index < i; index++)
{
__asm
{
mov eax, dword ptr [bytes]
add eax, dword ptr [index]
mov cl, byte ptr [eax]
xor cl, 101
xor cl, 53
not cl
mov byte ptr [eax], cl
mov eax, dword ptr [index]
add eax, 1
mov dword ptr [index], eax
}
}
fwrite(bytes, 1, i, handle->nieuwbstnd);
fclose(handle->nieuwbstnd);
free(handle);
free(bytes);
return 100.0f;
}
if (handle->huidig == 0)
{
fseek(handle->bestand, 0, SEEK_SET);
fseek(handle->nieuwbstnd, 0, SEEK_SET);
}
bytes = (char*)malloc(10485760);
if (bytes == NULL)
{
fcloseall();
free(handle);
return 100.0f;
}
fread_s(bytes, 10485760, 10485760, 1, handle->bestand); // Here
for (index = 0; index < 10485760; index++)
{
__asm
{
mov eax, dword ptr [bytes]
add eax, dword ptr [index]
mov cl, byte ptr [eax]
xor cl, 101
xor cl, 53
not cl
mov byte ptr [eax], cl
mov eax, dword ptr [index]
add eax, 1
mov dword ptr [index], eax
}
}
fwrite(bytes, 1, 10485760, handle->bestand);
free(bytes);
handle->huidig += 10485760;
handle->positie += 10485760;
fseek(handle->bestand, handle->huidig, SEEK_SET);
fseek(handle->nieuwbstnd, handle->positie, SEEK_SET);
calc = (float)handle->huidig;
calc /= (float)handle->size;
calc *= 100.0f;
if (calc >= 100.0)
{
fclose(handle->bestand);
fclose(handle->nieuwbstnd);
free(handle);
}
return calc;
}
编辑:解决