Note that there are some explanatory texts on larger screens.

plurals
  1. POc++ reading (.cso) compiled shader object returning \0
    primarykey
    data
    text
    <p>I've tried two different methods to read from this cso file. Which is microsofts compiled shader</p> <pre><code>HRESULT BasicReader::ReadData(_In_z_ wchar_t const* fileName, _Inout_ std::unique_ptr&lt;uint8_t[]&gt;&amp; data, _Out_ size_t* dataSize) { ScopedHandle hFile(safe_handle(CreateFileW(fileName, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr))); LARGE_INTEGER fileSize = { 0 }; FILE_STANDARD_INFO fileInfo; GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &amp;fileInfo, sizeof(fileInfo)); fileSize = fileInfo.EndOfFile; data.reset(new uint8_t[fileSize.LowPart]); DWORD bytesRead = 0; ReadFile(hFile.get(), data.get(), fileSize.LowPart, &amp;bytesRead, nullptr); *dataSize = bytesRead; } </code></pre> <p>GetFileInformationByHandleEx returned true and ReadFile returned true</p> <pre><code>HRESULT BasicReader::ReadData(_In_z_ wchar_t const* fileName, _Inout_ std::unique_ptr&lt;uint8_t[]&gt;&amp; data, _Out_ size_t* dataSize) { std::ifstream fstream; fstream.open(fileName, std::ifstream::in | std::ifstream::binary); if (fstream.fail()) return false; char* val; fstream.seekg(0, std::ios::end); size_t size = size_t(fstream.tellg()); val = new char[size]; fstream.seekg(0, std::ios::beg); fstream.read(val, size); fstream.close(); auto f = reinterpret_cast&lt;unsigned char*&gt;(val); data.reset(f); *dataSize = size; } </code></pre> <p>Both of these methods make data = \0 However; when I point to another file in the same directory, it gives me data. What is happening here? Here's the <a href="https://www.dropbox.com/s/5il0mme9u9y1nvu/VertexShader.cso" rel="nofollow">file</a>.</p> <p>I read the first few bytes of the file and it's this:</p> <pre><code>0 2 254 255 254 255 124 1 68 66 85 71 40 0 0 0 184 5 0 0 0 0 0 0 1 0 0 0 144 0 0 0 72 0 0 0 148 0 0 0 4 0 0 0 104 5 0 0 212 2 0 0 67 58 92 85 115 101 114 115 92 106 97 99 111 98 95 48 48 48 92 68 111 99 117 109 101 110 116 115 92 86 105 115 117 97 108 32 8... </code></pre> <p>And the working file looks like this: </p> <pre><code>68 68 83 32 124 0 0 0 7 16 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 0 0 64 0 0 0 0 0 0 0 32 0 0 0 0 0 255 0 0 255 0 0 255 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload