title: WinAPI - GetRawInputBuffer
body: <p>I have problem with GetRawInputBuffer. Code returns no error, but there are no data present in retrieved response.</p>
  
  <p>I have written code according to this <a href="https://stackoverflow.com/questions/10866226/using-getrawinputbuffer-correctly">Using GetRawInputBuffer correctly</a></p>
  
  <pre><code>    UINT RawInputSize;
      UINT Result;
      Result = GetRawInputBuffer(NULL, &amp;(RawInputSize), sizeof(RAWINPUTHEADER));
      if (Result == -1)
      {
          DWORD ErrorCode = GetLastError();
          return;
      }
  
      UINT AllocatedBufferByteCount = RawInputSize * 16;
      RAWINPUT* RawInputBuffer = reinterpret_cast&lt;RAWINPUT*&gt;(malloc(AllocatedBufferByteCount));
  
      UINT AllocatedBufferByteCountTwo = AllocatedBufferByteCount;
      Result = GetRawInputBuffer(RawInputBuffer, &amp;(AllocatedBufferByteCountTwo), sizeof(RAWINPUTHEADER));
      if (Result == -1)
      {
          DWORD ErrorCode = GetLastError();
          return;
      }
  
      UINT RawInputCount = Result;
  
      RAWINPUT* RawInput = RawInputBuffer;
      for (unsigned int i = 0; i &lt; RawInputCount; ++i)
      {
          switch (RawInput-&gt;header.dwType)
          {
              case RIM_TYPEMOUSE:
              {
                  this-&gt;UpdateMouse(RawInput-&gt;data.mouse);
                  break;
              }
              case RIM_TYPEKEYBOARD:
              {
                  this-&gt;UpdateKeyboard(RawInput-&gt;data.keyboard);
                  break;
              }
          }
  
  
          RawInput = NEXTRAWINPUTBLOCK(RawInput); 
      }
  
      DefRawInputProc(&amp;(RawInputBuffer), RawInputCount, sizeof(RAWINPUTHEADER));
  </code></pre>
  
  <p>This code is called outside <code>case WM_INPUT</code>. <code>RawInputCount</code> is always zero. If I use <code>GetRawInputData</code> inside <code>case WM_INPUT</code>, I am recieving data correctly.</p>
  
  <p>What is wrong with this code and why are my results empty?</p>