title: WriteFile returning error 1784
body: <p>I am creating a program to populate a disk with a dummy file system.</p>
  
  <p>Currently, I am writing files of variable sizes using <code>WriteFile</code>.</p>
  
  <pre><code>        WriteFile(hFile, FileData, i * 1024, &amp;dwWrote, NULL);
          err = GetLastError();
  </code></pre>
  
  <p>err returns #1784 which translates to </p>
  
  <blockquote>
    <p>The supplied user buffer is not valid for the requested operation.     ERROR_INVALID_USER_BUFFER</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>Any ideas on how to get past <code>ERROR_INVALID_USER_BUFFER</code>?</p>
  
  <p>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.</p>
  
  <p>EDIT:</p>
  
  <pre><code>FileData = (char *) malloc(sizeof(char) * (size_t)k * 1024);
  memset(FileData, 245, sizeof(char) * (size_t)k * 1024);
  </code></pre>
  
  <p>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).</p>