I am creating a program to populate a disk with a dummy file system.
Currently, I am writing files of variable sizes using WriteFile
.
WriteFile(hFile, FileData, i * 1024, &dwWrote, NULL);
err = GetLastError();
err returns #1784 which translates to
The supplied user buffer is not valid for the requested operation. ERROR_INVALID_USER_BUFFER
So for the first 24 files, the write operation works. For file #25 on, the write operation fails. The files are still created but the WriteFile function does not populate the files.
Any ideas on how to get past ERROR_INVALID_USER_BUFFER
?
Every reference I can find to the error is limited to crashing programs and I cannot figure out how it relates to the issue I am experiencing.
EDIT:
FileData = (char *) malloc(sizeof(char) * (size_t)k * 1024);
memset(FileData, 245, sizeof(char) * (size_t)k * 1024);
FileData is set and allocated to the size of the maximum anticipate buffer. i is the loop variable that iterates until it increments to the Maximum Size (k).