すべての引数は正しいですが、読み取られたアイテムの正しい値を返します。関数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;
}
編集:解決済み