<div class="content" name="CprepDiskRawWrite" uuid="d90247b5-67be-440e-ba02-0d2d585177f6"><p>The <b>CprepDiskRawWrite</b> method writes information
directly to a single 512 byte sector on a given disk.</p><dl>
<dd>
<div><pre> HRESULT CprepDiskRawWrite(
   [in] CPREP_DISKID DiskId,
   [in] unsigned long ulSector,
   [in] unsigned long cbData,
   [in, size_is(cbData)] byte* pbData,
   [out] unsigned long* pcbDataWritten,
   [out] unsigned long* ulLatency
 );
</pre></div>
</dd></dl><p><b>DiskId: </b>The identifier of the <b>ClusPrepDisk</b>
representing the disk that holds the sector to which to write.</p><p><b>ulSector: </b>The sector number to write to.</p><p><b>cbData: </b>The size, in bytes of the buffer <i>pbData</i>.</p><p><b>pbData: </b>The data to write to the disk.</p><p><b>pcbDataWritten: </b>If the CprepDiskRawWrite
method is successful, the server MUST set this value to 512. If an error
occurs, the server MUST set <b>pcbDataWritten</b> to zero.</p><p><b>ulLatency: </b>The time, in milliseconds, that the
write took to be performed.</p><p><b>Return Values: </b>A signed, 32-bit value that
indicates return status. If the method returns a negative value, it has failed.
Zero or positive values indicate success, with the lower 16 bits in positive
nonzero values containing warnings or flags defined in the method
implementation. For more information about Win32 error codes and <span><a href="../ms-dtyp/a9046ed2-bfb2-4d56-a719-2824afce59ac" data-linktype="relative-path">HRESULT</a></span>
values, see <span><a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a></span>
sections <span><a href="../ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d" data-linktype="relative-path">2.2</a></span>
and <span><a href="../ms-erref/0642cb2f-2075-4469-918c-4441e69c548a" data-linktype="relative-path">2.1</a></span>.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000000 S_OK</td>
  <td>The call was successful.</td>
 </tr><tr>
  <td>0x80070002 ERROR_FILE_NOT_FOUND</td>
  <td>The disk was not found.</td>
 </tr><tr>
  <td>0x8007001D ERROR_WRITE_FAULT</td>
  <td>The size of the passed buffer was larger than 512 bytes.</td>
 </tr><tr>
  <td>0x80070548 ERROR_INVALID_SERVER_STATE</td>
  <td>The server&#39;s Prepare State is not Online.</td>
 </tr></tbody></table>
</dd>
<dd>
<p>For any other condition, this method MUST return a
value that is not one of the values listed in the preceding table. The client
MUST behave in one consistent, identical manner for all values that are not
listed in the preceding table.</p>
</dd></dl><p>Exceptions Thrown: No exceptions are thrown beyond those
thrown by the underlying <span><a href="b30bcd1c-8ff6-46d2-a27e-61bd85ace9f4#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a></span> protocol <span><a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a></span>.</p><p>The opnum field value for this method is 4.</p><p>When processing this call, the server MUST do the following:
</p><ul><li><p><span><span> 
</span></span>Obtain the <b>ClusPrepDisk</b> identified by the <i>DiskId</i>
parameter as specified in section <span><a href="c17ce220-d244-45c9-95c0-4c31942253ee" data-linktype="relative-path">3.2.4</a></span>.</p>
</li><li><p><span><span> 
</span></span>If the passed <i>cbData</i> is greater than 512, then return
ERROR_WRITE_FAULT.</p>
</li><li><p><span><span> 
</span></span>Write a single sector of 512 bytes from <i>pbData</i> to the disk
at the correct sector. If the size of <i>cbData</i> is less than 512 bytes,
then <i>pbData</i> is padded to 512 bytes with arbitrary data.</p>
<p><b>Note</b>  While
performing the write operation, use the <b>Latency Time Source</b> ADM element
in an implementation-specific manner to determine the elapsed time. For
example, prior to initiating the write operation, observe the current time of
day in millisecond granularity. Upon completion of the write, again observe the
current time of day. The elapsed time can be calculated by subtracting the
first observed value from the second.</p>
</li><li><p><span><span> 
</span></span>Set <i>pcbDataWritten</i> to 512.</p>
</li><li><p><span><span> 
</span></span>Set <i>ulLatency</i> to the time, in milliseconds, that the write
operation took to complete.</p>
</li></ul><p>The server returns the following information to the client:</p><ul><li><p><span><span> 
</span></span>The amount of data written (512 bytes).</p>
</li><li><p><span><span> 
</span></span>How long the write took.</p>
</li></ul></div>