title: Cannot WriteFile to a volume in C
body: <p>I am having some trouble with the <code>WriteFile</code> function in <strong>C</strong>.</p>
  
  <p>I open a handle to the volume T: with <code>CreateFile</code>:</p>
  
  <pre><code>HANDLE hvol = CreateFile("\\\\.\\T:", GENERIC_READ | GENERIC_WRITE, 3,
                    NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  </code></pre>
  
  <p>Set the file pointer with <code>SetFilePointer</code>:</p>
  
  <pre><code>DWORD offset = SetFilePointer(hvol, bps + datarunOffset[0], NULL, FILE_BEGIN);
  </code></pre>
  
  <p>And write with:</p>
  
  <pre><code>bool wsuccess = WriteFile(hvol, filearray, secfilesize, &amp;byteswritten, NULL);
  </code></pre>
  
  <p>Where <code>filearray</code> is an array of the byte values of a small file, and <code>secfilesize</code> is the number of elements in <code>filearray</code> rounded to a multiple of the disk's sector size (512).</p>
  
  <p>If I have set the file pointer to <strong>0x400</strong> (the second sector of <strong>$Boot</strong>) then the array is written with no error codes.</p>
  
  <p>If I have set the file pointer to <strong>0x3200</strong> (the second sector of <strong>$UpCase</strong>) then nothing is written and </p>
  
  <blockquote>
    <p>error code 5: access denied</p>
  </blockquote>
  
  <p>is returned.</p>
  
  <p>I cannot find a solution and I have full control over the volume. It just seemed odd that I could write to <strong>$Boot</strong> but not <strong>$UpCase</strong>, is there any reason for this? and can anyone offer a solution?</p>