title: Read data from a disk in c++
body: <p>I'm trying to read some data that lies outside of the partition table, I can successfully read the raw data, but it appears to be encoded in Unicode (UTF-8) or something. There is an application that has been written to read this data and display it properly so I know it can be done.</p>
  
  <p>This data is called "Image Safe Data" and it is something Novell ZenWorks places on the disk at the sixth sector (0x05).</p>
  
  <p>The raw data looks like this:</p>
  
  <pre><code>ZISD♂   Æ☻      ☺   └¿ ├└¿ ☺    ñ3åG    ╓ï╝Y    ≡   ♣   §   ╗ç9%¥⌂+0Kâ¬ê
  
  
    :☺               @   f 8 b 3 4 6 6 2 9 3 b 3 2 b b f d c 8 c b d 6 2 2 1 2 1 0 d
  2 1 ♫   M H S T R E E ▬   F H I F L 0 0 0 5 9 3     L   \ \ F H 0 1 F S N T H 0
  9 \ A P P S \ i m g s \ C X P P N 6 7 1 0 B . z m g $   t r i n i t y - h e a l
   t h . o r g ▬   F H I F L 0 0 0 5 9 3 H   Z N W
  </code></pre>
  
  <p>I wrote the following code to read the data directly from disk in C++:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  
  
  void main() {
      DWORD nRead;
      char buf[512];
  
      HANDLE hDisk = CreateFile("\\\\.\\PhysicalDrive0", 
          GENERIC_READ, FILE_SHARE_READ,        
          NULL, OPEN_EXISTING, 0, NULL);
  
      SetFilePointer(hDisk, 0xA00, 0, FILE_BEGIN);
      ReadFile(hDisk, buf, 512, &amp;nRead, NULL);
      for (int currentpos=0;currentpos &lt; 512;currentpos++) {
          std::cout &lt;&lt; buf[currentpos];
      }
      CloseHandle(hDisk);
  }
  </code></pre>
  
  <p>I'm a novice in C++. I need to find a way to output this data so that it can be read by a script if possible. It looks to be delimited by inconsistent characters.</p>